/* =========================================================
   Dist Softtun — дизайн-система
   Идея: модули в меню — остановки на линии маршрута.
   Цвета задаются токенами; фирменная палитра меняется здесь.
   ========================================================= */

:root {
  --ink: #0F1D33;            /* сайдбар */
  --ink-2: #172A4A;
  --ink-text: #C3CDE0;
  --ink-muted: #7383A3;
  --ink-line: #2A3D60;

  --primary: #2346D9;        /* кобальт: действия */
  --primary-hover: #1B37B0;
  --primary-soft: #E8EDFD;
  --on-primary: #FFFFFF;
  --apricot: #F59A3C;        /* абрикос: только маршрут и логотип */

  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --line: #E1E5ED;
  --line-strong: #CBD2DF;
  --text: #141C2E;
  --muted: #5C677D;
  --faint: #8C96AA;

  --ok: #13915B;  --ok-soft: #E3F5EC;
  --warn: #B86E06; --warn-soft: #FCF1DF;
  --bad: #CC3434;  --bad-soft: #FCE8E8;

  --radius: 10px;
  --radius-sm: 7px;
  --sidebar: 262px;
  --topbar: 60px;
  --focus: 0 0 0 3px rgba(35, 70, 217, .28);
  --font: "Manrope", "Noto Sans Armenian", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #0A111F;
  --ink-2: #131E35;
  --ink-text: #BAC5DA;
  --ink-muted: #687897;
  --ink-line: #22314F;

  --primary: #6D8CFF;
  --primary-hover: #8DA5FF;
  --primary-soft: #1B2747;
  --on-primary: #0A1430;

  --bg: #0D1321;
  --surface: #141C2D;
  --surface-2: #19233A;
  --line: #243049;
  --line-strong: #33415E;
  --text: #E6EAF3;
  --muted: #98A4BC;
  --faint: #6F7C96;

  --ok: #3CC98A;  --ok-soft: #12342A;
  --warn: #F0B44F; --warn-soft: #3A2C12;
  --bad: #FF7474;  --bad-soft: #3D1A1E;
  --focus: 0 0 0 3px rgba(109, 140, 255, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 500 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 750; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 10px; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.app.collapsed { --sidebar: 72px; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar); padding: 0 18px;
  color: #fff; flex: none;
}
.brand:hover { color: #fff; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.brand-name b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand-name small { font-size: 11.5px; color: var(--ink-muted); font-weight: 600; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; scrollbar-width: thin; scrollbar-color: var(--ink-line) transparent; }
.nav-group { margin-top: 14px; }
.nav-title {
  padding: 0 10px 6px 12px;
  font-size: 12px; font-weight: 650; color: var(--ink-muted);
  white-space: nowrap;
}
/* Линия маршрута */
.nav-group ul { list-style: none; margin: 0; padding: 0; position: relative; }
.nav-group ul::before {
  content: ""; position: absolute; left: 21px; top: 16px; bottom: 16px;
  border-left: 2px dotted var(--ink-line);
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px 0 38px;
  border-radius: 8px;
  color: var(--ink-text); font-weight: 600; font-size: 13.5px;
  white-space: nowrap;
}
.nav a::before {                       /* остановка */
  content: ""; position: absolute; left: 16px; top: 50%;
  width: 12px; height: 12px; margin-top: -6px;
  border-radius: 50%;
  background: var(--ink); border: 2px solid var(--ink-line);
  transition: border-color .15s, background .15s;
}
.nav a .ic { color: var(--ink-muted); }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a:hover::before { border-color: var(--ink-muted); }
.nav a.active { background: var(--ink-2); color: #fff; }
.nav a.active::before {
  background: var(--apricot); border-color: var(--apricot);
  box-shadow: 0 0 0 4px rgba(245, 154, 60, .22);
}
.nav a.active .ic { color: var(--apricot); }
.nav a.soon { color: var(--ink-muted); cursor: default; }
.nav a.soon:hover { background: transparent; color: var(--ink-muted); }
.nav a.soon::before { border-style: dashed; }
.nav a span { overflow: hidden; text-overflow: ellipsis; }
.nav .tag {
  margin-left: auto; flex: none; font-style: normal; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px; background: var(--ink-2); color: var(--ink-muted);
}
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--ink-line); font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; }

.app.collapsed .brand-name, .app.collapsed .nav-title, .app.collapsed .nav a span,
.app.collapsed .nav .tag, .app.collapsed .sidebar-foot { display: none; }
.app.collapsed .nav a { padding: 0; justify-content: center; }
.app.collapsed .nav a::before, .app.collapsed .nav-group ul::before { display: none; }
.app.collapsed .nav a.active { box-shadow: inset 3px 0 0 var(--apricot); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; gap: 10px;
  padding: 0 24px 0 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 10px;
  width: min(380px, 40vw); height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--faint);
  font: inherit; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.search-trigger kbd { margin-left: auto; }
kbd {
  font: 600 11px/1 var(--font); padding: 3px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--muted);
}
.outlet-select { max-width: 220px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px;
  border-radius: 99px; color: var(--text); cursor: pointer; border: 1px solid transparent;
  background: none; font: inherit;
}
.user-chip:hover { border-color: var(--line); color: var(--text); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 800; font-size: 13px;
}
.user-chip .who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-chip .who b { font-size: 13px; }
.user-chip .who small { font-size: 11.5px; color: var(--muted); }

