/* SNG Cargo CRM — «маршрут груза»: воронка нарисована как линия со станциями, остальное — спокойная рабочая поверхность */
:root {
  --ground: #e9edf1;        /* бетон склада */
  --surface: #ffffff;
  --sunk: #f4f6f8;
  --ink: #15212c;
  --ink-2: #4d5b68;
  --ink-3: #7d8a96;
  --rule: #d8dee4;
  --blue: #0f4c75;          /* контейнер */
  --blue-2: #e3edf5;
  --amber: #e5a100;         /* сигнальный */
  --amber-2: #fdf3d8;
  --red: #c8341e;
  --red-2: #fbe7e3;
  --green: #1e8a5a;
  --green-2: #e1f3ea;
  --bubble-in: #ffffff;
  --bubble-bot: #e8eef4;
  --bubble-mgr: #d9efe3;
  --lift: 0 1px 0 rgba(21, 33, 44, .06), 0 1px 3px rgba(21, 33, 44, .08);
  --ui: "Golos Text", system-ui, "Segoe UI", sans-serif;
  --disp: "Unbounded", "Golos Text", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f161d; --surface: #17212b; --sunk: #1d2934; --ink: #e7edf2; --ink-2: #aab6c1; --ink-3: #7c8994;
    --rule: #2a3744; --blue: #5aa7db; --blue-2: #1b3346; --amber: #f2b829; --amber-2: #3a2f10;
    --red: #ff7a64; --red-2: #3d1f1a; --green: #4fcf92; --green-2: #15342a;
    --bubble-in: #1d2934; --bubble-bot: #22313f; --bubble-mgr: #1b3a2d; --lift: 0 1px 0 rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.45 var(--ui); display: flex; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- левая колонка ---------- */
.rail { width: 76px; background: var(--blue); color: #cfe0ee; display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 4px; flex: none; position: sticky; top: 0; height: 100vh; }
@media (prefers-color-scheme: dark) { .rail { background: #0b2233; } }
.mark { font: 700 13px var(--disp); color: #fff; letter-spacing: .02em; padding: 8px 0 14px; }
.rail button { width: 64px; border: 0; background: none; color: inherit; border-radius: 12px; padding: 8px 0 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; position: relative; }
.rail button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail button.on { background: rgba(255, 255, 255, .16); color: #fff; }
.badge:not(:empty) { position: absolute; top: 2px; right: 8px; background: var(--amber); color: #1d1600; border-radius: 9px;
  font: 700 11px/18px var(--ui); min-width: 18px; padding: 0 5px; }
.rail-end { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.me { width: 36px; height: 36px; border-radius: 50%; background: #fff; color: var(--blue); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; }

/* ---------- верхняя панель ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.bar { display: flex; align-items: center; gap: 14px; padding: 14px 24px 10px; flex-wrap: wrap; }
.bar h1 { font: 700 20px var(--disp); margin: 0 8px 0 0; letter-spacing: -.01em; }
.search { flex: 1; max-width: 420px; min-width: 180px; display: flex; align-items: center; gap: 8px; background: var(--surface);
  border-radius: 10px; padding: 0 10px; box-shadow: var(--lift); color: var(--ink-3); }
.search input { border: 0; background: none; padding: 9px 0; flex: 1; min-width: 0; outline: none; color: var(--ink); }
.search:focus-within { outline: 2px solid var(--blue); }
kbd { font: 12px var(--ui); border: 1px solid var(--rule); border-radius: 5px; padding: 0 6px; color: var(--ink-3); }
.seg { display: flex; background: var(--sunk); border-radius: 10px; padding: 3px; box-shadow: inset 0 0 0 1px var(--rule); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--lift); }
.sync { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.notice:not(:empty) { margin: 0 24px 8px; padding: 10px 14px; border-radius: 10px; background: var(--red-2); color: var(--red); }

#view { flex: 1; min-height: 0; overflow: auto; }

/* ---------- воронка: маршрут + колонки ---------- */
.board { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0 12px; padding: 4px 24px 24px;
  width: max(100%, calc(var(--n) * 206px + 48px)); min-height: 100%; align-content: start; grid-template-rows: auto 1fr; }
.stop { position: relative; padding: 0 2px 14px; cursor: default; }
.stop::before { content: ""; position: absolute; left: 0; right: -12px; top: 9px; height: 3px; background: var(--rule); }
.stop:last-child::before, .stop.lost::before { right: 0; }
.stop .dot { position: relative; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--rule); }
.stop.has .dot { border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 4px var(--blue-2); }
.stop.has::before { background: linear-gradient(90deg, var(--blue), var(--rule)); }
.stop.won.has .dot { border-color: var(--green); background: var(--green); box-shadow: 0 0 0 4px var(--green-2); }
.stop.lost .dot { border-style: dashed; }
.stop.lost.has .dot { background: var(--surface); border-color: var(--ink-3); box-shadow: none; }
.stop.hot .dot { border-color: var(--amber); background: var(--amber); box-shadow: 0 0 0 4px var(--amber-2); }
.stop h2 { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.stop .n { font: 700 22px/1.1 var(--disp); color: var(--ink); margin-top: 2px; display: flex; align-items: baseline; gap: 8px; }
.stop .sum { font: 500 13px var(--ui); color: var(--green); }
.lane { display: flex; flex-direction: column; gap: 8px; min-height: 120px; border-radius: 12px; padding: 4px; margin: 0 -4px;
  transition: background .12s; }
.lane.drop { background: var(--blue-2); outline: 2px dashed var(--blue); outline-offset: -2px; }
.lane .empty { color: var(--ink-3); font-size: 13px; padding: 14px 6px; }

.card { position: relative; background: var(--surface); border-radius: 10px; padding: 10px 12px 10px 14px; box-shadow: var(--lift);
  cursor: pointer; display: grid; grid-template-columns: 32px 1fr; gap: 2px 10px; overflow: hidden; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.card.high::before { background: var(--red); }
.card.mid::before { background: var(--amber); }
.card:hover { box-shadow: 0 0 0 1px var(--rule), var(--lift); }
.card.sel { box-shadow: 0 0 0 2px var(--blue); }
.card .avatar { grid-row: span 2; }
.card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .ago { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.card .last { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .last i { font-style: normal; color: var(--ink-3); }
.card .foot { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.card .alert { grid-column: 1 / -1; font-size: 12px; font-weight: 500; margin-top: 4px; }
.card.high .alert { color: var(--red); }
.card.mid .alert { color: #9a6c00; }
@media (prefers-color-scheme: dark) { .card.mid .alert { color: var(--amber); } }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; background: hsl(var(--h, 205) 45% 42%); }
.avatar.big { width: 44px; height: 44px; font-size: 16px; }
.chip { font-size: 12px; border-radius: 6px; padding: 1px 7px; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.chip.money { background: var(--green-2); color: var(--green); font-weight: 600; }
.chip.bot { background: var(--blue-2); color: var(--blue); }
.chip.who { margin-left: auto; }

/* ---------- списки ---------- */
.sheet { padding: 4px 24px 32px; max-width: 1180px; }
.group { margin-bottom: 24px; }
.group h2 { font-size: 15px; margin: 6px 0 10px; display: flex; gap: 8px; align-items: center; }
.group h2 .n { font: 700 13px var(--disp); background: var(--surface); border-radius: 8px; padding: 2px 8px; box-shadow: var(--lift); }
.rows { background: var(--surface); border-radius: 12px; box-shadow: var(--lift); overflow: hidden; }
.r { display: grid; grid-template-columns: 32px minmax(150px, 1.2fr) minmax(120px, .8fr) 2fr 90px 70px; gap: 12px;
  align-items: center; padding: 10px 16px; border-top: 1px solid var(--rule); cursor: pointer; position: relative; }
.r:first-child { border-top: 0; }
.r:hover { background: var(--sunk); }
.r.high { box-shadow: inset 4px 0 0 var(--red); }
.r.mid { box-shadow: inset 4px 0 0 var(--amber); }
.r .who b { display: block; }
.r .who small, .r .when { color: var(--ink-3); font-size: 12px; }
.r .what { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r .what.alert { color: var(--red); font-weight: 500; white-space: normal; }
.r .money { font-weight: 600; color: var(--green); text-align: right; }
.r .when { text-align: right; }
.done { text-align: center; padding: 56px 16px; color: var(--ink-2); }
.done b { display: block; font: 700 18px var(--disp); color: var(--ink); margin-bottom: 6px; }

/* ---------- карточка клиента ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 20, 30, .28); z-index: 9; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1040px, calc(100vw - 76px)); background: var(--surface);
  z-index: 10; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(10, 20, 30, .18);
  animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.d-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.d-id { min-width: 0; flex: 1; }
.d-id h2 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-sub { display: flex; gap: 10px; align-items: center; color: var(--ink-3); font-size: 13px; flex-wrap: wrap; }
.mode { display: inline-flex; align-items: center; gap: 5px; }
.mode::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.mode.mgr::before { background: var(--amber); }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 6px; border-radius: 8px; }
.icon:hover { background: var(--sunk); color: var(--ink); }
.d-tabs { display: none; }
.d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 320px; }
.d-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--ground); }
.d-flags:not(:empty) { padding: 10px 18px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: 12px; font-weight: 500; border-radius: 8px; padding: 4px 10px; }
.flag.high { background: var(--red-2); color: var(--red); }
.flag.mid { background: var(--amber-2); color: #8a6000; }
@media (prefers-color-scheme: dark) { .flag.mid { color: var(--amber); } }
.log { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 12px; color: var(--ink-2); background: var(--surface); border-radius: 8px; padding: 2px 10px;
  margin: 10px 0 6px; box-shadow: var(--lift); }
.msg { max-width: min(78%, 620px); padding: 7px 11px 6px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: var(--lift); }
.msg + .msg.same { margin-top: -1px; }
.msg .meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; text-align: right; }
.msg .by { font-size: 12px; font-weight: 600; margin-bottom: 1px; }
.msg.client { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--bubble-bot); border-top-right-radius: 4px; }
.msg.bot .by { color: var(--blue); }
.msg.manager { align-self: flex-end; background: var(--bubble-mgr); border-top-right-radius: 4px; }
.msg.manager .by { color: var(--green); }
.msg .sys { color: var(--ink-3); font-size: 12px; display: block; margin-bottom: 2px; }
.msg.fresh { animation: pop .25s ease-out; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.composer { padding: 8px 14px 12px; background: var(--ground); }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.quick button { border: 1px solid var(--rule); background: var(--surface); border-radius: 16px; padding: 4px 12px; cursor: pointer;
  white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.quick button:hover { border-color: var(--blue); color: var(--blue); }
.compose-row { display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border-radius: 14px; padding: 6px 6px 6px 14px;
  box-shadow: var(--lift); }
.compose-row:focus-within { outline: 2px solid var(--blue); }
.compose-row textarea { flex: 1; border: 0; background: none; resize: none; outline: none; padding: 7px 0; max-height: 180px; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; cursor: pointer; display: grid; place-items: center; }
.send:disabled { background: var(--rule); color: var(--ink-3); cursor: not-allowed; }
.window { font-size: 12px; color: var(--ink-3); padding: 6px 4px 0; }
.window.closed { color: var(--red); }

.d-deal { overflow-y: auto; padding: 6px 18px 28px; border-left: 1px solid var(--rule); }
.d-deal h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }
.route-v { list-style: none; margin: 0; padding: 0; }
.route-v li { position: relative; padding: 0 0 0 26px; }
.route-v li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -6px; width: 2px; background: var(--rule); }
.route-v li:last-child::before { display: none; }
.route-v button { border: 0; background: none; width: 100%; text-align: left; padding: 5px 8px; border-radius: 8px; cursor: pointer;
  color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.route-v button:hover { background: var(--sunk); color: var(--ink); }
.route-v li > i { position: absolute; left: 0; top: 8px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--rule);
  background: var(--surface); }
.route-v li.past > i { background: var(--blue); border-color: var(--blue); }
.route-v li.past::before { background: var(--blue); }
.route-v li.cur > i { background: var(--surface); border: 5px solid var(--blue); }
.route-v li.cur button { color: var(--ink); font-weight: 600; background: var(--blue-2); }
.route-v li.cur.won > i { border-color: var(--green); }
.route-v li.cur.won button { background: var(--green-2); }
.route-v li.cur.lost > i { border-color: var(--ink-3); }
.route-v small { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.auto { font-size: 12px; color: var(--ink-3); margin: 6px 0 0 26px; }
.auto button { border: 0; background: none; color: var(--blue); padding: 0; cursor: pointer; font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.field span { font-size: 12px; color: var(--ink-3); }
.field input, .field select, .note-add textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); }
.field input:focus, .field select:focus, .note-add textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.pair { display: grid; grid-template-columns: 1fr; gap: 0; }
.note-add { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { font-size: 13px; white-space: pre-wrap; border-left: 2px solid var(--rule); padding: 0 0 0 10px; }
.timeline li small { display: block; color: var(--ink-3); font-size: 12px; }
.timeline li.none { border: 0; padding: 0; color: var(--ink-3); }

.btn { border: 1px solid var(--rule); background: var(--surface); padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500;
  display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.danger-ghost { color: var(--red); border-color: var(--red-2); }
.btn.danger-ghost:hover { background: var(--red-2); border-color: var(--red); }
.hint-text { font-size: 13px; color: var(--ink-3); margin: 0 0 8px; }
dialog p { color: var(--ink-2); margin: 0 0 6px; }
.btn:disabled { opacity: .5; cursor: default; }

dialog { border: 0; border-radius: 16px; padding: 22px; background: var(--surface); color: var(--ink); width: min(420px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 20, 30, .35); }
dialog h3 { margin: 0 0 14px; font-size: 17px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reasons label { cursor: pointer; }
.reasons input { position: absolute; opacity: 0; }
.reasons span { display: inline-block; border: 1px solid var(--rule); border-radius: 18px; padding: 6px 14px; }
.reasons input:checked + span { border-color: var(--red); background: var(--red-2); color: var(--red); font-weight: 600; }
.reasons input:focus-visible + span { outline: 2px solid var(--blue); }
.dlg-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 18px; border-radius: 10px; z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }

/* ---------- вход ---------- */
.login-body { display: grid; place-items: center; background: var(--blue); min-height: 100vh; }
.login { background: var(--surface); padding: 32px 28px; border-radius: 18px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.login .brand { font: 700 20px var(--disp); margin-bottom: 4px; }
.login .brand small { display: block; font: 400 13px var(--ui); color: var(--ink-3); margin-top: 6px; }
.login label { display: flex; flex-direction: column; gap: 5px; color: var(--ink-2); font-size: 13px; }
.login input { padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }
.login .btn { justify-content: center; padding: 10px; }
.err { color: var(--red); min-height: 1.2em; margin: 0; font-size: 13px; }

/* ---------- заказы: журнал отправок ---------- */
.grow { flex: 1; }
.ledger { padding: 4px 24px 32px; min-height: 100%; border-radius: 14px; }
.ledger.drop { outline: 2px dashed var(--blue); outline-offset: -8px; background: var(--blue-2); }
.ledger-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.month { display: flex; align-items: center; gap: 2px; background: var(--surface); border-radius: 10px; box-shadow: var(--lift); padding: 2px; }
.month b { font: 700 15px var(--disp); min-width: 150px; text-align: center; letter-spacing: -.01em; }
.month .icon { font-size: 18px; line-height: 1; padding: 4px 10px; }
.gs { font-size: 12px; }
.gs.ok { color: var(--green); }
.gs.ok::before { content: "● "; }
.gs.off { color: var(--ink-3); }
.gs.warn { border: 0; background: var(--amber-2); color: #8a6000; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .gs.warn { color: var(--amber); } }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.fig { background: var(--surface); border-radius: 12px; box-shadow: var(--lift); padding: 12px 16px; display: flex; flex-direction: column; }
.fig span { font-size: 12px; color: var(--ink-3); }
.fig b { font: 700 22px/1.25 var(--disp); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.fig small { color: var(--ink-3); font-size: 12px; }
.fig.pos b { color: var(--green); }
.fig.neg b, .fig.warn b { color: var(--red); }
.fig.warn b { color: #9a6c00; }
@media (prefers-color-scheme: dark) { .fig.warn b { color: var(--amber); } }

.tbl { background: var(--surface); border-radius: 12px; box-shadow: var(--lift); overflow: auto; max-width: 100%; }
.ledger-t { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.ledger-t th { position: sticky; top: 0; background: var(--sunk); color: var(--ink-2); font-weight: 600; font-size: 12px; text-align: left;
  padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--rule); z-index: 1; }
.ledger-t td { padding: 7px 10px; border-top: 1px solid var(--rule); vertical-align: top; }
.ledger-t tbody tr:first-child td { border-top: 0; }
.ledger-t .n { text-align: right; white-space: nowrap; }
.ledger-t td small { display: block; color: var(--ink-3); font-size: 11px; }
.ledger-t .who b { font-weight: 600; }
.ledger-t .tk { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.ledger-t .gd { min-width: 140px; max-width: 260px; }
.ledger-t .d { white-space: nowrap; color: var(--ink-2); }
.ledger-t .dim, .dim { color: var(--ink-3); }
.ledger-t .pos { color: var(--green); font-weight: 600; }
.ledger-t .neg { color: var(--red); font-weight: 600; }
.ledger-t tbody tr[data-oid], .ledger-t tr.link-row { cursor: pointer; }
.ledger-t tbody tr[data-oid]:hover, .ledger-t tr.link-row:hover { background: var(--sunk); }
.ledger-t tfoot td { border-top: 2px solid var(--rule); font-weight: 700; background: var(--sunk); }
.ledger-t.compact td, .ledger-t.compact th { padding: 6px 10px; }
.warn-dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--amber); color: #1d1600;
  font-weight: 700; font-size: 12px; cursor: help; }
.pill { display: inline-block; font-size: 12px; border-radius: 6px; padding: 1px 8px; white-space: nowrap; background: var(--sunk); color: var(--ink-2); }
.pill.in_transit { background: var(--blue-2); color: var(--blue); }
.pill.arrived { background: var(--amber-2); color: #8a6000; }
.pill.issued { background: var(--green-2); color: var(--green); }
@media (prefers-color-scheme: dark) { .pill.arrived { color: var(--amber); } }

/* карточка заказа */
dialog.wide { width: min(860px, 94vw); }
dialog.huge { width: min(1240px, 96vw); }
.o-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.o-grid fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; align-content: start; }
.o-grid fieldset:first-child { grid-row: span 2; }
.o-grid legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; margin: 8px 0 0; }
.o-grid .field { margin-top: 8px; }
.o-grid .wide2 { grid-column: 1 / -1; }
.o-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; background: var(--sunk); border-radius: 12px; padding: 12px 14px; }
.o-sum span { display: block; font-size: 12px; color: var(--ink-3); }
.o-sum b { font: 700 17px var(--disp); font-variant-numeric: tabular-nums; }
.o-sum small { display: block; font-size: 11px; color: var(--ink-3); }
.o-sum .pos b { color: var(--green); }
.o-sum .neg b { color: var(--red); }

/* загрузка накладной */
.imp-body { max-height: 62vh; overflow: auto; margin-top: 10px; }
.imp-body .tbl { box-shadow: 0 0 0 1px var(--rule); }
.ledger-t.imp input { width: 100%; min-width: 70px; padding: 4px 6px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); font-size: 13px; }
.ledger-t.imp td.n input { width: 76px; text-align: right; }
.ledger-t.imp td.gd input { min-width: 170px; }
.ledger-t.imp tr.warns td { border-top: 0; padding-top: 0; }
.ledger-t.imp tr.warns span { display: inline-block; background: var(--amber-2); color: #8a6000; border-radius: 6px; padding: 1px 8px; margin: 0 6px 4px 0; font-size: 12px; }
@media (prefers-color-scheme: dark) { .ledger-t.imp tr.warns span { color: var(--amber); } }
.ledger-t.imp tr.skip td { color: var(--ink-3); }
.act { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.act.new { background: var(--green-2); color: var(--green); }
.act.attach, .act.upd { background: var(--blue-2); color: var(--blue); }
.act.same, .act.skip { background: var(--sunk); color: var(--ink-3); }
.imp-note { font-size: 13px; color: var(--ink-2); align-self: center; }
.link { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; font-size: 13px; }
.link.danger { color: var(--red); margin-left: 8px; }
h3.with-act { display: flex; justify-content: space-between; align-items: baseline; }
.orders-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.orders-mini li { display: grid; grid-template-columns: auto 1fr auto; gap: 0 8px; align-items: baseline; font-size: 13px; padding: 6px 8px;
  border-radius: 8px; background: var(--sunk); cursor: pointer; }
.orders-mini li:hover { box-shadow: 0 0 0 1px var(--rule); }
.orders-mini li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.orders-mini li small { grid-column: 2 / -1; color: var(--ink-3); font-size: 12px; }
.orders-mini li .m { font-weight: 600; font-variant-numeric: tabular-nums; }
.orders-mini li.none { background: none; padding: 0; color: var(--ink-3); cursor: default; display: block; }

/* выбор строк и «груз прибыл» */
.ledger-t .cb { width: 30px; padding-right: 0; }
.ledger-t .cb input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue); }
.ledger-t tr.picked td { background: var(--blue-2); }
.selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface); border-radius: 12px;
  box-shadow: 0 0 0 2px var(--blue), var(--lift); padding: 8px 12px; margin-bottom: 10px; position: sticky; top: 0; z-index: 3; }
.btn.notify { background: var(--amber); border-color: var(--amber); color: #1d1600; font-weight: 600; }
.btn.notify:hover { filter: brightness(.96); }
.nt { display: block; font-size: 11px; margin-top: 3px; color: var(--ink-3); white-space: nowrap; cursor: help; }
.nt.delivered, .nt.read { color: var(--green); }
.nt.failed { color: var(--red); font-weight: 600; }
.ntf-body { max-height: 62vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.ntf { border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; }
.ntf.on { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.ntf.blocked { background: var(--sunk); }
.ntf header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ntf .tgts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tgt { font-size: 12px; border-radius: 6px; padding: 2px 8px; white-space: nowrap; cursor: help; }
.tgt.txt { background: var(--green-2); color: var(--green); }
.tgt.tpl { background: var(--blue-2); color: var(--blue); }
.tgt.no { background: var(--red-2); color: var(--red); }
.ntf .why { margin: 8px 0 0; padding-left: 18px; color: var(--red); font-size: 13px; }
.ntf .bind { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ntf .bind input { padding: 6px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); min-width: 200px; }
.ntf .manual { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.ntf .manual .grow { flex: 1; }
.ntf .manual a.btn { text-decoration: none; }
.nt.manual { color: var(--ink-2); }
.msg-preview { margin: 8px 0 0; white-space: pre-wrap; font: 13px/1.45 var(--ui); background: var(--bubble-bot); border-radius: 10px;
  padding: 8px 12px; color: var(--ink); }
.ntf.blocked .msg-preview { opacity: .6; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14px; cursor: pointer; flex-wrap: wrap; }
.check.inline { margin: 0; align-items: center; }
.check input { margin-top: 3px; accent-color: var(--blue); }
.check small { flex-basis: 100%; padding-left: 24px; color: var(--ink-3); font-size: 12px; }
.o-grid.two-col { grid-template-columns: 1fr 1fr; }
.field.narrow { max-width: 280px; }
.field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); resize: vertical; }
h3.sub { margin-top: 22px; font-size: 15px; }
.code-hint .hint { font-size: 12px; color: var(--ink-2); background: var(--sunk); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.code-hint .hint.warn { background: var(--amber-2); }
.code-hint .link { font-size: 12px; font-weight: 600; }

/* аналитика */
.stats { max-width: 1240px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border-radius: 14px; box-shadow: var(--lift); padding: 16px 18px; min-width: 0; }
.panel h2 { font-size: 15px; margin: 0 0 8px; }
.panel .tbl { box-shadow: none; border: 1px solid var(--rule); }
.two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.legend { font-size: 12px; color: var(--ink-3); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.legend i, .legend b { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--blue-2); box-shadow: inset 0 0 0 1px var(--blue); }
.legend b { background: var(--green); box-shadow: none; margin-left: 8px; }
.bars { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; height: 220px; align-items: end; }
.mbar { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.mbar .col { flex: 1; position: relative; }
.mbar .col i, .mbar .col b { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px 4px 0 0; }
.mbar .col i { background: var(--blue-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 35%, transparent); }
.mbar .col b { background: var(--green); left: 22%; right: 22%; }
.mbar:hover .col i { background: color-mix(in srgb, var(--blue) 30%, var(--blue-2)); }
.mbar span { font-size: 11px; color: var(--ink-3); text-align: center; margin-top: 4px; white-space: nowrap; }
.mbar span em { display: block; font-style: normal; color: var(--ink-2); font-weight: 600; }
.share { min-width: 120px; white-space: nowrap; font-size: 12px; color: var(--ink-2); }
.share i { display: inline-block; height: 8px; border-radius: 4px; background: var(--green); margin-right: 6px; vertical-align: middle; max-width: 70%; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  .rail { width: 100%; height: 60px; flex-direction: row; justify-content: space-around; position: sticky; bottom: 0; top: auto; padding: 0 6px; z-index: 8; }
  .mark, .rail-end .me { display: none; }
  .rail-end { margin: 0; flex-direction: row; }
  .main { height: calc(100vh - 60px); }
  .bar { padding: 12px 16px 8px; gap: 10px; }
  .bar h1 { font-size: 17px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  kbd, .sync { display: none; }
  .board { padding: 4px 16px 16px; grid-template-columns: repeat(var(--n), 78vw); width: max-content; }
  #view { scroll-snap-type: x proximity; }
  .stop, .lane { scroll-snap-align: start; }
  .sheet { padding: 4px 16px 24px; }
  .r { grid-template-columns: 32px 1fr auto; }
  .r .stage, .r .what:not(.alert) { display: none; }
  .r .what.alert { grid-column: 2 / -1; }
  .r .when { display: none; }
  .drawer { width: 100vw; }
  .d-head { padding: 10px 12px; flex-wrap: wrap; }
  .d-actions { order: 4; width: 100%; }
  .d-tabs { display: flex; border-bottom: 1px solid var(--rule); }
  .d-tabs button { flex: 1; border: 0; background: none; padding: 10px; cursor: pointer; color: var(--ink-3); font-weight: 500;
    border-bottom: 2px solid transparent; }
  .d-tabs button.on { color: var(--blue); border-color: var(--blue); }
  .d-body { grid-template-columns: 1fr; }
  .d-body[data-pane="chat"] .d-deal, .d-body[data-pane="deal"] .d-chat { display: none; }
  .d-deal { border: 0; }
  .msg { max-width: 88%; }
  .rail button { width: 52px; font-size: 10px; }
  .ledger { padding: 4px 12px 24px; }
  .month b { min-width: 120px; font-size: 14px; }
  .o-grid, .two { grid-template-columns: 1fr; }
  .o-sum { grid-template-columns: repeat(2, 1fr); }
  .bars { height: 160px; gap: 3px; }
}

/* ---------- роли: недоступное прячется (права проверяет сервер, это только интерфейс) ---------- */
body:not(.can-work) .need-work, body:not(.can-admin) .need-admin, body:not(.can-finance) .need-finance,
body:not(.can-finance) .fin { display: none !important; }
.only-viewer { display: none; }
body[data-role="viewer"] .only-viewer { display: block; }
.readonly-note { margin: 10px 14px; padding: 8px 12px; border-radius: 10px; background: var(--sunk); color: var(--ink-2); font-size: 13px; }
button.me { border: 0; cursor: pointer; font: inherit; }
.users-t td .pill.role-admin { background: var(--blue-2); color: var(--blue); }
.users-t td .pill.role-manager { background: var(--green-2); color: var(--green); }
.users-t td .pill.role-viewer { background: var(--sunk); color: var(--ink-2); }
.users-t tr.off td { color: var(--ink-3); }
.users-t tr { cursor: pointer; }
.roles-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.roles-help div { border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.roles-help b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- двухфакторный вход ---------- */
.twofa { display: grid; gap: 8px; margin-bottom: 6px; }
.twofa .qr { width: 220px; height: 220px; border: 1px solid var(--rule); border-radius: 12px; background: #fff; }
.twofa .secret { font-size: 13px; letter-spacing: .04em; user-select: all; }
.twofa .codes { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--sunk); font-size: 15px; line-height: 1.7; columns: 2; }
.twofa details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.ok-text { margin: 0; color: var(--green); font-weight: 600; font-size: 14px; }
.twofa-admin { display: grid; gap: 6px; margin: 4px 0 8px; }
.login-hint { margin: 0 0 4px; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
