/* Hallmark · shape: app screen · genre: modern-minimal · theme: custom (Telegram themeParams из brief.md) · surface: absolute
 * paper: Telegram secondary_bg #efeff4 / #000, browser #f4f4f5 · accent: Telegram button #2481cc / #3e88f7, browser #171717 · display: Geist · body: Geist
 * nav: Telegram-шапка с «Назад», нижний таб-бар и MainButton на телефоне; боковое меню на компьютере · signature: сверка прихода с раздачей недовоза · states: loading, empty, error, offline, pending, closed, full
 * axes: light/grotesk/cool · posture: restrained · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E4 S5 R5 V3 · weakest: V, раскладка намеренно повторяет привычки Telegram и iOS-групп, новизна тут вредна; характер отдан сверке и расчёту, где цифры считаются из состояния */
/* Hallmark · waive 47b · one 390px frame, the live Tabak app screens inside · the reviewer toggles phone mode to see the real Telegram Mini App layout on a desktop */
/* Hallmark · waive 7b · surface: absolute, white section and black dark-theme paper are Telegram themeParams defaults · a Mini App must match the Telegram client it opens in */
/* Hallmark · waive 72 · the phone frame scrolls inside itself, the measured text sits in that scroller below the frame edge · phone mode clips the Tabak screen to a 390px device height on purpose */
/* Hallmark · answered F4 · the Telegram MainButton on phone and the desktop page action are one primary rendered per layout; quiet, plain and segmented controls are not filled primaries */
/* Hallmark · answered F25 · the desktop filter and order columns move into the filter sheet and the order sheet behind the MainButton on a phone, nothing is cut */
@import url("../tokens.css");
@import url("../base.css");

/* ---------- Документ и стенд ---------- */
html, body { height: 100%; overflow-x: clip; }
body { display: flex; flex-direction: column; height: 100dvh; background: var(--proto-stage); font-size: var(--text-md); line-height: 1.45; font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-weight: 600; letter-spacing: 0; line-height: 1.25; color: var(--color-ink); }
button { color: inherit; }
.i { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i--s { width: 18px; height: 18px; }

.skip { position: absolute; left: var(--space-md); top: calc(-1 * var(--space-3xl)); z-index: var(--z-toast); padding: var(--space-xs) var(--space-md); background: var(--proto-active); color: var(--proto-active-ink); border-radius: var(--radius-control); }
.skip:focus-visible { top: var(--space-xs); outline: 2px solid var(--proto-ink); outline-offset: 2px; }

/* Панель прототипа: нейтральная, вне темы приложения */
.proto { flex-shrink: 0; position: relative; z-index: var(--z-sticky-nav); display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; min-height: var(--panel-h); padding: var(--space-xs) var(--space-md); background: var(--proto-bg); color: var(--proto-ink); border-bottom: 1px solid var(--proto-rule); font-size: var(--text-sm); }
.proto-name { font-weight: 600; margin-right: var(--space-xs); }
.proto-group { display: flex; align-items: center; gap: var(--space-xs); }
.proto-label { color: var(--proto-muted); }
.proto-seg { display: inline-flex; border: 1px solid var(--proto-rule); border-radius: var(--radius-control); padding: var(--space-3xs); gap: var(--space-3xs); background: var(--proto-bg); }
.proto-seg button, .proto-btn, .proto select { min-height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--proto-ink); padding: 0 var(--space-sm); cursor: pointer; font-size: var(--text-sm); white-space: nowrap; transition: background-color var(--dur-micro) var(--ease-out); }
.proto select { border: 1px solid var(--proto-muted); background: var(--proto-bg); padding: 0 var(--space-xs); }
.proto-seg button[aria-pressed="true"] { background: var(--proto-active); color: var(--proto-active-ink); }
.proto-seg button:hover:not([aria-pressed="true"]), .proto-btn:hover { background: var(--proto-rule); }
.proto-btn { display: inline-flex; align-items: center; gap: var(--space-2xs); border: 1px solid var(--proto-rule); }
.proto-btn[aria-pressed="true"] { background: var(--proto-active); color: var(--proto-active-ink); border-color: var(--proto-active); }
.proto-btn:active, .proto-seg button:active { transform: translateY(1px); }
.proto :focus-visible { outline: 2px solid var(--proto-ink); outline-offset: 2px; }
.proto-badge { min-width: 20px; height: 20px; padding: 0 var(--space-2xs); border-radius: var(--radius-pill); background: var(--proto-active); color: var(--proto-active-ink); font-size: var(--text-xs); display: inline-grid; place-items: center; }
.proto-btn[aria-pressed="true"] .proto-badge { background: var(--proto-active-ink); color: var(--proto-active); }
.proto-spacer { flex: 1; }

.stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; }
.stage.is-phone { padding: var(--space-lg) var(--space-md); align-items: center; }
.frame { position: relative; container-type: inline-size; contain: layout; width: 100%; height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--color-paper); color: var(--color-ink); }
.stage.is-phone .frame { width: var(--frame-phone); max-width: 100%; height: min(844px, 100%); border-radius: 28px; box-shadow: var(--shadow-frame); }

/* ---------- Телефон: шапка, экран, низ ---------- */
.tg-head { position: sticky; top: 0; z-index: var(--z-sticky); flex-shrink: 0; display: grid; grid-template-columns: minmax(88px, auto) minmax(0, 1fr) minmax(88px, auto); align-items: center; min-height: 52px; padding: 0 var(--space-xs); background: var(--color-surface); border-bottom: 1px solid var(--color-rule); }
.tg-head h1 { font-size: var(--text-md); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-back { display: inline-flex; align-items: center; text-decoration: none; gap: var(--space-3xs); min-height: 44px; padding: 0 var(--space-xs); border: 0; background: transparent; color: var(--color-link); border-radius: var(--radius-control); cursor: pointer; font-size: var(--text-md); transition: background-color var(--dur-micro) var(--ease-out); }
.tg-back:hover { background: var(--color-paper-2); }
.tg-back:active { transform: translateY(1px); }

.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.page { padding: var(--space-md) var(--space-md) var(--space-xl); display: flex; flex-direction: column; gap: var(--space-lg); }
.page-title { font-size: var(--text-2xl); }
.page-lead { color: var(--color-muted); max-width: 60ch; }

.dock { position: sticky; bottom: 0; z-index: var(--z-sticky); flex-shrink: 0; background: var(--color-surface); border-top: 1px solid var(--color-rule); }
.main-wrap { padding: var(--space-xs) var(--space-md) var(--space-xs); display: flex; flex-direction: column; gap: var(--space-2xs); }
.main-note { font-size: var(--text-xs); color: var(--color-muted); text-align: center; }
.main-btn { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: 0 var(--space-md); border: 0; border-radius: 12px; background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-md); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.main-btn .main-sum { font-weight: 500; }
.main-btn--split { justify-content: space-between; }
.main-btn:hover { background: var(--color-ink-2); }
.main-btn:active { transform: translateY(1px); }
.main-btn:disabled, .main-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 0 var(--space-xs); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3xs); min-height: 54px; border: 0; background: transparent; color: var(--color-muted); font-size: var(--text-xs); cursor: pointer; text-decoration: none; border-radius: var(--radius-control); position: relative; transition: background-color var(--dur-micro) var(--ease-out); }
.tab[aria-current="page"] { color: var(--color-link); font-weight: 500; }
.tab:hover { background: var(--color-paper-2); }
.tab:active { transform: translateY(1px); }
.tab-badge { position: absolute; top: var(--space-2xs); left: calc(50% + var(--space-xs)); min-width: 18px; height: 18px; padding: 0 var(--space-2xs); border-radius: var(--radius-pill); background: var(--color-badge); color: var(--color-badge-ink); font-size: 0.6875rem; display: grid; place-items: center; font-weight: 600; }

