/* =====================================================================
   A-Consulting — калькулятор юнит-экономики. Общие стили.
   ===================================================================== */

:root {
  --bg:            #f2f0f9;
  --card:          #ffffff;
  --ink:          #1e1733;
  --ink-2:        #4a4266;
  --muted:        #948eab;
  --line:         #e7e2f2;
  --line-2:       #f2eff9;

  /* Основной цвет проекта — сиреневый */
  --brand:        #7b5ed0;
  --brand-dark:   #5c3fb0;
  --brand-soft:   #f0ebfd;

  --green:        #1f9d6b;
  --green-soft:   #e4f6ee;
  --red:          #d4485f;
  --amber:        #e2872f;
  --violet:       #8b6ee0;

  /* Палитра структуры расходов */
  --c-commission: #57bde8;   /* голубой */
  --c-logistics:  #2f6fd0;   /* синий */
  --c-acquiring:  #9ec9ee;   /* приглушённый голубой */
  --c-ads:        #f2a9c8;   /* светло-розовый */
  --c-cost:       #f2d377;   /* светло-жёлтый */
  --c-crossdock:  #c3bada;   /* серо-сиреневый */
  --c-storage:    #b6adc9;
  --c-tax:        #ef8b3c;   /* оранжевый */
  --c-profit:     #23a86f;   /* зелёный */

  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 1px 2px rgba(30,23,51,.05), 0 4px 16px rgba(30,23,51,.05);
  --shadow-lg:    0 8px 32px rgba(30,23,51,.13);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Тёмная тема — переключатель в шапке (UI.toggleTheme, common.js), сохраняется
   в localStorage и применяется атрибутом data-theme на <html> ещё до отрисовки
   (инлайн-скрипт в <head> каждой страницы), чтобы не было мигания светлым. */
:root[data-theme="dark"] {
  --bg:            #171321;
  --card:          #201a2e;
  --ink:           #ede9f7;
  --ink-2:         #bfb8d6;
  --muted:         #8d84a8;
  --line:          #362d4d;
  --line-2:        #2a2239;

  --brand:         #9b7ff0;
  --brand-dark:    #b79cff;
  --brand-soft:    #2c2444;

  --green:         #38c98f;
  --green-soft:    #16302a;
  --red:           #ff6f80;
  --amber:         #f0a24a;
  --violet:        #a58af0;

  --c-commission:  #5cc2ee;
  --c-logistics:   #5b8ff0;
  --c-acquiring:   #7fa6d6;
  --c-ads:         #f2a9c8;
  --c-cost:        #e0c15f;
  --c-crossdock:   #a99bd0;
  --c-storage:     #8f84a8;
  --c-tax:         #f0a15c;
  --c-profit:      #3bc98f;

  --shadow:        0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.5);
}
:root[data-theme="dark"] img:not([src*=".svg"]) { filter: brightness(.92) contrast(1.05); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------- Шапка и вкладки ----------------------- */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--brand);
  margin-bottom: 14px;
  transition: color .15s, letter-spacing .15s;
}
.brand svg, .brand img { flex: none; }
.brand:hover { color: var(--brand-dark); letter-spacing: -.1px; text-decoration: none; }
.brand span { color: var(--ink); }

.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  display: block;
  text-align: center;
  text-decoration: none;
}
.tab:hover { text-decoration: none; }

.tab-pill {
  display: block;
  padding: 8px 22px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  transition: .15s;
  white-space: nowrap;
}
.tab:hover .tab-pill { border-color: var(--brand); color: var(--brand); }

