:root { --bg: #fff; --fg: #1d1d1b; --muted: #6b6b66; --line: #e6e4dc; --accent: #c2410c; --accent-fill: #c2410c; --ok-bg: #e8f3de; --ok: #27500a; --err-bg: #fcebeb; --err: #791f1f; --chip-on: #faeeda; --chip-on-fg: #633806; --info-bg: #e6eefb; --info: #1d4ed8; }
@media (prefers-color-scheme: dark) { :root { --bg: #1b1b1a; --fg: #f1efe8; --muted: #a8a69e; --line: #3a3936; --accent: #f0997b; --ok-bg: #27500a; --ok: #c0dd97; --err-bg: #501313; --err: #f7c1c1; --chip-on: #633806; --chip-on-fg: #fac775; --info-bg: #1e2b4a; --info: #9cc0f9; } }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 20px 0 4px; }
.bar-end { display: inline-flex; align-items: baseline; gap: 12px; }
.bar { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.muted, .note { color: var(--muted); font-size: 14px; }
.ok, .error { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.ok { background: var(--ok-bg); color: var(--ok); }
.error { background: var(--err-bg); color: var(--err); }
.row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.name { flex: 1; min-width: 0; }
.name b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-weight: 500; font-size: 15px; overflow-wrap: anywhere; }
.name span { display: block; font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--fg); font-size: 20px; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.stepper button:active { background: var(--line); }
.stepper input { width: 56px; height: 44px; text-align: center; font-size: 17px; font-weight: 600; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--fg); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.qty { display: flex; position: relative; }
.qty.changed input { color: var(--accent); border: 2px solid var(--accent); }
.qty.changed::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.row.short .stepper input { color: var(--err); border: 2px solid var(--err); }
.row.over .stepper input { color: var(--ok); border: 2px solid var(--ok); }
.order-row { flex-wrap: wrap; }
.order-row .name { flex: 1 1 120px; }
.controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.order-row .stepper:not(.leftover) input { border-color: var(--accent); }
.stepper.leftover input { width: 48px; color: var(--info); border-color: var(--info); font-weight: 500; }
.stepper.leftover input::placeholder { color: var(--info); opacity: 0.45; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.legend .key::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; border: 2px solid var(--accent); vertical-align: -1px; }
.legend .key.left::before { border-color: var(--info); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chips { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; white-space: nowrap; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--fg); font-size: 14px; }
.chip.on { background: var(--chip-on); color: var(--chip-on-fg); border-color: transparent; }
details summary { padding: 14px 0; color: var(--muted); }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.sticky button, .stack button { width: 100%; max-width: 560px; display: block; margin: 0 auto; }
.primary { min-height: 52px; padding: 10px 16px; border: 0; border-radius: 14px; background: var(--accent-fill); color: #fff; font-size: 17px; font-weight: 600; text-align: center; }
a.primary { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.primary.big { width: 100%; min-height: 64px; margin: 12px 0 4px; font-size: 19px; }
.link { border: 0; background: none; color: var(--muted); padding: 16px 0; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.stack input { height: 52px; font-size: 20px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--fg); }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto; padding: 12px 14px; border-radius: 12px; background: var(--fg); color: var(--bg); font-size: 14px; z-index: 10; pointer-events: none; }
#toast[hidden] { display: none; }
.chips.wrap { flex-wrap: wrap; margin: 8px 0; padding: 0; }
details.other summary { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; padding: 8px 14px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; list-style: none; }
details.sold-out { margin: 16px 0 0; }
details.sold-out > summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--fg); font-size: 15px; list-style: none; cursor: pointer; }
details.sold-out > summary::-webkit-details-marker { display: none; }
details.sold-out > summary .chip { display: inline-flex; align-items: center; }
details.sold-out[open] > summary .chip { display: none; }
input[type="search"], select { width: 100%; height: 44px; margin: 8px 0; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--fg); }
.tabs { display: flex; gap: 6px; margin: 12px 0; overflow-x: auto; scrollbar-width: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg); text-decoration: none; font-size: 14px; }
.tabs a[aria-current="page"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.total { flex: none; min-width: 52px; text-align: right; font-size: 18px; font-weight: 600; }
.badge { color: var(--accent); font-style: normal; }
a.chip { flex: none; display: inline-flex; align-items: center; text-decoration: none; }
.row select { margin: 6px 0 0; }
.row.doc { flex-wrap: wrap; }
.row.doc .name { flex: 1 1 150px; }  /* узко — кнопки уходят под название магазина, а не сжимают его */
.doc-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; }
form.return { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.return-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
form.return .primary { width: 100%; margin-top: 10px; }
.name .fix.received { color: var(--ok); }
.name .fix.received.bad { color: var(--err); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--line); }
.card span { font-size: 12px; color: var(--muted); }
.card b { font-size: 22px; font-weight: 600; }
.home-card { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.home-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.home-card-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--fg); }
.home-card .note { margin: 8px 0 0; }
.home-card .row:last-of-type { border-bottom: 0; }
.home-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.home-card-actions .primary { flex: 1 1 100%; }
.home-card.alert { border: 2px solid var(--err); }
.home-card-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.status { flex: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.attention { background: var(--err-bg); color: var(--err); }
.status.late { background: var(--err-bg); color: var(--err); }
.note .status { display: inline-block; }  /* плашка в строке текста переносится целиком */
.status.waiting { background: var(--chip-on); color: var(--chip-on-fg); }
.status.no_app { color: var(--muted); border: 1px solid var(--line); }
.catalog-item { border-bottom: 1px solid var(--line); }
.catalog-item > summary { display: block; padding: 10px 0; color: var(--fg); list-style: none; cursor: pointer; }
.catalog-item > summary::-webkit-details-marker { display: none; }
.catalog-item .name { flex-basis: 100%; }
.catalog-item form.inline { margin: 0 0 10px; }
form.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
form.inline select, form.inline input { width: auto; min-width: 0; height: 44px; margin: 0; }
form.inline input[name="qty"] { width: 90px; }
.stack select { height: 52px; font-size: 18px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--fg); }
@media (max-width: 480px) { .tabs a { padding: 8px 10px; } }
.remind a { display: block; padding: 10px 12px; border-radius: 10px; background: var(--chip-on); color: var(--chip-on-fg); font-size: 14px; text-decoration: none; }
.remind a::after { content: " →"; }
.nothing { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.nothing .ok { flex: 1; margin: 0; }
.nothing button:not(.link) { min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--fg); font-size: 15px; }
.nothing .link { padding: 8px 0; }
.live { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.live:not(:has(:not([hidden]))) { display: none; }
.offline { padding: 4px 10px; border-radius: 999px; font-size: 13px; background: var(--err-bg); color: var(--err); }
.offline[hidden] { display: none; }
@keyframes fresh { from { background: var(--chip-on); } to { background: transparent; } }
.row.fresh { animation: fresh 10s ease-out; }
.tabs a.fresh:not([aria-current="page"]) { animation: fresh 10s ease-out; border-color: var(--accent); }
.tabs a.fresh[aria-current="page"] { box-shadow: inset 0 0 0 3px var(--accent); }
.push { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.push[hidden] { display: none; }
.live .push { margin: 0; }
.push .note { margin: 0; }
.push .on-text { color: var(--ok); font-size: 14px; }

.name .fix { color: var(--fg); }
.fix mark { background: none; color: inherit; }
.fix mark.down { color: var(--err); }
.fix mark.up { color: var(--ok); }
.got { font-style: normal; font-weight: 600; }
.got.down { color: var(--err); }
.got.up { color: var(--ok); }
.note.late { color: var(--err); }
a.row { color: inherit; text-decoration: none; }
.status.sent { background: var(--ok-bg); color: var(--ok); }
.status.corrected { background: var(--chip-on); color: var(--chip-on-fg); }
.status.draft { color: var(--muted); border: 1px solid var(--line); }
.status.shipped { background: var(--info-bg); color: var(--info); }
.status.received, .status.accepted { background: var(--ok-bg); color: var(--ok); }
.status.discrepancy { background: var(--err-bg); color: var(--err); }
.doc-chips { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Аналитика */
.tabs.wrap { flex-wrap: wrap; overflow-x: visible; }
/* Ширина вкладки — по слову, без переноса: в равных колонках «Полугодие» рвалось на «Полугоди/е» (на 320 px пять
   слов занимают 262 из 286 px). */
.period { display: flex; margin: 12px 0 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.period a { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 3px; color: var(--fg); text-decoration: none; font-size: 13px; text-align: center; white-space: nowrap; }
.period a[aria-current="page"] { background: var(--fg); color: var(--bg); font-weight: 600; }
.period-bar { display: flex; align-items: center; gap: 8px; }
.period-bar p { flex: 1; margin: 0; text-align: center; }
.arrow { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); color: var(--fg); text-decoration: none; font-size: 18px; }
span.arrow { visibility: hidden; }
.analytics h2 { font-size: 15px; font-weight: 600; color: var(--fg); margin: 24px 0 4px; }
.analytics .note { margin: 4px 0; }
.cards.stats .card b { font-size: 20px; overflow-wrap: anywhere; }
.cards.stats .card.wide { grid-column: 1 / -1; }
.card b.bad, .drop { color: var(--err); }
.drop { flex: none; font-weight: 600; }
.rank { flex: none; width: 20px; color: var(--muted); }
.amount { flex: none; font-weight: 600; }
.reason { font-style: normal; color: var(--chip-on-fg); }
.by-store summary { padding: 10px 0; }
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table-scroll table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.table-scroll th, .table-scroll td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-weight: 400; }
.table-scroll thead th { color: var(--muted); }
.table-scroll th[scope="row"], .table-scroll thead th:first-child { position: sticky; left: 0; text-align: left; background: var(--bg); font-weight: 500; }
/* закреплённая колонка закрывает и поле слева — иначе в нём видны прокрученные ячейки */
.table-scroll th[scope="row"]::before, .table-scroll thead th:first-child::before { content: ""; position: absolute; top: 0; bottom: 0; right: 100%; width: 16px; background: var(--bg); }

/* Рейтинг магазинов */
.rank-row { gap: 10px; }
.rank-row .rank { text-align: right; font-variant-numeric: tabular-nums; }
.rank-figures { flex: none; text-align: right; }
.rank-figures .amount { display: block; }
.rank-change { font-size: 12px; color: var(--muted); }
.rank-row.mine { margin: 0 -10px; padding-left: 10px; padding-right: 10px; background: var(--chip-on); border-radius: 10px; }
.rank-row.mine .name span, .rank-row.mine .rank, .rank-row.mine .rank-change { color: var(--chip-on-fg); }

/* Зелёные показатели и залёживается */
.rise { flex: none; font-weight: 600; color: var(--ok); }
.amount.up { color: var(--ok); }
.stale h2 { margin-top: 28px; }
.stale-row { flex-wrap: wrap; }
.stale-row .name { flex: 1 1 60%; }
.stale-row .replace { color: var(--ok); }
.stale-action { flex: 1 1 100%; margin-top: 2px; }
.stale-action .chip { min-height: 38px; padding: 6px 14px; }