.content { padding: 24px; max-width: 1480px; width: 100%; }

/* ---------- Выпадающее меню ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 29, 51, .14); padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 7px; border: 0; background: none;
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); color: var(--text); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .lead { margin: 4px 0 0; color: var(--muted); max-width: 72ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .ic { opacity: .6; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px;
  border-radius: 8px; border: 1px solid transparent;
  font: 700 13.5px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--surface); border-color: var(--line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-plain { background: none; border: 0; color: var(--muted); }
.btn-plain:hover { color: var(--text); background: var(--surface-2); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.card-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { flex: 1; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }
.dash-grid > .card { margin-top: 0; }

/* ---------- Таблицы ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.toolbar .search input { padding-left: 36px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 12.5px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  position: sticky; top: 0;
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.table th a.sorted { color: var(--text); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.inactive td { color: var(--faint); }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table .row-link { color: var(--text); font-weight: 650; }
.table .row-link:hover { color: var(--primary); }
.table .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.table .tree-pad { display: inline-block; width: calc(var(--depth, 0) * 18px); }
.table .tree-pad + .tree-mark { color: var(--faint); margin-right: 6px; }

/* ---------- Пилюли, метки ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-off { background: transparent; color: var(--faint); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill-blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; background: var(--sw); border: 1px solid var(--line); vertical-align: middle; }

/* ---------- Формы ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field .req { color: var(--bad); }
.field .help { font-size: 12px; color: var(--faint); }
.field .error { font-size: 12.5px; color: var(--bad); font-weight: 600; }
.field.has-error .input { border-color: var(--bad); }

.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: 500 14px/1.4 var(--font);
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; }
select.input {
  appearance: none; padding-right: 34px; cursor: pointer;
  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='%238C96AA' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.num { text-align: right; }
.input-sm { height: 32px; font-size: 13px; padding: 0 9px; }
.input-color { padding: 4px; width: 64px; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong);
  position: relative; transition: background .15s; flex: none;
}
.check .box::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.check input:checked + .box { background: var(--primary); }
.check input:checked + .box::after { transform: translateX(16px); }
.check input:focus-visible + .box { box-shadow: var(--focus); }

.tick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.tick input { width: 16px; height: 16px; accent-color: var(--primary); }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; }
.days span {
  display: grid; place-items: center; width: 40px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line-strong); font-weight: 700; color: var(--muted); cursor: pointer;
}
.days input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.days input:focus-visible + span { box-shadow: var(--focus); }

.form-actions {
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions .left { margin-right: auto; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a.tab {
  display: inline-flex; align-items: center;
  height: 44px; padding: 0 14px; border: 0; background: none; cursor: pointer;
  font: 700 13.5px var(--font); color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover, .tabs a.tab:hover { color: var(--text); }
.tabs button.active, .tabs a.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tabs .cnt { font-size: 11.5px; color: var(--faint); margin-left: 4px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Строки-редакторы (единицы, цены) ---------- */
.rows-editor { width: 100%; border-collapse: collapse; }
.rows-editor th { font-size: 12px; color: var(--muted); font-weight: 700; text-align: left; padding: 0 8px 8px; }
.rows-editor td { padding: 4px 8px; vertical-align: middle; }
.rows-editor td:first-child, .rows-editor th:first-child { padding-left: 0; }
.rows-editor .eq { color: var(--muted); font-weight: 700; text-align: center; white-space: nowrap; }
.rows-editor .preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.add-row { margin-top: 10px; }

/* ---------- Уведомления ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.alert-err { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 420px; padding: 12px 14px;
  background: var(--ink); color: #fff; border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(15, 29, 51, .28); font-weight: 600;
  animation: toast-in .18s ease-out;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--apricot); flex: none; }
.toast.ok .dot { background: #3CC98A; }
.toast.err .dot { background: #FF7474; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Пустое состояние ---------- */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .ic { margin: 0 auto 12px; color: var(--faint); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.empty p { max-width: 46ch; margin: 0 auto 14px; }

/* ---------- Пагинация ---------- */
.pager { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
.pager a, .pager span {
  min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 8px;
  border-radius: 7px; font-weight: 700; color: var(--muted); font-size: 13px;
}
.pager a:hover { background: var(--surface-2); color: var(--text); }
.pager .cur { background: var(--primary); color: var(--on-primary); }

/* ---------- Дашборд ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.stat:hover { border-color: var(--line-strong); color: var(--text); }
.stat .stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 650; font-size: 13px; }
.stat .stat-label .ic { color: var(--faint); }
.stat .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.stat .stat-note { font-size: 12.5px; color: var(--faint); }

/* Маршрут внедрения на дашборде */
.journey { list-style: none; margin: 0; padding: 4px 0 0; position: relative; }
.journey::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 14px; border-left: 2px dotted var(--line-strong); }
.journey li { position: relative; padding: 0 0 16px 32px; }
.journey li:last-child { padding-bottom: 0; }
.journey li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
}
.journey li.done::before { background: var(--ok); border-color: var(--ok); }
.journey li.now::before { background: var(--apricot); border-color: var(--apricot); box-shadow: 0 0 0 4px rgba(245,154,60,.2); }
.journey b { display: block; font-size: 13.5px; }
.journey span { font-size: 12.5px; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed .when { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }

/* ---------- Права ---------- */
.perm-module { border-top: 1px solid var(--line); }
.perm-module:first-child { border-top: 0; }
.perm-module-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface-2); }
.perm-module-head h3 { flex: 1; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; padding: 14px 18px; }
.perm-list code { font-size: 11px; color: var(--faint); display: block; margin-left: 24px; }

