/* ============================================================
   Сервис поставок. Дизайн-язык.
   Один файл на все макеты: токены, сетка, компоненты, состояния.
   Светлая и темная тема. Десктоп в первую очередь.
   ============================================================ */

/* ---------- 1. Токены ---------- */

:root {
  /* Поверхности */
  --bg:            #F4F6F9;
  --bg-deep:       #ECEFF4;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --surface-3:     #F1F4F8;
  --overlay:       rgba(16, 22, 33, .38);

  /* Линии */
  --line:          #E2E7EE;
  --line-soft:     #EDF0F5;
  --line-strong:   #CFD6E1;

  /* Текст */
  --text:          #101828;
  --text-2:        #59657A;
  --text-3:        #8C97A8;
  --text-inv:      #FFFFFF;

  /* Акцент */
  --accent:        #3757D8;
  --accent-hover:  #2B47BC;
  --accent-soft:   #EDF1FE;
  --accent-line:   #C6D2FA;
  --accent-text:   #2B47BC;

  /* Семантика. Всегда идет вместе со значком и текстом, не одним цветом */
  --ok:            #0E7A57;
  --ok-soft:       #E6F6F0;
  --ok-line:       #B7E4D2;

  --warn:          #9A6206;
  --warn-soft:     #FDF3E2;
  --warn-line:     #F2D9A8;

  --alarm:         #B32318;
  --alarm-soft:    #FDECEA;
  --alarm-line:    #F5C4BE;

  /* Нет данных. Отдельный цвет: это не ошибка и не ноль */
  --void:          #6B7590;
  --void-soft:     #F2F4F8;
  --void-line:     #D8DEE9;

  --info:          #1D6FA3;
  --info-soft:     #E9F4FB;
  --info-line:     #B9DBF0;

  /* Ряд для графиков */
  --c1: #3757D8;  --c2: #E58A17;  --c3: #0E7A57;  --c4: #8B5CF6;
  --c5: #0891B2;  --c6: #B32318;  --c7: #64748B;

  /* Тени */
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 2px 8px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .05);
  --sh-3: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 8px rgba(16, 24, 40, .06);
  --sh-pop: 0 20px 48px rgba(16, 24, 40, .18);

  /* Скругления */
  --r-xs: 4px; --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-xl: 18px;

  /* Ритм. База 4 px */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px;

  /* Сетка приложения */
  --nav-w: 244px;
  --nav-w-min: 60px;
  --top-h: 56px;
  --page-max: 1680px;

  /* Шрифты */
  --font: "Inter", "SF Pro Text", -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas,
          "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --bg:            #0D1016;
  --bg-deep:       #090C11;
  --surface:       #141922;
  --surface-2:     #1A202B;
  --surface-3:     #202834;
  --overlay:       rgba(4, 6, 10, .62);

  --line:          #242C39;
  --line-soft:     #1D242F;
  --line-strong:   #364152;

  --text:          #E8ECF3;
  --text-2:        #A0AABC;
  --text-3:        #6D788C;
  --text-inv:      #0D1016;

  --accent:        #7A94FF;
  --accent-hover:  #94A9FF;
  --accent-soft:   #1B2340;
  --accent-line:   #2F3D6B;
  --accent-text:   #A8BAFF;

  --ok:            #43D3A0;
  --ok-soft:       #10291F;
  --ok-line:       #1D4A38;

  --warn:          #F0B429;
  --warn-soft:     #2B2110;
  --warn-line:     #4E3B14;

  --alarm:         #FF8579;
  --alarm-soft:    #2E1512;
  --alarm-line:    #5A251F;

  --void:          #8993A8;
  --void-soft:     #191F29;
  --void-line:     #2C3543;

  --info:          #5FB6E8;
  --info-soft:     #10222E;
  --info-line:     #1F3E52;

  --c1: #7A94FF;  --c2: #F0B429;  --c3: #43D3A0;  --c4: #B594FF;
  --c5: #4FC3DE;  --c6: #FF8579;  --c7: #94A3B8;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .5);
  --sh-2: 0 2px 10px rgba(0, 0, 0, .45);
  --sh-3: 0 14px 36px rgba(0, 0, 0, .55);
  --sh-pop: 0 22px 52px rgba(0, 0, 0, .68);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1016; --bg-deep: #090C11; --surface: #141922;
    --surface-2: #1A202B; --surface-3: #202834; --overlay: rgba(4,6,10,.62);
    --line: #242C39; --line-soft: #1D242F; --line-strong: #364152;
    --text: #E8ECF3; --text-2: #A0AABC; --text-3: #6D788C; --text-inv: #0D1016;
    --accent: #7A94FF; --accent-hover: #94A9FF; --accent-soft: #1B2340;
    --accent-line: #2F3D6B; --accent-text: #A8BAFF;
    --ok: #43D3A0; --ok-soft: #10291F; --ok-line: #1D4A38;
    --warn: #F0B429; --warn-soft: #2B2110; --warn-line: #4E3B14;
    --alarm: #FF8579; --alarm-soft: #2E1512; --alarm-line: #5A251F;
    --void: #8993A8; --void-soft: #191F29; --void-line: #2C3543;
    --info: #5FB6E8; --info-soft: #10222E; --info-line: #1F3E52;
    --c1: #7A94FF; --c2: #F0B429; --c3: #43D3A0; --c4: #B594FF;
    --c5: #4FC3DE; --c6: #FF8579; --c7: #94A3B8;
    --sh-1: 0 1px 2px rgba(0,0,0,.5);
    --sh-2: 0 2px 10px rgba(0,0,0,.45);
    --sh-3: 0 14px 36px rgba(0,0,0,.55);
    --sh-pop: 0 22px 52px rgba(0,0,0,.68);
  }
}

