/* Distribution — интерфейс сотрудников
   Идея: рабочий инструмент оптовика. Тихая бумажная основа, плотные таблицы,
   единственный яркий элемент — синий «штамп» статуса, как печать на накладной. */

:root {
  --paper: #F2F4F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --ink: #1D2633;
  --ink-2: #4A5566;
  --ink-3: #788293;
  --line: #DCE1E8;
  --line-2: #EAEDF2;
  --stamp: #2F45C8;
  --stamp-ink: #FFFFFF;
  --stamp-soft: #E9ECFB;
  --stamp-hover: #2638A8;
  --ok: #1D7A4C;
  --ok-soft: #E2F2E9;
  --warn: #A86A12;
  --warn-soft: #FBF0DA;
  --bad: #BE3A2F;
  --bad-soft: #FAE6E3;
  --violet: #6B45B8;
  --violet-soft: #EFE8FA;
  --focus: 0 0 0 3px rgba(47, 69, 200, .32);
  --shadow-pop: 0 12px 32px rgba(29, 38, 51, .16), 0 2px 6px rgba(29, 38, 51, .08);
  --r-sm: 6px;
  --r-md: 10px;
  --side: 232px;
  --top: 56px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131820; --surface: #1A202A; --surface-2: #202733; --ink: #E5E9EF; --ink-2: #AAB3C1; --ink-3: #7F8898;
    --line: #2D3543; --line-2: #252C38; --stamp: #7D8CFF; --stamp-ink: #0F1430; --stamp-soft: #252D52; --stamp-hover: #98A4FF;
    --ok: #4CC08A; --ok-soft: #173326; --warn: #E2A84A; --warn-soft: #3A2D15; --bad: #F07A6E; --bad-soft: #3D1E1B;
    --violet: #B49AF0; --violet-soft: #2D2445; --shadow-pop: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131820; --surface: #1A202A; --surface-2: #202733; --ink: #E5E9EF; --ink-2: #AAB3C1; --ink-3: #7F8898;
  --line: #2D3543; --line-2: #252C38; --stamp: #7D8CFF; --stamp-ink: #0F1430; --stamp-soft: #252D52; --stamp-hover: #98A4FF;
  --ok: #4CC08A; --ok-soft: #173326; --warn: #E2A84A; --warn-soft: #3A2D15; --bad: #F07A6E; --bad-soft: #3D1E1B;
  --violet: #B49AF0; --violet-soft: #2D2445; --shadow-pop: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
svg[aria-hidden="true"] { width: 18px; height: 18px; flex: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 14px/1.45 var(--font); font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--stamp); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .6em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12.5px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.bad-text { color: var(--bad); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Каркас ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--stamp); color: var(--stamp-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand-name { font-weight: 650; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.nav { padding: 4px 8px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-title { padding: 0 10px 4px; font-size: 12px; color: var(--ink-3); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--stamp-soft); color: var(--stamp); }
.nav a.active svg { opacity: 1; }
.nav .count { margin-left: auto; font-size: 12px; background: var(--stamp); color: var(--stamp-ink); border-radius: 10px; padding: 0 7px; line-height: 18px; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--ink-2); flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-2);
}
.topbar .grow { flex: 1; }
.btn.menu-btn { display: none; }
.content { padding: 20px 24px 48px; max-width: 1440px; width: 100%; }
.banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn); font-weight: 500; display: flex; gap: 10px; align-items: center; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--stamp-soft); color: var(--stamp); }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.page-head .sub { width: 100%; margin-top: -8px; color: var(--ink-3); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-weight: 500; margin-bottom: 6px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--stamp); border-color: var(--stamp); color: var(--stamp-ink); }
.btn.primary:hover { background: var(--stamp-hover); border-color: var(--stamp-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.solid-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.field .err { font-size: 12.5px; color: var(--bad); }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 14px var(--font); font-feature-settings: "tnum" 1;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.4; }
select.input { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23788293' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:focus { outline: none; border-color: var(--stamp); box-shadow: var(--focus); }
.input.invalid { border-color: var(--bad); }
.input.sm { height: 30px; font-size: 13px; }
.input.num { text-align: right; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 3px 0; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--stamp); flex: none; }
.check small { display: block; color: var(--ink-3); font-size: 12.5px; }
.grid { display: grid; gap: 12px 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 32px; }

/* ---------- Панели ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.panel-head h2, .panel-head h3 { margin-right: auto; }
.panel-body { padding: 16px; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.stack > * + * { margin-top: 16px; }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .search { flex: 1 1 240px; max-width: 360px; }
.filters .input { width: auto; min-width: 140px; }
.filters .search .input { width: 100%; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button {
  padding: 9px 12px; border: 0; background: none; color: var(--ink-2); font: 500 14px var(--font); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs .active { color: var(--stamp); border-bottom-color: var(--stamp); }
.tabs .n { font-size: 12px; color: var(--ink-3); margin-left: 4px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 4px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0;
}
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--surface-2); }
.t tr.sel td { background: var(--stamp-soft); }
.t .title { font-weight: 550; color: var(--ink); }
.t .sub { font-size: 12.5px; color: var(--ink-3); }
.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.t.compact td, .t.compact th { padding: 6px 10px; }
.t input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--stamp); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line-2); color: var(--ink-3); font-size: 13px; }
.bulk { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--stamp-soft); border-bottom: 1px solid var(--line); }
.bulk b { color: var(--stamp); margin-right: 6px; }

/* ---------- Статусы ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12.5px; font-weight: 550; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-new { background: var(--violet-soft); color: var(--violet); }
.b-confirmed { background: var(--stamp-soft); color: var(--stamp); }
.b-picking, .b-loading, .b-pending, .b-warn { background: var(--warn-soft); color: var(--warn); }
.b-shipped, .b-on_route { background: var(--warn-soft); color: var(--warn); }
.b-delivered, .b-active, .b-ok, .b-closed-ok { background: var(--ok-soft); color: var(--ok); }
.b-partial { background: var(--ok-soft); color: var(--ok); }
.b-returned, .b-canceled, .b-blocked, .b-bad { background: var(--bad-soft); color: var(--bad); }
.b-planned, .b-closed, .b-draft { background: var(--surface-2); color: var(--ink-2); }
.b-posted { background: var(--ok-soft); color: var(--ok); }
.cat { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--ink-2); }
.cat-A { color: var(--ok); border-color: currentColor; }
.cat-C { color: var(--ink-3); }

/* Штамп — единственный «громкий» элемент: статус документа как печать на накладной */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); position: relative; overflow: hidden; }
.doc-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 20px 22px 16px; border-bottom: 1px dashed var(--line); }
.doc-no { font-size: 13px; color: var(--ink-3); }
.doc-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; padding: 14px 22px; border-bottom: 1px solid var(--line-2); }
.doc-meta .k { font-size: 12.5px; color: var(--ink-3); }
.doc-meta .v { font-weight: 550; }
.stamp {
  --c: var(--stamp);
  display: inline-grid; place-items: center; min-width: 132px; padding: 8px 14px; border: 2.5px solid var(--c); border-radius: 10px;
  color: var(--c); font-weight: 750; font-size: 15px; letter-spacing: .02em; transform: rotate(-4deg); text-align: center; line-height: 1.15;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 18%, transparent); align-self: start;
  animation: stamp-in .32s cubic-bezier(.2, 1.4, .4, 1) both;
}
.stamp small { display: block; font-size: 11.5px; font-weight: 600; opacity: .85; letter-spacing: 0; }
.stamp.s-new { --c: var(--violet); }
.stamp.s-picking, .stamp.s-shipped, .stamp.s-on_route, .stamp.s-loading { --c: var(--warn); }
.stamp.s-delivered, .stamp.s-partial, .stamp.s-posted, .stamp.s-closed { --c: var(--ok); }
.stamp.s-canceled, .stamp.s-returned { --c: var(--bad); }
.stamp.s-draft, .stamp.s-planned { --c: var(--ink-3); }
@keyframes stamp-in { from { transform: rotate(-4deg) scale(1.35); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stamp { animation: none; } }

/* ---------- Показатели ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--ink-3); text-decoration: none; }
.kpi .k { color: var(--ink-2); font-size: 13px; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.kpi .d { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.kpi.lead { grid-column: span 2; background: var(--stamp); border-color: var(--stamp); color: var(--stamp-ink); }
.kpi.lead .k, .kpi.lead .d, .kpi.lead .v small { color: color-mix(in srgb, var(--stamp-ink) 78%, transparent); }
.kpi.lead .v { font-size: 30px; }
.kpi.alert .v { color: var(--bad); }
.meter { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--stamp); border-radius: 3px; }
.meter.ok > i { background: var(--ok); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 6px; font-size: 12.5px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; opacity: 0; transition: opacity .1s; }
.chart .tip.on { opacity: 1; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t1 { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .t2 { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }
.loader { display: flex; justify-content: center; padding: 40px; }
.spin { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--stamp); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Модальные окна ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(15, 20, 30, .42); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-pop); animation: pop .16s ease-out; }
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1100px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.modal-head h2 { margin-right: auto; }
.modal-body { padding: 4px 18px 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 12px 12px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

.toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-pop); font-weight: 500; max-width: min(520px, 92vw); pointer-events: auto; animation: pop .16s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* Выпадающий поиск (клиент, товар) */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); max-height: 320px; overflow-y: auto; }
.picker-item { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.picker-item .grow { flex: 1; min-width: 0; }
.picker-item .sub { font-size: 12.5px; color: var(--ink-3); }
.picker-item.hl, .picker-item:hover { background: var(--stamp-soft); }
.picker-empty { padding: 12px; color: var(--ink-3); }

/* Строки документа (заказ, приход) */
.lines td .input { height: 32px; }
.lines .qty-in { width: 96px; }
.lines .price-in { width: 120px; }
.lines .bonus td { color: var(--ok); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; justify-content: end; padding: 12px 16px; min-width: 260px; margin-left: auto; }
.totals .grand { font-size: 18px; font-weight: 700; }

/* Вход */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); }
.auth-art { background: var(--stamp); color: var(--stamp-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.05; max-width: 12ch; letter-spacing: -.03em; }
.auth-art p { max-width: 42ch; opacity: .85; font-size: 15px; }
.auth-art .route { position: absolute; right: -40px; bottom: -20px; width: min(70%, 560px); opacity: .9; }
.auth-form { background: var(--surface); padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-form h2 { font-size: 22px; margin-bottom: 4px; }
.auth-form form { display: grid; gap: 14px; margin-top: 22px; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch button { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; padding: 3px 8px; font: 500 12.5px var(--font); color: var(--ink-2); cursor: pointer; }
.lang-switch button.active { border-color: var(--stamp); color: var(--stamp); }

/* Права */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; }

/* Маршрут по дням */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week .day { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); min-height: 120px; }
.week .day-h { padding: 8px 10px; border-bottom: 1px solid var(--line-2); font-weight: 600; display: flex; justify-content: space-between; }
.week .day.today .day-h { color: var(--stamp); }
.week .pt { padding: 6px 10px; border-bottom: 1px solid var(--line-2); font-size: 13px; display: flex; gap: 6px; align-items: center; cursor: grab; }
.week .pt:last-child { border-bottom: 0; }
.week .pt .x { margin-left: auto; color: var(--ink-3); cursor: pointer; border: 0; background: none; font-size: 15px; }

/* ============ Мобильный режим (агент, экспедитор) ============ */
.m-shell { min-height: 100vh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.m-top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 10px; min-height: 54px; }
.m-top h1 { font-size: 18px; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-top .back-btn { margin-left: -8px; }
.m-content { padding: 14px 16px 24px; }
.m-tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom); }
.m-tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; color: var(--ink-3); font-size: 11.5px; font-weight: 500; text-decoration: none; position: relative; }
.m-tabs a svg { width: 22px; height: 22px; }
.m-tabs a.active { color: var(--stamp); }
.m-tabs .dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10.5px; line-height: 16px; text-align: center; padding: 0 4px; }
.m-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.m-card + .m-card { margin-top: 10px; }
.m-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.m-sum > div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.m-sum .k { font-size: 12px; color: var(--ink-3); }
.m-sum .v { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; align-items: flex-start; }
.stop:last-child { border-bottom: 0; }
.stop:hover { text-decoration: none; }
.stop-n { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; color: var(--ink-2); }
.stop.done .stop-n { background: var(--ok); border-color: var(--ok); color: #fff; }
.stop.skip .stop-n { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink-3); }
.stop .grow { flex: 1; min-width: 0; }
.stop .t1 { font-weight: 600; }
.stop .t2 { font-size: 13px; color: var(--ink-3); }
.stop .debt { font-weight: 600; font-size: 13px; text-align: right; white-space: nowrap; }
.m-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.m-actions .btn { height: 52px; flex-direction: column; gap: 3px; font-size: 13px; }
.m-actions .btn svg { width: 20px; height: 20px; }
.sticky-cta { position: fixed; z-index: 25; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); padding: 10px 16px; background: linear-gradient(transparent, var(--paper) 30%); }
.sticky-cta.no-tabs { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.sticky-cta .btn { width: 100%; height: 50px; font-size: 16px; justify-content: space-between; padding: 0 18px; }
.prod { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); align-items: center; }
.prod:last-child { border-bottom: 0; }
.prod img, .prod .ph { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; border: 1px solid var(--line-2); }
.prod .grow { flex: 1; min-width: 0; }
.prod .t1 { font-weight: 550; line-height: 1.25; }
.prod .t2 { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.prod .price { font-weight: 650; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--surface-2); font-size: 20px; color: var(--ink); cursor: pointer; }
.stepper input { width: 48px; height: 38px; border: 0; text-align: center; font: 600 15px var(--font); background: var(--surface); color: var(--ink); }
.stepper.on { border-color: var(--stamp); }
.stepper.on input { color: var(--stamp); }
.add-btn { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--stamp); background: var(--surface); color: var(--stamp); font-size: 22px; cursor: pointer; flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 6px 12px; font: 500 13px var(--font); color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.chip.active { background: var(--stamp); border-color: var(--stamp); color: var(--stamp-ink); }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); cursor: pointer; }
.sync-pill.off { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.sync-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync-pill.off i { background: var(--warn); }
.big-num { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .cols, .cols.even { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 90; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-pop); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,20,30,.35); z-index: 80; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 40px; }
  .banner { margin: 12px 16px 0; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .kpi.lead { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; min-height: 220px; }
  .auth-art .route { width: 70%; }
  .auth-form { padding: 28px 20px 40px; }
  .perm-grid { grid-template-columns: 1fr; }
  .modal-back { padding: 0; align-items: flex-end; }
  .modal { border-radius: 14px 14px 0 0; max-height: 94vh; overflow-y: auto; }
  .modal-foot { border-radius: 0; position: sticky; bottom: 0; }
  .filters .input { flex: 1 1 140px; }
  .doc-head { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .hide-m { display: none !important; }
}
@media (min-width: 861px) { .only-m { display: none !important; } }

/* ---------- Печать ---------- */
@media print {
  .side, .topbar, .no-print, .banner, .m-tabs, .sticky-cta { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .content { padding: 0; }
  .panel, .doc { border: 0; }
}

.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.auth-logo svg { width: 28px; height: 28px; }
.brand-mark svg { width: 20px; height: 20px; }
.auth-art h1 { margin-bottom: 14px; }
@media (max-width: 860px) { .auth-art .route { display: none; } .auth-art { min-height: 0; gap: 18px; } }

/* Правки после проверки страниц */
.back svg, .banner svg { width: 16px; height: 16px; flex: none; }
.banner svg { width: 18px; height: 18px; }
.t th.num { text-align: right; }
.cols > * { min-width: 0; }
.seg button { white-space: nowrap; }
@media (max-width: 860px) {
  .doc-head .stamp { justify-self: start; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.lead { grid-column: 1 / -1; }
  .kpi .v { font-size: 20px; }
}

.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.list-row > svg { color: var(--ink-3); }
.cols > .panel + .panel, .cols > .panel { margin-top: 0; }
