:root {
  color-scheme: light dark;
  --blue: #007aff; --green: #34c759; --red: #ff3b30; --orange: #ff9500; --gray: #8e8e93;
  --ozon: #005bff; --wb: #cb11ab; --ym: #fc0;
  --bg: #f2f2f7; --surface: #ffffff; --surface-2: #f2f2f7;
  --fill: rgba(120,120,128,.12); --fill-strong: rgba(120,120,128,.2);
  --label: #000; --label-2: rgba(60,60,67,.6); --label-3: rgba(60,60,67,.3);
  --separator: rgba(60,60,67,.18); --glass: rgba(249,249,249,.8);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 0 0 .5px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.18), 0 0 0 .5px rgba(0,0,0,.06);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --pill: 980px;
  --ease: cubic-bezier(.32,.72,0,1); --fast: 200ms var(--ease); --slow: 400ms var(--ease);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a;
  --bg: #000; --surface: #1c1c1e; --surface-2: #2c2c2e;
  --fill: rgba(118,118,128,.24); --fill-strong: rgba(118,118,128,.36);
  --label: #fff; --label-2: rgba(235,235,245,.6); --label-3: rgba(235,235,245,.3);
  --separator: rgba(84,84,88,.6); --glass: rgba(30,30,32,.72);
}}
:root[data-theme="dark"] {
  --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a;
  --bg: #000; --surface: #1c1c1e; --surface-2: #2c2c2e;
  --fill: rgba(118,118,128,.24); --fill-strong: rgba(118,118,128,.36);
  --label: #fff; --label-2: rgba(235,235,245,.6); --label-3: rgba(235,235,245,.3);
  --separator: rgba(84,84,88,.6); --glass: rgba(30,30,32,.72);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--label); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.t-large { font-size: 34px; font-weight: 700; letter-spacing: -.024em; line-height: 1.15; }
.t-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.t-title3 { font-size: 20px; font-weight: 600; }
.t-head { font-size: 17px; font-weight: 600; }
.t-body { font-size: 17px; }
.t-sub { font-size: 15px; }
.t-foot { font-size: 13px; }
.t-cap { font-size: 12px; }
.muted { color: var(--label-2); }
.faint { color: var(--label-3); }
.num { font-variant-numeric: tabular-nums; }

/* Панель сверху — стекло */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--separator); padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar .grow { flex: 1; min-width: 0; }
.page { padding: 16px; max-width: 1100px; margin: 0 auto; }

/* Кнопки */
.btn {
  height: 32px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: var(--fill); font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: transform var(--fast), background var(--fast), opacity var(--fast); -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.filled { background: var(--blue); color: #fff; font-weight: 590; }
.btn.tinted { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.btn.plain { background: transparent; color: var(--blue); }
.btn.destructive { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.btn.success { background: var(--green); color: #fff; font-weight: 590; }
.btn.lg { height: 50px; font-size: 17px; border-radius: var(--r-md); padding: 0 20px; width: 100%; }

/* Сегментированный контрол */
.seg { display: flex; background: var(--fill); border-radius: var(--r-sm); padding: 2px; gap: 2px; overflow-x: auto; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 6px 10px; font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; color: var(--label); transition: background var(--fast);
}
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: var(--pill); background: var(--fill-strong); color: var(--label-2); font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] .badge { background: var(--blue); color: #fff; }
.badge.red { background: var(--red); color: #fff; }

/* Группы-списки */
.group { margin: 18px 0 0; }
.group > h3 { margin: 0 16px 6px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--label-2); }
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 44px; position: relative; }
.row + .row::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: .5px solid var(--separator); }
.row.clickable { cursor: pointer; transition: background var(--fast); }
.row.clickable:active { background: var(--fill); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.chev { color: var(--label-3); }

/* Поля */
.field { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; }
.field label { font-size: 13px; color: var(--label-2); }
.input {
  height: 40px; border: 0; border-radius: var(--r-sm); background: var(--fill); padding: 0 12px; width: 100%; outline: none;
  transition: box-shadow var(--fast);
}
.input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 30%, transparent); }
select.input { appearance: none; }

/* Чипы площадок и направлений */
.mp { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; }
.mp.ozon { background: var(--ozon); } .mp.wb { background: var(--wb); } .mp.ym { background: var(--ym); }
.chip { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: var(--pill); background: var(--fill); color: var(--label-2); white-space: nowrap; }
.chip.due { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.chip.late { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.chip.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }

/* Фильтры сеткой 2×2 на телефоне */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.filters .input { font-size: 15px; height: 38px; padding: 0 10px; }
@media (min-width: 760px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }

/* Лист (карточка заказа) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; opacity: 0; transition: opacity var(--fast); }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg); max-height: 92dvh; overflow: auto; transform: translateY(100%); transition: transform var(--slow);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.sheet.open { transform: translateY(0); }
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; bottom: 0; width: 440px; border-radius: 0; max-height: none; transform: translateX(100%); }
  .sheet.open { transform: translateX(0); }
}
.sheet-head { position: sticky; top: 0; background: var(--surface); padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: .5px solid var(--separator); z-index: 1; }
.item { display: flex; gap: 12px; padding: 12px 16px; align-items: center; }
.item + .item { border-top: .5px solid var(--separator); }
.item img { width: 72px; height: 72px; border-radius: var(--r-sm); object-fit: cover; background: var(--fill); flex: none; }
.item .noimg { width: 72px; height: 72px; border-radius: var(--r-sm); background: var(--fill); flex: none; display: grid; place-items: center; color: var(--label-3); }
.item .name { font-size: 17px; font-weight: 500; line-height: 1.3; }
.qty { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.qty.many { color: var(--orange); }

/* Пустое состояние */
.empty { padding: 48px 24px; text-align: center; color: var(--label-2); }
.empty .t-title3 { color: var(--label); margin-bottom: 6px; }

/* Тост */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 30;
  background: var(--surface); box-shadow: var(--shadow-md); border-radius: var(--pill); padding: 10px 18px; font-weight: 500; max-width: calc(100vw - 32px);
  transition: transform var(--fast), opacity var(--fast); border-left: 4px solid var(--blue);
}
.toast.show { transform: translateX(-50%); opacity: 1; }
.toast.ok { border-color: var(--green); } .toast.err { border-color: var(--red); }

/* Логин */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 8px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hstack { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.flash { animation: flash var(--slow); }
@keyframes flash { from { background: color-mix(in srgb, var(--green) 30%, transparent); } to { background: transparent; } }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); display: inline-block; }
.status-dot.on { background: var(--green); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; padding: 10px 16px; }
.kv dt { color: var(--label-2); } .kv dd { margin: 0; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--fill); padding: 1px 5px; border-radius: 4px; }

/* Волна по артикулам */
.thumb { width: 52px; height: 52px; border-radius: var(--r-sm); object-fit: cover; background: var(--fill); flex: none; }
.thumb.noimg { display: grid; place-items: center; color: var(--label-3); }
.take { text-align: right; flex: none; }
.take-n { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; color: var(--blue); }
.take-l { font-size: 11px; color: var(--label-2); }
.take-big { display: flex; align-items: center; gap: 16px; padding: 16px; }
.take-big img { width: 96px; height: 96px; border-radius: var(--r-md); object-fit: cover; background: var(--fill); }
.take-big-n { font-size: 48px; font-weight: 700; line-height: 1; letter-spacing: -.03em; color: var(--blue); font-variant-numeric: tabular-nums; }
