/* Модуль закупок поверх дизайн-системы AppUplift 2 (app.css).
   Цвета данных — проверенная палитра (валидатор dataviz): ряды --s1..--s3, этапы пути товара — порядковая шкала --r1..--r5. */
:root {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --r1: #86b6ef; --r2: #5598e7; --r3: #2a78d6; --r4: #1c5cab; --r5: #104281;
  --surface-2: #f6f8fa;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --r1: #184f95; --r2: #256abf; --r3: #3987e5; --r4: #6da7ec; --r5: #9ec5f4;
  }
}
:root[data-theme="dark"] {
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --r1: #184f95; --r2: #256abf; --r3: #3987e5; --r4: #6da7ec; --r5: #9ec5f4;
}
html[lang="zh"] body { font-family: "Onest", "Noto Sans SC", "PingFang SC", system-ui, sans-serif; }
.small { font-size: 12px; }
.kpi .val { overflow-wrap: anywhere; }
.tbl .inline-input { width: 76px; min-height: 32px; }
#plan-table td:first-child { min-width: 150px; }
.pre { white-space: pre-line; margin: 0; overflow-wrap: anywhere; }
.err { color: var(--crit); margin: 0; }
.neg { color: var(--crit); }

/* вход и язык */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; }
.lang-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.lang-switch button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); min-height: 32px; }
.lang-switch button.on { background: var(--ink); color: var(--surface); }
nav .grp { text-transform: none; letter-spacing: 0; font-size: 12px; padding: 14px 10px 4px; }
.side-foot span:nth-child(2) { color: var(--muted); }
.toast.bad { background: var(--crit); }

/* ---------- Путь товара ---------- */
.route { padding: 18px 18px 14px; }
.rail { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 4px; background: var(--surface-2); }
.rail .seg-r { min-width: 4px; }
.stations { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: relative; }
.stations::before { content: ""; position: absolute; left: 10%; right: 10%; top: 21px; height: 2px; background: var(--line); }
.stations li { position: relative; }
.stations a { display: grid; gap: 1px; justify-items: center; text-align: center; padding: 12px 6px 6px; border-radius: 10px; color: inherit; text-decoration: none; }
.stations a:hover { background: var(--surface-2); }
.st-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--surface); position: relative; z-index: 1; margin-bottom: 8px; }
.stations .empty .st-dot { background: var(--surface); border: 2px solid var(--line); }
.st-name { font-size: 13px; color: var(--muted); }
.st-money { font-family: var(--f-display); font-weight: 600; font-size: clamp(15px, 1.9vw, 21px); letter-spacing: -.02em; line-height: 1.35; }
.stations .empty .st-money { color: var(--muted); font-weight: 400; }
.st-units { font-weight: 600; font-size: 13px; }
.st-meta { font-size: 12px; color: var(--muted); line-height: 1.35; }
.defect-note { margin: 8px 0 0; font-size: 13px; }

