/* ZP-MOP — кастомный CSS, без фреймворков. */

/* Токены, шрифты, каркас (сайдбар, мобильная шапка, тема) и загрузка приходят из
   бренд-системы: vendor/bark-brand-system/brand.css подключается раньше этого файла.
   Здесь только то, чего в бренде нет. */
:root {
  /* Цвет продукта barkledger — чаша фавикона и слово модуля (tokens.productColors.ledger). */
  --product-color: #164a2f;
  --logo-module: var(--product-color);
  --logo-module-dark: #23754a;

  /* Псевдонимы для экранов zp-mop поверх токенов бренда. */
  --bg-elev: var(--surface);
  --border: var(--line);
  --border-strong: #d3d8e2;
  --text: var(--ink);
  --text-muted: var(--muted);
  --text-subtle: var(--faint);
  --primary: var(--accent);
  --primary-soft: var(--accent-soft);
  --danger: var(--bad);
  --danger-soft: var(--bad-soft);
  --success: var(--ok);
  --success-soft: var(--ok-soft);
  --warning: var(--warn);
  --warning-soft: var(--warn-soft);
  --radius: var(--radius-panel);
  --shadow-sm: var(--shadow-card);
  --shadow: var(--shadow-up);
  --shadow-lg: var(--shadow-pop);
  --font: var(--sans);
}

:root[data-theme="dark"] {
  --border-strong: #343d4a;
}

* {
  box-sizing: border-box;
}

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

body.bark-app {
  background: var(--bg);
  color: var(--ink);
}

/* Текст ссылки — --accent-strong: чистый --accent на белом даёт 3,9:1, ниже AA (бренд 5.0.0). */
a {
  color: var(--accent-strong);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0;
}
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 15px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

p { margin: 0 0 8px; }

/* --- Layout --- */
.app-main {
  min-width: 0;
}

/* Общий a:hover специфичнее .bark-logo и .bark-sidebar__item из brand.css: без этого правила
   логотип и пункты меню подчёркиваются при наведении. */
.bark-logo:hover,
.bark-sidebar__item:hover { text-decoration: none; }

/* В brand.css у модалки и алерта свой display, и атрибут hidden без этого правила их не прячет. */
.bark-modal-backdrop[hidden],
.bark-alert[hidden] { display: none; }
.bark-modal__header h2 { margin: 0; }

/* «Сообщить о баге»: части диалога через 16px, чипы выбора потока в строку. */
.bug-report__body { display: grid; gap: var(--space-4); }
.bug-report__kinds { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-tile);
  background: linear-gradient(150deg, #1d2733, #14181f);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--logo-font);
  font-weight: 800;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.brand-mark img {
  display: block;
  width: 22px;
  height: 22px;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}
.container-wide {
  max-width: min(1760px, 100%);
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .muted { color: var(--text-muted); }

/* --- Cards / panels --- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.stat-value {
  font-size: 24px;
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-top: 4px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:disabled,
.btn[disabled] {
  background: var(--chip);
  border-color: var(--line-control);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 1;
}
.btn:disabled:hover { background: var(--chip); }
.btn:disabled:active { transform: none; }
.btn.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgb(20 24 31 / 38%);
  backdrop-filter: blur(2px);
}
.page-loader.is-visible {
  display: flex;
}
.page-loader-box {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
}
.page-loader-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loader-spin 0.8s linear infinite;
}
.page-loader-text {
  line-height: 1.35;
}
@keyframes loader-spin {
  to { transform: rotate(360deg); }
}
.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 1;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-strong);
  color: var(--on-fill);
  border-color: var(--accent-strong);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--chip);
  border-color: var(--line-control);
  color: var(--muted);
}

.btn-danger {
  background: var(--bad-strong);
  color: var(--on-fill);
  border-color: var(--bad-strong);
}
.btn-danger:hover { background: var(--bad-hover); border-color: var(--bad-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink2);
}
.btn-ghost:hover { background: var(--chip); color: var(--text); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn .icon {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 32px;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}
.icon-action:hover { background: var(--accent-soft); color: var(--accent); }
.icon-action:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-action .icon {
  fill: none;
  height: 17px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 17px;
}

/* --- Forms --- */
label.lbl, .form-label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  min-height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--field);
  transition: border 0.12s ease, box-shadow 0.12s ease;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:disabled, select.input:disabled, textarea.input:disabled {
  color: var(--text);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  opacity: 1;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
}
.input::placeholder { color: var(--text-subtle); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 auto; }

.field { margin-bottom: 14px; }
.field-reset { border: 0; margin: 0 0 14px; padding: 0; }
.access-note {
  background: var(--info-soft);
  border: 1px solid color-mix(in srgb, var(--info) 28%, transparent);
  border-radius: var(--radius-control);
  color: var(--ink2);
  margin-bottom: 16px;
  padding: 10px 12px;
}
.access-note-in-card { border-width: 0 0 1px; border-radius: 0; margin: 0; }

/* --- Flash --- */
.flash-wrap {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.flash {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: fadeSlide 0.2s ease;
}
.flash.success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash.warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.flash.info { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Login --- */
.login-bg {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-pop);
  padding: 32px;
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
}
.login-card .muted { color: var(--text-muted); margin-bottom: 24px; }

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card > .table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 2;
}
.table tbody tr:nth-child(even) { background: var(--surface-2); }
.table tbody tr:hover { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.table td.id, .table th.id { color: var(--text-muted); font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.table td.tight, .table th.tight { width: 1%; white-space: nowrap; }
.table .badge { font-size: 10px; }
.table .muted { font-size: 10.5px !important; }
.table .input,
.table .btn-sm { font-size: 11px; }

.table th a.sortable-head {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.table th a.sortable-head:hover { color: var(--text); }
.table th a.sortable-head.active { color: var(--primary); }
.table th a.sortable-head.active .sort-arrow { color: var(--accent); opacity: 1; }
.table th a.sortable-head .sort-arrow { font-size: 11px; opacity: 0.8; }

/* --- Pagination --- */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pager .pager-info { color: var(--text-muted); margin-right: 8px; }
.pager a, .pager span.cur {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  background: var(--bg-elev);
}
.pager a:hover { background: var(--bg); text-decoration: none; }
.pager span.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager .gap { padding: 0 2px; color: var(--text-subtle); }

/* --- Editable grid --- */
.grid-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.grid-toolbar .grow { flex: 1 1 260px; }
.grid-toolbar > select.input { width: auto; flex: 1 1 160px; }
.grid-toolbar > select[name="motivation_setup"] { flex-basis: 240px; }
.grid-toolbar > select[name="per"] { flex: 0 0 112px; }
.grid-status {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 120px;
}
.grid-status.dirty { color: var(--warning); font-weight: 600; }

.grid {
  font-size: 11px;
  min-width: 0;
}
.grid th, .grid td { padding: 12px; }
.grid .offer-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.grid .cell-editable {
  position: relative;
  padding: 0;
  min-width: 0;
  background: var(--surface);
}
.grid .cell-editable.readonly-sample {
  background: var(--surface-2);
}
.grid .readonly-cell {
  background: var(--surface-2);
  min-width: 0;
  padding: 0;
}
.grid .readonly-cell .cell-select {
  appearance: none;
  cursor: default;
  opacity: 1;
  pointer-events: none;
}
.grid .cell-input, .grid .cell-select {
  width: 100%;
  border: 0;
  outline: 0;
  min-width: 0;
  padding: 12px 8px;
  font-size: 11px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  height: 100%;
}

.offers-table-wrap {
  overflow-x: clip;
}
.offers-table {
  table-layout: fixed;
  width: 100%;
}
.offers-col-group { width: 12%; }
.offers-col-name { width: 18%; }
.offers-col-mot-group { width: 11%; }
.offers-col-level { width: 7%; }
.offers-col-money { width: 7%; }
.offers-col-percent { width: 5%; }
.offers-col-category { width: 12%; }
.offers-col-bonus { width: 9%; }
.offers-table th,
.offers-table td {
  min-width: 0;
}
.offers-table th a.sortable-head {
  line-height: 1.25;
  white-space: normal;
}
.offers-table .badge {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.offers-table .cell-select {
  font-size: 11px;
  text-overflow: ellipsis;
}
.grid .auto-badge {
  position: absolute;
  right: 6px;
  bottom: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 10px;
  line-height: 1.3;
  pointer-events: auto;
  cursor: help;
}
.bonus-value-cell {
  position: relative;
}
.bonus-value-row {
  align-items: center;
  display: flex;
  gap: 3px;
  justify-content: flex-end;
  min-width: 0;
}
.bonus-value {
  cursor: help;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.bonus-edit {
  margin: -5px -5px -5px 1px;
  transition: background 0.1s ease, color 0.1s ease;
}
.bonus-meta-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 3px 5px;
  justify-content: flex-end;
  margin-top: 2px;
  min-height: 14px;
}
.bonus-change-badge,
.auto-badge-inline,
.bonus-lock-badge,
.history-status {
  border-radius: 999px;
  display: inline-flex;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 6px;
  white-space: nowrap;
}
.bonus-change-badge.temporary {
  background: var(--warn-soft);
  color: var(--warn);
}
.bonus-change-badge.permanent {
  background: var(--accent-soft);
  color: var(--accent);
}
.auto-badge-inline {
  background: var(--ok-soft);
  color: var(--ok);
  cursor: help;
}
.bonus-lock-badge {
  align-items: center;
  background: var(--warn-soft);
  color: var(--warn);
  justify-content: center;
  margin-right: auto;
  padding: 2px 5px;
}
.bonus-lock-badge .icon {
  fill: none;
  height: 12px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  width: 12px;
}
.offers-table td.bonus-change-temporary {
  background: var(--warn-soft) !important;
  box-shadow: inset 3px 0 0 var(--warn);
}
.offers-table td.bonus-change-permanent {
  background: var(--accent-soft) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.grid td[data-field="bonus"] .cell-input {
  padding-right: 52px;
}
.quick-tip {
  position: fixed;
  z-index: 2000;
  max-width: 380px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.06s ease, transform 0.06s ease;
}
.quick-tip.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Fixed bonus editor and history --- */
.app-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  max-height: min(760px, calc(100dvh - 32px));
  max-width: calc(100vw - 32px);
  overflow: auto;
  padding: 0;
  width: 560px;
}
.app-dialog::backdrop {
  background: rgb(20 24 31 / 48%);
  backdrop-filter: blur(2px);
}
.dialog-header,
.dialog-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 20px;
}
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 2px 0 0; }
.dialog-footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.dialog-body { padding: 20px; }
.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.bonus-dialog-offer {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}
.bonus-values-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}
.bonus-values-grid .num { font-family: var(--mono); text-align: right; }
.bonus-autofill-setting {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-bottom: 16px;
  padding: 12px 0;
}
.bonus-autofill-help {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 0 48px;
}
.segment-control {
  background: var(--chip);
  border-radius: 10px;
  display: inline-grid;
  gap: 2px;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 3px;
}
.segment-control label { cursor: pointer; margin: 0; }
.segment-control input { opacity: 0; pointer-events: none; position: absolute; }
.segment-control span {
  align-items: center;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
}
.segment-control input:checked + span {
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--accent);
}
.segment-control input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.bonus-mode-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bonus-comment { line-height: 1.45; min-height: 84px; padding: 10px 12px !important; resize: vertical; }
.bonus-history-link { display: inline-flex; font-size: 13px; font-weight: 500; }
.button-count {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
}
.history-control-bar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}
.history-scope-tabs {
  background: var(--chip);
  border-radius: 10px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}