/* ---------- 2. База ---------- */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.012em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 14.5px; }
h4 { font-size: 13px; }
p  { margin: 0 0 var(--s3); }
a  { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* Полосы прокрутки: тонкие, не отвлекают от таблиц */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 8px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 3. Числа ---------- */

.num, .tbl td.num, .val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
/* Копейки и дробная часть глушатся: разряды рублей должны читаться первыми */
.kop { color: var(--text-3); font-size: .88em; }
.cur { color: var(--text-3); font-size: .88em; margin-left: 2px; }

/* ---------- 4. Оболочка ---------- */

.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.app.nav-min { grid-template-columns: var(--nav-w-min) 1fr; }

/* Боковое меню */
.nav {
  position: sticky; top: 0; height: 100vh; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--top-h); padding: 0 var(--s4);
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.nav-logo {
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), #6E86F0);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 2px 6px rgba(55, 87, 216, .35);
}
.nav-name { font-weight: 660; font-size: 13.5px; letter-spacing: -.01em; white-space: nowrap; }
.nav-name span { display: block; font-weight: 450; font-size: 11px; color: var(--text-3); }
.nav-scroll { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2) var(--s5); }
.nav-group {
  padding: var(--s4) var(--s3) var(--s1); font-size: 10.5px; font-weight: 620;
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-3);
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px var(--s3); margin-bottom: 1px;
  border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .ic { color: currentColor; opacity: .85; flex: none; }
.nav-item .pill {
  margin-left: auto; font-size: 10.5px; font-weight: 650; padding: 1px 6px;
  border-radius: 20px; background: var(--alarm-soft); color: var(--alarm);
  border: 1px solid var(--alarm-line);
}
.nav-item .pill.q { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.nav-foot { flex: none; border-top: 1px solid var(--line-soft); padding: var(--s3); }

.app.nav-min .nav-name, .app.nav-min .nav-group,
.app.nav-min .nav-item span:not(.pill), .app.nav-min .nav-foot .who { display: none; }
.app.nav-min .nav-item { justify-content: center; padding: 8px; }

/* Верхняя полоса */
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 25;
  height: var(--top-h); flex: none;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s6); background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 16px; font-weight: 640; }
.top .crumb { color: var(--text-3); font-size: 12px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.page { padding: var(--s6); max-width: var(--page-max); width: 100%; }
.page.flush { padding: 0; max-width: none; }
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s5); }
.page-head .sub { color: var(--text-2); font-size: 12.5px; margin-top: 3px; max-width: 78ch; }
.page-head .acts { margin-left: auto; display: flex; gap: var(--s2); flex: none; }