/* ---------- Компьютер: меню и колонки ---------- */
.wide { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.side { display: flex; flex-direction: column; gap: var(--space-lg); padding: var(--space-lg) var(--space-sm); background: var(--color-surface); border-right: 1px solid var(--color-rule); min-height: 0; overflow-y: auto; }
.wordmark { font-size: var(--text-lg); font-weight: 600; padding: 0 var(--space-sm); }
.side-nav { display: flex; flex-direction: column; gap: var(--space-3xs); }
.side-link { display: flex; align-items: center; gap: var(--space-sm); min-height: 40px; padding: 0 var(--space-sm); border-radius: var(--radius-control); color: var(--color-ink); text-decoration: none; transition: background-color var(--dur-micro) var(--ease-out); }
.side-link:hover { background: var(--color-paper-2); }
.side-link[aria-current="page"] { background: var(--color-fill); font-weight: 500; }
.side-link .side-count { margin-left: auto; font-size: var(--text-xs); color: var(--color-muted); }
.side-foot { margin-top: auto; padding: 0 var(--space-sm); font-size: var(--text-sm); color: var(--color-muted); }
.side-foot strong { display: block; color: var(--color-ink); font-weight: 500; }
.wide-main { min-height: 0; display: flex; flex-direction: column; }
.wide .scroller { display: flex; flex-direction: column; }
.wide .page { width: 100%; max-width: var(--container); margin-inline: auto; padding: var(--space-lg) var(--gutter) var(--space-2xl); }
.wide .page--fill { flex: 1; min-height: 0; padding-bottom: var(--space-lg); }
.page-head { display: flex; align-items: flex-start; gap: var(--space-md); flex-wrap: wrap; }
.page-head > div:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-xs); }
.page-head-actions { display: flex; gap: var(--space-xs); align-items: center; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: var(--space-3xs); color: var(--color-link); text-decoration: none; font-size: var(--text-sm); min-height: 32px; border-radius: 8px; align-self: flex-start; }
.back-link:hover { text-decoration: underline; }
.cols { display: grid; gap: var(--space-lg); grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.cols--list { grid-template-columns: 360px minmax(0, 1fr); }
.col { display: flex; flex-direction: column; gap: var(--space-lg); min-width: 0; }

/* ---------- Группы (секции на сером фоне) ---------- */
.group-wrap { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.group-title { font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); padding: 0 var(--space-md); display: flex; align-items: baseline; gap: var(--space-xs); }
.group-title .group-title-end { margin-left: auto; font-weight: 400; }
.group-title--ink { color: var(--color-ink); font-size: var(--text-lg); font-weight: 600; padding: 0; }
.group { background: var(--color-surface); border-radius: var(--radius-card); overflow: hidden; }
.group-foot { font-size: var(--text-xs); color: var(--color-muted); padding: 0 var(--space-md); line-height: 1.4; }
.group-pad { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.row { position: relative; display: flex; align-items: center; gap: var(--space-sm); min-height: 48px; padding: var(--space-sm) var(--space-md); color: var(--color-ink); text-decoration: none; width: 100%; border: 0; background: transparent; text-align: left; font: inherit; }
.row + .row::before, .row + .row-extra::before, .row-extra + .row::before { content: ""; position: absolute; top: 0; left: var(--space-md); right: 0; border-top: 1px solid var(--color-rule); }
.row-extra { position: relative; }
a.row, button.row { cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out); }
a.row:hover, button.row:hover { background: var(--color-paper-2); }
a.row:active, button.row:active { background: var(--color-paper-3); }
a.row:focus-visible, button.row:focus-visible { outline-offset: -2px; }
.row[aria-current="page"] { background: var(--color-selected); }
.row[aria-current="page"] .row-title { font-weight: 600; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3xs); }
.row-title { font-weight: 500; overflow-wrap: break-word; }
.row-sub { font-size: var(--text-sm); color: var(--color-muted); overflow-wrap: break-word; }
.row-end { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3xs); flex-shrink: 0; }
.row-end--inline { flex-direction: row; align-items: center; gap: var(--space-xs); }
.row .i-chev { color: var(--color-muted); }
.row--total .row-title, .row--total .money { font-weight: 600; font-size: var(--text-lg); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money--muted, .muted { color: var(--color-muted); }
.money--due { color: var(--color-ink); font-weight: 600; }
.money--over { color: var(--color-success); font-weight: 500; }
.strike { text-decoration: line-through; color: var(--color-muted); }
.warn-text { color: var(--color-warn); }
.err-text { color: var(--color-error); }
.ok-text { color: var(--color-success); }

/* ---------- Кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: 40px; padding: 0 var(--space-md); border: 1px solid var(--color-accent); border-radius: var(--radius-control); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn:hover { background: var(--color-ink-2); border-color: var(--color-ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--quiet { background: var(--color-fill); color: var(--color-ink); border-color: transparent; }
.btn--quiet:hover { background: var(--color-fill-2); border-color: transparent; }
.btn--plain { background: transparent; color: var(--color-link); border-color: transparent; padding: 0 var(--space-xs); }
.btn--plain:hover { background: var(--color-paper-2); border-color: transparent; }
.btn--danger { background: transparent; color: var(--color-error); border-color: transparent; padding: 0 var(--space-xs); }
.btn--danger:hover { background: var(--color-error-bg); border-color: transparent; }
.btn--block { width: 100%; }
.btn--lg { min-height: 44px; font-size: var(--text-md); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--color-muted); cursor: pointer; position: relative; transition: background-color var(--dur-micro) var(--ease-out); }
.icon-btn::after { content: ""; position: absolute; inset: -4px; }
.icon-btn:hover { background: var(--color-paper-2); color: var(--color-ink); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; }
.field-label { font-size: var(--text-sm); color: var(--color-muted); }
.field-help { font-size: var(--text-xs); color: var(--color-muted); min-height: 1lh; }
.field-help.is-error { color: var(--color-error); }
.input { width: 100%; min-height: 40px; padding: 0 var(--space-sm); border: 1px solid var(--color-field-edge); border-radius: var(--radius-input); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-md); }
.input::placeholder { color: var(--color-muted); }
.input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -1px; }
.input:disabled { opacity: 0.55; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--color-error); }
.input--num { width: 72px; text-align: right; padding: 0 var(--space-xs); }
.input--money { width: 120px; text-align: right; }
select.input { padding-right: var(--space-xl); cursor: pointer; }
.search { position: relative; }
.search .i { position: absolute; left: var(--space-sm); top: 50%; transform: translateY(-50%); color: var(--color-muted); pointer-events: none; }
.search .input { padding-left: var(--space-xl); }
.inline-form { display: flex; gap: var(--space-xs); align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 120px; }
.inline-form.group-pad { flex-direction: row; align-items: flex-end; }
.alloc .btn--plain { align-self: flex-start; }
.check { width: 20px; height: 20px; accent-color: var(--color-accent); cursor: pointer; flex-shrink: 0; margin: 0; }
.check:disabled { cursor: not-allowed; opacity: 0.55; }
.check-row { display: flex; align-items: center; gap: var(--space-sm); min-height: 36px; cursor: pointer; border-radius: 8px; }
.check-row:hover { background: var(--color-paper-2); }
.check-row .count-n { margin-left: auto; color: var(--color-muted); font-size: var(--text-sm); }

.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; appearance: none; margin: 0; border-radius: var(--radius-pill); background: var(--color-fill-2); cursor: pointer; transition: background-color var(--dur-short) var(--ease-in-out); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow-knob); transition: transform var(--dur-short) var(--ease-in-out); }
.switch:checked { background: var(--color-success); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.switch:disabled { opacity: 0.55; cursor: not-allowed; }

/* Чипы, сегменты, степпер */
.chips { display: flex; gap: var(--space-xs); overflow-x: auto; padding-bottom: var(--space-3xs); scrollbar-width: none; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
.chip { display: inline-flex; align-items: center; gap: var(--space-2xs); min-height: 36px; padding: 0 var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-sm); white-space: nowrap; cursor: pointer; flex-shrink: 0; transition: background-color var(--dur-micro) var(--ease-out); }
.chip:hover { background: var(--color-paper-2); }
.chip:active { transform: translateY(1px); }
.chip[aria-pressed="true"] { background: var(--color-ink); color: var(--color-surface); border-color: var(--color-ink); }
.chip .chip-n { color: inherit; opacity: 0.8; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); overflow-x: auto; scrollbar-width: none; padding: var(--space-3xs); gap: var(--space-3xs); border-radius: var(--radius-control); background: var(--color-fill); }
.seg button { min-height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--color-ink); font-size: var(--text-sm); cursor: pointer; padding: 0 var(--space-sm); white-space: nowrap; transition: background-color var(--dur-micro) var(--ease-out); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--color-fill-2); }
.seg button[aria-pressed="true"] { background: var(--color-surface); font-weight: 500; box-shadow: var(--shadow-knob); }
.seg button:active { transform: translateY(1px); }
.seg--inline { display: inline-grid; }
.stepper { display: inline-flex; align-items: center; border-radius: var(--radius-control); background: var(--color-fill); flex-shrink: 0; }
.stepper button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--color-link); border-radius: var(--radius-control); cursor: pointer; position: relative; transition: background-color var(--dur-micro) var(--ease-out); }
.stepper button::after { content: ""; position: absolute; inset: -4px 0; }
.stepper button:hover { background: var(--color-fill-2); }
.stepper button:active { transform: translateY(1px); }
.stepper button:disabled { opacity: 0.55; cursor: not-allowed; }
.stepper output { min-width: 28px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.add-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: var(--radius-control); background: var(--color-fill); color: var(--color-link); cursor: pointer; flex-shrink: 0; position: relative; transition: background-color var(--dur-micro) var(--ease-out); }
.add-btn::after { content: ""; position: absolute; inset: -4px; }
.add-btn:hover { background: var(--color-fill-2); }
.add-btn:active { transform: translateY(1px); }
.add-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Статусы и этапы */
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 var(--space-xs); border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 500; white-space: nowrap; }
.status[data-tone="collect"] { color: var(--st-collect); background: var(--st-collect-bg); }
.status[data-tone="sent"] { color: var(--st-sent); background: var(--st-sent-bg); }
.status[data-tone="sverka"] { color: var(--st-sverka); background: var(--st-sverka-bg); }
.status[data-tone="done"] { color: var(--st-done); background: var(--st-done-bg); }
.status[data-tone="gray"] { color: var(--st-gray); background: var(--st-gray-bg); }
.status[data-tone="cancel"] { color: var(--st-cancel); background: var(--st-cancel-bg); }
.status[data-tone="warn"] { color: var(--color-warn); background: var(--color-warn-bg); }
.stages { display: flex; flex-direction: column; gap: var(--space-xs); }
.stages-bar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2xs); list-style: none; margin: 0; padding: 0; }
.stages-bar li { display: flex; flex-direction: column; gap: var(--space-2xs); font-size: var(--text-xs); color: var(--color-muted); min-width: 0; }
.stages-bar li::before { content: ""; height: 4px; border-radius: 2px; background: var(--color-fill-2); }
.stages-bar li[data-state="done"]::before { background: var(--color-muted); }
.stages-bar li[data-state="now"] { color: var(--color-ink); font-weight: 500; }
.stages-bar li[data-tone="collect"]::before { background: var(--st-collect); }
.stages-bar li[data-tone="sent"]::before { background: var(--st-sent); }
.stages-bar li[data-tone="sverka"]::before { background: var(--st-sverka); }
.stages-bar li[data-tone="done"]::before { background: var(--st-done); }
.stages-bar li[data-tone="gray"]::before { background: var(--st-gray); }
.stages-bar .stage-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stages-note { font-size: var(--text-sm); color: var(--color-muted); }
.frame:not(.is-wide) .stages-bar .stage-name { display: none; }