.tab.active .tab-pill {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tab-note {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ------------------------------ Каркас ----------------------------- */

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px 120px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.8px;
  margin: 6px 0 10px;
}

.badges { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid #ddd2f7;
}
.badge.warn { background: #fff4e0; color: #8a5a05; border-color: #ffdfa8; }
.badge.ok   { background: var(--green-soft); color: #0a6d3d; border-color: #bfe9d3; }

/* Переключатель FBO/FBS */
.segmented {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  margin: 0 auto 20px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 8px 34px;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: .15s;
}
.segmented button.active { background: var(--brand-soft); color: var(--brand-dark); }
.segmented[hidden] { display: none; }

.center { display: flex; justify-content: center; }
.center[hidden] { display: none; }

/* Двухколоночная сетка */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .page-title { font-size: 24px; }
}

.col { display: flex; flex-direction: column; gap: 16px; }
.col-left { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 4px; }
@media (max-width: 1000px) { .col-left { position: static; max-height: none; overflow: visible; } }

/* ------------------------------ Карточки --------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.tint { background: linear-gradient(180deg, #f7f4fe, #efe9fc); border-color: #e0d7f7; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.2px;
}
.card-title .ico {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
}

.section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 12px;
}

/* ------------------------------- Формы ----------------------------- */

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

.field label,
.field > .lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 5px;
}

/* Базовое правило — работает и вне .field (подписи под заголовками,
   пояснения к панелям и т.п.), .field .hint ниже только чуть подвинут */
.hint {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}
.field .hint { margin-top: 4px; }

input[type="text"], input[type="number"], input[type="search"],
input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  transition: .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(123,94,208,.15);
}
input:disabled, input[readonly] { background: var(--line-2); color: var(--ink-2); }

/* Поле пароля с кнопкой-глазком показать/скрыть */
.pw-field { position: relative; }
.pw-field input[type="password"], .pw-field input[type="text"] { padding-right: 38px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  border-radius: 6px;
}
.pw-toggle:hover { color: var(--ink-2); background: var(--line-2); }
.pw-toggle.on { color: var(--brand); }