/* ---------- 5. Кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 12.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap; box-shadow: var(--sh-1);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.pri {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.18);
}
.btn.pri:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.ic-only { padding: 0; width: 32px; justify-content: center; }
.btn.sm.ic-only { width: 26px; }
.btn.danger { color: var(--alarm); border-color: var(--alarm-line); background: var(--alarm-soft); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn-set { display: inline-flex; box-shadow: var(--sh-1); border-radius: var(--r-sm); }
.btn-set .btn { box-shadow: none; border-radius: 0; margin-left: -1px; }
.btn-set .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-set .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.btn-set .btn.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); z-index: 1; }

.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > label { font-size: 11.5px; font-weight: 560; color: var(--text-2); }
.inp, select.inp, textarea.inp {
  height: 32px; padding: 0 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 12.5px; width: 100%;
}
textarea.inp { height: auto; padding: 7px 10px; resize: vertical; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp::placeholder { color: var(--text-3); }
select.inp { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: right 12px center, right 7px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.inp-search { position: relative; }
.inp-search .ic { position: absolute; left: 9px; top: 8px; color: var(--text-3); }
.inp-search .inp { padding-left: 30px; }
.hint { font-size: 11.5px; color: var(--text-3); }

.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 12.5px; }
.chk input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

.swx { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }
.swx input { display: none; }
.swx i {
  width: 32px; height: 18px; border-radius: 20px; background: var(--line-strong);
  position: relative; transition: background .15s; flex: none;
}
.swx i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.swx input:checked + i { background: var(--accent); }
.swx input:checked + i::after { transform: translateX(14px); }

/* ---------- 6. Карточки и панели ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { margin-right: auto; }
.card-body { padding: var(--s5); }
.card-body.tight { padding: var(--s4); }
.card-foot {
  padding: var(--s3) var(--s5); border-top: 1px solid var(--line-soft);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 12px; color: var(--text-2);
}

.grid { display: grid; gap: var(--s4); }
/* Без этого таблица с длинными строками распирает колонку сетки и рвет страницу */
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1400px) {
  .g6 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .g4, .g3, .g-2-1, .g-1-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.row { display: flex; align-items: center; gap: var(--s3); }
.row.wrap { flex-wrap: wrap; }
.spacer { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack.sm { gap: var(--s2); }

/* ---------- 7. Плитка показателя ---------- */

.tiles { display: grid; gap: var(--s3); }

.tile {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s4) var(--s4) var(--s3);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  box-shadow: var(--sh-1); cursor: pointer;
}
.tile:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); text-decoration: none; }
.tile-t {
  font-size: 11.5px; font-weight: 570; color: var(--text-2);
  display: flex; align-items: center; gap: 5px; min-height: 17px;
}
.tile-v {
  font-size: 27px; font-weight: 660; letter-spacing: -.025em; line-height: 1.15;
  font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 5px;
}
.tile-v .u { font-size: 12px; font-weight: 520; color: var(--text-3); letter-spacing: 0; }
.tile-d { font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.tile-drill {
  margin-top: auto; padding-top: var(--s2); font-size: 11.5px; font-weight: 550;
  color: var(--accent-text); display: flex; align-items: center; gap: 4px; opacity: 0;
}
.tile:hover .tile-drill { opacity: 1; }

.tile.lv-warn { border-color: var(--warn-line); background: var(--warn-soft); }
.tile.lv-warn .tile-v { color: var(--warn); }
.tile.lv-alarm { border-color: var(--alarm-line); background: var(--alarm-soft); }
.tile.lv-alarm .tile-v { color: var(--alarm); }
.tile.lv-ok .tile-v { color: var(--ok); }

/* Нет данных. Пунктир и прочерк, чтобы отличать от нуля */
.tile.lv-void { background: var(--void-soft); border-style: dashed; border-color: var(--void-line); }
.tile.lv-void .tile-v { color: var(--void); font-weight: 500; }
.tile.lv-void .tile-d { color: var(--void); }

.tile-big .tile-v { font-size: 38px; }

/* ---------- 8. Метки состояния. Значок обязателен ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px 1px 5px; border-radius: 20px; font-size: 11.5px; font-weight: 570;
  border: 1px solid var(--line); background: var(--surface-3); color: var(--text-2);
  white-space: nowrap; line-height: 18px;
}
.tag .ic { flex: none; }
.tag.ok    { background: var(--ok-soft);    color: var(--ok);    border-color: var(--ok-line); }
.tag.warn  { background: var(--warn-soft);  color: var(--warn);  border-color: var(--warn-line); }
.tag.alarm { background: var(--alarm-soft); color: var(--alarm); border-color: var(--alarm-line); }
.tag.info  { background: var(--info-soft);  color: var(--info);  border-color: var(--info-line); }
.tag.acc   { background: var(--accent-soft);color: var(--accent-text); border-color: var(--accent-line); }
.tag.void  { background: var(--void-soft);  color: var(--void);  border-color: var(--void-line); border-style: dashed; }
.tag.sq { border-radius: var(--r-xs); }
.tag.lg { font-size: 12.5px; padding: 3px 10px 3px 8px; }

/* Точка статуса. Всегда рядом с текстом, никогда вместо него */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.dot.alarm { background: var(--alarm); } .dot.void { background: var(--void); }

/* ---------- 9. Оговорки ---------- */

.note {
  display: flex; gap: 9px; padding: 10px var(--s4); border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
}
.note .ic { flex: none; margin-top: 2px; color: var(--text-3); }
.note b { color: var(--text); font-weight: 600; }
.note.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.note.warn .ic, .note.warn b { color: var(--warn); }
.note.alarm { background: var(--alarm-soft); border-color: var(--alarm-line); color: var(--alarm); }
.note.alarm .ic, .note.alarm b { color: var(--alarm); }
.note.info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }
.note.info .ic, .note.info b { color: var(--info); }
.note.void { background: var(--void-soft); border-color: var(--void-line); border-style: dashed; color: var(--void); }
.note.void .ic, .note.void b { color: var(--void); }
.note ul { margin: 4px 0 0; padding-left: 17px; }
.note li { margin-bottom: 2px; }