/* Цифры */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--color-surface); border-radius: var(--radius-card); }
.figure-cell { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-3xs); min-width: 0; }
.figure-cell + .figure-cell { border-left: 1px solid var(--color-rule); }
.figure-label { font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; }
.figure-value { margin: 0; font-size: var(--text-xl); font-weight: 600; white-space: nowrap; }
.main-note--end { text-align: right; }
.frame:not(.is-wide) .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.frame:not(.is-wide) .figure-cell:nth-child(3) { border-left: 0; }
.frame:not(.is-wide) .figure-cell:nth-child(n+3) { border-top: 1px solid var(--color-rule); }
.big-figure { display: flex; flex-direction: column; gap: var(--space-3xs); }
.big-figure .figure-value { font-size: var(--text-3xl); }
.progress { height: 8px; border-radius: 4px; background: var(--color-fill-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--st-done); border-radius: 4px; transform-origin: left; }

/* Тонированные сообщения внутри экрана */
.note { display: flex; gap: var(--space-sm); align-items: flex-start; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-card); background: var(--color-surface); font-size: var(--text-sm); }
.note .i { margin-top: var(--space-3xs); }
.note--warn { background: var(--color-warn-bg); }
.note--warn .i { color: var(--color-warn); }
.note--error { background: var(--color-error-bg); }
.note--error .i { color: var(--color-error); }
.note--info { background: var(--st-collect-bg); }
.note--info .i { color: var(--st-collect); }
.note-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2xs); }
.note-body strong { font-weight: 600; }
.note .btn { align-self: flex-start; }

