/* Переменные: цвета и размеры общие для всех экранов. */
:root {
  --bg:#f4f5f7;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --line:#e5e7eb;
  --line-strong:#cbd5e1;
  --ink:#0f172a;
  --ink-2:#334155;
  --muted:#5f6b7a;
  --accent:#2563eb;
  --accent-hover:#1d4ed8;
  --accent-soft:#eff6ff;
  --accent-soft-2:#dbeafe;
  --ok:#15803d;
  --ok-soft:#dcfce7;
  --warn:#b45309;
  --warn-soft:#fef3c7;
  --danger:#dc2626;
  --danger-text:#b91c1c;
  --danger-soft:#fee2e2;
  --info:#0369a1;
  --info-soft:#e0f2fe;
  --tone-sale-bg:var(--ok-soft);
  --tone-sale-ink:var(--ok);
  --tone-return-bg:#ffedd5;
  --tone-return-ink:#c2410c;
  --tone-receipt-bg:var(--accent-soft-2);
  --tone-receipt-ink:var(--accent-hover);
  --tone-transfer-bg:#ede9fe;
  --tone-transfer-ink:#6d28d9;
  --tone-stock-bg:#ccfbf1;
  --tone-stock-ink:#0f766e;
  --tone-money-bg:#fef9c3;
  --tone-money-ink:#854d0e;
  --tone-reports-bg:#e0e7ff;
  --tone-reports-ink:#4338ca;
  --tone-partners-bg:#fce7f3;
  --tone-partners-ink:#be185d;
  --tone-products-bg:#fae8ff;
  --tone-products-ink:#a21caf;
  --tone-inventory-bg:#cffafe;
  --tone-inventory-ink:#0e7490;
  --tone-writeoff-bg:var(--danger-soft);
  --tone-writeoff-ink:var(--danger-text);
  --tone-docs-bg:#f1f5f9;
  --tone-docs-ink:#475569;
  --tone-settings-bg:var(--tone-docs-bg);
  --tone-settings-ink:var(--tone-docs-ink);
  --r-sm:8px;
  --r-md:12px;
  --r-lg:16px;
  --r-pill:999px;
  --shadow-1:0 1px 2px rgba(15,23,42,.06);
  --shadow-2:0 4px 16px rgba(15,23,42,.08);
  --shadow-up:0 -4px 16px rgba(15,23,42,.08);
  color-scheme:light;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-size:16px;
  line-height:1.45;
  color:var(--ink);
  background:var(--bg);
}

/* Основа. Переносы не дают длинному названию растянуть страницу. */
* { box-sizing:border-box; min-width:0; }
body { margin:0; overflow-wrap:anywhere; }
body.signed-in { padding-bottom:calc(80px + env(safe-area-inset-bottom)); }
h1,h2,h3,p,dl,ol,ul { margin:0 0 16px; }
h1 { font-size:1.375rem; line-height:1.3; font-weight:700; margin:0; }
h2 { font-size:1.125rem; font-weight:700; margin-top:24px; }
h3 { font-size:1rem; margin-top:20px; }
h2:first-child,h3:first-child { margin-top:0; }
p:last-child { margin-bottom:0; }
a { color:var(--accent); text-underline-offset:4px; min-height:44px; max-width:100%; display:inline-flex; align-items:center; gap:8px; overflow-wrap:anywhere; }
small,.small { font-size:.875rem; color:var(--muted); }
.muted,.hint,.filter-summary { color:var(--muted); }
.hint { font-size:.875rem; margin:8px 0 16px; }
.number,.metric strong,.doc-total,.sale-number,.model-values { font-variant-numeric:tabular-nums; }
.number { text-align:right; }
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible { outline:3px solid var(--accent-soft-2); outline-offset:2px; }
button,a,input,select,textarea,summary { -webkit-tap-highlight-color:var(--accent-soft); }