/* Строка-подпись под цифрами: из чего сложилось */
.legend { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.legend b { color: var(--text-2); font-weight: 600; }

/* ---------- 10. Таблица ---------- */

.tbl-wrap {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; box-shadow: var(--sh-1);
}
.tbl-tools {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: 10px var(--s4); border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.tbl-scroll { overflow: auto; max-height: 62vh; position: relative; }
.tbl-scroll.tall { max-height: 74vh; }
.tbl-scroll.short { max-height: 42vh; }

.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th, .tbl td {
  padding: 0 10px; height: 34px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.tbl thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 600; font-size: 11.5px; height: 36px;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 var(--line);
  cursor: pointer; user-select: none;
}
.tbl thead th:hover { color: var(--text); background: var(--surface-3); }
.tbl thead tr.grp th {
  height: 26px; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); text-align: center; top: 0; z-index: 4;
  border-right: 1px solid var(--line);
}
.tbl thead tr.grp + tr th { top: 26px; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr.on td { background: var(--accent-soft); }
.tbl tbody tr.on:hover td { background: var(--accent-soft); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.num { font-variant-numeric: tabular-nums; }
.tbl td.mut { color: var(--text-3); }
.tbl td.str { font-weight: 600; }

/* Закрепленные слева колонки */
.tbl .stick { position: sticky; z-index: 2; background: var(--surface); }
.tbl thead .stick { z-index: 5; background: var(--surface-2); }
.tbl tbody tr:hover .stick { background: var(--surface-2); }
.tbl tbody tr.on .stick { background: var(--accent-soft); }
.tbl .s0 { left: 0; width: 38px; min-width: 38px; padding: 0 0 0 12px; }
.tbl .s1 { left: 38px; width: 112px; min-width: 112px; }
.tbl .s2 { left: 150px; min-width: 240px; }
.tbl .s-end { box-shadow: 4px 0 8px -4px rgba(16,24,40,.22); }
:root[data-theme="dark"] .tbl .s-end { box-shadow: 4px 0 8px -4px rgba(0,0,0,.6); }

/* Итоговая строка */
.tbl tfoot td {
  position: sticky; bottom: 0; z-index: 4;
  background: var(--surface-3); font-weight: 650;
  border-top: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--line);
  height: 36px;
}
.tbl tfoot td.stick { z-index: 6; background: var(--surface-3); }

/* Ячейка с правкой руками */
.cell-edit {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 5px;
  border-radius: var(--r-xs); border: 1px solid transparent;
  border-bottom: 1px dashed var(--line-strong); cursor: text; min-width: 46px;
  justify-content: flex-end; font-variant-numeric: tabular-nums;
}
td:hover .cell-edit { border-color: var(--line-strong); background: var(--surface); }
.cell-edit.on {
  border: 1px solid var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cell-edit.dirty { background: var(--warn-soft); border-bottom-color: var(--warn); color: var(--warn); font-weight: 620; }
.cell-was { font-size: 10.5px; color: var(--text-3); text-decoration: line-through; }

/* Микрополоса внутри ячейки */
.bar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 40px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); }
.bar.alarm > i { background: var(--alarm); }

.tbl-foot {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: 9px var(--s4); border-top: 1px solid var(--line);
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}

/* Подгрузка по прокрутке */
.load-more {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; color: var(--text-3); font-size: 12px;
  border-top: 1px dashed var(--line);
}
.spin { width: 13px; height: 13px; border: 2px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Панель массового редактирования */
.bulk {
  position: sticky; bottom: 0; z-index: 8;
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s4); background: var(--text); color: var(--surface);
  border-radius: var(--r-md); margin: 0 var(--s4) var(--s4); box-shadow: var(--sh-3);
}
:root[data-theme="dark"] .bulk { background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); }
.bulk .btn { background: transparent; border-color: rgba(255,255,255,.28); color: inherit; box-shadow: none; }
.bulk .btn:hover { background: rgba(255,255,255,.12); }
:root[data-theme="dark"] .bulk .btn { border-color: var(--line-strong); }
:root[data-theme="dark"] .bulk .btn:hover { background: var(--surface-2); }
.bulk b { font-variant-numeric: tabular-nums; }