.empty { padding: var(--space-xl) var(--space-md); display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm); background: var(--color-surface); border-radius: var(--radius-card); }
.empty h2 { font-size: var(--text-lg); }
.empty p { color: var(--color-muted); max-width: 46ch; }

.skel { display: block; border-radius: 6px; background: var(--color-fill); }
.skel-line { height: 14px; }
.keep-motion.skel-pulse { animation: skel 1.4s ease-in-out infinite; }
@keyframes skel { 50% { opacity: 0.55; } }

/* ---------- Каталог ---------- */
.cat-tools { display: flex; flex-direction: column; gap: var(--space-sm); }
.cat-tools-row { display: flex; gap: var(--space-xs); align-items: center; }
.cat-tools-row .search { flex: 1; min-width: 0; }
.cat-tools-row .input-grow { flex: 1; min-width: 0; width: auto; }
.cat-tools-row--wrap { flex-wrap: wrap; }
.cat-tools-row--between { justify-content: space-between; }
.cat-count { font-size: var(--text-sm); color: var(--color-muted); padding: 0 var(--space-md); }
.brand-head { display: flex; align-items: baseline; gap: var(--space-xs); padding: var(--space-md) var(--space-md) var(--space-3xs); background: var(--color-paper); font-size: var(--text-md); font-weight: 600; }
.brand-head span { font-size: var(--text-sm); color: var(--color-muted); font-weight: 400; }
.flavor { position: relative; padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); }
.flavor + .flavor::before { content: ""; position: absolute; top: 0; left: var(--space-md); right: 0; border-top: 1px solid var(--color-rule); }
.flavor-head { display: flex; align-items: baseline; gap: var(--space-xs); flex-wrap: wrap; }
.flavor-name { font-size: var(--text-md); font-weight: 600; overflow-wrap: break-word; min-width: 0; }
.flavor-line { font-size: var(--text-sm); color: var(--color-muted); }
.flavor-descr { font-size: var(--text-sm); color: var(--color-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 70ch; }
.flavor-meta { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xs); align-items: center; font-size: var(--text-xs); }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 var(--space-xs); border-radius: 6px; background: var(--color-fill); color: var(--color-ink); font-size: var(--text-xs); }
.tag--sale { background: var(--color-warn-bg); color: var(--color-warn); font-weight: 500; }
.flavor-hist { display: inline-flex; align-items: center; gap: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); }
.packs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2xs); }
.pack { display: flex; align-items: center; gap: var(--space-sm); min-height: 44px; }
.pack-g { width: 52px; flex-shrink: 0; font-weight: 500; }
.pack-price { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pack-price .money { font-weight: 500; }
.pack-per { font-size: var(--text-xs); color: var(--color-muted); }
.pack-row-end { display: flex; align-items: center; gap: var(--space-xs); margin-left: auto; }
.sentinel { height: 1px; }
.load-more { display: flex; justify-content: center; padding: var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }

.cat-wide { display: grid; grid-template-columns: 284px minmax(0, 1fr) 320px; gap: var(--space-lg); height: 100%; min-height: 0; }
.cat-col { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-md); padding-bottom: var(--space-lg); }
.cat-col--list { gap: var(--space-sm); }
.filter-group { display: flex; flex-direction: column; gap: var(--space-2xs); }
.filter-group h3 { font-size: var(--text-sm); font-weight: 600; padding: var(--space-xs) 0 var(--space-2xs); }
.filter-list { display: flex; flex-direction: column; padding: var(--space-3xs); }
.filter-list--scroll { max-height: 280px; overflow-y: auto; }
.filter-more { align-self: flex-start; }
.sum-line { display: flex; justify-content: space-between; gap: var(--space-sm); align-items: baseline; }
.saved { display: inline-flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-xs); color: var(--color-success); }