/* Каркас: телефон, общие заголовки, навигация. */
.topbar { height:56px; background:var(--surface); border-bottom:1px solid var(--line); display:flex; align-items:center; gap:12px; padding:0 16px; }
.brand { text-decoration:none; color:var(--ink); gap:8px; font-weight:700; }
.topbar .brand { flex:1; }
.brand-mark { width:32px; height:32px; border-radius:10px; background:var(--ink); color:var(--surface); display:inline-flex; justify-content:center; align-items:center; flex:none; font-size:1.125rem; font-weight:700; }
.company-name,.short-user>span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.short-user { flex:0 1 auto; max-width:42%; text-decoration:none; color:var(--ink-2); font-size:.875rem; }
.avatar { width:32px; height:32px; flex:none; border-radius:var(--r-pill); background:var(--accent-soft); color:var(--accent); font-weight:700; display:inline-flex; align-items:center; justify-content:center; }
.sidebar { display:none; }
main { max-width:1180px; margin:0 auto; padding:24px 16px; }
.page-header { display:grid; gap:16px; margin-bottom:24px; }
.title-line { display:flex; flex-wrap:wrap; align-items:center; gap:12px; }
.page-lead { color:var(--muted); margin:8px 0 0; }
.page-actions { display:flex; flex-direction:column; gap:8px; }
.page-actions:empty { display:none; }
.page-actions>.button { width:100%; }
.page-actions .help-link { align-self:flex-start; }
.back-link { color:var(--muted); text-decoration:none; font-size:.875rem; margin-top:-12px; margin-bottom:8px; }
.help-link { font-size:.875rem; text-decoration:none; }
.help-link .icon,.back-link .icon { width:20px; height:20px; }
.bottom-nav { display:grid; grid-auto-flow:column; grid-auto-columns:1fr; position:fixed; bottom:0; left:0; right:0; z-index:5; height:calc(64px + env(safe-area-inset-bottom)); padding-bottom:env(safe-area-inset-bottom); background:var(--surface); border-top:1px solid var(--line); }
.bottom-nav a { display:flex; flex-direction:column; justify-content:center; gap:0; text-decoration:none; color:var(--muted); font-size:11px; font-weight:600; text-align:center; padding:4px; }
.nav-icon { width:56px; max-width:100%; height:32px; display:flex; align-items:center; justify-content:center; border-radius:var(--r-pill); }
.bottom-nav [aria-current] { color:var(--accent); }
.bottom-nav [aria-current] .nav-icon { background:var(--accent-soft); }

