/*
  ProSeller — приватный контур.

  Направление: диспетчерская. Это инструмент, в который смотрят каждый день,
  чтобы ответить на вопрос «почему на маркетплейсе ноль». Отсюда всё остальное:
  плотность вместо воздуха, моноширинные цифры с табличными знакоместами,
  холодный почти-чёрный фон и ровно один сигнальный цвет — янтарный. Янтарным
  подсвечивается только то место, где алгоритм вмешался в число. Если строка
  не горит янтарным, значит остаток уехал как есть.
*/

:root {
  --bg: #0b0d10;
  --bg-deep: #070809;
  --panel: #12151a;
  --panel-2: #171b21;
  --raise: #1c2129;
  --line: #232a33;
  --line-soft: #1a1f26;

  --text: #dde3ea;
  --text-2: #a8b2be;
  --dim: #6c7684;
  --faint: #454e5a;

  --signal: #f2a33c;
  --signal-dim: #7a5320;
  --ok: #4fb477;
  --danger: #e05260;
  --cyan: #56b6e0;

  --ozon: #4f8cff;
  --yandex: #ffcc00;

  --radius: 8px;
  --rail-w: 292px;

  --ui: 'Golos Text', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Едва заметное зерно: убирает «пластиковость» больших тёмных плоскостей. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input {
  font: inherit;
  color: inherit;
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: 100vh;
}

/* ───────────────────────────── Боковая колонка ───────────────────────────── */

.rail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 17px 18px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.mark {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  background: linear-gradient(150deg, var(--signal), #b9701c);
  box-shadow: 0 0 0 3px rgb(242 163 60 / 8%);
}

.brand__name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__env {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
}

.rail__search {
  padding: 12px 14px;
}

.rail__search input,
.table-tools input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.rail__search input::placeholder,
.table-tools input::placeholder {
  color: var(--faint);
}

.rail__search input:focus,
.table-tools input:focus {
  border-color: var(--faint);
}

.rail__nodes {
  overflow-y: auto;
  padding: 0 10px 12px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.group {
  margin-top: 10px;
}

.group__label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 8px 6px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
}

.group__label i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.group--ozon .group__label i {
  color: var(--ozon);
}

.group--yandex .group__label i {
  color: var(--yandex);
}

.node {
  --spine: var(--faint);
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 10px 8px 0;
  cursor: pointer;
  transition:
    background 0.14s,
    border-color 0.14s;
}

.node::before {
  content: '';
  height: 26px;
  border-radius: 0 2px 2px 0;
  background: var(--spine);
  opacity: 0.55;
  transition: opacity 0.14s;
}

.group--ozon .node {
  --spine: var(--ozon);
}

.group--yandex .node {
  --spine: var(--yandex);
}

.node:hover {
  background: var(--panel);
}

.node.is-active {
  background: var(--panel-2);
  border-color: var(--line);
}

.node.is-active::before {
  opacity: 1;
}

.node.is-off {
  opacity: 0.42;
}

.node__name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node__meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.node.is-off .node__dot {
  background: var(--faint);
}

.rail__foot {
  border-top: 1px solid var(--line-soft);
  padding: 13px 14px 15px;
}

.quota__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--dim);
}

.quota__value {
  font-family: var(--mono);
  color: var(--text-2);
}

.quota__bar {
  margin-top: 7px;
  height: 3px;
  border-radius: 2px;
  background: var(--raise);
  overflow: hidden;
}

.quota__bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #7fd39a);
  transition: width 0.4s ease;
}

.quota__note {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--faint);
}

/* ──────────────────────────────── Основное ──────────────────────────────── */

.main {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px 15px;
  border-bottom: 1px solid var(--line);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
}

.chip--accent {
  color: var(--signal);
  border-color: var(--signal-dim);
  background: rgb(242 163 60 / 7%);
}

.head__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  transition:
    background 0.14s,
    border-color 0.14s,
    transform 0.08s;
}

.btn:hover:not(:disabled) {
  background: var(--raise);
  border-color: var(--faint);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--signal);
  border-color: var(--signal);
  color: #17120a;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
  background: #ffb559;
  border-color: #ffb559;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Показатели */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  background: var(--bg);
  padding: 13px 24px 14px;
}

.metric__label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dim);
}

.metric__value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.metric__hint {
  font-size: 11px;
  color: var(--faint);
  margin-top: 1px;
}

.metric--signal .metric__value {
  color: var(--signal);
}

.metric--muted .metric__value {
  color: var(--dim);
}

/* Полоса состояния */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  font-size: 12.5px;
  background: rgb(242 163 60 / 7%);
  border-bottom: 1px solid var(--signal-dim);
  color: #f0cb96;
}

.banner b {
  color: var(--signal);
  font-weight: 600;
}

/* ──────────────────────────────── Таблица ──────────────────────────────── */