/* ---------- Таблицы ---------- */
.table-wrap { background: var(--color-surface); border-radius: var(--radius-card); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 500; color: var(--color-muted); padding: var(--space-sm) var(--space-sm); white-space: nowrap; border-bottom: 1px solid var(--color-rule); }
.table td { padding: var(--space-xs) var(--space-sm); border-top: 1px solid var(--color-rule); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--space-md); }
.table th:last-child, .table td:last-child { padding-right: var(--space-md); }
.table .num { text-align: right; white-space: nowrap; }
.table .who { color: var(--color-muted); }
.table tr.is-selected td { background: var(--color-paper-2); }
.table tr.is-short td { background: var(--color-warn-bg); }
.table .td-name { font-weight: 500; color: var(--color-ink); }
.table .td-sub { display: block; color: var(--color-muted); font-size: var(--text-xs); font-weight: 400; }
.table tbody tr.sub-row td { border-top: 0; padding-top: 0; }

/* Кому сколько */
.alloc { display: flex; flex-direction: column; gap: var(--space-xs); padding: var(--space-sm) var(--space-md); background: var(--color-warn-bg); border-radius: var(--radius-input); }
.alloc-head { display: flex; justify-content: space-between; gap: var(--space-sm); font-size: var(--text-sm); flex-wrap: wrap; }
.alloc-row { display: flex; align-items: center; gap: var(--space-sm); justify-content: space-between; }
.alloc-row .stepper { background: var(--color-surface); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); padding: 0 var(--space-md) var(--space-sm); }

/* Свод для поставщика */
.supplier-part { display: flex; flex-direction: column; gap: var(--space-xs); }
.supplier-text { margin: 0; padding: var(--space-sm); border-radius: var(--radius-input); background: var(--color-fill); font: var(--text-xs)/1.5 var(--font-body); white-space: pre-wrap; max-height: 220px; overflow-y: auto; color: var(--color-ink); }

/* ---------- Чат с ботом ---------- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--color-paper); }
.chat-head { flex-shrink: 0; display: flex; align-items: center; gap: var(--space-sm); min-height: 56px; padding: 0 var(--space-md); background: var(--color-surface); border-bottom: 1px solid var(--color-rule); }
.chat-ava { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--color-accent); color: var(--color-accent-ink); flex-shrink: 0; }
.chat-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-title strong { font-weight: 600; }
.chat-title span { font-size: var(--text-xs); color: var(--color-muted); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.chat-log-inner { width: 100%; max-width: 640px; margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-sm); }
.chat-day { align-self: center; font-size: var(--text-xs); color: var(--color-muted); padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-pill); background: var(--color-surface); }
.msg { max-width: min(86%, 460px); display: flex; flex-direction: column; gap: var(--space-2xs); }
.msg-bubble { background: var(--color-surface); border-radius: 16px 16px 16px 4px; padding: var(--space-xs) var(--space-sm); display: flex; flex-direction: column; gap: var(--space-2xs); }
.msg-bubble p { font-size: var(--text-md); line-height: 1.4; }
.msg-time { align-self: flex-end; font-size: var(--text-xs); color: var(--color-muted); }
.chat-new { align-self: stretch; display: flex; align-items: center; gap: var(--space-sm); font-size: var(--text-xs); color: var(--color-link); font-weight: 500; }
.chat-new::before, .chat-new::after { content: ""; flex: 1; border-top: 1px solid var(--color-link); opacity: 0.5; }
.msg-kb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2xs); }
.msg-kb a { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 var(--space-sm); border-radius: 10px; background: var(--color-surface); color: var(--color-link); font-size: var(--text-sm); font-weight: 500; text-decoration: none; text-align: center; transition: background-color var(--dur-micro) var(--ease-out); }
.msg-kb a:hover { background: var(--color-paper-3); }
.msg-kb a:active { transform: translateY(1px); }
.chat-foot { flex-shrink: 0; padding: var(--space-xs) var(--space-md) var(--space-sm); background: var(--color-surface); border-top: 1px solid var(--color-rule); display: flex; flex-direction: column; gap: var(--space-2xs); }
.chat-foot-inner { width: 100%; max-width: 640px; margin-inline: auto; }

/* ---------- Шторки ---------- */
.layer { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; flex-direction: column; justify-content: flex-end; }
.scrim { position: absolute; inset: 0; background: var(--color-scrim); border: 0; padding: 0; cursor: default; }
.sheet { position: relative; max-height: calc(100% - var(--space-xl)); display: flex; flex-direction: column; background: var(--color-paper); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-sheet); }
.frame.is-wide .layer { justify-content: center; align-items: center; }
.frame.is-wide .sheet { width: min(560px, calc(100% - var(--space-2xl))); max-height: calc(100% - var(--space-2xl)); border-radius: 16px; }
.sheet-head { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-md) var(--space-md) var(--space-sm); }
.sheet-head h2 { flex: 1; font-size: var(--text-lg); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--space-md) var(--space-md); display: flex; flex-direction: column; gap: var(--space-md); }
.sheet-foot { padding: var(--space-sm) var(--space-md) var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); background: var(--color-surface); border-top: 1px solid var(--color-rule); }
.frame.is-wide .sheet-foot { flex-direction: row-reverse; justify-content: flex-start; border-radius: 0 0 16px 16px; }
.frame.is-wide .sheet-foot .main-btn { width: auto; min-height: 40px; font-size: var(--text-sm); padding: 0 var(--space-lg); border-radius: var(--radius-control); }
.sheet-foot .btn { min-height: 44px; }
.frame.is-wide .sheet-foot .btn { min-height: 40px; }
.confirm-text { color: var(--color-ink); }
.is-entering .scrim { animation: fade-in var(--dur-short) var(--ease-out); }
.is-entering .sheet { animation: sheet-in var(--dur-long) var(--ease-out); }
.frame.is-wide .is-entering .sheet { animation: pop-in var(--dur-short) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } }

/* Тост */
.toast { position: absolute; left: 50%; bottom: var(--space-lg); z-index: var(--z-toast); transform: translateX(-50%); display: flex; align-items: center; gap: var(--space-sm); width: max-content; max-width: calc(100% - var(--space-xl)); padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md); border-radius: 12px; background: var(--color-ink); color: var(--color-surface); font-size: var(--text-sm); box-shadow: var(--shadow-toast); }
.dock .toast { bottom: calc(100% + var(--space-xs)); }
.toast { pointer-events: none; }
.toast .btn { pointer-events: auto; }
.toast[hidden] { display: none; }
.toast-text { padding: var(--space-xs) 0; }
.toast .btn--plain { color: var(--color-surface); text-decoration: underline; }
.toast .btn--plain:hover { background: transparent; text-decoration-thickness: 2px; }
.toast .btn--plain:focus-visible { outline-color: var(--color-surface); }
.toast.is-entering { animation: pop-in var(--dur-short) var(--ease-out); }

.offline { flex-shrink: 0; display: flex; gap: var(--space-xs); align-items: center; padding: var(--space-xs) var(--space-md); background: var(--color-warn-bg); font-size: var(--text-sm); }
.offline .i { color: var(--color-warn); }

.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.steps li { counter-increment: s; }
.steps .row::after { content: counter(s); order: -1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--color-fill); font-weight: 600; font-size: var(--text-sm); flex-shrink: 0; }

/* Телефон: касание от 44 px */
.frame:not(.is-wide) .btn { min-height: 44px; }
.frame:not(.is-wide) .stepper button, .frame:not(.is-wide) .add-btn { width: 44px; height: 44px; }
.frame:not(.is-wide) .chip { min-height: 40px; }
.frame:not(.is-wide) .seg button { min-height: 36px; }
.frame:not(.is-wide) .input { min-height: 44px; font-size: var(--text-md); }
.frame:not(.is-wide) .icon-btn { width: 44px; height: 44px; }
.frame:not(.is-wide) .check-row { min-height: 44px; }
.frame.is-wide .chips { flex-wrap: wrap; overflow: visible; }