/* Компоненты: значки, кнопки, карточки и формы. */
svg.icon { width:24px; height:24px; display:inline-block; flex:none; vertical-align:middle; }
.icon-circle { display:inline-flex; width:40px; height:40px; flex:none; border-radius:var(--r-pill); align-items:center; justify-content:center; background:var(--surface-2); color:var(--muted); }
.tone-sale { background:var(--tone-sale-bg); color:var(--tone-sale-ink); }
.tone-return { background:var(--tone-return-bg); color:var(--tone-return-ink); }
.tone-receipt { background:var(--tone-receipt-bg); color:var(--tone-receipt-ink); }
.tone-transfer { background:var(--tone-transfer-bg); color:var(--tone-transfer-ink); }
.tone-stock { background:var(--tone-stock-bg); color:var(--tone-stock-ink); }
.tone-money { background:var(--tone-money-bg); color:var(--tone-money-ink); }
.tone-reports { background:var(--tone-reports-bg); color:var(--tone-reports-ink); }
.tone-partners { background:var(--tone-partners-bg); color:var(--tone-partners-ink); }
.tone-products { background:var(--tone-products-bg); color:var(--tone-products-ink); }
.tone-inventory { background:var(--tone-inventory-bg); color:var(--tone-inventory-ink); }
.tone-writeoff { background:var(--tone-writeoff-bg); color:var(--tone-writeoff-ink); }
.tone-docs { background:var(--tone-docs-bg); color:var(--tone-docs-ink); }
.tone-settings { background:var(--tone-settings-bg); color:var(--tone-settings-ink); }
button,.button { font:inherit; line-height:1.25; font-weight:600; min-height:48px; min-width:44px; max-width:100%; display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:12px 16px; border:1px solid var(--accent); border-radius:10px; background:var(--accent); color:var(--surface); text-decoration:none; white-space:normal; cursor:pointer; transition:background-color 120ms,border-color 120ms,box-shadow 120ms; }
.primary { background:var(--accent); color:var(--surface); border-color:var(--accent); }
.secondary { background:var(--surface); color:var(--ink); border-color:var(--line-strong); }
.quiet { background:transparent; color:var(--accent); border-color:transparent; }
.danger { background:var(--surface); color:var(--danger-text); border-color:var(--danger-text); }
.quiet.danger { background:transparent; border-color:transparent; }
button:disabled,.button[aria-disabled=true] { opacity:.5; cursor:default; }
.full-width { width:100%; }
.actions { display:flex; gap:8px; margin:16px 0; }
.wrap { flex-wrap:wrap; align-items:center; }
.actions form { margin:0; }
.panel { padding:16px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-1); margin-bottom:16px; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:24px 0 12px; }
.section-head h2 { margin:0; }
.section-head a { flex:none; font-size:.875rem; text-decoration:none; }
.section-head .icon { width:16px; height:16px; }
.tiles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-bottom:24px; }
.tiles>.empty,.size-buttons>.empty { grid-column:1 / -1; }
.tile { padding:16px; border-radius:var(--r-lg); border:1px solid var(--line); background:var(--surface); box-shadow:var(--shadow-1); text-decoration:none; color:var(--ink); transition:border-color 120ms,box-shadow 120ms; }
.tile.action { display:flex; flex-direction:column; gap:12px; align-items:flex-start; }
.tile-copy { display:flex; flex-direction:column; gap:4px; }
.tile-copy strong { font-weight:600; }
.tile-copy>span { color:var(--muted); font-size:.8125rem; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.tile.metric { display:flex; flex-direction:column; align-items:flex-start; justify-content:space-between; gap:8px; position:relative; }
.metric>span { color:var(--muted); font-size:.875rem; padding-right:12px; }
.metric strong { font-size:1.5rem; line-height:1.3; font-weight:700; max-width:100%; }
.metric small { font-size:.8125rem; font-weight:400; }
.metric>.icon { position:absolute; right:8px; top:12px; width:16px; height:16px; color:var(--muted); }
.row-panel { padding-top:8px; padding-bottom:8px; }
.row-panel h2 { margin:12px 0 8px; }
.row-link { display:flex; gap:12px; min-height:64px; padding:12px 0; text-decoration:none; color:var(--ink); border-bottom:1px solid var(--line); }
.row-link:last-child { border-bottom:0; }
.row-copy { flex:1; display:flex; flex-direction:column; gap:4px; }
.row-copy strong { font-weight:600; }
.row-copy>span { color:var(--muted); font-size:.8125rem; }
svg.icon.row-chevron { color:var(--muted); width:20px; height:20px; }
.tile.metric[aria-current] { border-color:var(--accent); background:var(--accent-soft); }
.badge { display:inline-flex; align-items:center; gap:8px; padding:4px 8px; border-radius:var(--r-pill); font-size:.8125rem; font-weight:600; max-width:100%; width:fit-content; }
.badge::before { content:""; width:6px; height:6px; flex:none; border-radius:var(--r-pill); background:currentColor; }
.draft { color:var(--tone-docs-ink); background:var(--tone-docs-bg); }
.posted,.received { color:var(--ok); background:var(--ok-soft); }
.sent { color:var(--warn); background:var(--warn-soft); }
.cancelled { color:var(--danger-text); background:var(--danger-soft); }
.notice,.error,.demo-banner,.info-note { display:flex; align-items:flex-start; gap:12px; padding:16px; border-radius:var(--r-md); margin-bottom:16px; }
.notice { background:var(--ok-soft); color:var(--ok); }
.error { background:var(--danger-soft); color:var(--danger-text); }
.demo-banner,.info-note { background:var(--info-soft); color:var(--info); }
label { display:block; font-size:.875rem; font-weight:600; color:var(--ink-2); margin-bottom:16px; }
input,select,textarea { font:inherit; line-height:1.25; font-size:16px; color:var(--ink); width:100%; max-width:100%; min-height:48px; padding:12px; border:1px solid var(--line-strong); border-radius:10px; background:var(--surface); margin-top:8px; transition:border-color 120ms,box-shadow 120ms; }
input:focus,select:focus,textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
input[aria-invalid=true],select[aria-invalid=true],textarea[aria-invalid=true] { border-color:var(--danger); }
.field-error { color:var(--danger-text); font-size:.875rem; }
textarea { min-height:96px; resize:vertical; }
input[type=hidden] { display:none; }
input[type=file] { padding:8px; }
input[type=file]::file-selector-button { font:inherit; padding:8px; border:0; border-radius:var(--r-sm); color:var(--ink); background:var(--surface-2); margin-right:8px; }
.check { display:flex; align-items:center; gap:12px; min-height:44px; }
.check input { flex:none; width:22px; height:22px; min-height:22px; margin:0; padding:0; accent-color:var(--accent); }
fieldset { padding:0; margin:0; border:0; }
fieldset:disabled input,fieldset:disabled select,fieldset:disabled textarea { background:var(--surface-2); color:var(--ink-2); opacity:1; }
.form-grid { display:grid; gap:0 20px; }
.form-grid>.full-width { grid-column:1 / -1; }
.filters { display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; margin-bottom:16px; }
.filters label { flex:1 1 calc(50% - 12px); margin:0; }
.filters label:has(input[name=q]) { flex-basis:100%; }
.search { display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; margin-bottom:16px; }
.search label { flex:1 1 160px; margin:0; }
.input-icon { position:relative; display:block; }
.input-icon>.icon { position:absolute; left:12px; bottom:12px; color:var(--muted); pointer-events:none; }
.input-icon>input { padding-left:44px; }
.filters .input-icon { width:100%; }
.narrow { max-width:560px; }
.qty-input { width:88px; }
.price-input { width:140px; }
.empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; text-align:center; padding:24px 16px; margin-bottom:16px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); }
.empty>.icon-circle { width:56px; height:56px; background:var(--accent-soft); color:var(--accent); }
.empty p { color:var(--muted); margin:0; font-size:.875rem; max-width:40em; }
.empty strong { font-size:1rem; }
.panel .empty { box-shadow:none; background:var(--surface-2); }
summary { display:flex; position:relative; gap:8px; align-items:center; min-height:48px; padding:12px 24px 12px 0; list-style:none; cursor:pointer; font-weight:600; }
summary::-webkit-details-marker { display:none; }
summary::after { content:""; width:8px; height:8px; border-right:2px solid var(--muted); border-bottom:2px solid var(--muted); transform:rotate(45deg); position:absolute; right:4px; top:20px; transition:transform 120ms; }
details[open]>summary::after { transform:rotate(225deg); }
details[open]>summary { margin-bottom:12px; }
.action-bar { display:flex; flex-wrap:wrap; gap:8px; position:sticky; bottom:calc(72px + env(safe-area-inset-bottom)); z-index:3; padding:12px; margin:16px 0; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); box-shadow:var(--shadow-up); }
.action-bar>.primary,.action-bar>button:not(.secondary):not(.quiet):not(.danger),.action-bar>form:has(>button:not(.secondary):not(.quiet):not(.danger)) { flex:1 0 100%; }
.action-bar form>button { width:100%; }
.action-bar>.secondary { flex:1; }
.period-choice { flex:1 0 100%; }
.period-choice legend { font-size:.875rem; font-weight:600; color:var(--ink-2); margin-bottom:8px; }
.period-buttons { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; }
.period-buttons label { position:relative; margin:0; }
.period-buttons input { position:absolute; opacity:0; width:1px; height:1px; min-height:0; margin:0; }
.period-buttons span { display:flex; align-items:center; justify-content:center; text-align:center; min-height:44px; padding:8px; border:1px solid var(--line-strong); border-radius:var(--r-pill); background:var(--surface); color:var(--ink-2); font-size:.8125rem; cursor:pointer; }
.period-buttons input:checked+span { color:var(--surface); background:var(--accent); border-color:var(--accent); }
.period-buttons input:focus-visible+span { outline:3px solid var(--accent-soft-2); outline-offset:2px; }
.facts { display:grid; gap:0 24px; margin-bottom:16px; }
.facts>div { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.5fr); gap:12px; padding:12px 0; border-bottom:1px solid var(--line); }
.facts dt { color:var(--muted); font-size:.875rem; }
.facts dd { margin:0; text-align:right; }
.note-text { white-space:pre-wrap; }
.doc-total { display:flex; flex-wrap:wrap; align-items:baseline; gap:8px; margin:20px 0; }
.doc-total strong,.sale-number { font-size:1.5rem; font-weight:700; }
.pagination { margin:20px 0; }