/* ---------- графики ---------- */
.chart-host { min-height: 120px; }
.chart .axis-l { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .mk { stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit.on { fill: var(--ink); fill-opacity: .04; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.chart.hb .hit { cursor: pointer; }
.chart.hb .track { fill: var(--surface-2); }
.chart.hb .lb { fill: var(--ink); font-size: 12px; }
.chart.hb .val { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart.hb .marker { stroke: var(--ink); stroke-width: 2; }
.legend .mk-line { width: 2px; height: 12px; background: var(--ink); }
.ctip { position: absolute; z-index: 30; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(21, 32, 43, .14); padding: 8px 10px; font-size: 12px; pointer-events: none; min-width: 150px; max-width: 280px; }
.ctip b { display: block; margin-bottom: 4px; }
.ctip div { display: flex; align-items: center; gap: 6px; }
.ctip div span { margin-left: auto; font-weight: 600; padding-left: 12px; }
.ctip i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-card .seg button { min-height: 30px; }

/* ---------- списки сроков ---------- */
.due-list { display: grid; gap: 6px; margin-top: 8px; }
.due { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-2); color: inherit; text-decoration: none; border-left: 3px solid transparent; }
a.due:hover { background: var(--line); }
.due.warn { border-left-color: var(--warn); }
.due.crit { border-left-color: var(--crit); }
.due-date { font-weight: 600; font-size: 13px; }
.due-what { display: grid; min-width: 0; }
.due-what b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-what .muted { font-size: 12px; }
.due-sum { font-weight: 700; white-space: nowrap; }

/* ---------- поток (канбан) ---------- */
.toolbar input[type=search] { min-width: 220px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(185px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x proximity; align-items: start; }
.col { min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 240px;
  scroll-snap-align: start; border-top: 4px solid var(--c); }
.col.focus { outline: 2px solid var(--c); outline-offset: 1px; }
.col header { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; }
.col header .st-dot { margin: 0; width: 10px; height: 10px; box-shadow: none; }
.col header h2 { font-size: 14px; font-weight: 600; }
.col-meta { font-size: 12px; text-align: right; color: var(--muted); line-height: 1.3; }
.col-body { display: grid; gap: 8px; padding: 0 10px 10px; align-content: start; grid-template-columns: minmax(0, 1fr); }
.col-more { min-width: 0; margin: 0; }
.col-more summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.col-more .col-body { padding: 8px 0 0; }
.fcard { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: grid; gap: 6px;
  grid-template-columns: minmax(0, 1fr); }
.fc-head { min-width: 0; }
.fc-head .small { flex: none; }
.fc-head { display: grid; gap: 0; }
.fc-head a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.fc-head a:hover { color: var(--accent); }
.fc-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.fc-items li { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.fc-items b { flex: none; }
.fc-items .clip { max-width: none; flex: 1; min-width: 0; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.fc-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.fc-foot .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- заказ ---------- */
.journey { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); position: relative; }
.journey::before { content: ""; position: absolute; left: 7px; right: 33%; top: 6px; height: 2px; background: var(--line); }
.journey li { display: grid; gap: 2px; align-content: start; position: relative; padding-right: 10px; }
.j-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); position: relative; z-index: 1; }
.journey li.done .j-dot { background: var(--r4); border-color: var(--r4); }
.j-name { font-size: 12px; color: var(--muted); margin-top: 6px; }
.j-date { font-weight: 600; }
.j-dur { font-size: 12px; color: var(--muted); }
.paybar { display: flex; gap: 3px; height: 14px; margin: 10px 0 12px; }
.pb-seg { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.pb-fill { display: block; height: 100%; background: var(--good); }
.pb-fill.crit { background: var(--crit); }
.sbar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; min-width: 120px; background: var(--surface-2); }
.sbar span { min-width: 3px; }
.sbar-l { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); margin-top: 4px; }
.sbar-l i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.meter { width: 70px; }

/* ---------- формы ---------- */
.forms { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.form { display: grid; gap: 10px; align-content: start; }
.form .field { display: grid; gap: 4px; }
.form .field label { font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea { width: 100%; min-height: 40px; }
.form input[type=checkbox] { width: auto; min-height: 0; }
.form .btn { min-height: 44px; justify-self: start; }
.form h3 { font-size: 14px; margin: 6px 0 0; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form.wide { max-width: 860px; }
.field.narrow { max-width: 260px; }
.big-in { font-size: 18px; font-weight: 600; }
.lines-ed { display: grid; gap: 6px; }
.line-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(70px, 1fr) minmax(80px, 1fr) minmax(90px, 1fr) 36px; gap: 6px; align-items: center; }
.line-row output { text-align: right; font-weight: 600; }
.sumbox { display: grid; gap: 8px; padding: 12px; border-radius: 9px; background: var(--surface-2); }
.sum-total { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sum-total b { font-family: var(--f-display); font-size: 20px; }
.sum-stages { display: grid; gap: 4px; }
.sum-stages div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
.sum-stages .muted { grid-column: 1 / -1; }
.rem { display: grid; gap: 6px; }
.rem .item, .card > .item { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-2); border: 0; grid-template-columns: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
.mono { font-family: var(--f-mono); font-size: 12px; }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checks { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }

/* диалог */
dialog.dlg { border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
  box-shadow: 0 12px 40px rgba(21, 32, 43, .25); }
dialog.dlg::backdrop { background: rgba(15, 20, 26, .45); }
dialog.dlg h2 { font-size: 16px; }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
details.card { padding: 12px 16px; }
.view > details.card + details.card { margin-top: -8px; }
details.card > summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--ink); }
details.card[open] > summary { margin-bottom: 10px; }
details.card > .card { border: 0; padding: 0; }
.sum-right { margin-left: auto; font-weight: 600; }

/* план, отчёты, настройки */
.plan-box.order_now { box-shadow: inset 3px 0 0 var(--crit); }
.plan-box.soon { box-shadow: inset 3px 0 0 var(--warn); }
.dl-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-top: 8px; }
.dl { display: grid; gap: 4px; justify-items: start; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; }
.dl:hover { border-color: var(--accent); }
.outbox { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.msg { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--surface-2); display: grid; gap: 6px; }
.msg p { font-size: 13px; }
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state p { color: var(--muted); max-width: 560px; margin: 8px auto 14px; }

@media (max-width: 820px) {
  .tbl { font-size: 12px; }
  .tbl .hide-m { display: none; }
  .tbl td:first-child { min-width: 110px; }
  .clip { max-width: 180px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; }
  .stations { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .stations::before { left: 22px; right: auto; top: 18px; bottom: 18px; width: 2px; height: auto; }
  .stations a { grid-template-columns: 30px minmax(0, 1fr) auto; justify-items: start; text-align: left; align-items: center; padding: 8px 6px; gap: 0 8px; }
  .st-dot { grid-row: span 3; margin: 0 0 0 1px; justify-self: center; }
  .st-name { grid-column: 2; font-size: 13px; color: var(--ink); font-weight: 600; }
  .st-money { grid-column: 3; grid-row: 1 / span 2; justify-self: end; font-size: 16px; }
  .st-units { grid-column: 2; font-weight: 400; color: var(--muted); }
  .st-meta { grid-column: 2 / -1; }
  .board { grid-auto-columns: 84%; }
  .due { grid-template-columns: 82px minmax(0, 1fr); }
  .due-sum { grid-column: 2; }
  .line-row { grid-template-columns: 1fr 1fr 36px; }
  .line-row input[name=l_name] { grid-column: 1 / -1; }
  .line-row output { grid-column: 1 / 3; text-align: left; }
  .journey { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .journey::before { display: none; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .side, .top .lang-switch, #menu-btn, .seg, .btn { display: none !important; } #app { display: block; } }