.table-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  border-bottom: 1px solid var(--line);
}

.table-tools input {
  max-width: 320px;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  background: var(--panel);
  border: none;
  border-right: 1px solid var(--line);
  padding: 7px 11px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.14s;
}

.segmented button:last-child {
  border-right: none;
}

.segmented button:hover {
  background: var(--raise);
}

.segmented button.is-active {
  background: var(--raise);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--signal);
}

.table-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.table-scroll {
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.grid tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  /* 3429 строк рендерятся без виртуализации: браузер пропускает отрисовку
     того, что за экраном, а высота задана заранее — прокрутка не дёргается. */
  content-visibility: auto;
  contain-intrinsic-size: auto 37px;
}

.grid tbody tr:hover {
  background: var(--panel);
}

.grid tbody tr.is-picked {
  background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--signal);
}

.grid td {
  padding: 8px 14px;
  vertical-align: middle;
}

.c-art {
  width: 130px;
}

.c-src {
  width: 110px;
}

.c-path {
  width: 300px;
}

.c-out {
  width: 108px;
}

.art {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 120px;
}

.name {
  color: var(--text-2);
  display: block;
  max-width: 46ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name--empty {
  color: var(--faint);
  font-style: italic;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.src {
  color: var(--text-2);
}

/* Путь числа — то, ради чего эта таблица существует. */

.path {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.step {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}

.step--cut {
  color: var(--signal);
  border-color: var(--signal-dim);
  background: rgb(242 163 60 / 8%);
}

.step--stop {
  color: var(--danger);
  border-color: #5c2429;
  background: rgb(224 82 96 / 8%);
}

.arrow {
  color: var(--faint);
  font-size: 11px;
}

.path--clean {
  color: var(--faint);
  font-size: 12px;
}

.out {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.out--same {
  color: var(--text);
}

.out--cut {
  color: var(--signal);
}

.out--zero {
  color: var(--faint);
}

.out--skip {
  color: var(--dim);
  font-size: 12px;
  font-weight: 400;
}

.table-end {
  padding: 18px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

/* ───────────────────────── Панель разбора строки ───────────────────────── */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px rgb(0 0 0 / 45%);
  padding: 22px 24px;
  overflow-y: auto;
  z-index: 40;
  animation: slide-in 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes slide-in {
  from {
    transform: translateX(18px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drawer {
    animation: none;
  }
}

.drawer__close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
}

.drawer__close:hover {
  color: var(--text);
}

.drawer h2 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 600;
  padding-right: 30px;
}

.drawer .sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  margin-bottom: 18px;
}

.dsection {
  margin-top: 20px;
}

.dsection h3 {
  margin: 0 0 9px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 500;
}

.stores {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.store {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  padding: 7px 11px;
  font-size: 12.5px;
}

.store span {
  color: var(--text-2);
}

.store b {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.store--sum {
  background: var(--raise);
}

.ladder {
  display: grid;
  gap: 0;
  border-left: 2px solid var(--line);
  padding-left: 0;
}

.rung {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0 9px 12px;
  position: relative;
}

.rung::before {
  content: '';
  position: absolute;
  left: -6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--line);
}

.rung--acted::before {
  border-color: var(--signal);
  background: var(--signal);
}

.rung__no {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}

.rung__text {
  font-size: 12.5px;
  color: var(--text-2);
}

.rung--acted .rung__text {
  color: var(--text);
}

.rung__val {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rung--acted .rung__val {
  color: var(--signal);
}

.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--faint);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .c-path,
  .c-src {
    display: none;
  }
}

/* Шаги заполнения индикатора квоты. Классы вместо inline-стиля:
   CSP запрещает style-атрибуты, и ослаблять её ради полоски не станем. */
.quota__bar i.q-0 { width: 0%; }
.quota__bar i.q-5 { width: 5%; }
.quota__bar i.q-10 { width: 10%; }
.quota__bar i.q-15 { width: 15%; }
.quota__bar i.q-20 { width: 20%; }
.quota__bar i.q-25 { width: 25%; }
.quota__bar i.q-30 { width: 30%; }
.quota__bar i.q-35 { width: 35%; }
.quota__bar i.q-40 { width: 40%; }
.quota__bar i.q-45 { width: 45%; }
.quota__bar i.q-50 { width: 50%; }
.quota__bar i.q-55 { width: 55%; }
.quota__bar i.q-60 { width: 60%; }
.quota__bar i.q-65 { width: 65%; }
.quota__bar i.q-70 { width: 70%; }
.quota__bar i.q-75 { width: 75%; }
.quota__bar i.q-80 { width: 80%; }
.quota__bar i.q-85 { width: 85%; }
.quota__bar i.q-90 { width: 90%; }
.quota__bar i.q-95 { width: 95%; }
.quota__bar i.q-100 { width: 100%; }