input[type="number"] { -moz-appearance: textfield; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23948eab' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.row-2:last-child, .row-3:last-child { margin-bottom: 0; }
.row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

/* Поля в строке выравниваем по нижнему краю подписи: если одна подпись
   переносится на две строки, а соседняя нет — инпуты всё равно на одной линии */
.row-2 > .field,
.row-3 > .field {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.row-2 > .field[hidden],
.row-3 > .field[hidden] { display: none; }
.row-2 > .field > label,
.row-3 > .field > label {
  display: flex;
  align-items: flex-end;
  min-height: 2.5em;          /* место под две строки подписи */
  margin-bottom: 5px;
}
.row-2 > .field > .hint,
.row-3 > .field > .hint { margin-top: auto; padding-top: 4px; }

/* ------------------------------- Кнопки ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: .14s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { filter: brightness(.93); color: #fff; }
.btn.amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.amber:hover { filter: brightness(.93); color: #fff; }
.btn.violet { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.violet:hover { filter: brightness(.93); color: #fff; }
.btn.pink { background: #d9559e; border-color: #d9559e; color: #fff; }
.btn.pink:hover { filter: brightness(.93); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[hidden] { display: none; }

/* ------------------------------- KPI ------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 1180px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 620px)  { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  min-width: 0;
}
.kpi .v {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .v.neg { color: var(--red); }
.kpi .v.neutral { color: var(--brand); }
.kpi .v.muted { color: var(--muted); }
/* Оттенки в пределах одного цвета, чтобы карточки различались глазом */
.kpi .v.green-2 { color: #2bb07c; }
.kpi .v.green-3 { color: #3c9d84; }
.kpi .v.brand-2 { color: #9a7ee0; }

/* Выбор маркетплейса */
.market-switch {
  display: inline-flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  margin-bottom: 16px;
}
.market-switch button {
  border: 0;
  background: transparent;
  padding: 8px 20px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.market-switch button:hover { color: var(--brand); }
.market-switch button.active { background: var(--brand); color: #fff; }
.market-switch button .soon {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  opacity: .6;
  margin-left: 5px;
}
.kpi .k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

/* ------------------------------- P&L ------------------------------- */

/* П&L может быть длиннее, чем «Параметры расчёта» + «Структура расходов»
   рядом — скроллим его отдельно, чтобы не приходилось листать всю
   раскрытую строку, чтобы увидеть эти два блока целиком */
.pnl-scroll { max-height: 480px; overflow-y: auto; }

.pnl { width: 100%; border-collapse: collapse; }
.pnl-scroll .pnl th {
  position: sticky;
  top: 0;
  background: var(--brand-soft);   /* фон .rowdetail — иначе шов виден при скролле */
}
.pnl th {
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.pnl th:nth-child(2), .pnl th:nth-child(3) { text-align: right; }
.pnl td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.pnl td:nth-child(2), .pnl td:nth-child(3) { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pnl td:nth-child(3) { color: var(--muted); font-weight: 600; width: 78px; }
.pnl tr:last-child td { border-bottom: 0; }

.pnl tr.sub td { color: var(--ink-2); }
.pnl tr.sub td:first-child { padding-left: 8px; }
.pnl tr.subtotal { background: var(--brand-soft); }
.pnl tr.subtotal td { font-weight: 800; }
.pnl tr.subtotal td:first-child::before { content: "▸ "; color: var(--brand); }
.pnl tr.total td { font-weight: 800; border-top: 1px solid var(--line); }
.pnl tr.result td { font-weight: 800; font-size: 14.5px; color: var(--green); }
.pnl .pos { color: var(--green); }
.pnl .neg { color: var(--ink); }

/* --------------------------- Структура расходов -------------------- */

.struct { display: flex; flex-direction: column; gap: 6px; }
.struct-row { display: grid; grid-template-columns: 108px 1fr; gap: 10px; align-items: center; }
.struct-row .name { font-size: 11.5px; font-weight: 700; color: var(--ink-2); text-align: right; }
.struct-bar {
  position: relative;
  height: 17px;
  background: var(--line-2);
  border-radius: 4px;
  overflow: hidden;
}
.struct-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  min-width: 2px;
  transition: width .25s;
}
.struct-bar b {
  position: absolute;
  left: 6px; top: 0;
  line-height: 17px;
  font-size: 10.5px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 3px rgba(0,0,0,.35);
  white-space: nowrap;
}
/* На светлой заливке (жёлтый, розовый, голубой) белый текст не читается */
.struct-bar b.on-light { color: #3a3357; text-shadow: none; }
.struct-bar b.outside { color: var(--ink-2); text-shadow: none; }

/* --------------------------- Соинвест и налоги --------------------- */

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; }
.kv + .kv { border-top: 1px solid rgba(123,94,208,.10); }
.kv .k { color: var(--ink-2); }
.kv .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.kv.accent .v { color: var(--green); }
.kv.sep { margin-top: 8px; border-top: 1px solid rgba(123,94,208,.22); padding-top: 10px; }

/* ------------------------------ Кластеры --------------------------- */

.cluster-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.cluster-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.cluster-row {
  display: grid;
  grid-template-columns: 22px 1fr 62px 58px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}
.cluster-row:last-child { border-bottom: 0; }
.cluster-row:hover { background: var(--line-2); }
.cluster-row .cname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-row input[type="number"] { padding: 4px 6px; font-size: 12px; text-align: right; }
.cluster-row .ctariff {
  text-align: right;
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.cluster-row.off { opacity: .45; }

.cluster-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}
.cluster-summary div { display: flex; gap: 5px; align-items: baseline; }
.cluster-summary .k { color: var(--muted); }
.cluster-summary .v { font-weight: 800; }

/* ---------------------------- Нижняя панель ------------------------ */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 30;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin-top: 26px;
  line-height: 1.6;
}

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

.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1e1733;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.autocomplete { position: relative; }
.ac-list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.ac-list.open { display: block; }
.ac-item { padding: 8px 11px; cursor: pointer; font-size: 12.5px; border-bottom: 1px solid var(--line-2); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.sel { background: var(--brand-soft); }
.ac-item .r { float: right; font-weight: 800; color: var(--brand); }
.ac-empty { padding: 10px 11px; color: var(--muted); font-size: 12px; }

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

/* Переключатель вкл/выкл (уведомления и т.п.) */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: .15s;
  pointer-events: none;
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .15s;
  box-shadow: 0 1px 2px rgba(30,23,51,.25);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(123,94,208,.25); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.switch input:disabled { cursor: not-allowed; }

.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.notif-row:last-child { border-bottom: none; }

.stub {
  text-align: center;
  padding: 90px 20px;
}
.stub h2 { font-size: 26px; margin: 0 0 8px; }
.stub p { color: var(--muted); max-width: 460px; margin: 0 auto; }
.stub .big { font-size: 54px; margin-bottom: 14px; }

.scroll-x { overflow-x: auto; }

/* --------------------------- Главная (хаб) -------------------------- */

.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 640px) { .hub-grid { grid-template-columns: 1fr; } }

.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 30px;
  color: var(--ink);
  transition: .15s;
}
.hub-card:hover {
  text-decoration: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.hub-ico { font-size: 40px; margin-bottom: 14px; }
.hub-card h2 { font-size: 21px; margin: 0 0 8px; letter-spacing: -.3px; }
.hub-card p { color: var(--muted); margin: 0 0 18px; max-width: 480px; }
.hub-go { font-weight: 700; color: var(--brand-dark); margin-top: auto; }

.hub-soon {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ======================= Мульти-артикул ============================ */

.globals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.multi-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 70vh;
}

table.multi {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  white-space: nowrap;
}

table.multi thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--brand-soft);
  border-bottom: 1px solid var(--line);
  padding: 8px 14px 8px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
table.multi thead th.num { text-align: right; }

/* Перетаскиваемая граница столбца — узкая полоса у правого края заголовка */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}
.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: 3px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
}
.col-resize-handle:hover::after,
body.col-resizing .col-resize-handle.active::after { background: var(--brand); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing * { cursor: col-resize !important; }

table.multi thead .th-label {
  cursor: pointer;
  user-select: none;
}
table.multi thead .th-label:hover { color: var(--brand-dark); }
table.multi thead .th-arrow { color: var(--brand); }

table.multi thead .th-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  border-radius: 4px;
  color: var(--ink-2);
  vertical-align: middle;
}
table.multi thead .th-filter svg { width: 11px; height: 11px; display: block; }
table.multi thead .th-filter:hover { border-color: var(--brand); color: var(--brand-dark); }
table.multi thead .th-filter.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.col-filter-popup {
  position: fixed;
  z-index: 50;
  width: 240px;
  max-height: 360px;
  padding: 10px;
  font-size: 12.5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
/* display вынесен из базового правила — иначе перебивает атрибут [hidden] */
.col-filter-popup:not([hidden]) { display: flex; flex-direction: column; }
.col-filter-popup input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  margin-bottom: 8px;
  border-radius: 6px;
  font-size: 12.5px;
}
.cf-actions { display: flex; gap: 12px; margin-bottom: 6px; }
.cf-actions button {
  border: none;
  background: none;
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 11.5px;
  padding: 0;
}
.cf-actions button:hover { text-decoration: underline; }
.cf-list {
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 4px 0;
}
.cf-row { display: flex; align-items: center; gap: 6px; padding: 3px 2px; cursor: pointer; }
.cf-row input { margin: 0; flex: none; }
.cf-row span.cf-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-count { color: var(--muted); font-size: 11px; }
.cf-empty { color: var(--muted); padding: 10px 4px; text-align: center; }

/* ------------------------------- Модалка ---------------------------- */
/* Простое диалоговое окно поверх страницы — вместо window.prompt(), когда
   нужно больше одного поля. display вынесен из базового правила по тому же
   приёму, что и у .col-filter-popup — иначе перебивает атрибут [hidden]. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(24, 18, 40, .45);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop:not([hidden]) { display: flex; }
.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.modal-box textarea { resize: vertical; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.cf-footer { display: flex; justify-content: flex-end; margin-top: 8px; }

table.multi .idx {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--card);
}
table.multi thead th.idx { z-index: 7; background: var(--brand-soft); }

table.multi th.frozen,
table.multi td.frozen {
  position: sticky;
  z-index: 3;
  background: var(--card);
  box-shadow: 1px 0 0 var(--line);
}
table.multi thead th.frozen { z-index: 7; background: var(--brand-soft); }
table.multi tbody tr.art:hover td.frozen { background: var(--line-2); }
table.multi tbody tr.art.open td.frozen { background: var(--brand-soft); }

table.multi tbody td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.multi tbody tr.art { cursor: pointer; }
table.multi tbody tr.art:hover { background: var(--line-2); }
table.multi tbody tr.art.open { background: var(--brand-soft); }
table.multi tbody tr.art.open td { font-weight: 700; }

.col-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--card);
}
.col-chip input { margin: 0; }
.col-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  opacity: .35;
  line-height: 1;
}
.col-chip button.on { opacity: 1; }

table.multi td input,
table.multi td select {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  min-width: 44px;
}
table.multi td input[type="number"] { text-align: right; }
table.multi td.name input { font-weight: 700; }
table.multi td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
table.multi td.pos { color: var(--green); }
table.multi td.neg { color: var(--red); }
table.multi td.idx { color: var(--muted); text-align: center; width: 34px; font-weight: 700; }

table.multi tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--brand-soft);
  border-top: 1px solid var(--line);
  padding: 9px 6px;
  font-weight: 800;
}

.rowdetail td { background: var(--brand-soft); padding: 0 !important; }
.rowdetail .inner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 2px solid var(--brand-soft);
  white-space: normal;
}
@media (max-width: 900px) { .rowdetail .inner { grid-template-columns: 1fr; } }

.rowdetail .kpis { grid-column: 1 / -1; }
.rowdetail .kpi { box-shadow: none; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--line-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  margin-right: 5px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }

.dropzone {
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: var(--brand-soft);
  padding: 22px;
  text-align: center;
  margin-bottom: 16px;
  transition: .15s;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* ====================== Вход и пользователь ======================== */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #f3f0fa, #e5dcf7);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
}
.auth-card .brand { font-size: 22px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.auth-note { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin: 18px 0 0; text-align: center; }

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.auth-remember input { width: auto; accent-color: var(--brand); cursor: pointer; }

.auth-error {
  background: #fdeaea;
  border: 1px solid #f5c2c2;
  color: #a32020;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}
.auth-ok {
  background: var(--green-soft);
  border: 1px solid #bfe9d3;
  color: #0a6d3d;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Полоса пользователя в шапке */
.userbar {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
@media (max-width: 900px) {
  .userbar { position: static; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
}

/* Переключатель тёмной темы — зеркально .userbar, в левом углу шапки, живёт
   вне #userbar (тот перезаписывается целиком в UI.renderUserbar) — виден
   и до входа, и после */
.theme-toggle {
  position: absolute; top: 18px; left: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); cursor: pointer;
  font-size: 16px; line-height: 1; color: var(--ink-2); transition: .15s; padding: 0;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand-dark); }
@media (max-width: 900px) {
  .theme-toggle { position: static; display: flex; margin: 0 auto 8px; }
}
/* Один ряд: компания, имя, Админка/Профиль, Выйти */
.userbar .who-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.userbar .who-company { color: var(--muted); font-size: 13px; white-space: nowrap; }
.userbar .company-caption {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.userbar .company-switch {
  width: auto;
  padding: 8px 32px 8px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--card);
  color: var(--brand-dark);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.userbar .company-switch:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(123,94,208,.15); }
.userbar .company-switch:hover { border-color: var(--brand); }
.userbar .btn { padding: 9px 18px; font-size: 14px; }

.save-state {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  min-width: 96px;
  text-align: right;
}
.save-state.ok { color: var(--green); }
.save-state.err { color: var(--red); }

/* ============================ Админка ============================== */

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1000px) { .admin-grid { grid-template-columns: 1fr; } }
/* Строка «Сотрудники | Новый сотрудник» у владельца — таблице больше
   места, форме меньше, порядок колонок обратный основной сетке */
.admin-grid-even { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); margin-bottom: 18px; }

/* Совсем без второй колонки (сотрудник) — карточка узкая, как форма */
.admin-grid-single { grid-template-columns: minmax(0, 1fr); max-width: 620px; }

/* Блок на всю ширину (владелец: профиль сверху, представления снизу) */
.admin-grid-full { grid-template-columns: minmax(0, 1fr); margin-bottom: 18px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th {
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}
table.plain td { padding: 8px; border-bottom: 1px solid var(--line-2); }
table.plain tr:last-child td { border-bottom: 0; }
table.plain tr.sel { background: var(--brand-soft); }
table.plain tr.clickable { cursor: pointer; }
table.plain tr.clickable:hover { background: var(--line-2); }
table.plain td.actions { text-align: right; white-space: nowrap; }

/* Панель «Представления» в админке уже сама достаточно узкая (колонка
   грида) — nowrap там только выталкивал кнопки за карточку. Пусть
   переносятся внутри своей ячейки вместо этого. */
#viewsGroups td.actions { white-space: normal; }
#viewsGroups td.actions .btn { margin: 2px 0 2px 6px; }

/* «Сотрудники»: с кнопкой «Редактировать» их стало 4 — тем же приёмом,
   вместо горизонтальной прокрутки всей карточки переносим кнопки внутри
   ячейки и слегка сужаем их самих */
#usersBody td.actions { white-space: normal; }
#usersBody td.actions .btn {
  margin: 2px 0 2px 6px;
  padding: 5px 8px;
  font-size: 11px;
}

/* «Компании»: «Редактировать»/«Удалить» друг под другом, не в ряд — с колонкой
   «Площадки» вдобавок иначе не помещалось без горизонтальной прокрутки карточки */
#companiesBody td.actions { display: flex; flex-direction: column; gap: 4px; white-space: normal; }
#companiesBody td.actions .btn { width: 100%; }

.role-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--line-2);
  color: var(--ink-2);
}
.role-chip.admin { background: #ece2fb; color: #5c3fb0; }
.role-chip.owner { background: var(--brand-soft); color: var(--brand-dark); }
.role-chip.off { background: #fdeaea; color: #a32020; }

/* Переключатели площадок на компанию (админка → Компании) — по какой из них
   компания уже видит Юнит-экономику/Логистику. Оттенки — под цвета лого. */
.mp-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800;
  cursor: pointer; border: 1.5px solid transparent; margin-right: 4px; user-select: none;
  background: var(--line-2); color: var(--muted); transition: .12s;
}
.mp-toggle.wb { border-color: #7b5ed0; color: #7b5ed0; background: transparent; }
.mp-toggle.wb.on { background: #7b5ed0; color: #fff; }
.mp-toggle.ozon { border-color: #2f6fd0; color: #2f6fd0; background: transparent; }
.mp-toggle.ozon.on { background: #2f6fd0; color: #fff; }
.mp-toggle.ym { border-color: #d9a900; color: #a37c00; background: transparent; }
.mp-toggle.ym.on { background: #f5c518; color: #4a3800; }
.mp-toggle:hover { filter: brightness(.96); }

/* ======================= Схемы отгрузок ============================ */

.scheme-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.scheme-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: .14s;
}
.scheme-tab:hover { border-color: var(--brand); color: var(--brand); }
.scheme-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.scheme-tab .x {
  display: grid;
  place-items: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .1);
  font-size: 10px;
  line-height: 1;
}
.scheme-tab.active .x { background: rgba(255, 255, 255, .28); }
.scheme-tab .x:hover { background: var(--red); color: #fff; }
.scheme-tab.add { border-style: dashed; color: var(--brand); }

.pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.pick-row input[type="number"] { width: 66px; padding: 5px 8px; text-align: center; }

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 340px;
  overflow-y: auto;
}

.cluster-cell {
  display: grid;
  grid-template-columns: 17px 1fr 64px;
  gap: 7px;
  align-items: center;
  font-size: 12.5px;
}
.cluster-cell input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.cluster-cell .cn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cluster-cell input[type="number"] { padding: 3px 6px; font-size: 12px; text-align: right; }
.cluster-cell.off .cn { color: var(--muted); }
.cluster-cell.off input[type="number"] { background: var(--line-2); color: var(--muted); }