/* ---------- 11. Состояния ---------- */

.state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s3); padding: var(--s9) var(--s6); color: var(--text-2);
}
.state .ic-big {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
}
.state.void .ic-big { background: var(--void-soft); color: var(--void); border: 1px dashed var(--void-line); }
.state.alarm .ic-big { background: var(--alarm-soft); color: var(--alarm); }
.state h3 { color: var(--text); }
.state p { max-width: 56ch; font-size: 12.5px; margin: 0; }

.sk { background: var(--surface-3); border-radius: var(--r-xs); animation: pulse 1.35s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.sk-line { height: 11px; }
.sk-num { height: 22px; width: 68%; }
.sk-tile { height: 96px; border-radius: var(--r-md); }

.prog { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--accent); border-radius: 4px;
  transition: width .3s; }
.prog.stripe > i {
  background-image: linear-gradient(115deg, rgba(255,255,255,.28) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
  background-size: 14px 14px; animation: stripe 1s linear infinite;
}
@keyframes stripe { to { background-position: 14px 0; } }

/* ---------- 12. Панель расшифровки ---------- */

.veil {
  position: fixed; inset: 0; background: var(--overlay); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.veil.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--line); z-index: 61;
  box-shadow: var(--sh-pop); transform: translateX(102%); transition: transform .2s cubic-bezier(.32,.72,.35,1);
  display: flex; flex-direction: column;
}
.drawer.wide { width: 760px; }
.drawer.on { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); flex: none;
}
.drawer-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s5); }
.drawer-foot { flex: none; padding: var(--s3) var(--s5); border-top: 1px solid var(--line);
  background: var(--surface-2); display: flex; gap: var(--s2); align-items: center; }

/* Разбор суммы: слагаемые формулой */
.calc { display: flex; flex-direction: column; font-size: 12.5px; }
.calc-row {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.calc-row .sign { color: var(--text-3); font-weight: 620; text-align: center; }
.calc-row .amt { font-variant-numeric: tabular-nums; font-weight: 560; }
.calc-row .lbl small { display: block; color: var(--text-3); font-size: 11px; }
.calc-row.total {
  border-bottom: none; border-top: 2px solid var(--text); margin-top: 4px;
  padding-top: 9px; font-weight: 680; font-size: 14px;
}
.calc-row.neg .amt { color: var(--alarm); }
.calc-row.void .amt { color: var(--void); }

.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 7px var(--s4); font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 520; }

.code {
  font-family: var(--mono); font-size: 11.5px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px;
  color: var(--text-2); overflow-x: auto; line-height: 1.6;
}

/* ---------- 13. Цепочка движения ---------- */