/* Таблицы на телефоне: каждая строка — карточка с подписями. */
.table-wrap { max-width:100%; margin-bottom:16px; }
table,tbody,tfoot { display:block; width:100%; }
table { border-collapse:collapse; }
thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
tbody>tr,tfoot>tr { display:block; padding:16px; margin-bottom:8px; border:1px solid var(--line); border-radius:var(--r-md); background:var(--surface); box-shadow:var(--shadow-1); }
td,th { overflow-wrap:anywhere; }
.table-wrap td,.table-wrap th { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.4fr); align-items:center; gap:12px; padding:8px 0; text-align:right; border-bottom:1px solid var(--line); font-size:.875rem; font-weight:400; }
td::before,tbody th::before,tfoot th::before { content:attr(data-label); color:var(--muted); font-size:.8125rem; text-align:left; }
.table-wrap tr>td:first-child,.table-wrap tr>th:first-child,.table-wrap [colspan] { display:block; font-size:1rem; text-align:left; font-weight:600; padding-top:0; }
tr>td:first-child::before,tr>th:first-child::before,[colspan]::before { display:none; }
.table-wrap td:last-child,.table-wrap th:last-child { border-bottom:0; }
.table-wrap td a { justify-self:end; }
.table-wrap tr>td:first-child a { justify-self:start; }
.table-wrap .badge { justify-self:end; }
.table-wrap .qty-input,.table-wrap .price-input { width:100%; }
.table-wrap input { margin:0; }
.row-details { margin-top:-8px; border-top:0; border-top-left-radius:0; border-top-right-radius:0; box-shadow:none; }
.table-wrap .row-details>td:first-child { font-weight:400; }
.row-details table tr { background:var(--surface-2); }
tfoot th { font-weight:700 !important; }
.document-lines td[data-label="Действие"] { display:flex; justify-content:flex-end; }
.document-lines td[data-label="Действие"]::before { display:none; }