.history-scope-tabs a {
  align-items: center;
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 500;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  text-decoration: none;
}
.history-scope-tabs a:hover { color: var(--ink); }
.history-scope-tabs a.active {
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--accent);
}
.history-scope-tabs a span {
  font-family: var(--mono);
  font-size: 11px;
}
.history-active-summary {
  align-items: center;
  display: flex;
  font-size: 12px;
  gap: 8px;
}
.history-active-summary span {
  border-radius: 999px;
  padding: 5px 9px;
}
.history-active-summary .temporary { background: var(--warn-soft); color: var(--warn); }
.history-active-summary .permanent { background: var(--accent-soft); color: var(--accent); }
.bonus-automation-status {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 3px;
  display: grid;
  gap: 12px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  margin-bottom: 14px;
  min-height: 72px;
  padding: 12px 14px;
}
.bonus-automation-status.is-healthy { border-left-color: var(--ok); }
.bonus-automation-status.is-warning { border-left-color: var(--bad); }
.bonus-automation-status__icon {
  align-items: center;
  background: var(--ok-soft);
  border-radius: 50%;
  color: var(--ok);
  display: flex;
  font-size: 15px;
  font-weight: 600;
  height: 28px;
  justify-content: center;
  width: 28px;
}
.bonus-automation-status.is-warning .bonus-automation-status__icon {
  background: var(--bad-soft);
  color: var(--bad);
}
.bonus-automation-status__body { display: grid; font-size: 12px; gap: 2px; }
.bonus-automation-status__body strong { color: var(--ink); font-size: 13px; }
.bonus-automation-status__body span { color: var(--muted); }
.bonus-automation-status__stats { display: flex; font-size: 11px; gap: 10px; white-space: nowrap; }
.bonus-automation-status__stats span { color: var(--muted); }
.bonus-automation-status__stats strong { color: var(--ink); font-family: var(--mono); }
.bonus-history-table { min-width: 1080px; }
.bonus-history-table td { vertical-align: top; }
.bonus-history-table .history-active-temporary td { background: color-mix(in srgb, var(--warn-soft) 52%, var(--surface)); }
.bonus-history-table .history-active-temporary td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.bonus-history-table .history-active-permanent td { background: color-mix(in srgb, var(--accent-soft) 48%, var(--surface)); }
.bonus-history-table .history-active-permanent td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.history-offer-name { color: var(--ink); font-weight: 600; }
.history-change-value { white-space: nowrap; }
.history-old-value { color: var(--muted); font-weight: 400; }
.history-date { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bonus-countdown {
  color: var(--warn);
  font-family: var(--mono);
  font-size: 10px;
  margin-top: 4px;
  white-space: nowrap;
}
.bonus-countdown.is-due,
.bonus-countdown-inline.is-due { color: var(--bad); }
.bonus-auto-return-label {
  color: var(--ok);
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}
.bonus-countdown-inline {
  color: var(--warn);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}
.history-status { background: var(--surface-2); color: var(--muted); }
.history-status.status-active { background: var(--accent-soft); color: var(--accent); }
.history-status.status-reverted { background: var(--ok-soft); color: var(--ok); }
.history-status.status-failed { background: var(--bad-soft); color: var(--bad); }
.empty-table-cell { color: var(--muted); padding: 32px !important; text-align: center !important; }
/* Числовые ячейки: inputs выравниваем по правому краю под заголовок */
.grid td.num .cell-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.grid .cell-input:focus, .grid .cell-select:focus {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.grid .cell-editable.dirty {
  background: var(--warn-soft);
}
.grid .cell-editable.dirty::before {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warning);
}
.grid .cell-editable.invalid {
  background: var(--danger-soft);
}
.grid .cell-editable.invalid::before {
  background: var(--danger);
}
.grid .cell-editable.selected {
  box-shadow: inset 0 0 0 2px var(--primary);
  z-index: 1;
}
.grid .cell-editable.range {
  background: var(--primary-soft);
}
.fill-handle {
  display: none;
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 10px;
  height: 10px;
  background: var(--primary);
  border: 2px solid var(--surface);
  border-radius: 2px;
  cursor: crosshair;
  z-index: 3;
}
/* Показываем fill-handle при наведении на строку или когда ячейка selected */
.grid tbody tr:hover .cell-editable .fill-handle,
.grid .cell-editable.selected .fill-handle {
  display: block;
}

.grid-footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.cat-1 { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.cat-2 { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.cat-3 { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.empty { background: transparent; color: var(--text-subtle); border-color: var(--border); }

.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* --- Salary control and read-only calculator --- */
.page-eyebrow {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin-bottom: 5px;
  text-transform: uppercase;
}
.control-page-header .muted,
.calculator-header .muted {
  margin: 5px 0 0;
}
.control-freshness {
  align-items: flex-end;
  color: var(--faint);
  display: flex;
  flex-direction: column;
  font-size: 11px;
  gap: 1px;
}
.control-freshness strong {
  color: var(--ink2);
  font-size: 12px;
  font-weight: 600;
}
.control-filters {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
  grid-template-columns: 168px 168px minmax(220px, 1fr) auto;
  margin-bottom: 16px;
  padding: 16px;
}
.control-filters .form-label { color: var(--muted); }
.control-filter-submit { min-width: 112px; }
.control-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}
.control-stats .stat { min-width: 0; }
.control-stats .stat--accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.control-stats .stat--accent .stat-value { color: var(--accent); }
.issue-groups {
  display: grid;
  gap: 10px;
}
.issue-group {
  --issue-color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-card);
  min-width: 0;
  overflow: hidden;
}
.issue-group--danger { --issue-color: var(--bad); }
.issue-group--warning { --issue-color: var(--warn); }
.issue-group--info { --issue-color: var(--info); }
.issue-group--muted { --issue-color: var(--faint); }
.issue-group > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 14px;
  grid-template-columns: 9px minmax(260px, 1fr) 92px minmax(146px, auto) 24px;
  list-style: none;
  min-height: 76px;
  padding: 13px 16px;
}
.issue-group > summary::-webkit-details-marker { display: none; }
.issue-group > summary:hover { background: var(--surface-2); }
.issue-group[open] > summary { border-bottom: 1px solid var(--line); }
.issue-group__marker {
  background: var(--issue-color);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}
.issue-group__heading,
.issue-group__metric {
  display: grid;
  min-width: 0;
}
.issue-group__heading strong {
  font-size: 14px;
  font-weight: 600;
}
.issue-group__heading span,
.issue-group__metric span {
  color: var(--muted);
  font-size: 11px;
}
.issue-group__metric {
  justify-items: end;
}
.issue-group__metric strong {
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.issue-group__chevron {
  color: var(--faint);
  font-size: 24px;
  line-height: 1;
  text-align: center;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}
.issue-group[open] .issue-group__chevron { transform: rotate(90deg); }
.control-table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.control-table {
  font-size: 11px;
  table-layout: fixed;
}
.control-table th,
.control-table td { padding: 11px 12px; }
.control-table th:nth-child(1) { width: 11%; }
.control-table th:nth-child(2) { width: 9%; }
.control-table th:nth-child(3) { width: 16%; }
.control-table th:nth-child(4) { width: 17%; }
.control-table th:nth-child(5) { width: 12%; }
.control-table th:nth-child(6) { width: 12%; }
.control-table th:nth-child(7) { width: 23%; }
.crm-order-link {
  align-items: center;
  display: inline-flex;
  font-family: var(--mono);
  font-weight: 600;
  gap: 4px;
}
.crm-order-link span { font-family: var(--sans); }
.cell-primary {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.cell-meta {
  color: var(--faint);
  font-size: 10.5px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.manager-state {
  border-radius: 999px;
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 7px;
}
.manager-state.state-ok { background: var(--ok-soft); color: var(--ok); }
.manager-state.state-warn { background: var(--warn-soft); color: var(--warn); }
.manager-state.state-bad { background: var(--bad-soft); color: var(--bad); }
.control-reason > span {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.missing-products {
  display: grid;
  gap: 7px;
}
.missing-product {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.missing-product strong {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.missing-product > span {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.missing-product em {
  background: var(--warn-soft);
  border-radius: 999px;
  color: var(--warn);
  font-size: 9.5px;
  font-style: normal;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 6px;
}
.cell-delta {
  font-size: 10.5px;
  margin-top: 2px;
}
.cell-delta.positive { color: var(--ok); }
.cell-delta.negative { color: var(--bad); }
.control-empty {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  display: flex;
  gap: 14px;
  padding: 24px;
}
.control-empty > span {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 50%;
  color: var(--accent);
  display: inline-flex;
  flex: none;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  width: 36px;
}
.control-empty p { color: var(--muted); margin: 2px 0 0; }

.motivation-calculator {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-card);
  margin-top: 24px;
  overflow: hidden;
}
.calculator-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px 20px;
}
.calculator-readonly {
  background: var(--ok-soft);
  border-radius: 999px;
  color: var(--ok);
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
}
.calculator-body { padding: 20px; }
.calc-order-loader {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 560px) max-content;
  margin-bottom: 0;
}
.calc-order-loader .btn { justify-self: start; }
.calculator-order {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  margin-top: 16px;
  overflow: hidden;
}
.calculator-order__header {
  align-items: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 11px 13px;
}
.calculator-order__header > div:first-child {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
}
.calculator-order__link {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.calculator-order__header [data-order-project] {
  color: var(--muted);
  font-size: 12px;
}
.calculator-order__count {
  color: var(--faint);
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
}
.calculator-order__items { display: grid; }
.calculator-order__item {
  align-items: center;
  border-bottom: 1px solid var(--line-2);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 130px 54px;
  min-height: 42px;
  padding: 8px 13px;
}
.calculator-order__item:last-child { border-bottom: 0; }
.calculator-order__item strong {
  font-size: 12.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.calculator-order__price,
.calculator-order__quantity {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.calculator-order__quantity { color: var(--muted); }
.calculator-order[hidden],
.calculator-result[hidden] { display: none; }
.calculator-error[hidden] { display: none; }
.calculator-order + .calculator-result {
  margin-top: 16px;
}
.calculator-error {
  background: var(--bad-soft);
  border: 1px solid color-mix(in srgb, var(--bad) 24%, transparent);
  border-radius: var(--radius-control);
  color: var(--bad);
  margin-top: 14px;
  padding: 10px 12px;
}
.calculator-result {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}
.calculator-result__summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.calculator-result__summary > div {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  display: grid;
  gap: 4px;
  padding: 13px 14px;
}
.calculator-result__summary span {
  color: var(--muted);
  font-size: 11px;
}
.calculator-result__summary strong {
  font-family: var(--mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.calculator-result__summary > div:first-child {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.calculator-result__summary > div:first-child strong { color: var(--accent); }
.calculator-formula {
  color: var(--ink2);
  font-family: var(--mono);
  font-size: 12px;
  margin: 13px 0;
}
.calculator-result__table-wrap { box-shadow: none; }
.calculator-result__table { font-size: 11px; }

@media (max-width: 1100px) {
  .issue-group > summary {
    grid-template-columns: 9px minmax(220px, 1fr) 80px minmax(130px, auto) 24px;
  }
  .issue-group__heading span { display: none; }
  .control-table { font-size: 11px; }
  .control-table th,
  .control-table td { padding-left: 9px; padding-right: 9px; }
}

/* --- Calc icon + custom tooltip --- */
.calc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  font-size: 13px;
  color: var(--text-subtle);
  text-decoration: none;
  cursor: help;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
}
.calc-icon:hover {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

.info-popover {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-muted);
  background: var(--bg-elev);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}
.info-popover:hover,
.info-popover:focus {
  color: var(--primary);
  border-color: var(--primary);
  outline: none;
}
.info-popover-box {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 1000;
  display: none;
  width: min(520px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}
.info-popover-box code {
  font-size: 12px;
}
.info-popover:hover .info-popover-box,
.info-popover:focus .info-popover-box {
  display: block;
}

.calc-tip {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  min-width: 420px;
  max-width: 640px;
  pointer-events: none;
  animation: tipShow 0.12s ease;
}
@keyframes tipShow {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.calc-tip .tip-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.calc-tip .tip-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}
.calc-tip .tip-table th {
  text-align: left;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
.calc-tip .tip-table th.num { text-align: right; }
.calc-tip .tip-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.calc-tip .tip-table tr:last-child td { border-bottom: none; }
.calc-tip .tip-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-tip .tip-name { max-width: 260px; }

.calc-tip .tip-muted { color: var(--text-muted); }

.calc-tip .tip-foot {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.calc-tip .tip-foot .tip-total {
  margin-left: auto;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.tip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}
.tip-tag.tip-anchor { background: var(--primary-soft); color: var(--primary); }
.tip-tag.tip-plus   { background: var(--success-soft); color: var(--success); }
.tip-tag.tip-1p     { background: var(--warn-soft); color: var(--warn); }
.tip-tag.tip-nocat  { background: var(--danger-soft); color: var(--danger); }

.anchor-icon {
  display: inline-block;
  width: 13px;
  height: 13px;
  background: currentColor;
  -webkit-mask: url('../icons/anchor.svg') center / contain no-repeat;
  mask: url('../icons/anchor.svg') center / contain no-repeat;
  vertical-align: -2px;
}
.tip-tag .anchor-icon {
  flex: 0 0 auto;
}
.anchor-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* --- Multiselect (поиск с чипами) --- */
.ms-field { position: relative; }
.ms-chips {
  min-height: 38px;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--bg-elev);
  display: flex; flex-wrap: wrap; gap: 4px;
  align-items: center; cursor: text;
  transition: border 0.12s, box-shadow 0.12s;
}
.ms-field:focus-within .ms-chips {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ms-chip {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 260px;
}
.ms-chip > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chip-x {
  cursor: pointer; opacity: 0.7; font-size: 11px;
  padding: 0 2px;
}
.ms-chip-x:hover { opacity: 1; color: var(--danger); }
.ms-input {
  border: 0; outline: 0; background: transparent;
  font-size: 14px; padding: 4px;
  min-width: 140px; flex: 1;
  font-family: inherit; color: var(--text);
}
.ms-input::placeholder { color: var(--text-subtle); }
.ms-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  z-index: 80; background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto;
  margin-top: 4px;
}
.ms-opt {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line-2);
}
.ms-opt:last-child { border-bottom: none; }
.ms-opt:hover, .ms-opt.active { background: var(--primary-soft); }
.ms-opt mark { background: var(--warn-soft); color: var(--text); padding: 0; border-radius: 2px; }
.ms-opt-meta { font-size: 11px; color: var(--text-muted); display: block; margin-top: 2px; }
.ms-opt.ms-inactive { opacity: 0.65; }
.ms-opt.ms-empty { color: var(--text-muted); cursor: default; font-style: italic; }

/* Warn icon + warn tooltip sections */
.warn-icon {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 600;
  cursor: help;
  white-space: nowrap;
}
.warn-icon:hover { filter: brightness(0.95); }
.calc-tip .tip-warn-sec { margin-top: 8px; }
.calc-tip .tip-warn-sec:first-of-type { margin-top: 4px; }
.calc-tip .tip-warn-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.calc-tip .tip-warn-sec ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
}
.calc-tip .tip-warn-sec li { padding: 1px 0; }

/* --- Misc --- */
.hr { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

@media (max-width: 720px) {
  .topbar-inner { padding: 10px 16px; }
  .container { padding: 16px; }
  .nav .label { display: none; }

  .page-header {
    align-items: flex-start;
  }
  .page-header > .row {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .page-header > .row > .muted {
    align-self: center;
    grid-column: 1 / -1;
  }
  .page-header .btn {
    justify-content: center;
    min-width: 0;
  }
  .grid-toolbar > *,
  .grid-toolbar > select.input,
  .grid-toolbar > select[name="motivation_setup"],
  .grid-toolbar > select[name="per"] {
    flex: 1 1 100%;
    width: 100%;
  }
  .offers-editor {
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .offers-editor > .card-header {
    padding: 16px 0;
  }
  .offers-editor > .card-footer {
    background: transparent;
    padding: 16px 0 0;
  }
  .offers-table-wrap {
    background: transparent;
  }
  .offers-table,
  .offers-table tbody,
  .offers-table tr,
  .offers-table td {
    display: block;
    width: 100%;
  }
  .offers-table colgroup,
  .offers-table thead {
    display: none;
  }
  .offers-table tbody {
    display: grid;
    gap: 12px;
  }
  .offers-table tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-card);
    overflow: hidden;
  }
  .offers-table tbody tr:hover,
  .offers-table tbody tr:nth-child(even) {
    background: var(--surface);
  }
  .offers-table tbody td {
    align-items: center;
    border-bottom: 1px solid var(--line-2);
    display: grid;
    grid-template-columns: minmax(112px, 38%) minmax(0, 1fr);
    min-height: 44px;
    padding: 8px 12px;
    text-align: left;
  }
  .offers-table tbody td:last-child {
    border-bottom: 0;
  }
  .offers-table tbody td::before {
    color: var(--faint);
    content: attr(data-label);
    font: 600 10.5px/1.3 var(--sans);
    padding-right: 12px;
    text-transform: uppercase;
  }
  .offers-table tbody td.num {
    text-align: left;
  }
  .offers-table .cell-editable {
    padding: 0 12px;
  }
  .offers-table .cell-editable::before {
    align-self: center;
  }
  .offers-table .cell-input,
  .offers-table .cell-select {
    min-height: 43px;
    padding: 8px 0;
  }
  .offers-table td.num .cell-input {
    text-align: left;
  }
  .offers-table .readonly-cell {
    padding: 0 12px;
  }
  .bonus-value-row,
  .bonus-meta-row {
    justify-content: flex-start;
  }
  .icon-action {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }
  .bonus-edit { margin: -8px 0 -8px -4px; }
  .app-dialog {
    max-height: calc(100dvh - 16px);
    max-width: calc(100vw - 16px);
    width: calc(100vw - 16px);
  }
  .bonus-values-grid { grid-template-columns: 1fr; }
  .dialog-footer .btn { flex: 1 1 0; justify-content: center; }
}

@media (max-width: 900px) {
  .container,
  .container-wide {
    max-width: 100%;
    padding: 16px;
  }
  .control-filters {
    grid-template-columns: 1fr 1fr;
  }
  .control-filter-reason { grid-column: 1 / -1; }
  .control-filter-submit { justify-self: start; }
  .issue-group > summary {
    grid-template-columns: 9px minmax(180px, 1fr) 76px 24px;
  }
  .issue-group__amount { display: none; }
}

@media (max-width: 720px) {
  .history-control-bar { align-items: stretch; flex-direction: column; }
  .history-scope-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-scope-tabs a { justify-content: center; }
  .history-active-summary { flex-wrap: wrap; }
  .bonus-automation-status { align-items: start; grid-template-columns: 30px minmax(0, 1fr); }
  .bonus-automation-status__stats { flex-wrap: wrap; grid-column: 1 / -1; padding-left: 42px; }
  .control-freshness { align-items: flex-start; }
  .control-filters { grid-template-columns: 1fr 1fr; }
  .control-filter-submit {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: center;
  }
  .control-stats { grid-template-columns: 1fr; }
  .issue-group > summary {
    gap: 10px;
    grid-template-columns: 8px minmax(0, 1fr) 66px 20px;
    min-height: 68px;
    padding: 11px 12px;
  }
  .issue-group__heading strong { font-size: 13px; }
  .issue-group__metric strong { font-size: 12px; }
  .control-table,
  .control-table tbody,
  .control-table tr,
  .control-table td,
  .calculator-result__table,
  .calculator-result__table tbody,
  .calculator-result__table tr,
  .calculator-result__table td {
    display: block;
    width: 100%;
  }
  .control-table thead,
  .calculator-result__table thead { display: none; }
  .control-table tbody,
  .calculator-result__table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }
  .control-table tbody tr,
  .calculator-result__table tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    overflow: hidden;
  }
  .control-table tbody tr:nth-child(even),
  .control-table tbody tr:hover,
  .calculator-result__table tbody tr:nth-child(even),
  .calculator-result__table tbody tr:hover { background: var(--surface); }
  .control-table tbody td,
  .calculator-result__table tbody td {
    align-items: start;
    border-bottom: 1px solid var(--line-2);
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(100px, 38%) minmax(0, 1fr);
    min-height: 42px;
    padding: 8px 10px;
    text-align: left;
  }
  .control-table tbody td:last-child,
  .calculator-result__table tbody td:last-child { border-bottom: 0; }
  .control-table tbody td::before,
  .calculator-result__table tbody td::before {
    color: var(--faint);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
  }
  .control-table tbody td.num,
  .calculator-result__table tbody td.num { text-align: left; }
  .calc-order-loader { grid-template-columns: 1fr; }
  .calc-order-loader .btn { justify-content: center; }
  .calculator-header { padding: 16px; }
  .calculator-readonly { display: none; }
  .calculator-body { padding: 16px; }
  .calculator-order__header { align-items: flex-start; }
  .calculator-order__header > div:first-child { display: grid; gap: 2px; }
  .calculator-order__item {
    gap: 6px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .calculator-order__item strong { grid-column: 1 / -1; }
  .calculator-order__price { text-align: left; }
  .calculator-result__summary { grid-template-columns: 1fr; }
  .calculator-result__table tbody td::before { content: none; }
  .calculator-result__table tbody td {
    display: flex;
    justify-content: space-between;
  }
  .calculator-result__table tbody td:first-child {
    font-weight: 600;
    justify-content: flex-start;
  }
}

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

/* ---- Типы цен ---- */
.prices-page { display: flex; flex-direction: column; gap: var(--space-4); }
.prices-page .inline-form { display: inline-flex; margin: 0; }
.prices-page .small { font-size: 12px; }
.prices-page .grow { flex: 1 1 auto; }
.prices-page .num { text-align: right; }
.prices-page .nowrap { white-space: nowrap; }

/* Шапка: заголовок не сжимается в столбик, кнопки на узком экране уходят под него. */
.prices-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.prices-head h1 { flex: 1 1 12ch; min-width: 0; margin: 0; }
.prices-head__tools { display: flex; flex-wrap: wrap; gap: 8px; }
.prices-lead { max-width: var(--reading-max); margin: 0; color: var(--ink2); }
.prices-back { align-self: flex-start; font-size: 13px; }

/* Плашка «Цены в CRM» над таблицей: ушли ли цены и когда. */
.prices-crm { align-items: center; }
.prices-crm__body { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.prices-crm__title { color: var(--ink); font-weight: 700; }
.prices-alert { align-items: center; }
.prices-alert p { margin: 0 0 8px; }
.prices-owner__form { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.prices-owner__return { font-size: 13px; color: var(--ink2); }
.prices-owner__return > summary { cursor: pointer; }

/* Панель не обрезает выпадающий список колонок и липкую панель «Изменено». */
.prices-panel { overflow: visible; }

/* Тулбар: поиск и не больше трёх отборов (контракт бренд-системы). */
.prices-toolbar { padding: 12px 16px; }
.prices-search { position: relative; display: flex; align-items: center; flex: 1 1 240px; min-width: 220px; max-width: 420px; }
.prices-search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.prices-search .bark-field__control { width: 100%; padding-left: 34px; }
.prices-toolbar select.bark-field__control { width: auto; max-width: 280px; }
.prices-toolbar__check { font-size: 13px; color: var(--ink2); white-space: nowrap; }
.prices-per { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); }
.prices-per .bark-field__control { width: auto; }

/* Пока список подгружается: полоса над таблицей и приглушённые строки — клик принят. */
.prices-progress { position: relative; height: 2px; overflow: hidden; }
.prices-progress::after {
  content: ""; position: absolute; top: 0; left: 0; width: 30%; height: 2px;
  background: var(--accent); opacity: 0; transform: translateX(-100%);
}
[data-live].is-loading .prices-progress::after { opacity: 1; animation: prices-progress 900ms var(--ease-out) infinite; }
[data-live-region] { overflow-anchor: none; }
.prices-list { transition: opacity var(--motion-base) var(--ease-out); }
[data-live].is-loading .prices-list { opacity: 0.5; }
@keyframes prices-progress { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* Таблицы раздела: своя прокрутка, шапка остаётся на месте. */
.prices-table-wrap { overflow: auto; max-height: max(420px, calc(100vh - 300px)); }
.prices-table-wrap .bark-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); vertical-align: bottom; }
.prices-page .bark-table__sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: none; }
.prices-page .bark-table__sort:hover { text-decoration: none; }
.prices-page th[aria-sort="ascending"] .bark-table__sort,
.prices-page th[aria-sort="descending"] .bark-table__sort { color: var(--accent-strong); }
.prices-page th.num .bark-table__sort { justify-content: flex-end; }
.prices-table th.num { min-width: 120px; }
.prices-table th .prices-th-rule {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; white-space: nowrap;
  color: var(--accent-strong); font: 500 11px/1.2 var(--mono); letter-spacing: 0; text-transform: none;
}
.prices-offer { min-width: 240px; }
/* «история» рядом с названием — тише названия, чтобы не спорить с ним. */
.prices-offer__history { margin-left: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; text-decoration: none; border-bottom: 1px dashed currentColor; }
.prices-offer__history:hover { color: var(--ink2); text-decoration: none; }
.prices-offer .bark-pill { margin-left: 6px; }
.prices-offer__meta { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.prices-table td { vertical-align: middle; }
.prices-table .price-cell { min-width: 120px; white-space: nowrap; transition: background var(--motion-slow) var(--ease-out); }
.price-cell__in { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.prices-table .price-input { width: 104px; text-align: right; }
.prices-table .price-value { display: inline-flex; align-items: center; gap: 6px; color: var(--ink2); }
.prices-lock { flex: none; width: 12px; height: 12px; color: var(--muted); }
.prices-tag {
  display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--chip); color: var(--ink2); font-size: 11px; font-weight: 600;
}
.prices-tag--warn { background: var(--warn-soft); color: var(--warn-strong); }
.prices-next { display: block; margin-top: 2px; font-size: 11px; line-height: 1.2; }
.prices-table td.is-stale .prices-next { color: var(--warn-strong); }
.prices-table td.is-stale { box-shadow: inset 3px 0 0 var(--warn); }
.prices-table td.is-add .prices-next { color: var(--accent-strong); }
.prices-table td.is-add { box-shadow: inset 3px 0 0 var(--accent); }
.prices-table td.is-above, .prices-table td.is-above-live { color: var(--bad-strong); font-weight: 600; }
.prices-table td.is-above .prices-next { color: var(--bad-strong); }
.prices-table td.is-above { box-shadow: inset 3px 0 0 var(--bad); }
.prices-table td.is-above .price-input, .prices-table td.is-above-live .price-input { color: var(--bad-strong); border-color: var(--bad); }
.prices-table td.is-drift .price-input, .prices-table td.is-drift .price-value { text-decoration: underline dotted var(--warn-strong); }
.prices-table td.is-dirty .price-input { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.prices-table td.is-invalid .price-input { background: var(--bad-soft); border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
/* Только что ушла в CRM: зелёная подсветка гаснет за 1,6 с. */
.prices-table td.is-sent { background: var(--ok-soft); transition: none; }
.prices-table td.is-sent-fade { transition: background 1600ms var(--ease-out); }
.table tr.is-bad td, .bark-table tr.is-bad td { color: var(--bad-strong); }

/* «Изменено: N» — появляется, только когда есть правки, и не лежит поверх строк. */
.prices-savebar {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 16px;
  background: var(--accent-soft); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-panel) var(--radius-panel);
  padding-right: calc(16px + var(--corner-reserve, 0px)); /* справа — место под кнопкой «Сообщить о баге» */
  animation: prices-rise var(--motion-base) var(--ease-out);
}
.prices-savebar[hidden] { display: none; }
.prices-savebar__count { color: var(--ink); font-size: 14px; }
.prices-savebar__hint { color: var(--bad-strong); font-size: 13px; font-weight: 600; }
.prices-savebar .bark-btn svg { width: 16px; height: 16px; }
@keyframes prices-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.prices-columns { position: relative; }
.prices-columns > summary { list-style: none; cursor: pointer; }
.prices-columns > summary::-webkit-details-marker { display: none; }
.prices-columns__list {
  position: absolute; z-index: var(--z-dropdown); right: 0; top: calc(100% + 6px);
  width: min(420px, 90vw); max-height: 60vh; overflow: auto;
  padding: 10px 12px; display: grid; gap: 6px;
  background: var(--surface-pop); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: var(--shadow-pop);
}
.prices-columns__actions { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.prices-columns__item { display: flex; align-items: center; gap: 8px; }
.prices-columns__stat { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.prices-columns__hint { margin: 0; color: var(--muted); font-size: 12px; }

.prices-bulk > summary { cursor: pointer; list-style: none; }
.prices-bulk > summary::-webkit-details-marker { display: none; }
.prices-bulk__form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.prices-bulk__form .bark-field__control { width: auto; }
.prices-bulk__form input[name="bulk_value"] { width: 120px; }

/* Шаблоны */
.prices-templates__footer { justify-content: space-between; align-items: center; }
.prices-manual { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.prices-manual > summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.prices-manual__list { display: flex; flex-wrap: wrap; gap: 8px; }
.prices-manual__list .bark-toggle-chip { text-decoration: none; }
.prices-add { color: var(--accent-strong); font-size: 12px; }
.prices-warn { color: var(--warn-strong); }
.prices-bad { color: var(--bad-strong); font-weight: 600; }
/* Сводка предпросмотра — отдельной строкой под заголовком, а не рядом: длинная наезжала на него. */
.prices-preview__head { flex-wrap: wrap; row-gap: 4px; }
.prices-preview__stats { flex: 1 1 100%; color: var(--muted); font-size: 12px; }

/* История */
.prices-history__when { white-space: nowrap; color: var(--ink2); }
.prices-history__crm { white-space: nowrap; }
.prices-history td:nth-child(3) { min-width: 120px; }
/* Комментарий источника — одной строкой, полностью во всплывающей подсказке. */
.prices-history__comment { max-width: 240px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.prices-history__crm .bark-pill { gap: 4px; }
.prices-history__crm .bark-pill svg { width: 12px; height: 12px; }

/* Помощь */
.prices-help { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.prices-help__toc { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.prices-help__toc a { padding: 8px 12px; border-radius: 8px; color: var(--ink2); font-size: 14px; text-decoration: none; }
.prices-help__toc a:hover { background: var(--chip); color: var(--ink); text-decoration: none; }
.prices-help__body { display: flex; flex-direction: column; gap: 16px; max-width: var(--reading-max); }
.prices-help__section { padding: 20px 24px; scroll-margin-top: 16px; }
.prices-help__section h2 { margin: 0 0 8px; }
.prices-help__section ul, .prices-help__section ol { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 20px; color: var(--ink2); line-height: 1.55; }

/* Акции */
/* «Требует внимания»: разделы складываются, открыт «Поменяли в CRM» или единственный. */
.promos-attention { margin: 0 0 16px; }
.promos-attention .bark-panel__header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.promos-attention .bark-panel__title { display: inline-flex; align-items: center; gap: 8px; }
.promos-attention__group { border-top: 1px solid var(--line); }
.promos-attention__group > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px; cursor: pointer;
  color: var(--ink); font-size: 14px; font-weight: 600; list-style: none;
}
.promos-attention__group > summary::-webkit-details-marker { display: none; }
.promos-attention__group > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin-right: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform var(--motion-fast) var(--ease-out);
}
.promos-attention__group[open] > summary::before { transform: rotate(45deg); }
.promos-attention__group > summary:hover { background: var(--surface-2); }
.promos-attention__group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.promos-attention__group > summary .bark-data { color: var(--muted); font-weight: 500; }
.promos-attention__hint { margin: 0; padding: 0 20px 8px; color: var(--muted); font-size: 13px; }
.promos-attention__list { display: flex; flex-direction: column; margin: 0 20px 16px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 10px; }
.promos-attention__item { padding: 10px 12px; border-top: 1px solid var(--line); }
.promos-attention__item:first-child { border-top: 0; }
.promos-attention__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.promos-attention__head > a:first-child { font-weight: 600; }
.promos-attention__actions { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.promos-attention__note { margin: 6px 0 0; color: var(--ink2); font-size: 13px; }
.promos-diff { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 8px 0 0; font-size: 13px; }
.promos-diff dt { color: var(--muted); font-weight: 600; }
.promos-diff dd { margin: 0; min-width: 0; color: var(--ink2); }
.promos-diff del, .promos-diff ins { padding: 0 2px; border-radius: 3px; text-decoration: none; }
.promos-diff del { background: var(--bad-soft); color: var(--bad-strong); text-decoration: line-through; }
.promos-diff ins { background: var(--ok-soft); color: var(--ink); }
.promos-diff__text { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 400 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.promos-unused-ok { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.promo-crm-changed { margin: 0 0 16px; }
.promo-term__name { flex: 1 1 100%; }
.promo-term__name .bark-field__control { width: 100%; max-width: 480px; }
.promo-term__warn { color: var(--warn-strong); }
.promos-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--chip); }
.promos-tabs a { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 8px; color: var(--ink2); font-size: 13px; font-weight: 600; text-decoration: none; }
.promos-tabs a:hover { color: var(--ink); text-decoration: none; }
.promos-tabs a[aria-current="page"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-card); }
.promos-tabs .bark-data { font-weight: 500; }
.promos-table__name { min-width: 260px; }
.promo-facts__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.promo-facts__grid > div { display: flex; flex-direction: column; gap: 4px; }
.promo-facts__label { color: var(--muted); font-size: 12px; font-weight: 600; }
.promo-condition { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); }
.promo-condition summary { cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 600; }
.promo-code, .promo-desc { margin: 8px 0 0; padding: 12px; border-radius: 8px; font: 400 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.promo-code { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.promo-desc { color: var(--ink2); }
.promo-term__body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.promo-term__kind { margin: 0; padding: 0; border: 0; }
.promo-term__dates { display: flex; flex-wrap: wrap; gap: 12px; }
.promo-term__dates .bark-field__control { width: 170px; }
/* Бессрочной акции даты не нужны. */
.promo-term:has(input[value="permanent"]:checked) .promo-term__dates { display: none; }
.promo-term__hint { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: 12px; }
.promo-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
/* «Как работает» — главное в карточке: крупно над цифрами; не описано — предупреждение. */
.promo-rules { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; padding: 14px 16px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); }
.promo-rules__text { margin: 0; color: var(--ink); font-size: 15px; line-height: 1.5; }
.promo-rules--missing { background: var(--warn-soft); }
.promo-rules--missing .promo-rules__text { color: var(--warn-strong); font-size: 14px; }
.promo-checks { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); }
.promo-checks__list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.promo-checks__list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.promo-checks__list a { font-weight: 600; white-space: nowrap; }
.promo-term__rules { flex: 1 1 100%; }
.promo-term__rules textarea { width: 100%; min-height: 72px; resize: vertical; }
@media (max-width: 720px) {
  .promo-facts__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .promos-attention__group > summary { padding: 0 16px; }
  .promos-attention__hint { padding: 0 16px 8px; }
  .promos-attention__list { margin: 0 16px 16px; }
  .promos-attention__actions { margin-left: 0; }
  .promos-diff { grid-template-columns: minmax(0, 1fr); }
}

/* Мастер «Новая акция»: шаги панелями, цена и срок переключаются без скриптов. */
.promo-new__form { display: flex; flex-direction: column; gap: 16px; }
.promo-new__step .bark-panel__title { display: inline-flex; align-items: center; gap: 10px; }
.promo-new__num {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 700;
}
.promo-new__body { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
.promo-new__kinds, .promo-new__price { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; flex: 1 1 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.promo-new__kinds legend, .promo-new__price legend { flex: 1 1 100%; float: left; width: 100%; padding: 0; margin-bottom: 6px; }
.promo-new__what { flex: 1 1 420px; min-width: 0; }
.promo-new__name { display: flex; align-items: center; gap: 8px; }
.promo-new__prefix { flex: none; color: var(--ink); font-weight: 600; white-space: nowrap; }
.promo-new__name .bark-field__control { flex: 1 1 auto; min-width: 0; }
.promo-new__articles { flex: 1 1 320px; min-width: 0; }
.promo-new__articles textarea { width: 100%; resize: vertical; }
.promo-new__group { flex: 1 1 280px; min-width: 0; }
.promo-new__group .bark-field__control { width: 100%; }
.promo-new__fixed, .promo-new__pct { display: none; align-items: center; gap: 6px; color: var(--ink2); }
.promo-new__fixed .bark-field__control, .promo-new__pct input.bark-field__control { width: 96px; text-align: right; }
.promo-new__price:has(input[value="fixed"]:checked) .promo-new__fixed,
.promo-new__price:has(input[value="pct"]:checked) .promo-new__pct { display: inline-flex; }
.promo-new__price .bark-field__hint { flex: 1 1 100%; }
.promo-new__price.bark-field--error .bark-field__hint { color: var(--bad); }
/* Конструктор «Когда акция появляется в заказе»: строки-фразы, между ними «и», сверху итоговая фраза. */
.cond { display: flex; flex-direction: column; gap: 12px; }
.cond__keep { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; }
.cond__keep input { width: 16px; height: 16px; }
.cond__current { margin: -4px 0 12px; }
.promo-new__notice { border-left: 3px solid var(--warn, #d97706); padding-left: 12px; }
/* «Опишите акцию словами»: поле во всю ширину, под ним кнопка и ответ barkai. */
.promo-new__described { flex: 1 1 100%; min-width: 0; }
.promo-new__described textarea { width: 100%; resize: vertical; }
.promo-new__fill-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; flex: 1 1 100%; }
.promo-new__fill-result { flex: 1 1 100%; }
.promo-term__footer { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.cond__presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cond__presets-label { margin-right: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.cond__preset { height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out); }
.cond__preset:hover { border-color: var(--accent); color: var(--accent-strong); }
.cond__preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cond__summary { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: 14px; line-height: 1.5; }
.cond__summary > span { color: var(--ink2); }
.cond__summary.is-empty strong { color: var(--warn-strong); }
.cond__list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.cond__row { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cond [hidden] { display: none; }
.cond:not(.is-js) .cond__row + .cond__row { margin-top: 8px; }
.cond.is-js .cond__row:not(.is-first) { margin-top: 28px; }
.cond.is-js .cond__row:not(.is-first)::before {
  content: "и"; position: absolute; top: -23px; left: 14px; padding: 0 9px; border-radius: 999px;
  background: var(--chip); color: var(--ink2); font-size: 12px; font-weight: 700; line-height: 18px;
}
.cond.is-js .cond__on { display: none; }
.cond:not(.is-js) .cond__remove { display: none; }
.cond__on { flex: none; padding-top: 3px; }
.cond__on input { width: 16px; height: 16px; accent-color: var(--accent-strong); }
.cond__text { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; color: var(--ink); font-size: 14px; line-height: 1.6; }
.cond__text b { font-weight: 600; }
.cond__hint { color: var(--muted); font-size: 12px; }
.cond__num { width: 72px; text-align: right; }
.cond__unit { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cond__num--wide { width: 112px; }
.cond__text select { width: auto; max-width: 100%; }
.cond__remove { display: inline-grid; flex: none; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.cond__remove:hover { background: var(--bad-soft); color: var(--bad-strong); }
.cond__remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cond__remove svg { width: 16px; height: 16px; }
.cond__row.is-error { border-color: var(--bad); }
.cond__error { flex: 1 1 100%; color: var(--bad); font-size: 12px; }
.cond__add { position: relative; }
.cond__menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  width: min(760px, calc(100vw - 48px)); padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-pop); }
.cond__menu[hidden] { display: none; }
.cond__menu-group { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cond__menu-group[hidden] { display: none; }
.cond__menu-title { padding: 4px 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.cond__menu-item { padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.cond__menu-item[hidden] { display: none; }
.cond__menu-item:hover, .cond__menu-item:focus-visible { background: var(--surface-2); outline: none; }
.cond__note { margin: 0; color: var(--muted); font-size: 12px; }
.cond.bark-field--error > .cond__error { color: var(--bad); }
/* Шаг 4: «Как работает» и срок одной ровной строкой. */
.promo-new__final { display: flex; flex-direction: column; gap: 16px; }
.promo-new__final textarea { width: 100%; min-height: 84px; resize: vertical; }
.promo-new__term { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.promo-new__term legend { margin-bottom: 6px; padding: 0; }
.promo-new__term-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.promo-new__dates { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--ink2); font-size: 14px; }
.promo-new__dates label { display: inline-flex; align-items: center; gap: 6px; }
.promo-new__dates input { width: 156px; }
.promo-new__term:has(input[value="permanent"]:checked) :is(.promo-new__dates, .promo-new__term-dated) { display: none; }
.promo-new__term:not(:has(input[value="permanent"]:checked)) .promo-new__term-forever { display: none; }
.promo-new__term.bark-field--error .bark-field__hint { color: var(--bad); }
.promo-new__preview { scroll-margin-top: 16px; }
.promo-new__preview .bark-panel__header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.promo-new__stale { display: none; }
.promo-new__preview.is-stale .promo-new__stale { display: inline-flex; }
.promo-new__preview.is-stale > :not(.bark-panel__header) { opacity: .6; }
.promo-new__errors { margin: 6px 0 0; padding-left: 20px; }
.promo-new__check { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
.promo-new__check--ok { color: var(--ok); }
.promo-new__check--bad { color: var(--bad); }
.promo-new__offers td { vertical-align: top; }
.promo-new__offers td:first-child { text-align: left; }
.promo-new__more { margin: 8px 16px 12px; }
.promo-new__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.promo-new__actions > [hidden] { display: none; }
/* Выбранные товары акции и окно выбора с поиском. */
.promo-picked { display: flex; flex-direction: column; gap: 8px; flex: 1 1 100%; min-width: 0; }
/* Скрытые подписи колонок — внутри прокрутки таблицы, иначе на телефоне страница шире экрана. */
.promo-new .table-wrap { position: relative; }
.promo-picked__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.promo-picked__head .bark-data { color: var(--muted); font-weight: 500; }
.promo-picked__table td { vertical-align: middle; }
.promo-picked__table td:first-child { width: 1%; text-align: center; }
/* Заголовок «Нужен в заказе» не ломать на три строки: колонка шире галочки, но остаётся узкой. */
.promo-picked__table th:first-child { white-space: nowrap; text-align: center; }
.promo-picked__table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent-strong); }
.promo-picked__price { width: 104px; text-align: right; }
.promo-picked__empty { margin: 0; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 13px; }
.promo-picked.bark-field--error .bark-field__hint { color: var(--bad); }
.promo-new__alt { flex: 1 1 100%; }
.promo-new__alt > summary { cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 600; }
.promo-new__alt > .promo-new__body { margin-top: 12px; }
.promo-picker { width: min(760px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
.promo-picker::backdrop { background: rgba(15, 20, 25, .45); }
.promo-picker__box { display: flex; flex-direction: column; max-height: inherit; }
.promo-picker__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.promo-picker__filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.promo-picker__filters .prices-search { flex: 1 1 260px; }
.promo-picker__filters select { flex: 0 1 240px; min-width: 0; }
.promo-picker__results { flex: 1 1 auto; min-height: 160px; overflow: auto; padding: 0 16px; }
.promo-picker__results[aria-busy="true"] { opacity: .6; transition: opacity var(--motion-fast) var(--ease-out); }
.promo-picker__hint { margin: 24px 0; color: var(--muted); font-size: 13px; text-align: center; }
.promo-picker__list { margin: 0; padding: 0; list-style: none; }
.promo-picker__list li { border-top: 1px solid var(--line); }
.promo-picker__list li:first-child { border-top: 0; }
.promo-picker__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 8px 4px; cursor: pointer; }
.promo-picker__item:hover { background: var(--surface-2); }
.promo-picker__item input { width: 16px; height: 16px; accent-color: var(--accent-strong); }
.promo-picker__item.is-picked { cursor: default; opacity: .7; }
.promo-picker__name { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.promo-picker__base { color: var(--ink2); font-size: 13px; white-space: nowrap; }
.promo-picker__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.promo-picker__all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }
.promo-picker__status { flex: 1 1 auto; color: var(--muted); font-size: 12px; }
@media (max-width: 720px) {
  .promo-new__what, .promo-new__articles, .promo-new__group { flex-basis: 100%; }
  .cond__menu { grid-template-columns: minmax(0, 1fr); }
  .promo-new__name { flex-wrap: wrap; }
  .promo-picked__price { width: 84px; }
}

/* Загрузка файла */
.prices-import__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }

@media (max-width: 900px) {
  .prices-help { grid-template-columns: minmax(0, 1fr); }
  .prices-help__toc { position: static; }
}
@media (max-width: 720px) {
  .prices-search { flex-basis: 100%; max-width: none; }
  .prices-toolbar select.bark-field__control { flex: 1 1 140px; max-width: none; }
  .prices-table-wrap { max-height: none; }
  .prices-crm { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .prices-savebar, [data-live].is-loading .prices-progress::after { animation: none; }
  .prices-list, .prices-table .price-cell, .prices-table td.is-sent-fade { transition: none; }
}

.prices-editor__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
@media (max-width: 720px) { .prices-editor__fields { grid-template-columns: minmax(0, 1fr); } }
.prices-editor__pct { display: flex; align-items: center; gap: 8px; color: var(--ink2); }
.prices-editor__pct .bark-field__control { width: 88px; text-align: right; }
.prices-editor__round { border: 0; margin: 0; padding: 0; min-width: 0; }
.prices-segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--chip); }
.prices-segmented label { position: relative; }
.prices-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.prices-segmented span {
  display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: 7px;
  color: var(--ink2); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}
.prices-segmented input:checked + span { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-card); }
.prices-segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.prices-editor__danger { display: flex; align-items: center; gap: 12px; }
.prices-excl-col { width: 1%; text-align: center; white-space: nowrap; }
.prices-excl-col input { width: 16px; height: 16px; accent-color: var(--accent-strong); cursor: pointer; }