.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step { display: grid; grid-template-columns: 30px 1fr; gap: var(--s3); }
.chain-mark { display: flex; flex-direction: column; align-items: center; }
.chain-mark .pt {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line);
}
.chain-mark .ln { width: 2px; flex: 1; background: var(--line); min-height: 14px; }
.chain-step.miss .pt { background: var(--void-soft); color: var(--void); border: 1px dashed var(--void-line); }
.chain-step.miss .ln { background: repeating-linear-gradient(var(--void-line) 0 4px, transparent 4px 8px); }
.chain-step.na .pt { background: var(--surface-3); color: var(--text-3); border-color: var(--line); }
.chain-body { padding-bottom: var(--s4); min-width: 0; }
.chain-body h4 { display: flex; align-items: center; gap: 7px; }
.chain-body .when { font-size: 11.5px; color: var(--text-3); font-weight: 450; }
.chain-body .why { font-size: 12px; color: var(--void); margin-top: 3px; }
.chain-body .det {
  margin-top: 6px; font-size: 11.5px; color: var(--text-2);
  display: flex; gap: var(--s3) var(--s4); flex-wrap: wrap;
}
.chain-body .det b { color: var(--text); font-weight: 570; }

/* ---------- 14. Полосы этапов ---------- */

.legs { display: flex; flex-direction: column; gap: 2px; }
.leg {
  display: grid; grid-template-columns: 250px 1fr 190px; gap: var(--s4);
  align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
.leg:last-child { border-bottom: none; }
.leg-name { font-size: 12.5px; font-weight: 550; min-width: 0; }
.leg-name small { display: block; font-weight: 450; font-size: 11px; color: var(--text-3); }
.leg-track { height: 9px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.leg-track > i { display: block; height: 100%; border-radius: 5px; background: var(--c1); }
.leg.z-wb .leg-track > i { background: var(--c2); }
.leg.z-tot .leg-track > i { background: var(--c7); }
.leg-val { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.leg-val b { font-weight: 650; }
.leg-val small { color: var(--text-3); margin-left: 6px; font-size: 11px; }
.zone-title {
  display: flex; align-items: center; gap: 7px; margin: var(--s4) 0 var(--s2);
  font-size: 12.5px; font-weight: 620;
}
.zone-title i { width: 9px; height: 9px; border-radius: 3px; background: var(--c1); flex: none; }
.zone-title.wb i { background: var(--c2); }
.zone-title.tot i { background: var(--c7); }
.zone-title small { font-weight: 450; color: var(--text-3); }

/* ---------- 15. Карточки складов ---------- */

.wh-card {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4);
  background: var(--surface); display: flex; flex-direction: column; gap: 9px; cursor: pointer;
}
.wh-card:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); }
.wh-card.tot { background: var(--surface-3); border-color: var(--line-strong); }
.wh-card .wh-name { font-size: 12.5px; font-weight: 620; display: flex; align-items: center; gap: 7px; }
.wh-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.wh-nums div { min-width: 0; }
.wh-nums .n { font-size: 19px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.wh-nums .n.zero { color: var(--text-3); font-weight: 500; }
.wh-nums .n.hot { color: var(--accent-text); }
.wh-nums .k { font-size: 10.5px; color: var(--text-3); }

/* ---------- 16. Вкладки ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s5); }
.tab {
  padding: 8px 13px; font-size: 13px; font-weight: 550; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 620; }
.tab .cnt { font-size: 11px; color: var(--text-3); margin-left: 5px; font-variant-numeric: tabular-nums; }

/* Переключатель макетных состояний. Часть прототипа, а не продукта */
.states-bar {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: 7px var(--s4); border-radius: var(--r-md);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface-3) 8px 16px);
  border: 1px dashed var(--line-strong); margin-bottom: var(--s4); font-size: 12px;
}
.states-bar b { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }

/* ---------- 17. Сохраненные представления ---------- */

.views { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.view-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px;
  border-radius: 20px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12px; font-weight: 520; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.view-chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.view-chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); font-weight: 600; }
.view-chip .ic { opacity: .7; }

/* Активные фильтры */
.fchip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 4px 0 8px;
  border-radius: var(--r-xs); background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent-text); font-size: 11.5px; font-weight: 540;
}
.fchip b { font-weight: 650; }
.fchip button { border: none; background: none; color: inherit; cursor: pointer; padding: 2px; display: grid; opacity: .7; }
.fchip button:hover { opacity: 1; }

/* ---------- 18. График ---------- */