@media (max-width: 40rem) {
  .proto { gap: var(--space-xs); }
  .proto-label { display: none; }
  .stage.is-phone { padding: 0; }
  .stage.is-phone .frame { border-radius: 0; height: 100%; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .is-entering .sheet, .is-entering .scrim, .toast.is-entering, .frame.is-wide .is-entering .sheet { animation: none; }
  .switch::after, .switch, .btn, .main-btn, .chip, .stepper button, .add-btn, .row, .tab, .side-link, .seg button, .proto-btn, .proto-seg button, .icon-btn, .tg-back, .msg-kb a { transition: none; }
  .keep-motion.skel-pulse { animation-duration: 2.8s; }
}

/* ---------- Фильтры каталога: пилюли, разделы, выбор ---------- */
.i--xs { width: 14px; height: 14px; }
.pills { display: flex; gap: var(--space-xs); overflow-x: auto; padding: var(--space-2xs) 0; scrollbar-width: none; }
.frame.is-wide .pills { flex-wrap: wrap; overflow: visible; }
.pill { position: relative; display: inline-flex; align-items: center; gap: var(--space-2xs); flex-shrink: 0; min-height: 36px; padding: 0 var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-sm); white-space: nowrap; cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out); }
button.pill::after, .pill-main::after, .pill-x::after { content: ""; position: absolute; inset: -4px 0; }
button.pill:hover { background: var(--color-paper-2); }
button.pill:active, .pill-main:active, .pill-x:active { transform: translateY(1px); }
.pill .i { color: var(--color-muted); }
.pill.is-on { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-surface); }
.pill.is-on .i { color: inherit; }
button.pill.is-on:hover { background: var(--color-ink-hover); border-color: var(--color-ink-hover); }
.pill--set { padding: 0; gap: 0; cursor: default; }
.pill-main, .pill-x { position: relative; display: inline-flex; align-items: center; min-height: 34px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; border-radius: var(--radius-pill); }
.pill-main { padding: 0 var(--space-2xs) 0 var(--space-sm); }
.pill-x { justify-content: center; width: 32px; }
.pill-main:hover, .pill-x:hover { background: var(--color-ink-hover); }
.pill-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 var(--space-2xs); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-xs); font-weight: 600; }
.cat-count-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.cat-count-row .cat-count { padding: 0; }
.cat-count-row .input { width: auto; flex: 0 0 auto; }

.frow .row-main { flex: 0 0 auto; }
.frow .row-title { white-space: nowrap; }
.frow-val { margin-left: auto; flex: 0 1 auto; min-width: 0; max-width: 62%; text-align: right; color: var(--color-ink); overflow-wrap: anywhere; }
.frow-val.is-any { color: var(--color-muted); }
.frow[aria-expanded="true"] { background: var(--color-paper-2); }
.frow-toggle { cursor: pointer; }

.sheet--l2 { height: calc(100% - var(--space-xl)); }
.frame.is-wide .sheet--l2 { height: min(720px, calc(100% - var(--space-2xl))); }
.sheet-head--l2 { display: grid; grid-template-columns: minmax(96px, auto) minmax(0, 1fr) minmax(96px, auto); align-items: center; padding: var(--space-xs) var(--space-xs) var(--space-xs); }
.sheet-head--l2 h2 { text-align: center; }
.sheet-head--l2 .btn--plain { justify-self: end; }
.sheet-body--l2 { overflow: hidden; display: flex; flex-direction: column; gap: var(--space-sm); padding-bottom: 0; }
.fl2-fixed { flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-sm); }
.fsel { display: flex; flex-direction: column; gap: var(--space-2xs); max-height: 40vh; overflow-y: auto; }
.fsel-title, .fletter { font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); padding: 0 var(--space-md); }
.fletter { padding-top: var(--space-xs); }
.fl2-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2xs); padding-bottom: var(--space-md); }
.fopt-n { margin-left: auto; color: var(--color-muted); font-size: var(--text-sm); }
.fopt-check { width: 22px; height: 22px; display: grid; place-items: center; flex-shrink: 0; color: var(--color-link); }
.fopt.is-on .row-title { font-weight: 600; }
.fopt:disabled { opacity: 0.55; cursor: not-allowed; }
.fopt:disabled:hover { background: transparent; }
.fopt-empty { padding: var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }

.fpanel { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-sm) 0 var(--space-sm); background: var(--color-paper-2); }
.fpanel .search, .fpanel .seg { margin: 0 var(--space-sm); }
.fpanel .fsel { max-height: 180px; }
.fpanel .fl2-list { max-height: 320px; padding-bottom: 0; }
.fpanel .fopt { min-height: 40px; padding: var(--space-xs) var(--space-sm); }
.fpanel .row + .row::before { left: var(--space-sm); }
.fpanel .fsel-title, .fpanel .fletter { padding: 0 var(--space-sm); }
.fpanel-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-xs); padding: 0 var(--space-sm); }
.fopt-list { display: flex; flex-direction: column; }

.is-push .sheet-head, .is-push .sheet-body, .fpanel.is-push { animation: push-in var(--dur-short) var(--ease-out); }
.is-pop .sheet-head, .is-pop .sheet-body { animation: pop-back var(--dur-short) var(--ease-out); }
@keyframes push-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes pop-back { from { opacity: 0; transform: translateX(-24px); } }
.frame.is-wide .fpanel.is-push { animation-name: fade-in; }
.frame:not(.is-wide) .pill-x { width: 40px; }
@media (prefers-reduced-motion: reduce) {
  .is-push .sheet-head, .is-push .sheet-body, .fpanel.is-push, .is-pop .sheet-head, .is-pop .sheet-body { animation: none; }
  .pill, .pill-main, .pill-x { transition: none; }
}