/* Экраны: главная, касса, меню, справка и вход. */
.onboarding { border-color:var(--accent-soft-2); }
.onboarding ol { list-style:none; padding:0; margin:0; }
.onboarding li { display:flex; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); }
.onboarding li:last-child { border:0; padding-bottom:0; }
.step-number { width:32px; height:32px; border-radius:var(--r-pill); display:inline-flex; align-items:center; justify-content:center; background:var(--accent-soft); color:var(--accent); font-weight:700; flex:none; }
.step-done .step-number { background:var(--ok-soft); color:var(--ok); }
.step-done .step-copy { color:var(--muted); }
.step-pending .step-copy { color:var(--ink); }
.step-copy { flex:1; padding-top:4px; }
.step-copy .actions { margin:8px 0 0; }
.hero-action { display:flex; justify-content:flex-start; min-height:72px; margin:16px 0; width:100%; }
.hero-action .icon-circle { background:var(--surface); color:var(--accent); }
.hero-action strong,.hero-action small { display:block; color:inherit; }
.hero-action small { font-weight:400; }
.receiving { margin-bottom:24px; }
.receiving h2 { margin-top:0; }
.quick-actions { margin-bottom:24px; }
.sell-layout,.sell-checkout { display:grid; gap:16px; }
.sell-search { align-self:start; }
.summary-tiles .metric { min-height:112px; }
.filter-disclosure .filters { margin-top:8px; }
.audit-table td:last-child { white-space:pre-wrap; }
.sales-breakdown>summary { color:var(--ink-2); }
.sell-layout .panel { margin:0; }
.step-title { display:flex; align-items:center; gap:12px; margin:0 0 20px; }
.sale-search input { min-height:52px; }
.sale-search .input-icon>.icon { bottom:14px; }
.size-buttons { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; }
.size-choice { display:flex; flex-direction:column; align-items:flex-start; text-align:left; gap:4px; padding:16px; }
.size-choice>span { font-size:.875rem; font-weight:400; }
.size-choice .stock-choice { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.cart-line { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); align-items:center; gap:8px 12px; padding:16px 0; border-bottom:1px solid var(--line); }
.cart-line>div:first-child { grid-column:1 / -1; }
.cart-line p { margin:4px 0; font-size:.8125rem; }
.cart-line label { margin:0; }
.cart-line .number { align-self:end; padding-bottom:12px; }
.cart-line .quiet { justify-self:start; }
.payment-field { margin-bottom:16px; }
.payment-field label { margin-bottom:8px; }
.js-only { display:none; }
.js .js-only { display:inline-flex; }
.sell-submit { min-height:56px; }
.product-result { width:100%; text-align:left; justify-content:flex-start; margin:8px 0; }
.sale-result { text-align:center; margin:0 auto; }
.sale-result>.icon-circle,.error-screen>.icon-circle { width:56px; height:56px; margin-bottom:16px; }
.sale-result .doc-total { justify-content:center; }
.sale-result .actions { justify-content:center; }
.document-heading { display:flex; flex-wrap:wrap; gap:12px; align-items:center; }
.document-view>h2 { margin-top:24px; }
.menu-groups { display:grid; gap:0 16px; }
.profile-heading { display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.profile-heading .avatar { width:48px; height:48px; }
.profile-heading h2 { margin:0; }
.profile-heading p { margin:4px 0 0; color:var(--muted); font-size:.875rem; }
.profile .actions { margin-bottom:0; }
.model-group summary { display:block; }
.model-group summary>strong { display:block; margin-bottom:8px; }
.model-values { display:grid; gap:8px; margin-bottom:8px; }
.model-values>span { display:flex; justify-content:space-between; gap:12px; font-size:.875rem; color:var(--muted); }
.model-values b { color:var(--ink); text-align:right; }
.report-totals .facts { margin-bottom:0; }
.desktop-matrix { display:none; }
.mobile-matrix { display:block; }
.compact-matrix { display:table; table-layout:fixed; width:100%; background:var(--surface); }
.compact-matrix thead { display:table-header-group; position:static; width:auto; height:auto; clip-path:none; }
.compact-matrix tbody { display:table-row-group; }
.compact-matrix tr { display:table-row; }
.table-wrap .compact-matrix td,.table-wrap .compact-matrix th,.table-wrap .compact-matrix tr>th:first-child { display:table-cell; padding:12px 4px; font-size:.8125rem; text-align:right; border-bottom:1px solid var(--line); }
.compact-matrix th:first-child { width:28%; }
.table-wrap .compact-matrix tr>th:first-child { text-align:left; }
.compact-matrix thead th { color:var(--muted); font-weight:600; background:var(--surface-2); }
.compact-matrix small { display:block; font-size:.8125rem; font-weight:400; }
.compact-matrix td::before,.compact-matrix th::before { display:none; }
.help { max-width:850px; }
.help li { margin-bottom:12px; }
.help ul,.help ol { padding-left:24px; }
.help h2 { scroll-margin-top:24px; }
.help-toc { display:grid; gap:4px; }
.help-toc a { text-decoration:none; border-bottom:1px solid var(--line); }
.glossary>div { padding:12px 0; border-bottom:1px solid var(--line); }
.glossary dt { font-weight:600; }
.glossary dd { color:var(--muted); margin:4px 0 0; }
.error-screen { text-align:center; max-width:560px; margin:0 auto; }
.auth main { padding:32px 16px; max-width:432px; }
.auth-card { padding:24px; }
.auth-card>.brand-mark { width:56px; height:56px; font-size:1.625rem; margin-bottom:20px; }
.auth-card .page-header { margin-bottom:24px; }
.auth-footer { text-align:center; font-size:.875rem; color:var(--muted); }

/* Телефон / компьютер. Табличный вид начинается после 640 px. */
@media (min-width:641px) {
  .table-wrap { overflow-x:auto; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow-1); }
  table { display:table; }
  thead { display:table-header-group; position:static; width:auto; height:auto; clip-path:none; }
  tbody { display:table-row-group; }
  tfoot { display:table-footer-group; }
  tbody>tr,tfoot>tr { display:table-row; padding:0; margin:0; border:0; border-radius:0; box-shadow:none; }
  .table-wrap td,.table-wrap th,.table-wrap tr>td:first-child,.table-wrap tr>th:first-child,.table-wrap [colspan] { display:table-cell; padding:12px 16px; font-size:1rem; text-align:left; border-bottom:1px solid var(--line); font-weight:400; }
  .table-wrap tr>td:first-child,.table-wrap tr>th:first-child { font-weight:600; }
  .table-wrap thead th { font-size:.8125rem; color:var(--muted); font-weight:600; background:var(--surface-2); }
  .table-wrap tr>.number { text-align:right; }
  .table-wrap tr { height:48px; }
  td::before,tbody th::before,tfoot th::before { display:none; }
  .table-wrap tbody tr:last-child>td,.table-wrap tbody tr:last-child>th { border-bottom:0; }
  .document-lines td[data-label="Действие"] { display:table-cell; }
  .table-wrap .qty-input { width:88px; }
  .table-wrap .price-input { width:140px; }
  .row-details { border:0; }
  .table-wrap .row-details>td { font-weight:400; }
  .row-details table tr { background:var(--surface); }
  .form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .filters label { flex:1 1 160px; }
  .filters label:has(input[name=q]) { flex-basis:240px; }
  .desktop-matrix { display:block; }
  .mobile-matrix { display:none; }
  .size-buttons { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .facts { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (min-width:960px) {
  body.signed-in { padding-bottom:0; }
  .topbar,.bottom-nav { display:none; }
  .sidebar { display:flex; flex-direction:column; position:fixed; top:0; bottom:0; left:0; width:248px; padding:20px 16px; overflow-y:auto; background:var(--surface); border-right:1px solid var(--line); }
  .sidebar>.brand { margin-bottom:24px; }
  .nav-group { margin-bottom:20px; }
  .nav-caption { font-size:.8125rem; color:var(--muted); margin:0 12px 8px; }
  .nav-link { display:flex; min-height:44px; padding:8px 12px; gap:12px; border-radius:10px; color:var(--ink-2); text-decoration:none; }
  .nav-link .icon { width:20px; height:20px; }
  .nav-link[aria-current] { background:var(--accent-soft); color:var(--accent); font-weight:600; }
  .sidebar-profile { margin-top:auto; padding-top:16px; display:grid; grid-template-columns:32px minmax(0,1fr); align-items:center; gap:12px; border-top:1px solid var(--line); }
  .sidebar-profile strong { display:block; font-size:.875rem; }
  .sidebar-profile small { display:block; font-size:.8125rem; margin-top:4px; }
  .sidebar-profile form { grid-column:1 / -1; }
  .signed-in main { margin-left:248px; margin-right:auto; padding:32px 40px; }
  h1 { font-size:1.625rem; }
  button,.button { min-height:44px; padding:8px 16px; }
  .panel { padding:20px; }
  .page-header { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; }
  .page-heading { flex:1; }
  .page-actions { align-items:flex-end; flex:none; max-width:45%; }
  .page-actions>.button { width:auto; }
  .page-actions .help-link { align-self:flex-end; }
  .tiles { grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); }
  .tile.action { flex-direction:row; align-items:flex-start; }
  .row-panel { padding-top:8px; padding-bottom:8px; }
  .menu-groups { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
  .menu-groups>.panel:last-child { grid-column:1 / -1; }
  .action-bar { position:static; box-shadow:none; border:0; padding:0; margin:20px 0; align-items:center; }
  .action-bar>.primary,.action-bar>button:not(.secondary):not(.quiet):not(.danger),.action-bar>form:has(>button:not(.secondary):not(.quiet):not(.danger)),.action-bar>.secondary { flex:0 1 auto; }
  .period-buttons { display:flex; gap:8px; }
  .period-buttons label { flex:none; }
  .period-buttons span { padding:8px 16px; font-size:.875rem; }
  .model-values { display:flex; flex-wrap:wrap; gap:12px 24px; }
  .auth main { padding-top:64px; }
  .auth-card { padding:24px; }
  .auth .page-header { display:block; }
}
@media (min-width:1100px) {
  .sell-layout { grid-template-columns:minmax(0,1fr) minmax(0,1fr); align-items:start; }
  .sell-layout .size-buttons { grid-template-columns:minmax(0,1fr); }
}
@media (hover:hover) {
  a:hover { color:var(--accent-hover); }
  button:hover,.button:hover { background:var(--accent-hover); border-color:var(--accent-hover); color:var(--surface); }
  .secondary:hover { background:var(--surface-2); border-color:var(--line-strong); color:var(--ink); }
  .quiet:hover { background:var(--accent-soft); border-color:transparent; color:var(--accent-hover); }
  .danger:hover { background:var(--danger-soft); border-color:var(--danger-text); color:var(--danger-text); }
  .quiet.danger:hover { border-color:transparent; }
  .tile:hover { border-color:var(--line-strong); box-shadow:var(--shadow-2); color:var(--ink); }
  .row-link:hover { color:var(--ink); background:var(--surface-2); }
  .nav-link:hover { background:var(--surface-2); color:var(--ink); }
  .nav-link[aria-current]:hover { color:var(--accent); background:var(--accent-soft); }
  .bottom-nav a:hover { color:var(--accent); }
  tbody tr:hover { background:var(--surface-2); }
  button:disabled:hover { background:var(--accent); border-color:var(--accent); }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { transition:none !important; }
}