/* ---------- Журнал ---------- */
.diff { font-size: 12.5px; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; }
.diff dt { color: var(--muted); font-weight: 700; }
.diff dd { margin: 0; }
.diff del { color: var(--bad); text-decoration: line-through; margin-right: 6px; }
.diff ins { color: var(--ok); text-decoration: none; }

/* ---------- Импорт ---------- */
.steps { display: flex; gap: 0; list-style: none; margin: 0 0 18px; padding: 0; counter-reset: s; }
.steps li { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--faint); font-weight: 700; font-size: 13px; }
.steps li::before {
  counter-increment: s; content: counter(s);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line-strong); font-size: 12px; flex: none;
}
.steps li::after { content: ""; flex: 1; border-top: 2px dotted var(--line-strong); margin-right: 10px; }
.steps li:last-child::after { display: none; }
.steps li.done { color: var(--ok); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.now { color: var(--text); }
.steps li.now::before { border-color: var(--apricot); background: var(--apricot); color: #fff; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 36px 20px; border: 2px dashed var(--line-strong); border-radius: var(--radius);
  text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { display: none; }
.dropzone b { color: var(--text); }
.err-row td { background: var(--bad-soft) !important; }

/* ---------- Поиск (Ctrl+K) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 17, 31, .45);
  display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 90;
}
.modal-backdrop.open { display: flex; }
.palette {
  width: min(620px, calc(100vw - 32px)); background: var(--surface);
  border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(10, 17, 31, .35); overflow: hidden;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input .ic { color: var(--faint); }
.palette-input input { flex: 1; height: 54px; border: 0; background: none; font: 600 16px var(--font); color: var(--text); outline: none; }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-results a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--text);
}
.palette-results a .kind { margin-left: auto; font-size: 12px; color: var(--faint); }
.palette-results a.sel, .palette-results a:hover { background: var(--primary-soft); color: var(--text); }
.palette-results .none { padding: 18px; text-align: center; color: var(--muted); }

/* ---------- Вход ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
  background: var(--surface);
}
.auth-art {
  position: relative; overflow: hidden;
  background: var(--ink); color: #fff;
  padding: 44px 52px; display: flex; flex-direction: column;
}
.auth-art .brand { padding: 0; height: auto; }
.auth-art svg.map { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-art .claim { margin-top: auto; position: relative; max-width: 520px; }
.auth-art::after { content: ""; position: absolute; inset: auto 0 0 0; height: 46%; background: linear-gradient(to top, var(--ink) 35%, transparent); pointer-events: none; }
.auth-art .brand, .auth-art .claim { z-index: 1; position: relative; }
.auth-art .claim h1 { font-size: 32px; line-height: 1.15; font-weight: 800; letter-spacing: -.025em; color: #fff; }
.auth-art .claim p { color: var(--ink-text); margin-top: 14px; font-size: 15px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.auth-form h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.auth-form .btn { height: 44px; font-size: 14.5px; }
.auth-form .input { height: 44px; }
.pw-wrap { position: relative; }
.pw-wrap .btn { position: absolute; right: 4px; top: 4px; height: 36px; }
.auth-foot { font-size: 12.5px; color: var(--faint); text-align: center; }

/* ---------- Ошибки ---------- */
.error-page { max-width: 520px; margin: 8vh auto; text-align: center; }
.error-page .code { font-size: 72px; font-weight: 800; color: var(--line-strong); letter-spacing: -.04em; }

/* ---------- Адаптив ---------- */
.only-mobile { display: none; }
@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; } .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; } .span-6 { grid-column: span 12; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10,17,31,.45); }
  .app.collapsed { --sidebar: 252px; }
  .only-mobile { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 0 12px; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd { display: none; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-3 { grid-column: span 12; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 200px; padding: 28px; }
  .auth-art .claim h1 { font-size: 24px; }
  .user-chip .who { display: none; }
  .table td, .table th { padding: 9px 10px; }
  .steps li { font-size: 0; } .steps li::before { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.print-head { display: none; }
@media print {
  :root, :root[data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f4f5f8; --text: #000; --muted: #444; --faint: #666; --line: #d5d9e0; --line-strong: #b9c0cc; --primary: #1B37B0; color-scheme: light; }
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11.5px; }
  .sidebar, .topbar, .page-head .actions, .toolbar, .pager, .form-actions, .toasts, .no-print, .tabs a:not(.active) { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; } .card { border: 0; box-shadow: none; break-inside: auto; }
  .print-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 2px solid #000; font-size: 11px; }
  .print-head b { font-size: 13px; }
  .page-head .lead { display: none; }
  .table th, .table td { padding: 5px 6px; }
  .table thead { display: table-header-group; }
  .table tr { break-inside: avoid; }
  .dash-grid { gap: 8px; }
  a { color: inherit; }
}

/* ---------- Документы ---------- */
.item-picker { position: relative; }
.picker-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 14px 32px rgba(15, 29, 51, .16); padding: 6px; max-height: 340px; overflow-y: auto;
}
.picker-list button {
  display: grid; grid-template-columns: 1fr auto; gap: 0 12px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 7px; background: none; cursor: pointer; font: inherit; color: var(--text);
}
.picker-list button .muted { grid-column: 1; font-size: 12px; }
.picker-list button .stk { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.picker-list button.sel, .picker-list button:hover { background: var(--primary-soft); }
.picker-list .none { padding: 12px; color: var(--muted); text-align: center; }
.lines-table td { padding-top: 7px; padding-bottom: 7px; }
.lines-table .input-sm { min-width: 70px; }
.neg { color: var(--bad); font-weight: 700; }
.pos { color: var(--ok); font-weight: 700; }
.doc-totals {
  display: flex; justify-content: flex-end; gap: 28px; flex-wrap: wrap;
  padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.doc-totals div { display: flex; flex-direction: column; align-items: flex-end; }
.doc-totals span { font-size: 12px; color: var(--muted); font-weight: 650; }
.doc-totals em { font-style: normal; }
.doc-totals b { font-variant-numeric: tabular-nums; font-size: 15px; }
.doc-totals .grand b { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.table tfoot td { padding: 12px 14px; border-top: 1px solid var(--line-strong); background: var(--surface-2); }
.pay-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.rows-editor .help { display: block; font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ---------- Касса ---------- */
.pos-screen { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; height: calc(100vh - var(--topbar) - 48px); min-height: 560px; }
.pos-screen > .card { display: flex; flex-direction: column; min-height: 0; }
.pos-cats { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.chip {
  height: 32px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface);
  font: 700 13px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap;
  box-shadow: inset 3px 0 0 var(--c, transparent);
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pos-tiles { flex: 1; overflow-y: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.tile {
  display: flex; flex-direction: column; gap: 6px; text-align: left; min-height: 104px;
  padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2);
  font: inherit; color: var(--text); cursor: pointer; transition: border-color .12s, transform .08s;
}
.tile:hover { border-color: var(--primary); }
.tile:active { transform: scale(.98); }
.tile.out { opacity: .55; }
.tile .t-name { font-weight: 700; font-size: 13.5px; line-height: 1.3; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .t-price { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .t-stock { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pos-client { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pos-client-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos-client-main b { display: block; }
.pos-client-main .sub { font-size: 12px; display: block; }
.pos-client-search { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.pc-results { display: grid; gap: 2px; margin-top: 8px; max-height: 200px; overflow-y: auto; }
.pc-results button { text-align: left; padding: 8px 10px; border: 0; border-radius: 7px; background: none; font: inherit; color: var(--text); cursor: pointer; }
.pc-results button:hover { background: var(--primary-soft); }
.pos-lines { flex: 1; overflow-y: auto; padding: 4px 14px; }
.pl { padding: 10px 0; border-bottom: 1px solid var(--line); }
.pl-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pl-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.pl-row select.input-sm { width: auto; min-width: 64px; }
.pl-price { width: 90px; display: inline-block; }
.pl-sum { margin-left: auto; font-variant-numeric: tabular-nums; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.stepper button { width: 30px; height: 30px; border: 0; background: var(--surface-2); font: 700 16px var(--font); color: var(--text); cursor: pointer; }
.stepper input { width: 64px; height: 30px; border: 0; border-radius: 0; text-align: center; }
.pos-sum { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.pos-sum div { display: flex; flex-direction: column; }
.pos-sum span { font-size: 12px; color: var(--muted); font-weight: 650; }
.pos-sum b { font-variant-numeric: tabular-nums; }
.pos-sum .grand { text-align: right; }
.pos-sum .grand b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.pos-pay { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; }
.pos-pay .btn { height: 46px; font-size: 14px; }
.pos-foot { font-size: 12px; padding: 0 14px 12px; }
.pay-box { width: min(460px, calc(100vw - 32px)); }
.pm-row { display: grid; grid-template-columns: 1fr 160px; gap: 10px; align-items: center; padding: 6px 0; font-weight: 650; }
.pm-change { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; }
.pm-change b { font-size: 24px; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; }
.done-mark { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: var(--ok-soft); color: var(--ok); }
@media (max-width: 1100px) { .pos-screen { grid-template-columns: 1fr; height: auto; } .pos-tiles { max-height: 50vh; } }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 6px; }
.bars .bar { flex: 1; min-width: 6px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bars .bar span { width: 100%; max-width: 38px; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; }
.bars .bar:hover span { opacity: 1; background: var(--apricot); }
.bars .bar em { font-style: normal; font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.pnl td:last-child { width: 200px; }
.pnl tr.pnl-sub td { font-weight: 800; background: var(--surface-2); }
.pnl tr.pnl-total td { font-weight: 800; font-size: 16px; border-top: 2px solid var(--line-strong); }

/* ---------- Отчёты дистрибуции ---------- */
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.meter { position: relative; display: flex; align-items: center; gap: 10px; }
.meter::before { content: ""; flex: 1; height: 7px; border-radius: 9px; background: var(--line); }
.meter > span { position: absolute; left: 0; top: 50%; height: 7px; margin-top: -3.5px; width: calc((100% - 46px) * var(--v, 0) / 100); border-radius: 9px; background: var(--primary); }
.meter > span.ok { background: var(--ok); }
.meter > span.bad { background: var(--bad); }
.meter > i { position: absolute; top: 50%; left: calc((100% - 46px) * var(--v, 0) / 100); width: 2px; height: 13px; margin-top: -6.5px; background: var(--text); opacity: .55; border-radius: 2px; transform: translateX(-1px); }
.meter > em { width: 36px; text-align: right; font-style: normal; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.reason-bars { list-style: none; margin: 0; padding: 6px 18px 16px; }
.reason-bars li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; margin-top: 6px; border-radius: var(--radius-sm); overflow: hidden; }
.reason-bars li span, .reason-bars li b { position: relative; z-index: 1; }
.reason-bars li i { position: absolute; inset: 0 auto 0 0; background: var(--warn-soft); }
.api-key { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); font: 600 13.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.api-key code { flex: 1; }

/* Этапы рейса: остановки на линии */
.trip-steps { display: flex; margin: 0 0 16px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); counter-reset: st; }
.trip-steps span { position: relative; flex: 1; display: flex; align-items: center; gap: 10px; color: var(--faint); font-weight: 700; font-size: 13.5px; }
.trip-steps span::before { counter-increment: st; content: counter(st); flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); font-size: 12px; }
.trip-steps span:not(:last-child)::after { content: ""; flex: 1; margin-right: 12px; border-top: 2px dashed var(--line-strong); }
.trip-steps span.done { color: var(--muted); }
.trip-steps span.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.trip-steps span.done::after { border-top-style: solid; border-color: var(--ok); }
.trip-steps span.now { color: var(--text); }
.trip-steps span.now::before { border-color: var(--apricot); color: var(--apricot); box-shadow: 0 0 0 4px rgba(245, 154, 60, .18); }
@media (max-width: 640px) { .trip-steps { padding: 12px; } .trip-steps span { font-size: 12px; gap: 6px; } .trip-steps span:not(:last-child)::after { margin-right: 6px; } }

/* =========================================================
   Мобильный режим: агент и экспедитор
   Одной рукой: крупные цели, нижние вкладки, нижние листы
   ========================================================= */
.m-body { min-height: 100vh; padding-bottom: calc(74px + env(safe-area-inset-bottom)); background: var(--bg); }
.m-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 8px 0 12px; padding-top: env(safe-area-inset-top); box-sizing: content-box;
  background: var(--ink); color: #fff;
}
.m-mark { display: flex; width: 32px; height: 32px; }
.m-mark svg { width: 32px; height: 32px; }
.m-back, .m-icon { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: transparent; color: #fff; cursor: pointer; }
.m-back:active, .m-icon:active { background: var(--ink-2); }
.m-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.m-title b { font-size: 16.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-title small { color: var(--ink-muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-content { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }
.m-content > .alert { margin: 0 0 12px; }

.m-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.m-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; color: var(--faint); font-size: 11.5px; font-weight: 700; }
.m-tabs a.on { color: var(--primary); }
.m-tabs a.on .ic { stroke-width: 2.2; }
.m-tabs a:active { background: var(--surface-2); }

/* Шапка дня: тёмная карточка с кольцом прогресса */
.m-hero { --hero: var(--ink); --hero-2: var(--ink-2); margin: 0 0 14px; padding: 16px; border-radius: 16px; background: var(--hero); color: #fff; }
:root[data-theme="dark"] .m-hero { --hero: var(--surface); --hero-2: var(--surface-2); border: 1px solid var(--line); }
.m-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.m-hero small { color: var(--ink-muted); font-size: 12.5px; }
.m-hero h1 { margin: 2px 0 0; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.m-ring {
  --p: 0; flex: none; display: grid; place-items: center; align-content: center; width: 72px; height: 72px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--hero) 80%, transparent 81% 100%), conic-gradient(var(--apricot) calc(var(--p) * 1%), var(--ink-line) 0);
  text-align: center; line-height: 1.1;
}
.m-ring b { font-size: 17px; font-weight: 800; }
.m-ring small { font-size: 10.5px; }
.m-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.m-kpis > div { min-width: 0; padding: 10px; border-radius: 12px; background: var(--hero-2, var(--ink-2)); }
.m-kpis small { display: block; color: var(--ink-muted); font-size: 11.5px; }
.m-kpis b { display: block; font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.m-kpis em { display: block; font-style: normal; color: var(--ink-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-kpis-light > div { background: var(--surface-2); }
.m-kpis-light small, .m-kpis-light em { color: var(--muted); }

.m-agent-pick { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.m-next {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 14px 16px; border-radius: 14px;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px -8px rgba(35, 70, 217, .6);
}
.m-next > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-next small { opacity: .8; font-size: 12px; }
.m-next b { font-size: 16.5px; font-weight: 800; }
.m-next em { font-style: normal; opacity: .85; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-done { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 14px 16px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.m-h { margin: 18px 4px 10px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Остановки маршрута: та же линия, что в меню */
.m-stops { position: relative; list-style: none; margin: 0; padding: 0; }
.m-stops::before { content: ""; position: absolute; left: 27px; top: 22px; bottom: 22px; border-left: 2px dashed var(--line-strong); }
.m-stops li { position: relative; margin-bottom: 8px; }
.m-stops a { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.m-stops a:active { background: var(--surface-2); }
.m-dot {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted); font-size: 13px; font-weight: 800;
}
.m-stops li.done .m-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.m-stops li.refused .m-dot { background: var(--bad); border-color: var(--bad); }
.m-stops li:not(.done):first-of-type .m-dot, .m-stops li.done + li:not(.done) .m-dot { border-color: var(--apricot); color: var(--apricot); box-shadow: 0 0 0 4px rgba(245, 154, 60, .18); }
.m-stops li.done .m-stop-main b { color: var(--muted); }
.m-stop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-stop-main b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-stop-main small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.m-chips .pill { font-size: 11px; padding: 1px 7px; }
.m-stop-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.m-stop-side b { font-size: 14.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.m-stop-side small { font-size: 11.5px; color: var(--muted); }

/* Карточки, клиент, действия */
.m-card { margin-bottom: 12px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.m-client h1 { margin: 0 0 2px; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.m-client p { margin: 0; font-size: 13px; }
.m-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.m-links .btn { height: 38px; }
.m-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.m-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 88px; padding: 10px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 700 14px var(--font); cursor: pointer;
}
.m-action:active { transform: scale(.98); background: var(--surface-2); }
.m-action.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.m-list { list-style: none; margin: 0; padding: 0; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.m-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.m-list li:first-child { border-top: 0; }
.m-list li > span { min-width: 0; display: flex; flex-direction: column; }
.m-list b { font-size: 14px; }
.m-list small { color: var(--muted); font-size: 12.5px; }
.m-empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.m-empty .ic { color: var(--faint); }
.m-empty h2 { margin: 10px 0 6px; color: var(--text); font-size: 18px; }
.m-empty.small { padding: 18px; border: 1px dashed var(--line-strong); border-radius: 14px; }
.m-empty p { margin: 6px 0 14px; }
.m-menu { list-style: none; margin: 0; padding: 0; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.m-menu li + li { border-top: 1px solid var(--line); }
.m-menu a, .m-menu button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px; border: 0; background: none; color: var(--text); font: 700 15px var(--font); text-align: left; cursor: pointer; }
.m-menu form { margin: 0; }
.m-menu .ic { color: var(--muted); }

/* Нижний лист */
.m-sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; background: rgba(8, 14, 28, 0); transition: background .18s; }
.m-sheet.open { background: rgba(8, 14, 28, .5); }
.m-sheet-body {
  width: 100%; max-width: 640px; max-height: 88vh; margin: 0 auto; overflow: auto; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: var(--surface); transform: translateY(100%); transition: transform .18s ease-out;
}
.m-sheet.open .m-sheet-body { transform: none; }
.m-sheet-body::before { content: ""; display: block; width: 40px; height: 4px; margin: -6px auto 14px; border-radius: 4px; background: var(--line-strong); }
.m-sheet-body h2 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.m-sheet-body .field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.m-sheet-body .field > span, .m-card .field > span, .m-order-extra .field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.m-sheet-foot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 18px; }
.m-sheet-foot .btn, .m-cart .btn { height: 50px; font-size: 15px; justify-content: center; }
.m-big { height: 54px; font-size: 22px; font-weight: 800; }
.m-reasons { display: grid; gap: 8px; margin-top: 12px; }
.m-reasons label { display: block; cursor: pointer; }
.m-reasons input { position: absolute; opacity: 0; }
.m-reasons span { display: block; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.m-reasons input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.m-reasons input:focus-visible + span { box-shadow: var(--focus); }

/* Заказ: каталог со степперами и закреплённая корзина */
.m-order-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.m-order-tools .alert { margin: 0; }
.m-order-head { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 20; margin: -14px -14px 10px; padding: 10px 14px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.m-search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--faint); }
.m-content > .m-search { margin-bottom: 12px; }
.m-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: 600 15px var(--font); }
.m-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
.m-cats::-webkit-scrollbar { display: none; }
.m-cats button { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 700 13px var(--font); white-space: nowrap; cursor: pointer; }
.m-cats button.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.m-catalog { list-style: none; margin: 0 0 12px; padding: 0; }
.m-catalog li { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding: 10px 10px 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.m-catalog li.sel { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.m-item { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-item b { font-size: 14.5px; font-weight: 700; }
.m-item small { color: var(--muted); font-size: 12.5px; }
.m-step { flex: none; display: flex; align-items: center; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.m-step button { width: 42px; height: 44px; border: 0; background: none; color: var(--primary); font: 800 22px/1 var(--font); cursor: pointer; }
.m-step button:active { background: var(--primary-soft); }
.m-step input { width: 52px; height: 44px; border: 0; background: none; text-align: center; color: var(--text); font: 800 16px var(--font); outline: 0; }
.m-step-solo { padding-right: 10px; }
.m-step-solo input { width: 70px; }
.m-step em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.m-order-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.m-order-extra .field { display: flex; flex-direction: column; gap: 6px; }
.m-card .field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.m-cart {
  position: sticky; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 25; display: flex; align-items: center; gap: 12px;
  margin: 0 -4px; padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px -12px rgba(8, 14, 28, .55);
}
.m-cart > span { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.m-cart small, .m-cart em { color: var(--ink-muted); font-size: 12px; font-style: normal; }
.m-cart b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.m-cart .btn-ghost { background: var(--ink-2); color: #fff; border-color: var(--ink-line); }
.m-cart .btn:disabled { opacity: .45; }
#m-deliver .m-cart .btn { flex: 1; }
.m-total { display: flex; align-items: baseline; justify-content: space-between; }
.m-total span { color: var(--muted); font-weight: 700; }
.m-total b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Рейсы экспедитора */
.m-trips { list-style: none; margin: 0; padding: 0; }
.m-trips li { margin-bottom: 10px; }
.m-trips a { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.m-trips small { color: var(--muted); font-size: 12.5px; }
.m-trip-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.m-trip-top b { font-size: 17px; font-weight: 800; }
.progress { display: block; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 6px; }
.btn.busy { opacity: .7; pointer-events: none; }
.m-body .toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); }

@media (min-width: 700px) {
  .m-content { padding-top: 20px; }
  .m-order-head { margin-top: -20px; }
}

/* ---------- Дашборд продаж ---------- */
.bars-30 { height: 200px; gap: 3px; }
.bars-30 .bar { color: inherit; }
.bars-30 .bar.we span { opacity: .55; }
.bars-30 .bar.today span { background: var(--apricot); opacity: 1; }
.hbars { list-style: none; margin: 0; padding: 4px 18px 16px; }
.hbars li { display: grid; grid-template-columns: 1fr auto 38px; gap: 2px 10px; align-items: center; padding: 7px 0; }
.hbars li span { font-weight: 600; }
.hbars li b { font-variant-numeric: tabular-nums; }
.hbars li i { grid-column: 1 / 3; height: 6px; border-radius: 6px; background: var(--primary); }
.hbars li i.k-cash { background: var(--ok); } .hbars li i.k-card { background: var(--primary); } .hbars li i.k-bank { background: #7A5AF8; } .hbars li i.k-bonus { background: var(--apricot); } .hbars li i.k-credit { background: var(--bad); }
.hbars li em { grid-row: 1 / 3; grid-column: 3; font-style: normal; text-align: right; color: var(--muted); font-size: 12.5px; }
.table-compact td { padding-top: 9px; padding-bottom: 9px; }
.table .rank { width: 34px; color: var(--faint); font-weight: 800; }
.money-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.money-strip a { display: flex; flex-direction: column; padding: 12px 16px; background: var(--surface); color: var(--text); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.money-strip a:hover { background: var(--surface-2); }
.money-strip small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money-strip b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.money-strip em { font-style: normal; color: var(--faint); font-size: 11.5px; }

/* ---------- Отчёты: витрина, ABC, ДДС, прайс ---------- */
.report-hub section { margin-bottom: 22px; }
.report-hub h2 { margin: 0 0 10px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.report-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.report-tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; color: var(--text); transition: border-color .15s, transform .15s; }
.report-tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.report-tile b { display: block; font-size: 15px; }
.report-tile small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.report-ic { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.abc-badge { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-weight: 800; font-size: 12.5px; background: var(--surface-2); color: var(--muted); margin-right: 6px; }
.abc-badge.abc-A, .abc-A .abc-badge { background: var(--ok-soft); color: var(--ok); }
.abc-badge.abc-B, .abc-B .abc-badge { background: var(--primary-soft); color: var(--primary); }
.abc-badge.abc-C, .abc-C .abc-badge { background: var(--warn-soft); color: var(--warn); }
.abc-stat .stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); }
.meter > span.abc-fill-A { background: var(--ok); } .meter > span.abc-fill-C { background: var(--warn); }
.cf-table tr.cf-sec td { background: var(--surface-2); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cf-table tr.cf-sub td, .cf-table tfoot td { font-weight: 800; }
.cf-table tfoot tr.cf-total td { border-top: 2px solid var(--line-strong); }
.pricelist tr.cf-sec td { background: var(--surface-2); font-weight: 800; }
.print-only { display: none; }
.pricelist-head { padding: 0 0 10px; }
.pricelist-head b { font-size: 16px; } .pricelist-head span { display: block; color: var(--muted); }
.pricelist-head h2 { margin: 8px 0 0; font-size: 18px; }
@media print {
  .print-only { display: block; }
  body[data-route="reports/pricelist"] .print-head, body[data-route="reports/pricelist"] .page-head { display: none; }
}

/* ---------- Интеграции ---------- */
.lb-opts { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); margin-right: 2px; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.setup-steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.setup-steps li { padding-left: 4px; line-height: 1.55; }
.setup-steps code, .card-body code { font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ---------- Этап 7: долги, календарь ---------- */
.warn-t { color: var(--warn); }
.cal-doc { display: inline-block; margin: 2px 6px 2px 0; padding: 2px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text); background: var(--surface-2); border-left: 3px solid var(--line-strong); }
.cal-doc.in { border-left-color: var(--ok); } .cal-doc.out { border-left-color: var(--bad); }
.cal-over td { background: var(--warn-soft); }
.bell { position: relative; }
.bell-n { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font: 800 10.5px/17px var(--font); text-align: center; }
.notif-menu { width: 330px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.notif-item { display: flex !important; flex-direction: column; align-items: flex-start !important; gap: 1px !important; padding: 9px 14px !important; border-bottom: 1px solid var(--line); white-space: normal !important; }
.notif-item small { color: var(--muted); font-size: 12px; }
.notif-item.unread { box-shadow: inset 3px 0 0 var(--primary); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li + li { border-top: 1px solid var(--line); }
.notif-list a { display: flex; gap: 14px; align-items: center; padding: 14px 18px; color: var(--text); }
.notif-list a > span:nth-child(2) { flex: 1; } .notif-list b { display: block; } .notif-list small { color: var(--muted); }
.notif-list li.unread a { background: var(--primary-soft); }
.notif-list .when { color: var(--faint); font-size: 12px; white-space: nowrap; }
.promo-tag { color: var(--ok); font-weight: 700; }
.conv-out { color: var(--bad); font-weight: 700; } .conv-in { color: var(--ok); font-weight: 700; }
.accept-card { margin-bottom: 16px; border-color: var(--warn); }
.m-photo { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; font-weight: 700; color: var(--text); cursor: pointer; }
.m-photo span { display: flex; align-items: center; gap: 8px; } .m-photo em { font-style: normal; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.m-photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.m-photo.has { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }

/* Горизонтальная полоска в таблицах отчётов */
.hbar { display: inline-block; width: 140px; max-width: 100%; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; vertical-align: middle; }
.hbar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

/* Настройки: префиксы номеров и картинки печатных форм */
.prefix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; }
.prefix-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.prefix-row .input { width: 84px; flex: none; text-transform: none; }
.prefix-row.has-error .input { border-color: var(--bad); }
.brand-up { display: flex; gap: 12px; align-items: center; }
.brand-prev { width: 84px; height: 56px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: #fff; flex: none; overflow: hidden; }
.brand-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Переключатель языка */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.lang-switch a { padding: 5px 9px; font: 700 11.5px/1 var(--font); color: var(--muted); text-decoration: none; letter-spacing: .02em; }
.lang-switch a + a { border-left: 1px solid var(--line); }
.lang-switch a.on { background: var(--primary); color: #fff; }
.lang-switch a:not(.on):hover { color: var(--text); background: var(--hover, rgba(0,0,0,.04)); }
.auth-lang { position: absolute; top: 20px; right: 20px; }
.auth-form { position: relative; }
.m-lang a { padding: 6px 7px; }

/* Начало работы */
.guide-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; margin-bottom: 16px; flex-wrap: wrap; }
.guide-progress { display: flex; align-items: center; gap: 16px; }
.guide-progress h2 { margin: 0 0 2px; font-size: 17px; }
.guide-progress p { margin: 0; }
.guide-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.guide-ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.guide-ring b { position: relative; font-size: 14px; }
.guide-phase { margin-bottom: 16px; }
.guide-pn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink, #141C2E); color: #fff; font-size: 12px; margin-right: 10px; vertical-align: 1px; }
.guide-steps { list-style: none; margin: 0; padding: 0; }
.guide-step + .guide-step { border-top: 1px solid var(--line); }
.guide-step summary { display: grid; grid-template-columns: 28px 1fr auto 16px; align-items: center; gap: 12px; padding: 13px 18px; cursor: pointer; list-style: none; }
.guide-step summary::-webkit-details-marker { display: none; }
.guide-step summary:hover { background: var(--surface-2); }
.guide-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 12px/1 var(--font); border: 2px solid var(--line-strong, #c9d0dc); color: var(--muted); }
.guide-step.done .guide-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.guide-step.current .guide-dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px rgba(35, 70, 217, .14); }
.guide-title { display: flex; flex-direction: column; min-width: 0; }
.guide-title small { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.guide-step.done .guide-title b { color: var(--muted); }
[data-gchev] { color: var(--muted); transition: transform .15s; }
.guide-step details[open] [data-gchev] { transform: rotate(90deg); }
.guide-body { padding: 0 18px 16px 58px; }
.guide-how { margin: 0 0 12px; padding-left: 18px; }
.guide-how li { margin: 4px 0; }
.guide-next { display: flex; gap: 14px; align-items: flex-start; }
@media (max-width: 640px) {
  .guide-step summary { grid-template-columns: 28px 1fr 16px; }
  .guide-step summary .pill { display: none; }
  .guide-body { padding-left: 18px; }
}
.meter-line { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 16px; }
.meter-line i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

/* Сворачиваемые группы меню: открыта группа текущего раздела, остальные — по нажатию на заголовок */
.nav-group.nav-fold { margin-top: 4px; }
.nav .nav-title {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 8px 10px 8px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer;
  font: 650 12px/1.2 var(--font); color: var(--ink-muted); text-align: left;
}
.nav .nav-title:hover { color: #fff; background: var(--ink-2); }
.nav .nav-title span { overflow: hidden; text-overflow: ellipsis; }
.nav [data-chev] { flex: none; transition: transform .18s; opacity: .8; }
.nav-group.open [data-chev] { transform: rotate(90deg); }
.nav-group.open > .nav-title { color: #fff; }
.nav-fold > .nav-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; }
.nav-fold > .nav-items > ul { min-height: 0; overflow: hidden; }
.nav-fold.open > .nav-items { grid-template-rows: 1fr; }
.nav-fold.open > .nav-items > ul { padding-bottom: 6px; }
.app.collapsed .nav-fold > .nav-items { display: block; }
.app.collapsed .nav-fold > .nav-items > ul { overflow: visible; }
.app.collapsed .nav .nav-title { display: none; }