.chart { width: 100%; display: block; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--text-3); font-size: 10.5px; }
.chart .bar-r { fill: var(--c1); }
.chart .bar-r.dim { fill: var(--line-strong); }
.chart .ln { fill: none; stroke: var(--c2); stroke-width: 2; stroke-linejoin: round; }
.chart .pt { fill: var(--surface); stroke: var(--c2); stroke-width: 2; }
.chart-legend { display: flex; gap: var(--s4); font-size: 11.5px; color: var(--text-2); justify-content: center; margin-top: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* Ранжирование строк, доля в общем */
.rank { display: flex; align-items: center; gap: var(--s3); }
.rank .rbar { flex: 1; height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; min-width: 60px; }
.rank .rbar > i { display: block; height: 100%; background: var(--c1); border-radius: 4px; }
.rank .rbar.two { display: flex; flex-direction: column; gap: 2px; height: auto; background: none; }
.rank .rbar.two > i { height: 6px; background: var(--c1); }
.rank .rbar.two > i.b { background: var(--c3); }

/* ---------- 19. Прочее ---------- */

.sep { height: 1px; background: var(--line); margin: var(--s4) 0; }
.mut { color: var(--text-3); }
.strong { font-weight: 620; }
.mono { font-family: var(--mono); font-size: .93em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Прочерк на месте отсутствующего значения */
.dash { color: var(--void); font-weight: 500; }
.dash::after { content: "—"; }

.ttip { position: relative; border-bottom: 1px dotted var(--text-3); cursor: help; }
.ttip:hover::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 50;
  width: max-content; max-width: 320px; white-space: normal;
  background: var(--text); color: var(--surface); font-size: 11.5px; font-weight: 450;
  line-height: 1.45; padding: 7px 10px; border-radius: var(--r-sm); box-shadow: var(--sh-3);
}
:root[data-theme="dark"] .ttip:hover::after { background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); }

.who { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: var(--r-sm); cursor: pointer; }
.who:hover { background: var(--surface-3); }
.who .ch { margin-left: auto; color: var(--text-3); }

/* Всплывающее меню */
.menu {
  position: fixed; z-index: 70; min-width: 220px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--sh-pop);
}
.menu a, .menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; border: none; background: none; border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }
.menu .ic { color: var(--text-3); flex: none; }
.menu hr { border: none; border-top: 1px solid var(--line-soft); margin: 4px 0; }
.menu .head { padding: 7px 9px 5px; font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 620; }

.nav-brand:hover { background: var(--surface-3); }
.nav-brand { transition: background .12s; }

/* Всплывающая подсказка о том, что в макете дальше ничего не произойдет */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  z-index: 90; display: flex; align-items: center; gap: 9px;
  padding: 10px 15px; border-radius: var(--r-md); font-size: 12.5px;
  background: var(--text); color: var(--surface); box-shadow: var(--sh-pop);
  opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
}
:root[data-theme="dark"] .toast { background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.ava {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 11.5px; font-weight: 650;
}
.who-n { font-size: 12.5px; font-weight: 570; line-height: 1.25; min-width: 0; }
.who-n small { display: block; color: var(--text-3); font-weight: 450; font-size: 11px; }

/* Обложка прототипа */
.cover { max-width: 1180px; margin: 0 auto; padding: var(--s9) var(--s6); }
.cover-hero { margin-bottom: var(--s8); }
.cover-hero h1 { font-size: 34px; letter-spacing: -.03em; }
.cover-hero p { font-size: 15px; color: var(--text-2); max-width: 72ch; margin-top: var(--s3); }
.map-card {
  display: flex; flex-direction: column; gap: 5px; padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--sh-1); color: inherit;
}
.map-card:hover { border-color: var(--accent-line); box-shadow: var(--sh-2); text-decoration: none; }
.map-card .t { font-weight: 620; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.map-card .d { font-size: 12px; color: var(--text-2); line-height: 1.45; }
.map-card .s { font-size: 11px; color: var(--text-3); margin-top: auto; padding-top: 6px; }

/* Печать. Лист комплектации уходит на бумагу */
@media print {
  .nav, .top, .states-bar, .btn, .tbl-tools { display: none !important; }
  .app { display: block; }
  .page { padding: 0; }
  .card, .tbl-wrap { border: none; box-shadow: none; }
  .tbl-scroll { max-height: none; overflow: visible; }
}
