@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --ink: #14120d;
  --ink-2: #1d2027;
  --sidebar-0: #14171c;
  --sidebar-1: #0c0e12;
  --paper: #f6f4ef;
  --paper-deep: #efece3;
  --card: #ffffff;
  --line: #e6e1d3;
  --line-soft: #eeebe1;
  --muted: #756e5f;
  --muted-2: #9a927e;
  --sidebar-ink: #b9c0c7;

  --accent: #0c6b5a;
  --accent-hover: #0a5445;
  --accent-soft: #e3f1ec;
  --accent-line: #bfe2d6;

  --gold: #a9822f;
  --gold-soft: #f3e9d2;
  --gold-line: #e3cf9c;

  --ok: #1b7a4a;
  --ok-bg: #e7f6ee;
  --warn: #9a6b10;
  --warn-bg: #f8f0d6;
  --bad: #a4341e;
  --bad-bg: #f9ece8;

  --code-bg: #14171c;
  --code-fg: #d7e2ec;

  --shadow-sm: 0 1px 2px rgba(20, 18, 13, 0.05);
  --shadow: 0 1px 1px rgba(20, 18, 13, 0.03), 0 12px 28px -12px rgba(20, 18, 13, 0.16);
  --shadow-lg: 0 24px 60px -20px rgba(15, 14, 10, 0.28);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --font-display: "Fraunces", "Georgia", serif;
  --font: "Manrope", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --sidebar-w: 244px;
  --sidebar-w-collapsed: 72px;
  --ui-scale: 1;
  --font-size-root: 15px;
  --content-max: 76rem;
  --main-pad-y: calc(1.6rem * var(--ui-scale));
  --main-pad-x: max(1.25rem, calc((100% - var(--content-max)) / 2));
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  /* Адаптивный базовый кегль: меньше на узких, чуть крупнее на широких */
  font-size: clamp(12.5px, 0.55vw + 11.2px, 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  font-size: calc(var(--font-size-root) * var(--ui-scale));
  line-height: 1.5;
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Плотность UI под ширину / retina-ноутбуки (CSS px часто ~1280–1440 при 2x) */
@media (max-width: 1440px) {
  :root {
    --ui-scale: 0.94;
    --sidebar-w: 220px;
    --sidebar-w-collapsed: 64px;
    --radius: 12px;
  }
}
@media (max-width: 1280px) {
  :root {
    --ui-scale: 0.9;
    --sidebar-w: 204px;
  }
  .page-head h1 { font-size: clamp(1.25rem, 2.2vw, 1.55rem) !important; }
}
@media (max-width: 1100px) {
  :root { --ui-scale: 0.86; }
}
@media (min-width: 1600px) {
  :root { --ui-scale: 1.04; }
}
@media (min-width: 1920px) {
  :root { --ui-scale: 1.08; }
}
/* Retina / HiDPI: чуть плотнее, если физически пикселей много, а CSS-ширина средняя */
@media (min-resolution: 1.5dppx) and (max-width: 1600px) {
  :root { --ui-scale: 0.92; }
}
@media (min-resolution: 2dppx) and (max-width: 1440px) {
  :root {
    --ui-scale: 0.88;
    --sidebar-w-collapsed: 60px;
  }
}

/* Subtle grain + vignette give the flat panel a tactile, considered feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background:
    radial-gradient(1100px 520px at 100% -8%, rgba(169, 130, 47, 0.06), transparent 60%),
    radial-gradient(900px 460px at -8% 0%, rgba(12, 107, 90, 0.07), transparent 55%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); }

/* ——— App shell ——— */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  /* высота — по окну, а не по странице: растянутое на всю страницу меню прокручивалось бы вместе с ней */
  align-self: flex-start;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(185deg, var(--sidebar-0) 0%, var(--sidebar-1) 100%);
  color: var(--sidebar-ink);
  padding: 1.3rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  flex: 0 0 auto;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-lg);
  transition: width 0.2s ease, padding 0.2s ease;
  overflow-x: hidden;
  overflow-y: auto; /* низкое окно: меню прокручивается, нижний блок («Закрепить меню», «Выйти») не теряется */
  overscroll-behavior: contain;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.2rem 0.35rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.sidebar-brand-text {
  min-width: 0;
  flex: 1;
}

.sidebar-collapse-btn {
  appearance: none;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(169, 130, 47, 0.35);
  border-radius: 8px;
  background: rgba(12, 107, 90, 0.22);
  color: #e8d7a4;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}
.sidebar-collapse-btn:hover {
  background: rgba(12, 107, 90, 0.4);
  color: #fff;
}
.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sidebar-mark {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #1a9a80 0%, #0a4f44 62%, #06342c 100%);
  color: #fbf3df;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 6px 16px -4px rgba(10, 79, 68, 0.7);
  position: relative;
}
.sidebar-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(169, 130, 47, 0.55);
}

.sidebar-brand strong {
  display: block;
  color: #fdfcf8;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.71rem;
  color: #7c8590;
  font-weight: 550;
  letter-spacing: 0.01em;
  margin-top: 1px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.sidebar-kicker {
  padding: 0.9rem 0.65rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #616a76;
}
.sidebar-kicker:first-child { padding-top: 0.15rem; }

.sidebar-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.56rem 0.7rem 0.56rem 0.85rem;
  margin: 0 0.05rem;
  border-radius: 10px;
  color: var(--sidebar-ink);
  font-weight: 600;
  font-size: 0.89rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a.is-active {
  background: linear-gradient(90deg, rgba(12, 107, 90, 0.32), rgba(12, 107, 90, 0.1));
  color: #fff;
}
.sidebar-nav a.is-active::before {
  content: "";
  position: absolute;
  left: -0.05rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold), #7a5f22);
}

.sidebar-nav .ico {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  opacity: 0.85;
  color: currentColor;
}
.sidebar-nav .ico svg { width: 100%; height: 100%; }
.sidebar-nav a.is-active .ico { opacity: 1; color: #d9c78f; }

.sidebar-foot {
  padding: 0.85rem 0.65rem 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.73rem;
  color: #808894;
  letter-spacing: 0.01em;
}

.sidebar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(12, 107, 90, 0.22);
  color: #a8e9d2;
  font-weight: 650;
  font-size: 0.72rem;
  border: 1px solid rgba(168, 233, 210, 0.15);
}
.sidebar-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #35d99b;
  box-shadow: 0 0 0 3px rgba(53, 217, 155, 0.18);
}
.sidebar-status.is-off {
  background: rgba(164, 52, 30, 0.18);
  color: #f1b7a6;
  border-color: rgba(241, 183, 166, 0.18);
}
.sidebar-status.is-off::before {
  background: #f0755a;
  box-shadow: 0 0 0 3px rgba(240, 117, 90, 0.18);
}

.card .sidebar-status {
  margin-top: 0;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent-line);
}
.card .sidebar-status::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(27, 122, 74, 0.16);
}
.card .sidebar-status.is-off {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: #ead0c8;
}

/* Collapsed sidebar — icons only */
.sidebar.is-collapsed {
  width: var(--sidebar-w-collapsed);
  padding: 1rem 0.55rem;
  gap: 1rem;
}
.sidebar.is-collapsed .sidebar-brand {
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.15rem 0 0.85rem;
  align-items: center;
}
.sidebar.is-collapsed .sidebar-brand-text,
.sidebar.is-collapsed .sidebar-kicker,
.sidebar.is-collapsed .sidebar-label,
.sidebar.is-collapsed .sidebar-foot-label {
  display: none !important;
}
.sidebar.is-collapsed .sidebar-collapse-btn {
  margin-left: 0;
  transform: rotate(180deg);
}
.sidebar.is-collapsed .sidebar-nav a {
  justify-content: center;
  gap: 0;
  padding: 0.65rem;
  margin: 0;
}
.sidebar.is-collapsed .sidebar-nav a.is-active::before {
  left: 0.15rem;
  top: 0.45rem;
  bottom: 0.45rem;
}
.sidebar.is-collapsed .sidebar-nav .ico {
  width: 20px;
  height: 20px;
}
.sidebar.is-collapsed .sidebar-foot {
  display: flex;
  justify-content: center;
  padding: 0.65rem 0 0.1rem;
  text-align: center;
}
.sidebar.is-collapsed .sidebar-status {
  padding: 0.35rem;
  border-radius: 999px;
  font-size: 0;
  gap: 0;
  min-width: 1.6rem;
  min-height: 1.6rem;
  justify-content: center;
}
.sidebar.is-collapsed .sidebar-status::before {
  margin: 0;
}

.sidebar-foot-link {
  display: inline-block;
  margin-top: 0.55rem;
  color: #9fd4c4;
  font-weight: 650;
  text-decoration: none;
}
.sidebar-foot-link:hover { color: #d9c78f; }

.main {
  flex: 1;
  min-width: 0;
  padding: var(--main-pad-y) var(--main-pad-x) calc(3rem * var(--ui-scale));
  position: relative;
  z-index: 1;
}

/* Рабочие страницы с широкой таблицей: без центрированной колонки 76rem */
body.page-wide {
  --main-pad-x: clamp(1rem, 2vw, 2.25rem);
}
/* Одна прокрутка — у страницы; шапка таблицы липнет к верху окна.
   overflow: visible, иначе обёртка стала бы своим скролл-контейнером и sticky не работал бы. */
body.page-wide .table-wrap {
  max-height: none;
  overflow: visible;
}
@media (max-width: 1100px) {
  body.page-wide .table-wrap { overflow-x: auto; }
}

/* Таблица сделок: одна строка на сделку, длинное — многоточием с подсказкой */
#leadsTable th,
#leadsTable td {
  padding: 0.22rem 0.6rem;
  white-space: nowrap;
  line-height: 1.3;
}
#leadsTable thead th {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
#leadsTable input[type="checkbox"] {
  margin: 0;
  vertical-align: middle;
}
#leadsTable td[data-col="name"],
#leadsTable td[data-col="stage"],
#leadsTable td[data-col="delivery_method"] {
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
#leadsTable td[data-col="address"] {
  white-space: normal;
  min-width: 18rem;
}
#leadsTable td[data-col="price"],
#leadsTable td[data-col="weight"],
#leadsTable td[data-col="tariff_cost"],
#leadsTable th[data-col="price"],
#leadsTable th[data-col="weight"],
#leadsTable th[data-col="tariff_cost"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#leadsTable td select {
  min-width: 7.5rem;
  max-width: 10rem;
  min-height: 0;
  height: 1.55rem;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.85em;
}
#leadsTable tbody tr:hover {
  background: rgba(15, 156, 131, 0.05);
}

/* Страницы с длинной таблицей: карточка тянется на высоту окна */
html:has(body.page-fill) {
  height: 100%;
}
body.page-fill {
  height: 100%;
  overflow: hidden;
}
body.page-fill .app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.page-fill .sidebar {
  height: 100dvh;
  min-height: 0;
}
body.page-fill .main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 1.25rem;
}
body.page-fill .page-head,
body.page-fill .main > .card:not(.card-fill),
body.page-fill .main > p {
  flex: 0 0 auto;
}
body.page-fill .card-fill {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 0;
}
body.page-fill .card-fill > .muted,
body.page-fill .card-fill > .inline,
body.page-fill .card-fill > .meta,
body.page-fill .card-fill > .msg,
body.page-fill .card-fill > .row,
body.page-fill .card-fill > h2,
body.page-fill .card-fill > p {
  flex: 0 0 auto;
}
body.page-fill .card-fill .table-wrap {
  flex: 1 1 auto;
  max-height: none;
  min-height: 10rem;
  overflow: auto;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}

.page-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.page-head .lede {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.93rem;
  max-width: 56ch;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.save-hint {
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--muted);
  max-width: 22rem;
  text-align: right;
}
.save-hint.is-ok { color: var(--ok, #1f7a4d); }
.save-hint.is-err { color: var(--bad, #b42318); }
.save-hint.is-busy { color: var(--muted); }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 1.1rem; right: 1.1rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(169, 130, 47, 0.35), transparent);
}

.card h2 {
  margin: 0 0 0.9rem;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-family: var(--font);
}

.muted { color: var(--muted); }

.setup-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink);
  line-height: 1.55;
}
.setup-steps li { margin: 0.35rem 0; }
.setup-steps code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--paper-deep);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  margin: 0.55rem 0;
}

.batch-docs {
  align-items: center;
  margin-top: 0.15rem;
  margin-bottom: 0.75rem;
}
.batch-docs .btn[aria-disabled="true"],
.batch-docs .btn[href="#"] {
  opacity: 0.45;
  pointer-events: none;
}

.table-toolbar {
  align-items: end;
  margin: 0.6rem 0;
}
.columns-menu {
  position: relative;
  margin-left: auto;
}
.columns-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  width: min(18rem, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 0.95rem;
}
.columns-popover-title {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.columns-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 16rem;
  overflow: auto;
}
.columns-checks label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 550;
  margin: 0;
  cursor: pointer;
}
.columns-checks input {
  width: auto;
  margin: 0;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.65rem;
  align-items: end;
}

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 550;
}

.env-switch {
  gap: 1.25rem;
  margin: 0.35rem 0 0.5rem;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  min-height: 2.4rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(12, 107, 90, 0.55);
  box-shadow: 0 0 0 3px rgba(12, 107, 90, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
  min-height: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  accent-color: var(--accent);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: none;
  border-color: transparent;
}

td select { width: 100%; max-width: 11rem; min-width: 8rem; }
td .urgency-select { font-size: 12.5px; }
.tariff-cell .err { color: var(--bad); cursor: help; }

button,
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.95rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.87rem;
  cursor: pointer;
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled),
.btn:hover {
  background: var(--paper-deep);
  border-color: #d9d2bd;
  text-decoration: none;
}

button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }

button.primary,
.btn.primary {
  background: linear-gradient(155deg, #128571, var(--accent) 65%);
  color: #fff;
  border-color: var(--accent-hover);
  box-shadow: 0 8px 18px -8px rgba(12, 107, 90, 0.55);
}
button.primary:hover:not(:disabled),
.btn.primary:hover {
  background: linear-gradient(155deg, #0f9c83, var(--accent-hover) 65%);
  color: #fff;
  box-shadow: 0 10px 22px -8px rgba(12, 107, 90, 0.65);
}

button.danger,
.btn.danger {
  background: #8b2e2e;
  color: #fff;
  border-color: #6f2424;
}
button.danger:hover:not(:disabled),
.btn.danger:hover {
  background: #a33838;
  color: #fff;
}
/* Кнопка взведена: отмена в КСЭ уйдёт со следующего клика. */
button.danger.armed {
  background: #c1121f;
  border-color: #7d0b14;
  box-shadow: 0 0 0 3px rgba(193, 18, 31, 0.25);
}
button.danger:disabled {
  opacity: 0.6;
  cursor: progress;
}

th[title] {
  cursor: help;
  text-decoration: underline dotted rgba(117, 110, 95, 0.45);
  text-underline-offset: 0.2em;
}

.table-wrap {
  overflow: auto;
  max-height: min(70dvh, calc(100dvh - 16rem));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.68rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: #faf9f4;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 750;
  border-bottom: 1px solid var(--line);
}

tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f8faf8; }

.code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 340px;
  font: 12px/1.55 var(--mono);
  border: 1px solid #262a30;
}
.code:empty {
  display: flex;
  align-items: center;
  min-height: 2.7rem;
  padding: 0 1rem;
  opacity: 0.9;
}
.code:empty::before {
  content: attr(data-placeholder);
  font-family: var(--font);
  font-size: 12.5px;
  font-style: italic;
  color: #7c8794;
}

.msg {
  margin: 0.65rem 0;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
  border: 1px solid var(--accent-line);
}
.msg.err { background: var(--bad-bg); color: var(--bad); border-color: #f0d2c9; }
.msg.ok { background: var(--ok-bg); color: var(--ok); border-color: #cdeadb; }
.msg.warn { background: var(--warn-bg); color: var(--warn); border-color: #ead9a8; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.71rem;
  font-weight: 750;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  letter-spacing: 0.01em;
}
.badge.manual { background: var(--bad-bg); color: var(--bad); }
.badge.auto,
.badge.exact { background: var(--accent-soft); color: var(--accent-hover); }
.badge.empty { background: #efece3; color: var(--muted); }

.req { color: var(--bad); font-weight: 700; }
.meta { font-size: 0.86rem; color: var(--muted); margin-bottom: 0.75rem; }
code { font-family: var(--mono); font-size: 0.82em; }

/* Stats strip (export) */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.9rem 0;
  padding: 0.85rem;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
}
.stat span {
  font-size: 0.71rem;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* Home dashboard */
.home {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) 1.45fr;
  gap: 1.1rem;
  min-height: calc(100vh - 3.2rem);
}

.home-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--sidebar-0) 0%, #0a1a17 68%, #071310 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.home-hero::before {
  content: "";
  position: absolute;
  top: -30%;
  right: -25%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(169, 130, 47, 0.25), transparent 70%);
  pointer-events: none;
}

.home-hero h1 {
  margin: 1.1rem 0 0.5rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.home-hero p {
  margin: 0;
  color: #a9b3bd;
  font-size: 0.96rem;
  max-width: 32ch;
}

.home-checks {
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  position: relative;
}

.home-checks li {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  color: #dbe1e6;
  font-size: 0.9rem;
  font-weight: 550;
}

.home-checks li::before {
  content: "✓";
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(169, 130, 47, 0.22);
  color: #e4c877;
  font-size: 0.62rem;
  font-weight: 800;
  border: 1px solid rgba(228, 200, 119, 0.3);
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  align-content: start;
  margin-bottom: 1.1rem;
}

.home-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 168px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}
.home-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  opacity: 0;
  transition: opacity 0.18s ease;
}

.home-card:hover {
  border-color: rgba(12, 107, 90, 0.3);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.home-card:hover::before { opacity: 1; }

.home-card .icn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.home-card .icn svg { width: 17px; height: 17px; }

.home-card .tag {
  font-size: 0.68rem;
  font-weight: 750;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.home-card h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.home-card .count {
  margin-top: auto;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.home-card .go {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.87rem;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
  position: relative;
  background: var(--paper);
}
.login-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(760px 420px at 15% 8%, rgba(12, 107, 90, 0.1), transparent 55%),
    radial-gradient(600px 360px at 90% 90%, rgba(169, 130, 47, 0.09), transparent 55%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: min(430px, 100%);
  padding: 1.9rem 1.75rem;
  border-radius: var(--radius-lg);
}

.login-card .brand-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

.login-card .brand-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.login-card label { width: 100%; }
.login-card input { width: 100%; }
.login-card button.primary,
.login-card a.primary { width: 100%; margin-top: 0.85rem; }

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.65rem, env(safe-area-inset-left));
  z-index: 45;
  width: 2.65rem;
  min-width: 2.65rem;
  min-height: 2.65rem;
  padding: 0;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.mobile-nav-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  border: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
  border-radius: 0;
  background: rgba(12, 14, 18, 0.46);
  cursor: pointer;
}

.sidebar-close {
  display: none;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f4efe3;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}
.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.nav-overlay:hover {
  background: rgba(12, 14, 18, 0.46);
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), 88vw);
    max-width: 22rem;
    transform: translateX(-105%);
    transition: transform 0.2s ease, width 0.2s ease, padding 0.2s ease;
    z-index: 40;
    padding-top: max(1.1rem, env(safe-area-inset-top));
  }
  .sidebar.is-open { transform: none; }
  body.nav-open {
    overflow: hidden;
  }
  body.nav-open .nav-overlay {
    display: block;
  }
  .sidebar-close { display: grid; place-items: center; }
  .mobile-nav-toggle { display: inline-flex; }
  .main {
    padding: max(3.6rem, calc(env(safe-area-inset-top) + 3rem)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .page-head .lede { max-width: none; }
  .page-actions {
    width: 100%;
  }
  .page-actions > button,
  .page-actions > .btn,
  .page-actions > a {
    flex: 0 1 auto;
  }
  .home-cards { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .row > button,
  .row > .btn {
    flex: 0 1 auto;
  }
  body.page-fill .main {
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
}

.setting-check {
  display: flex;
  flex-direction: row; /* общий стиль label — колонка; галочка должна стоять слева от текста */
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0;
  cursor: pointer;
}
.setting-check input {
  margin-top: 0.35rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}
.setting-check-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.setting-check-text b {
  font-size: 0.98rem;
  font-weight: 750;
  color: var(--ink);
}
.setting-check-text small {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--muted);
}

.budget-lock {
  margin-top: 1.25rem;
  padding: 1.15rem 1.15rem 1.2rem;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(243, 233, 210, 0.5) 0%, #fff 38%);
  box-shadow: var(--shadow-sm);
}
.budget-lock-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.95rem;
}
.budget-lock-head h3 {
  margin: 0 0 0.28rem;
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--ink);
}
.budget-lock-head p {
  margin: 0;
  max-width: 44rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
}
.budget-lock-pill {
  flex: 0 0 auto;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6e5116;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  padding: 0.32rem 0.72rem;
}
.role-admin {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
  padding: 0.62rem 0.85rem;
  border-radius: 10px;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: #5d4412;
  font-size: 0.86rem;
  font-weight: 650;
}
.role-admin-mark {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold), #7a5f22);
  box-shadow: 0 0 0 4px rgba(169, 130, 47, 0.16);
}
.role-section-title {
  margin: 1.1rem 0 0;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.role-chip {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.22rem 0.55rem 0.22rem 0.4rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  min-height: 0;
}
.role-chip input {
  width: 15px;
  height: 15px;
  min-height: auto;
  accent-color: var(--ok);
}
.role-chip:has(:checked) {
  background: var(--ok-bg);
  border-color: #b7dcc6;
  color: var(--ok);
}
.budget-lock-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 550;
  line-height: 1.45;
}

/* Embed inside amoCRM widget iframe — no sidebar, denser padding */
body.embed {
  background: var(--paper);
  min-height: 100%;
}
body.embed .embed-app,
body.embed .app {
  display: block;
  min-height: 100%;
}
body.embed .main {
  padding: 1rem 1.1rem 1.5rem;
  max-width: none;
}
body.embed .page-head {
  margin-bottom: 0.85rem;
}
body.embed .page-head h1 {
  font-size: 1.35rem;
}
body.embed .card {
  margin-bottom: 0.85rem;
}
body.embed .table-wrap {
  max-height: min(42vh, 420px);
  overflow: auto;
}

/* CSE → amo status mapping */
.status-map {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.status-map-group h3 {
  margin: 0 0 0.55rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.status-map-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.status-map-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(11rem, 1fr) 2.15rem;
  align-items: center;
  gap: 0.45rem 0.7rem;
  padding: 0.4rem 0.55rem 0.4rem 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.status-map-row.is-mapped {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.status-map-name {
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--ink);
}
.status-map-name .pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.status-map-arrow {
  color: var(--muted-2);
  font-size: 0.95rem;
  line-height: 1;
  user-select: none;
}
.status-map-row select {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 2.15rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.86rem;
}
.status-map-row .del {
  width: 2.15rem;
  min-height: 2.15rem;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.status-map-row .del:hover {
  color: var(--bad);
  background: var(--bad-bg);
  border-color: transparent;
}
.status-map-empty {
  margin: 0;
  padding: 0.8rem 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .status-map-row {
    grid-template-columns: 1fr 2.15rem;
    grid-template-areas:
      "name del"
      "amo amo";
  }
  .status-map-name { grid-area: name; }
  .status-map-row select.cse { grid-area: name; }
  .status-map-arrow { display: none; }
  .status-map-row select.amo { grid-area: amo; }
  .status-map-row .del { grid-area: del; }
}

@media print {
  .sidebar, .mobile-nav-toggle, .page-actions { display: none !important; }
  .main { padding: 0; }
}

/* Mass import preview */
tbody tr.mi-error { background: var(--bad-bg); }
tbody tr.mi-warn { background: var(--warn-bg); }
tbody tr.mi-ok td.mi-index.ok { background: var(--ok-bg); }
td.mi-index.mismatch { background: #fccccc; font-weight: 750; }
td.mi-index.missing { background: #f9ece8; font-weight: 750; }
td.mi-index.from_api { background: #dbe7fb; }
td.mi-index.from_deal { background: #f3e9d2; }
tbody tr.mi-off { opacity: 0.42; }
.mi-issues { font-size: 0.78rem; color: var(--bad); max-width: 18rem; }
.mi-issues.warn { color: var(--warn); }
.mi-src { font-size: 0.72rem; color: var(--muted); }
.mass-import-table { font-size: 0.86rem; }
.mass-import-table td { padding: 0.45rem 0.55rem; vertical-align: top; }
.secret-page-note { font-size: 0.8rem; color: var(--muted-2); }

.mi-steps {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}
.mi-steps li {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: #efece3;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}
.mi-steps li.is-active { background: var(--accent-soft); color: var(--accent-hover); }
.mi-steps li.is-current { box-shadow: inset 0 0 0 2px var(--accent); }

.mi-sender {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-top: 0.75rem;
  background: #faf8f2;
}
.mi-sender-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.65rem;
}
.mi-sender-head input[type="text"] { flex: 1; }
.mi-sender-head .inline { flex: 0 0 auto; white-space: nowrap; }

.mi-senders-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.mi-senders-bar h2 { margin: 0 0 0.25rem; }
.mi-senders-bar .muted { margin: 0; }
.mi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.mi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink);
}
.mi-chip.is-default {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hover);
}
.mi-chip small { font-weight: 550; color: var(--muted); font-size: 0.72rem; }

.mi-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4.5rem 1rem 1.5rem;
}
.mi-modal[hidden] { display: none; }
.mi-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(20, 18, 13, 0.45);
  cursor: pointer;
}
.mi-modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.mi-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.55rem 1.2rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.mi-tab {
  border: 0;
  background: transparent;
  padding: 0.45rem 0.75rem 0.6rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.mi-tab.is-active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}
.mi-tpl {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-top: 0.75rem;
  background: #faf8f2;
}
.mi-tpl-head {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.55rem;
  flex-wrap: wrap;
}
.mi-tpl-head input[type="text"] { flex: 1; min-width: 10rem; }
.mi-tpl-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.65rem;
}
.mi-tpl-upload input[type="file"] { font-size: 0.82rem; }
.mi-const-val { width: 7rem; min-width: 5rem; }
.mi-tpl-cols select { max-width: 16rem; }
.mi-sender h3, .mi-const h3 {
  margin: 0.4rem 0 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.mi-modal-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.1rem 1.2rem 0.7rem;
  border-bottom: 1px solid var(--line-soft);
}
.mi-modal-head h2 { margin: 0 0 0.25rem; }
.mi-modal-head .muted { margin: 0; }
.mi-modal-x {
  min-height: 2.2rem;
  width: 2.2rem;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  flex: 0 0 auto;
}
.mi-modal-body {
  overflow: auto;
  padding: 0.4rem 1.2rem 1rem;
}
.mi-modal-foot {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.85rem 1.2rem 1.1rem;
  border-top: 1px solid var(--line-soft);
}
.mi-sender h3 {
  margin: 0.4rem 0 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}


/* ——— Мастер выгрузки: 4 шага, следующий открыт только после предыдущего ——— */
.stepper {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  counter-reset: step;
  margin: 0 0 1rem;
  padding: 0;
}
.stepper li {
  counter-increment: step;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.9rem;
}
.stepper li::before {
  content: counter(step);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  font-size: 0.8rem;
}
.stepper li.is-current {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(12, 107, 90, 0.12);
}
.stepper li.is-current::before { background: var(--accent); color: #fff; }
.stepper li.is-done { color: var(--accent); }
.stepper li.is-done::before { content: "✓"; background: rgba(12, 107, 90, 0.14); color: var(--accent); }
.stepper li.is-locked { opacity: 0.55; }

.step-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}
.step-head h2 { margin: 0.1rem 0 0.2rem; }
.step-num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}
.step-hint { margin: 0; color: var(--muted); }
.step-lock { display: none; margin: 0.25rem 0 0; font-weight: 650; color: var(--warn); }
.step-body { border: 0; margin: 0; padding: 0; min-width: 0; }

.step.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(12, 107, 90, 0.1); }
.step.is-done .step-num { background: rgba(12, 107, 90, 0.14); color: var(--accent); font-size: 0; }
.step.is-done .step-num::after { content: "✓"; font-size: 1rem; }
.step.is-locked .step-num { background: var(--line); color: var(--muted); }
.step.is-locked .step-hint { display: none; }
.step.is-locked .step-lock { display: block; }
/* Пока шаг закрыт — показываем только заголовок и подсказку, без пустых таблиц и кнопок. */
.step.is-locked .step-body { display: none; }

button.big { padding: 0.75rem 1.4rem; font-size: 1.02rem; }

/* Чек-лист печати */
.print-list {
  list-style: none;
  margin: 0.9rem 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.print-list li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.print-list li.is-done { background: rgba(12, 107, 90, 0.06); border-color: rgba(12, 107, 90, 0.35); }
.print-list li.is-done .print-text b { text-decoration: line-through; color: var(--muted); }
.print-done input { width: 1.25rem; height: 1.25rem; margin: 0; cursor: pointer; }
.print-text { flex: 1 1 auto; display: grid; gap: 0.15rem; }
.print-text span { color: var(--muted); font-size: 0.88em; }
.print-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.print-list.is-waiting .print-actions { opacity: 0.45; pointer-events: none; }

details.aux { margin-top: 1rem; }
details.aux > summary { cursor: pointer; color: var(--muted); font-weight: 650; }
details.card.aux > summary { margin: 0; }

@media (max-width: 900px) {
  .stepper { flex-direction: column; }
  .print-list li { flex-wrap: wrap; }
}

/* Импорт СДЭК/Почта: разовые настройки свёрнуты над шагами */
.mi-setup > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  color: var(--ink);
}
.mi-setup-state {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}
.mi-setup-state.is-bad { color: var(--bad); }
.mi-setup h3 { margin: 1rem 0 0.5rem; font-size: 0.95rem; }
.mi-setup .mi-chips { margin: 0; }
.step-msg-slot:empty { display: none; }
.step-msg-slot { margin-top: 0.75rem; }

/* Кнопка занята запросом: подпись «Обрабатываю…», повторно не нажать */
button.is-busy {
  cursor: progress;
  opacity: 0.85;
}
button.is-busy::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.45em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Ширина колонок мышкой (col-resize.js): край заголовка — ручка */
thead th::after {
  content: "";
  position: absolute;
  top: 22%;
  bottom: 22%;
  right: 0;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.12s ease;
}
thead th:hover::after { background: var(--line); }
thead th.colw-edge { cursor: col-resize; }
thead th.colw-edge::after { background: var(--accent); }
body.colw-dragging,
body.colw-dragging * {
  cursor: col-resize !important;
  user-select: none !important;
}
table.colw-fixed { table-layout: fixed; max-width: none; }
table.colw-fixed th,
table.colw-fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
}
table.colw-fixed td select,
table.colw-fixed td input:not([type="checkbox"]) {
  min-width: 0;
  max-width: 100%;
}

/* Импорт: телефон и сумма в одну строку, адрес переносится */
.mass-import-table td.mi-nowrap { white-space: nowrap; }
.mass-import-table td.mi-addr { min-width: 14rem; max-width: 28rem; }

/* Импорт: таблицы сделок и заказов — по высоте окна, листаются внутри,
   шапка колонок на месте. Длинный список удобно просматривать, не теряя заголовки. */
body.page-wide .table-wrap.mi-scroll {
  /* окно минус шапка шага, счётчики, кнопки над таблицей и сообщение под ней —
     шаг целиком помещается в экран, кнопки видны без прокрутки */
  /* запасная высота до первого пересчёта; точную ставит fit-tables.js */
  max-height: 60dvh;
  min-height: 12rem;
  overflow: auto;
}

/* Импорт, шаг 3: поля ручной правки в таблице */
.mass-import-table input.mi-edit {
  width: 100%;
  min-width: 6rem;
  padding: 0.2rem 0.35rem;
  font: inherit;
  font-size: 0.86rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  min-height: 0;
  height: auto;
}
.mass-import-table input.mi-edit:hover { border-color: var(--line); background: #fff; }
.mass-import-table input.mi-edit:focus { border-color: var(--accent); background: #fff; outline: none; box-shadow: 0 0 0 2px rgba(12, 107, 90, 0.15); }
.mass-import-table input.mi-edit.is-bad { border-color: #e3a497; background: #fff6f3; }
.mass-import-table input.mi-edit.is-edited { border-color: rgba(12, 107, 90, 0.45); background: #f1f8f5; }
.mass-import-table input.mi-edit-phone { min-width: 8.5rem; font-variant-numeric: tabular-nums; }
.mass-import-table input.mi-edit-index { min-width: 5rem; width: 5.5rem; font-variant-numeric: tabular-nums; }
.mass-import-table input.mi-edit-street { min-width: 14rem; }

/* Импорт, шаг 3: фильтр строк */
.mi-filter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}
.mi-filter button {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.mi-filter button:last-child { border-right: 0; }
.mi-filter button b { margin-left: 0.3rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.mi-filter button.is-on { background: var(--accent-soft); color: var(--accent-hover); }
.mi-filter button.is-on b { color: inherit; }
.mi-filter button[data-filter="error"] b { color: var(--bad); }
.mass-import-table select.mi-edit-kind { width: auto; min-width: 5.5rem; padding: 0.15rem 0.3rem; font-size: 0.86rem; height: auto; min-height: 0; }
.mass-import-table input.mi-edit-pvz { min-width: 6rem; width: 7rem; text-transform: uppercase; }

/* Импорт: строка таблицы — одна строка текста; полный текст во всплывашке.
   Замечания переносятся — их нужно прочитать целиком. */
.mass-import-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22rem;
  vertical-align: middle;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.mass-import-table td.mi-issues { white-space: normal; min-width: 14rem; max-width: 26rem; }
.mass-import-table td .mi-src { display: none; }
.mass-import-table td.mi-index .mi-src { display: block; }
.mi-file-row { align-items: end; margin: 0 0 0.75rem; }
.mi-view { margin-left: auto; }
.mi-file-table td, .mi-file-table th { max-width: 14rem; }

.mi-setup-state.is-muted { color: var(--muted); font-weight: 500; }
.mass-import-table input.mi-edit-pvz + .mi-pvz-addr { display: block; }

body.page-wide .step .stats { padding-top: 0.55rem; padding-bottom: 0.55rem; }
/* шаг 3: над таблицей ещё шаблон, фильтр и кнопки — таблица ниже, чтобы шаг влез целиком */
/* высоту таблиц импорта подбирает fit-tables.js */

/* Уже отгруженные сделки (есть трек-номер) — серые, с пометкой */
tr.is-shipped td { color: var(--muted); }
.shipped-badge {
  display: inline-block;
  padding: 0 0.4rem;
  margin-right: 0.3rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #eceae2;
  color: var(--muted);
  vertical-align: 0.05em;
}

/* Шаг 2 после обработки свёрнут в строку: работаем в таблице шага 3 */
.step-head .step-toggle { margin-left: auto; align-self: center; }
.step-summary { margin: 0.15rem 0 0; color: var(--accent); font-weight: 600; }
.step-summary:empty { display: none; }
.step.is-collapsed .step-body { display: none; }
.step.is-collapsed .step-hint { display: none; }
.step.is-collapsed .step-head { margin-bottom: 0; }

/* Пакет документов: варианты (СДЭК до ПВЗ / до двери / Почта) и история партий */
.variant-cards { display: grid; gap: 0.6rem; margin-top: 0.9rem; }
.variant-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.7rem 0.9rem;
}
.variant-title { display: flex; align-items: baseline; gap: 0.7rem; margin-bottom: 0.5rem; }
.variant-title span { color: var(--muted); font-size: 0.88rem; }
.variant-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.variant-actions button { font-size: 0.85rem; padding: 0.4rem 0.7rem; }
.history-list { display: grid; gap: 0.9rem; margin-top: 0.9rem; max-height: 60dvh; overflow: auto; }
.history-item { border-top: 1px solid var(--line-soft); padding-top: 0.7rem; display: grid; gap: 0.5rem; }
.history-head { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: baseline; }
.history-head span { color: var(--muted); font-size: 0.88rem; }
.history-item .variant-card { background: #faf9f4; }

/* Закреплённая панель внизу экрана: скачивание под рукой, пока правите таблицу */
.action-bar {
  position: fixed;
  left: var(--sidebar-w, 244px);
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem clamp(1rem, 2vw, 2.25rem);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 24px -16px rgba(20, 18, 13, 0.35);
}
.action-bar[hidden] { display: none; }
.action-bar-text { flex: 1 1 auto; min-width: 0; color: var(--ink); }
.action-bar-text b { font-weight: 700; }
body.has-action-bar .main { padding-bottom: 5.5rem; }
@media (max-width: 900px) {
  .action-bar { left: 0; flex-wrap: wrap; }
}

/* Телефон правится руками чаще всего — поле крупное и заметное */
.mass-import-table input.mi-edit-phone {
  min-width: 11.5rem;
  width: 11.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  border-width: 1.5px;
}
.mass-import-table input.mi-edit-phone::placeholder { color: #b9a9a2; font-size: 0.88rem; letter-spacing: 0; }
.mass-import-table input.mi-edit-phone.is-bad { border-color: #d9826f; background: #fff1ed; }
.mass-import-table tr.mi-error td { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Настройки выгрузки (формат, отправитель, разбивка) — у кнопок скачивания */
.export-options { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end; margin: 0 0 0.9rem; }
.export-options label:not(.inline) { display: grid; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.export-options select { min-width: 10rem; }
.export-options .inline { align-self: center; }
.export-options.is-compact { margin: 0; gap: 0.4rem 0.8rem; }
.export-options.is-compact label:not(.inline) { display: flex; align-items: center; gap: 0.4rem; }
.export-options.is-compact select { min-width: 8rem; padding-top: 0.3rem; padding-bottom: 0.3rem; font-size: 0.85rem; }
.export-options.is-compact .inline { font-size: 0.85rem; }
#barOptionsSlot:empty { display: none; }
.action-bar { flex-wrap: wrap; }
.action-bar-text { flex: 1 1 14rem; }

/* Нижняя панель: всё в одну строку — настройки, итог и кнопки */
.export-options .short { display: none; }
.export-options.is-compact .long { display: none; }
.export-options.is-compact .short { display: inline; }
.action-bar { flex-wrap: nowrap; gap: 0.6rem 0.9rem; padding-top: 0.55rem; padding-bottom: 0.55rem; }
.action-bar-text { flex: 0 1 15rem; font-size: 0.88rem; line-height: 1.25; }
#barOptionsSlot { flex: 1 1 auto; min-width: 0; }
.action-bar button { white-space: nowrap; flex: 0 0 auto; }
.export-options.is-compact select { min-width: 7rem; max-width: 12rem; }
@media (max-width: 1250px) {
  .action-bar { flex-wrap: wrap; }
  .action-bar-text { flex: 1 1 100%; }
}

/* ——— Мастер выгрузки: закреплённая полоса шагов и экраны ——— */
body[data-screen="1"] [data-wz]:not([data-wz~="1"]),
body[data-screen="2"] [data-wz]:not([data-wz~="2"]),
body[data-screen="3"] [data-wz]:not([data-wz~="3"]),
body[data-screen="4"] [data-wz]:not([data-wz~="4"]),
body[data-screen="5"] [data-wz]:not([data-wz~="5"]) { display: none !important; }
/* заголовок виден на шагах 1–2: ссылка «Отправка в КСЭ» открывает сразу шаг 2, и он не должен пропадать */
body[data-screen="3"] .page-head,
body[data-screen="4"] .page-head,
body[data-screen="5"] .page-head { display: none; }
[data-wz] { animation: wz-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes wz-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.wizard-bar {
  position: sticky;
  top: 0.5rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0.6rem 0.6rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 14px 34px -18px rgba(20, 18, 13, 0.45);
  overflow: hidden;
}
.wizard-steps { display: flex; flex: 1 1 auto; gap: 0.3rem; margin: 0; padding: 0; list-style: none; min-width: 0; }
.wizard-steps li { flex: 1 1 0; min-width: 0; }
.wz-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem 0.4rem 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s ease, box-shadow 0.25s ease;
}
.wz-pill:hover:not(:disabled) { background: var(--accent-soft); transform: translateY(-1px); }
.wz-pill:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.wz-num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-weight: 750;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.wz-text { display: grid; min-width: 0; line-height: 1.2; }
.wz-text b { font-size: 0.93rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-text small { color: var(--muted); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-pill.is-current { background: var(--accent-soft); border-color: rgba(12, 107, 90, 0.4); box-shadow: 0 8px 18px -12px rgba(12, 107, 90, 0.8); }
.wz-pill.is-current .wz-num { background: linear-gradient(145deg, #12a88d, var(--accent)); color: #fff; transform: scale(1.1); }
.wz-pill.is-done .wz-num { background: rgba(12, 107, 90, 0.14); color: var(--accent); font-size: 0; }
.wz-pill.is-done .wz-num::after { content: "✓"; font-size: 1.05rem; }
.wz-pill.is-ready { border-color: rgba(12, 107, 90, 0.35); border-style: dashed; }
.wz-pill.is-ready .wz-num { background: rgba(12, 107, 90, 0.14); color: var(--accent); }
.wz-pill.is-locked { opacity: 0.45; cursor: not-allowed; }

.wz-nav { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.wz-back { background: transparent; box-shadow: none; }
.wz-next { min-width: 11rem; justify-content: center; }
.wz-next .wz-arrow { display: inline-block; transition: transform 0.2s ease; }
.wz-next:hover:not(:disabled) .wz-arrow { transform: translateX(4px); }
.wz-next[data-act="package"]:hover:not(:disabled) .wz-arrow { transform: translateY(3px); }
.wz-next.is-busy { min-width: 14rem; }

.wz-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(12, 107, 90, 0.08); }
.wz-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #2fc4a3);
  border-radius: 0 3px 3px 0;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (max-width: 1150px) { .wz-text small { display: none; } .wz-next { min-width: 8rem; } }
@media (max-width: 860px) { .wz-text { display: none; } .wz-pill { justify-content: center; padding: 0.3rem; } }

/* Панель скачивания (бывший шаг 4): сразу под таблицей, закреплена у низа окна */
.dock {
  position: sticky;
  bottom: 0.5rem;
  z-index: 55;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 -14px 34px -22px rgba(20, 18, 13, 0.5), 0 10px 26px -18px rgba(20, 18, 13, 0.3);
}
.dock.is-pulse { animation: dock-pulse 1.2s ease 1; }
@keyframes dock-pulse {
  0% { box-shadow: 0 0 0 0 rgba(12, 107, 90, 0.55); }
  40% { box-shadow: 0 0 0 10px rgba(12, 107, 90, 0.18); }
  100% { box-shadow: 0 0 0 0 rgba(12, 107, 90, 0); }
}
.dock-body { border: 0; margin: 0; padding: 0; min-width: 0; }
.dock-main { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 1rem; }
.dock .export-options { margin: 0; gap: 0.4rem 0.8rem; }
.dock .export-options select { min-width: 8rem; padding-top: 0.32rem; padding-bottom: 0.32rem; font-size: 0.86rem; }
.dock-actions { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; }
.dock-summary { font-weight: 650; color: var(--ink); white-space: nowrap; }
.variant-cards.compact { display: grid; gap: 0.35rem; margin-top: 0.55rem; }
.variant-cards.compact .variant-card { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; padding: 0.35rem 0.6rem; border-radius: 12px; }
.variant-cards.compact .variant-title { margin: 0; min-width: 12rem; }
.variant-cards.compact .variant-actions button { padding: 0.28rem 0.6rem; font-size: 0.8rem; }

/* Шаги 2–3 в мастере: заголовок компактнее — таблице больше места */
body[data-screen] .step-head { margin-bottom: 0.55rem; }
body[data-screen] .step-head .step-num { width: 1.8rem; height: 1.8rem; font-size: 0.9rem; }
body[data-screen] .step-hint { font-size: 0.86rem; }
@media (prefers-reduced-motion: reduce) {
  [data-wz], .dock.is-pulse, .wz-progress i, .wz-num { animation: none !important; transition: none !important; }
}

/* Экран 4 компактнее: заголовок шага не нужен (его заменяет полоса шагов), счётчики — одной строкой */
body[data-screen="4"] [data-step="4"] .step-head { display: none; }
[data-step="4"] .mi-file-row { align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.mi-legend { flex: 1 1 24rem; color: var(--muted); font-size: 0.84rem; line-height: 1.3; }
[data-step="4"] .stats, [data-step="3"] .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.6rem;
  padding: 0.4rem 0.9rem;
  margin: 0 0 0.5rem;
}
[data-step="4"] .stat, [data-step="3"] .stat { display: flex; align-items: baseline; gap: 0.4rem; }
[data-step="4"] .stat b, [data-step="3"] .stat b { font-size: 1.05rem; }
[data-step="4"] .stat span, [data-step="3"] .stat span { margin: 0; }
/* Панель скачивания: подписи слева от списков — одна строка вместо двух */
.dock .export-options label:not(.inline) { display: flex; align-items: center; gap: 0.4rem; color: var(--ink); font-size: 0.84rem; }
.dock .export-options { align-items: center; }
.dock-main { align-items: center; }

/* Экран 5 — отдельный экран «Выгрузить» (там же позже появится создание заказов в СДЭК по API) */
[data-step="5"] .dock-main { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 1.2rem; }
[data-step="5"] .dock-actions { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; }
[data-step="5"] .export-options { margin: 0; }
[data-step="5"] .variant-cards { margin-top: 1rem; }

/* Выбор ПВЗ на карте */
.mi-pvz-cell { display: flex; align-items: center; gap: 0.3rem; }
.mi-pvz-cell input { flex: 1 1 auto; min-width: 0; }
.mi-map-btn { flex: 0 0 auto; padding: 0.2rem 0.45rem; font-size: 1rem; line-height: 1; border-radius: 8px; }
.pvz-modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.pvz-modal[hidden] { display: none; }
/* фон почти прозрачный и не закрывает окно по клику: за ним нужно видеть карточку заказа */
.pvz-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 13, 0.12); }
.pvz-panel {
  position: relative;
  width: min(1180px, 100%);
  height: min(780px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--card, #fff);
  border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(20, 18, 13, 0.6);
  overflow: hidden;
  resize: both;
  min-width: min(640px, 100%);
  min-height: 420px;
  max-width: 100vw;
  max-height: 100vh;
  animation: wz-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.pvz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 0.9rem 1.1rem 0.4rem; cursor: move; user-select: none; touch-action: none; }
.pvz-full { user-select: text; cursor: text; color: var(--text, #1a1a1a); }
.pvz-panel.is-moved { box-shadow: 0 18px 60px -20px rgba(20, 18, 13, 0.75); }
.pvz-head h3 { margin: 0; font-size: 1.15rem; }
.pvz-sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }
.pvz-x { font-size: 1.4rem; line-height: 1; padding: 0.1rem 0.6rem; background: transparent; box-shadow: none; }
.pvz-search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.3rem 1.1rem 0.7rem; }
.pvz-search input { flex: 1 1 22rem; }
.pvz-status { font-size: 0.85rem; color: var(--muted); }
.pvz-status.ok { color: var(--accent); }
.pvz-status.err { color: var(--bad); }
.pvz-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; border-top: 1px solid var(--line); }
.pvz-list { list-style: none; margin: 0; padding: 0; overflow: auto; border-right: 1px solid var(--line); background: #faf9f4; }
.pvz-list li { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background 0.12s ease; }
.pvz-list li:hover { background: #fff; }
.pvz-list li.is-on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.pvz-list li.pvz-empty { cursor: default; color: var(--muted); display: block; }
.pvz-n { flex: 0 0 auto; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; }
.pvz-list li.is-on .pvz-n { background: var(--accent); color: #fff; }
.pvz-info { flex: 1 1 auto; min-width: 0; display: grid; gap: 0.1rem; }
.pvz-info b em { font-style: normal; font-weight: 600; font-size: 0.72rem; color: var(--accent); margin-left: 0.4rem; }
.pvz-info span { font-size: 0.88rem; }
.pvz-info small { color: var(--muted); }
.pvz-km { flex: 0 0 auto; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.pvz-map { min-height: 280px; }
.pvz-foot { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1.1rem; border-top: 1px solid var(--line); }
.pvz-chosen { flex: 1 1 auto; min-width: 0; color: var(--muted); }
.pvz-chosen b { color: var(--ink); }
.pvz-pin span {
  display: grid; place-items: center; width: 100%; height: 100%;
  border-radius: 50%; background: #fff; color: var(--ink);
  border: 2px solid var(--accent); font: 700 0.8rem/1 system-ui, sans-serif;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background 0.15s ease;
}
.pvz-pin.is-on span { background: var(--accent); color: #fff; transform: scale(1.25); }
.pvz-pin.is-current span { border-color: #d19a1a; }
.pvz-pin.pvz-home span { background: #fff5e0; border-color: #d19a1a; font-size: 1.1rem; }
/* страницу за окном выбора пункта не блокируем: нужно прокрутить и сверить адрес заказа */
body.pvz-open { overflow: auto; }
@media (max-width: 900px) { .pvz-body { grid-template-columns: 1fr; grid-template-rows: 40% 60%; } .pvz-list { border-right: 0; border-bottom: 1px solid var(--line); } }

/* Шаг 1 — для чего выгрузка */
.target-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; max-width: 760px; }
.target-card {
  display: grid; gap: 0.35rem; justify-items: start; text-align: left; padding: 1.2rem 1.3rem;
  background: var(--card, #fff); border: 2px solid var(--line); border-radius: 16px; box-shadow: none; cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.target-card:hover { transform: translateY(-2px); border-color: rgba(12, 107, 90, 0.45); box-shadow: 0 14px 28px -20px rgba(12, 107, 90, 0.7); }
.target-card.is-on { border-color: var(--accent); background: var(--accent-soft); }
.target-card b { font-size: 1.15rem; }
.target-card small { color: var(--muted); font-size: 0.86rem; line-height: 1.35; white-space: normal; }
.target-ico { font-size: 1.8rem; line-height: 1; }
/* тарифы СДЭК — только когда выгрузка для СДЭК */
body:not([data-target="cdek"]) .mi-cdek-col { display: none !important; }
.mi-tariff { max-width: 22rem; font-size: 0.84rem; }

/* Улучшения интерфейса (по рекомендациям UI/UX Pro Max): фокус, иконки, касания, прогресс */
:where(button, a, summary, select, [role="radio"], li[tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
html { scroll-padding-top: 5.5rem; } /* закреплённая полоса шагов не закрывает поле в фокусе */
.ico { display: block; flex: 0 0 auto; }
.target-ico { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.target-card.is-on .target-ico { background: var(--accent); color: #fff; }
.mi-map-btn { display: grid; place-items: center; min-width: 2rem; min-height: 2rem; color: var(--accent); }
.pvz-pin.pvz-home span { display: grid; place-items: center; }
.pvz-list li:focus-visible { outline-offset: -2px; }
.wz-count { flex: 0 0 auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 1150px) { .wz-count { display: none; } }
.mi-skel {
  display: block; height: 1.7rem; width: 12rem; max-width: 100%; border-radius: 8px;
  background: linear-gradient(90deg, #ece9df 25%, #f6f4ec 50%, #ece9df 75%);
  background-size: 200% 100%; animation: mi-skel 1.2s ease-in-out infinite;
}
@keyframes mi-skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (pointer: coarse) {
  .wz-pill, .wz-next, .wz-back, .target-card, .mi-map-btn, .pvz-x { min-height: 44px; min-width: 44px; }
  .mi-tariff, .mass-import-table select.mi-edit { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) { .mi-skel { animation: none; } }

/* Читаемость мелкого текста: контраст не ниже 4.5:1, кегль не меньше ~11,5 px */
:root { --gold-ink: #7a5a12; }
.page-eyebrow, .tag { color: var(--gold-ink); }
.page-eyebrow { font-size: 0.76rem; }
th { font-size: 0.76rem; }
.sidebar-kicker { font-size: 0.74rem; color: #8b95a2; }
.wz-num, .step.is-locked .step-num { color: #5f584a; }
.secret-page-note { color: var(--muted); }
/* Кнопки в шапке страницы: на узких экранах уходят под заголовок, слева, без «лесенки» справа */
@media (max-width: 1100px) {
  .page-head > .page-actions { flex: 1 1 100%; justify-content: flex-start; }
}
/* Галочка в панели выгрузки: по одной линии с полями списков, а не по центру всего блока */
.export-options .inline { align-self: flex-end; min-height: 2.4rem; }

/* История партий: очистка */
.history-tools { display: flex; justify-content: flex-end; margin-top: 0.6rem; }
.history-tools[hidden], #btnClearHistory[hidden] { display: none; }
.history-head { position: relative; }
.history-del { margin-left: auto; padding: 0.2rem 0.6rem; font-size: 0.8rem; background: transparent; box-shadow: none; color: var(--bad); border: 1px solid var(--bad-bg); }
.history-del:hover { background: var(--bad-bg); }

/* Что из партии уже скачивали */
.history-badge { font-size: 0.78rem; font-weight: 650; padding: 0.12rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.history-badge.is-new { background: var(--warn-bg); color: var(--warn); }
.history-badge.is-part { background: var(--gold-soft); color: var(--gold-ink); }
.history-badge.is-done { background: var(--ok-bg); color: var(--ok); }
.variant-actions button.is-got { border-color: var(--accent-line); }
.variant-actions button.is-got:not(.primary) { background: var(--accent-soft); color: var(--accent-hover); }
.got-tick { font-weight: 800; }

/* Выгрузка для КСЭ — внутри мастера «Выгрузка»: свои шаги 4–5, остальное прячем */
body:not([data-target="cse"]) .cse-only { display: none !important; }
body[data-target="cse"] .mi-only { display: none !important; }
.cse-rules { margin: 0 0 0.85rem; }
.cse-rules ul { margin: 0.5rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.cse-rules li b { color: var(--ink); }
#cseCheckCard .pickup-row { align-items: flex-end; }

/* Три варианта «куда» — в один ряд на широком экране */
.target-cards { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); max-width: 1000px; }
@media (min-width: 900px) { .target-cards { grid-template-columns: repeat(3, 1fr); } }

/* Общая история выгрузок: метка «что это» и фильтр */
.history-tools { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.kind-badge { font-size: 0.78rem; font-weight: 700; padding: 0.12rem 0.6rem; border-radius: 999px; white-space: nowrap; color: #fff; background: var(--accent); }
.kind-badge.kind-cdek { background: #2f6f9f; }
.kind-badge.kind-cse { background: #8a5a14; }
.mi-filter b { margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.history-head .kind-badge { color: #fff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; }

/* Домик получателя на карте ПВЗ: крупный, яркий, с пульсирующим ореолом — не теряется среди пунктов */
.pvz-pin.pvz-home span {
  background: #e5342b; color: #fff; border: 3px solid #fff; font-size: 1.1rem;
  box-shadow: 0 0 0 2px #e5342b, 0 6px 14px rgba(229, 52, 43, 0.55);
  animation: pvz-home-pulse 1.8s ease-out infinite;
}
.pvz-pin.pvz-home svg { width: 26px; height: 26px; stroke-width: 2.4; }
@keyframes pvz-home-pulse {
  0% { box-shadow: 0 0 0 2px #e5342b, 0 0 0 0 rgba(229, 52, 43, 0.55); }
  100% { box-shadow: 0 0 0 2px #e5342b, 0 0 0 16px rgba(229, 52, 43, 0); }
}
@media (prefers-reduced-motion: reduce) { .pvz-pin.pvz-home span { animation: none; } }

/* «Настройки» в боковом меню: интеграция и логи спрятаны в раскрывающийся блок внизу */
.sidebar-settings { margin-top: 0.9rem; padding-top: 0.6rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-settings summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.56rem 0.7rem 0.56rem 0.85rem; border-radius: 10px;
  color: var(--sidebar-ink); font-weight: 600; font-size: 0.89rem;
}
.sidebar-settings summary::-webkit-details-marker { display: none; }
.sidebar-settings summary:hover { background: rgba(255, 255, 255, 0.055); color: #fff; }
.sidebar-settings[open] summary { color: #fff; }
.sidebar-chevron { margin-left: auto; width: 0.5rem; height: 0.5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: 0.6; transition: transform 0.15s ease; }
.sidebar-settings[open] .sidebar-chevron { transform: rotate(-135deg); }
.sidebar-settings-links { display: flex; flex-direction: column; gap: 0.15rem; margin: 0.2rem 0 0.2rem 0.55rem; padding-left: 0.4rem; border-left: 1px solid rgba(255, 255, 255, 0.1); }

/* Главная: крупный выбор «что отправляем» и последние выгрузки */
.home-start { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 0 0 1.2rem; max-width: 1000px; }
.home-start-card {
  display: grid; gap: 0.5rem; align-content: start; padding: 1.15rem 1.2rem; border-radius: 16px;
  background: #fff; border: 2px solid var(--line); color: inherit; text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.home-start-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 14px 28px -20px rgba(12, 107, 90, 0.7); text-decoration: none; }
.home-start-card b { font-size: 1.2rem; }
.home-start-card small { color: var(--muted); font-size: 0.88rem; line-height: 1.35; }
.home-start-card .go { color: var(--accent); font-weight: 700; margin-top: 0.3rem; }
.home-recent { max-width: 1000px; }
.recent-list { display: grid; gap: 0.25rem; margin-top: 0.7rem; }
.recent-item { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; padding: 0.55rem 0.4rem; border-top: 1px solid var(--line-soft); color: inherit; text-decoration: none; }
.recent-item:hover { background: var(--accent-soft); text-decoration: none; }
.recent-item span:last-child { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 800px) { .home-start { grid-template-columns: 1fr; } }

/* Окно настроек импорта: шире, компактнее, шаблоны сворачиваются */
.mi-modal-panel { width: min(1180px, 100%); }
.mi-tpl { padding: 0; }
.mi-tpl > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 1rem; font-size: 0.95rem;
}
.mi-tpl > summary::-webkit-details-marker { display: none; }
.mi-tpl > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s ease; }
.mi-tpl[open] > summary::before { transform: rotate(90deg); }
.mi-tpl[open] > summary { border-bottom: 1px solid var(--line-soft); }
.mi-tpl-count { margin-left: auto; color: var(--muted); font-size: 0.82rem; }
.mi-tpl-head { padding: 0.7rem 1rem 0.2rem; margin: 0; }
.mi-file-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; font-weight: 600; font-size: 0.85rem;
  padding: 0.45rem 0.8rem; border: 1px dashed var(--accent); border-radius: 10px; color: var(--accent); background: #fff;
}
.mi-file-btn:hover { background: var(--accent-soft); }
.mi-file-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.mi-tpl-wrap { margin: 0.4rem 1rem 1rem; max-height: 52vh; overflow: auto; }
.mi-tpl-cols thead th { position: sticky; top: 0; z-index: 1; background: #f4f1e8; }
.mi-tpl-cols td { padding: 0.2rem 0.4rem; }
.mi-tpl-cols input[type="text"], .mi-tpl-cols select { min-height: 2rem; padding-top: 0.2rem; padding-bottom: 0.2rem; font-size: 0.86rem; }
.mi-tpl-cols select { max-width: 22rem; width: 100%; }
.mi-tpl-cols td:last-child button { min-height: 2rem; min-width: 2rem; padding: 0; }

/* Напоминание в каждом шаге: что выбрано на первом (Почта / СДЭК / КСЭ) */
.target-banner {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  padding: 0.5rem 0.8rem; margin: 0 0 0.7rem; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-line, rgba(12, 107, 90, 0.3));
  font-size: 0.88rem;
}
.target-banner[hidden] { display: none; }
.target-banner .kind-badge { font-size: 0.85rem; padding: 0.2rem 0.75rem; }
.target-banner-text { color: var(--ink); flex: 1 1 18rem; }
.target-banner-change { min-height: 2rem; padding: 0.2rem 0.7rem; font-size: 0.82rem; }

/* СДЭК: адреса, куда возят только экспрессом (дорого) */
.mass-import-table tr.mi-pricey td:first-child { box-shadow: inset 4px 0 0 #e8590c; }
.mass-import-table tr.mi-pricey td:has(.mi-tariff) { background: #fff0e0; }
.mi-pricey-badge {
  display: inline-block; margin: 0 0 0.2rem; padding: 0.05rem 0.5rem; border-radius: 999px;
  background: #e8590c; color: #fff; font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.mi-filter button[data-filter="pricey"] b { color: #e8590c; }

/* «Дорого, если доставка > N % суммы»: одна строка в виде компактной плашки, а не колонка (label по умолчанию вертикальный) */
.mi-pct {
  display: inline-flex; flex-direction: row; flex-wrap: nowrap; align-items: center; align-self: center; gap: 0.4rem;
  min-height: 2.4rem; padding: 0.2rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0; color: var(--muted); white-space: nowrap;
}
.mi-pct input { width: 3.2rem; min-height: 1.8rem; padding: 0.1rem 0.3rem; text-align: center; font-weight: 700; color: var(--ink); -moz-appearance: textfield; appearance: textfield; }
.mi-pct input::-webkit-outer-spin-button,
.mi-pct input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Сумма заказа — второй строкой под номером сделки, колонку не добавляем */
.mi-id-sum { font-size: 0.7rem; line-height: 1.1; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mi-id-sum.is-high { color: #e8590c; font-weight: 700; }
.mi-tariff-wrap { display: flex; align-items: center; gap: 0.35rem; }
.mi-tariff-wrap .mi-tariff { flex: 1 1 auto; min-width: 0; }
.mi-tariff-wrap .mi-pricey-badge { flex: 0 0 auto; margin: 0; }

/* Шаг 3: поиск и фильтры сделок */
.deals-filter { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }
.deals-filter input[type="search"] { flex: 1 1 18rem; min-width: 12rem; max-width: 28rem; }
.mass-import-table tr.mi-open { cursor: pointer; }
.mass-import-table tr.mi-open:hover td { background: var(--accent-soft); }
.mass-import-table tr[hidden] { display: none; }

/* Окно «Заказ» справа: состав и все данные по сделке */
body.drawer-open { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 13, 0.4); }
.drawer-panel {
  position: relative; width: min(560px, 100%); height: 100%; display: flex; flex-direction: column;
  background: var(--card, #fff); box-shadow: -18px 0 40px -24px rgba(0, 0, 0, 0.5);
}
.drawer-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: 1rem 1.2rem 0.7rem; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { margin: 0 0 0.2rem; }
.drawer-head a { font-size: 0.86rem; }
.drawer-body { overflow: auto; padding: 0.4rem 1.2rem 1.4rem; display: grid; gap: 0.2rem; align-content: start; }
.drawer-body section { padding: 0.5rem 0; border-bottom: 1px solid var(--line-soft); }
.drawer-body h3 { margin: 0 0 0.4rem; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kv { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.25rem 0.8rem; margin: 0; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.drawer-items { width: 100%; font-size: 0.86rem; }
.drawer-items th, .drawer-items td { padding: 0.3rem 0.4rem; }
.drawer-items tfoot td { border-top: 1px solid var(--line); text-align: right; }
.drawer-issues { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; }
.drawer-issues li.is-error { color: var(--bad); }
.drawer-issues li.is-warn { color: var(--warn); }
.drawer-fields { margin-top: 0.5rem; }
.drawer-fields summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
@media (max-width: 700px) { .kv { grid-template-columns: 1fr; } }


/* ---- Рабочие таблицы: компактный вид, закреплённые колонки, заметные ручки ширины ---- */
.mi-resize-hint { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--muted); }
.compact-toggle.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.mi-extra-chips { margin: 0.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mi-extra-chips[hidden] { display: none; }
.mi-extra-chips button { min-height: 0; padding: 0.1rem 0.5rem; font-size: 0.78rem; }

/* первые две колонки (галочка, номер и сумма заказа) закреплены слева — видно при прокрутке вправо */
#dealsTable th:nth-child(1), #dealsTable td:nth-child(1),
#previewTable th:nth-child(1), #previewTable td:nth-child(1) {
  position: sticky; left: 0; z-index: 2; width: 2.1rem; min-width: 2.1rem; max-width: 2.1rem;
  padding-left: 0.5rem; padding-right: 0.3rem; background: var(--card);
}
#dealsTable th:nth-child(2), #dealsTable td:nth-child(2),
#previewTable th:nth-child(2), #previewTable td:nth-child(2) {
  position: sticky; left: 2.1rem; z-index: 2; min-width: 5.2rem; background: var(--card);
  box-shadow: 1px 0 0 var(--line), 6px 0 8px -6px rgba(0, 0, 0, 0.18);
}
#dealsTable thead th:nth-child(-n+2), #previewTable thead th:nth-child(-n+2) { z-index: 4; background: #faf9f4; }
#previewTable tr.mi-error td:nth-child(-n+2) { background: var(--bad-bg); }
#previewTable tr.mi-warn td:nth-child(-n+2) { background: var(--warn-bg); }
.mass-import-table tr.mi-pricey td:nth-child(-n+2) { background-color: #fff0e0; }
.mass-import-table tr.mi-open:hover td:nth-child(-n+2) { background: var(--accent-soft); }
/* «снята галочка»: вместо прозрачности строки (сквозь закреплённые ячейки просвечивал бы текст) приглушаем содержимое */
.mass-import-table tbody tr.mi-off { opacity: 1; }
.mass-import-table tbody tr.mi-off td > * { opacity: 0.42; }
.mass-import-table tbody tr.mi-off td:first-child > * { opacity: 1; }

/* ручка ширины колонки — видна всегда, а не только при наведении */
.mass-import-table thead th { padding-right: 0.9rem; }
.mass-import-table thead th::after {
  top: 18%; bottom: 18%; width: 3px; background: var(--line);
}
.mass-import-table thead th:hover::after { background: var(--accent-line, rgba(12, 107, 90, 0.5)); }
.mass-import-table thead th.colw-edge::after { background: var(--accent); }

/* компактный вид: для небольших экранов */
body.compact .mass-import-table { font-size: 0.78rem; }
body.compact .mass-import-table td { padding: 0.16rem 0.35rem; }
body.compact .mass-import-table th { padding: 0.35rem 0.9rem 0.35rem 0.4rem; font-size: 0.62rem; }
body.compact .mass-import-table input.mi-edit,
body.compact .mass-import-table select.mi-edit,
body.compact .mass-import-table select.mi-edit-kind,
body.compact .mi-tariff { min-height: 1.6rem; height: auto; padding-top: 0.05rem; padding-bottom: 0.05rem; font-size: 0.78rem; }
body.compact .mass-import-table input.mi-edit-phone { min-width: 7rem; font-size: 0.85rem; letter-spacing: 0; }
body.compact .mass-import-table input.mi-edit-street { min-width: 9rem; }
body.compact .mass-import-table td.mi-addr { min-width: 10rem; }
body.compact .mass-import-table td.mi-issues { min-width: 9rem; max-width: 16rem; font-size: 0.7rem; }
body.compact .mass-import-table tr.mi-error td { padding-top: 0.16rem; padding-bottom: 0.16rem; }
body.compact .mi-tariff { max-width: 15rem; }
body.compact .mi-id-sum { font-size: 0.66rem; }
body.compact .step-head { margin-bottom: 0.3rem; }
body.compact .stats { padding-top: 0.3rem; padding-bottom: 0.3rem; }

/* Меню спрятано (узкий экран или выбор пользователя): открывается кнопкой ☰ поверх страницы */
body.nav-hide .sidebar {
  position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 88vw); max-width: 22rem;
  transform: translateX(-105%); transition: transform 0.2s ease; z-index: 40;
}
body.nav-hide .sidebar.is-open { transform: none; }
body.nav-hide.nav-open { overflow: hidden; }
body.nav-hide.nav-open .nav-overlay { display: block; }
body.nav-hide .sidebar-close { display: grid; place-items: center; }
body.nav-hide .mobile-nav-toggle { display: inline-flex; }
body.nav-hide .sidebar-hide-btn { display: none; }
body.nav-hide .sidebar-collapse-btn:not(.sidebar-hide-btn) { display: none; }
body:not(.nav-hide) .sidebar-pin-btn { display: none; }
body.nav-hide .main { padding-top: max(var(--main-pad-y), 3.4rem); }
.sidebar.is-collapsed .sidebar-hide-btn { transform: none; }
.sidebar-pin-btn {
  appearance: none; width: 100%; margin: 0 0 0.6rem; padding: 0.5rem 0.7rem; cursor: pointer;
  border: 1px solid rgba(169, 130, 47, 0.35); border-radius: 8px; background: rgba(12, 107, 90, 0.22); color: #e8d7a4; font-weight: 650;
}
.sidebar-pin-btn:hover { background: rgba(12, 107, 90, 0.4); }

/* «Колонки» таблицы сделок: раздел с полями amoCRM */
.columns-amo { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--line-soft); }
.columns-amo-search { width: 100%; margin: 0.3rem 0; min-height: 2rem; }
.columns-amo-list { max-height: 14rem; overflow: auto; display: grid; gap: 0.1rem; }
.columns-amo-list label { font-size: 0.82rem; }


/* Окно «Заказ»: поля для правки */
.drawer-body .oe { width: 100%; min-height: 2rem; padding: 0.2rem 0.45rem; font-size: 0.9rem; }
.oe-include { display: flex; gap: 0.5rem; align-items: center; padding: 0.55rem 0; font-weight: 600; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.oe-note { margin: 0.3rem 0 0; font-size: 0.78rem; }
.oe-pvz { display: flex; gap: 0.4rem; align-items: center; }
.oe-pvz input { flex: 1 1 auto; text-transform: uppercase; }
.oe-pvz button { flex: 0 0 auto; min-height: 2rem; padding: 0.2rem 0.6rem; font-size: 0.82rem; }
.mi-phone-extra { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.25; padding: 0.1rem 0.45rem 0; white-space: nowrap; }
.kv .mi-phone-extra { padding-left: 0; font-size: 0.86rem; }
.oe-stale { margin: 0.5rem 0; font-size: 0.86rem; }
.oe-stale button, .oe-note button { min-height: 1.8rem; padding: 0.15rem 0.6rem; font-size: 0.82rem; }

/* Страница-копия для разработки (СДЭК по API) */
.dev-badge { display: inline-block; margin-left: 0.6rem; padding: 0.15rem 0.7rem; border-radius: 999px; background: #e8590c; color: #fff; font: 700 0.72rem/1.4 system-ui, sans-serif; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; }
.dev-note { margin: 0.4rem 0 0.2rem; padding: 0.5rem 0.8rem; border-radius: 10px; background: #fff0e0; border: 1px solid #f1c8a4; color: #8a3d05; font-size: 0.86rem; max-width: 52rem; }
.gift-tag { display: inline-block; margin-left: 0.3rem; padding: 0 0.45rem; border-radius: 999px; background: #e7f6ee; color: #1b7a4a; font-size: 0.7rem; font-weight: 700; }
.api-account-row { display: flex; align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem; max-width: 40rem; }
.api-account-row label { flex: 1 1 18rem; }
.api-account { margin-bottom: 1rem; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #faf8f2; }

/* /export-api: ответ СДЭК в окне «Заказ» */
.oe-json { max-height: 18rem; overflow: auto; margin: 0.4rem 0 0; padding: 0.5rem 0.6rem; font-size: 0.75rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; background: rgba(127, 127, 127, 0.1); border-radius: 6px; }
#apiSendTable .ok { color: var(--ok, var(--good, #1a7f37)); }
#apiSendTable .is-error { color: var(--bad); }
#apiSendTable .is-warn { color: var(--warn); }
#apiSendTable .api-seq { font-size: 1.15em; }

/* Роли и доступ */
.acc-roles { display: grid; gap: 12px; margin: 0 0 12px; }
.acc-role { border: 1px solid var(--line, #d9dfdb); border-radius: 10px; padding: 12px; }
.acc-group { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.acc-group legend { font-size: .78rem; font-weight: 700; color: var(--muted, #5d6a63); text-transform: uppercase; padding: 0; margin: 4px 0; width: 100%; }

/* пачка «в работе»: список и полоса «дополняем пачку» */
#workCard[hidden] { display: none; }
#workCard .history-list { margin-top: 0.6rem; }
.add-mode-bar {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  padding: 0.5rem 0.8rem; margin: 0 0 0.8rem; border-radius: 12px;
  background: var(--gold-soft); border: 1px solid var(--gold-ink, #8a6d1d);
  font-size: 0.88rem; color: var(--ink);
}
.add-mode-bar[hidden] { display: none; }
.add-mode-bar #addModeText { flex: 1 1 18rem; }
.add-mode-bar button { min-height: 2rem; padding: 0.2rem 0.7rem; font-size: 0.82rem; }
#apiSendBody tr[data-deal] { cursor: pointer; }
#apiSendBody tr[data-deal]:hover td { background: rgba(12, 107, 90, 0.06); }

/* /export-api: блок «Отправка в СДЭК по API», нижняя панель документов, история выгрузок отдельно */
#historyCard.is-api-hidden { display: none !important; }
#btnHistory.is-active { background: var(--ok-bg, #e7f6ee); border-color: var(--ok, #1b7a4a); color: var(--ok, #1b7a4a); }

.api-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.65rem; margin: 0 0 1rem; }
.api-stat { position: relative; padding: 0.7rem 0.9rem 0.7rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.api-stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--line); }
.api-stat.is-ok::before { background: var(--ok); }
.api-stat.is-warn::before { background: #e8590c; }
.api-stat.is-bad::before { background: var(--bad); }
.api-stat b { display: block; font-size: 1.6rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.api-stat span { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
@media (max-width: 720px) { .api-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.api-track { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin: 0 0 1rem; padding: 0.65rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.6); }
.api-track-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
.api-seg { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.api-seg label { display: block; margin: 0; cursor: pointer; }
.api-seg input { position: absolute; opacity: 0; pointer-events: none; }
.api-seg span { display: block; padding: 0.3rem 0.9rem; border-radius: 999px; font-size: 0.84rem; font-weight: 650; color: var(--muted); transition: background 0.15s ease, color 0.15s ease; }
.api-seg input:checked + span { background: var(--ok); color: #fff; }
.api-seg input:focus-visible + span { outline: 2px solid var(--ok); outline-offset: 2px; }
.api-track-hint { flex: 1 1 18rem; margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }

.api-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; margin: 0 0 0.8rem; }
.api-actions .primary { min-height: 2.7rem; padding-inline: 1.3rem; }
.api-actions-gap { flex: 1 1 0; }
.api-table { margin-top: 0.9rem; }

.api-docs-bar {
  position: sticky; bottom: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem;
  margin: 1rem -0.25rem 0; padding: 0.7rem 1rem; border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(8px); box-shadow: 0 -8px 24px rgba(20, 40, 32, 0.12);
}
.api-docs-bar[hidden] { display: none; }
.api-docs-title { margin-right: 0.3rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }

/* Настройки отправки → кабинеты СДЭК: список карточек и экран одного кабинета */
.ss-dirty { color: #b25e09; font-size: 0.85rem; font-weight: 700; }
.ca-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.9rem; margin: 0.4rem 0 0.4rem; }
.ca-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.45rem; padding: 1rem 1.1rem; text-align: left; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20, 40, 32, 0.05); cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ca-card:hover { border-color: var(--ok); box-shadow: 0 6px 18px rgba(12, 107, 90, 0.12); transform: translateY(-1px); }
.ca-card:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }
.ca-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: 1.05rem; }
.ca-card-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-card-line { display: flex; gap: 0.6rem; font-size: 0.86rem; line-height: 1.35; }
.ca-card-line i { flex: 0 0 5.6rem; font-style: normal; color: var(--muted); font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.02em; padding-top: 0.08rem; }
.ca-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 0.3rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.ca-open { color: var(--ok); font-weight: 700; font-size: 0.86rem; white-space: nowrap; }
.ca-state { min-width: 0; font-size: 0.8rem; font-weight: 650; padding: 0.15rem 0.6rem; border-radius: 999px; }
.ca-state.is-ok { background: var(--ok-bg); color: var(--ok); }
.ca-state.is-warn { background: #fff0e0; color: #b25e09; }
.ca-badge { flex: 0 0 auto; padding: 0.12rem 0.65rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; }
.ca-badge.is-test { background: #e8f0f9; color: #2a5f9e; }
.ca-badge.is-prod { background: #fde9e3; color: var(--bad); }
.ca-empty { padding: 1.6rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.6); }

.ca-detail { display: grid; gap: 0.9rem; }
.ca-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; }
.ca-bar h3 { flex: 1 1 auto; margin: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 0.6rem; }
.ca-sec { padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.ca-sec h4 { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.6rem; font-size: 1rem; }
.ca-n { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--ok); color: #fff; font-size: 0.8rem; font-weight: 700; }
.ca-hint { margin: -0.2rem 0 0.7rem; color: var(--muted); font-size: 0.84rem; line-height: 1.4; }
.ca-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1rem; }
.ca-fields .ca-wide { grid-column: 1 / -1; }
.ca-fields small { font-weight: 500; letter-spacing: 0; line-height: 1.35; }
.ca-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; margin-top: 0.8rem; }
.ca-probe.is-ok { color: var(--ok); font-weight: 650; }
.ca-probe.is-bad { color: var(--bad); font-weight: 650; }
.ca-seg { margin: 0 0 0.8rem; }
.ca-pvz { display: flex; gap: 0.4rem; align-items: center; }
.ca-pvz input { flex: 1; min-width: 0; }
@media (max-width: 720px) { .ca-fields { grid-template-columns: 1fr; } }

/* Шапка меню: знак и название слева, две кнопки (свернуть / скрыть) столбиком справа — в одну строку они не помещались и название ломалось */
.sidebar:not(.is-collapsed) .sidebar-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.65rem;
  row-gap: 0.3rem;
}
.sidebar:not(.is-collapsed) .sidebar-brand .sidebar-mark,
.sidebar:not(.is-collapsed) .sidebar-brand .sidebar-brand-text { grid-row: 1 / span 2; }
.sidebar:not(.is-collapsed) .sidebar-brand .sidebar-collapse-btn { grid-column: 3; margin-left: 0; width: 28px; height: 28px; }
.sidebar:not(.is-collapsed) .sidebar-brand .sidebar-close { grid-column: 3; grid-row: 1; }
.sidebar:not(.is-collapsed) .sidebar-brand strong { line-height: 1.15; }

/* кнопки блока отправки с атрибутом hidden должны прятаться (иначе общий стиль кнопок показывает их всегда) */
.api-actions [hidden] { display: none !important; }

/* боевой контур: заметная плашка и красная кнопка создания */
.api-prod-banner { margin: 0 0 1rem; padding: 0.7rem 1rem; border: 1px solid var(--bad); border-left-width: 5px; border-radius: var(--radius-sm); background: #fde9e3; color: var(--bad); font-size: 0.92rem; line-height: 1.4; }
.api-prod-banner[hidden] { display: none; }
.api-actions .primary.is-prod { background: var(--bad); border-color: var(--bad); }
.api-actions .primary.is-prod:hover { filter: brightness(1.08); }
.ca-check { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 0.6rem; margin: 0.7rem 0 0; padding: 0.7rem 0.9rem; border: 1px solid var(--bad); border-radius: var(--radius-sm); background: #fff6f3; font-size: 0.9rem; font-weight: 600; letter-spacing: 0; color: var(--ink); cursor: pointer; }
.ca-check input { margin-top: 0.2rem; flex: 0 0 auto; }
.ca-check small { display: block; margin-top: 0.15rem; font-weight: 500; color: var(--muted); line-height: 1.35; }
.api-track-field { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.82rem; font-weight: 650; color: var(--muted); letter-spacing: 0; }
.api-track-field select { min-height: 2rem; padding: 0.15rem 0.5rem; }

/* /export-api, шаг 1: кабинет СДЭК карточками, чтобы выбор был заметен */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.api-account-pick { margin-top: 1.1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.7); }
.api-account-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.8rem; margin: 0 0 0.7rem; }
.api-account-head b { font-size: 1.05rem; }
.api-acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.7rem; }
.api-acc-card { display: flex; flex-direction: column; align-items: stretch; gap: 0.3rem; padding: 0.8rem 0.95rem; text-align: left; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.api-acc-card:hover { border-color: var(--ok); }
.work-scroll { overflow-x: auto; }
table.work-table { width: 100%; border-collapse: collapse; }
table.work-table th { padding: 6px 10px; text-align: left; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: transparent; border-bottom: 1px solid var(--line); }
table.work-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.work-table tr:last-child td { border-bottom: 0; }
table.work-table tr.is-open td { background: var(--ok-bg); }
table.work-table th.n, table.work-table td.n { text-align: right; }
table.work-table .work-actions { text-align: right; white-space: nowrap; }
.api-acc-card:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--line); }
.api-acc-card.is-on { border-color: var(--ok); background: var(--ok-bg); box-shadow: 0 0 0 3px rgba(12, 107, 90, 0.12); }
.api-acc-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.api-acc-line { color: var(--muted); font-size: 0.82rem; line-height: 1.3; }
.api-acc-mark { margin-top: 0.2rem; font-size: 0.82rem; font-weight: 700; color: var(--ok); }
.api-acc-cards.is-empty .api-acc-card { border-color: #e8590c; }
.api-acc-cards.is-empty .api-acc-mark { color: #b25e09; }
.api-account-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.8rem; font-size: 0.92rem; }
.api-link { min-height: 0; padding: 0.1rem 0.5rem; border: 0; background: transparent; color: var(--ok); font-size: 0.85rem; font-weight: 650; text-decoration: underline; box-shadow: none; cursor: pointer; }

/* пункты меню, недоступные роли, скрываются совсем (display у ссылок задан выше, поэтому одного hidden мало) */
.sidebar-nav a[hidden], .sidebar-settings[hidden], .sidebar-nav .sidebar-kicker[hidden] { display: none !important; }
.sidebar-nav.is-pending { visibility: hidden; }
[data-perm][hidden] { display: none !important; }

/* страница выгрузки показывает только свой раздел: файлы (Почта, СДЭК) или КСЭ */
body[data-mode="files"] #targetCards [data-target="cse"],
body[data-mode="files"] #historyFilter [data-hfilter="cse"],
body[data-mode="cse"] #targetCards [data-target="pochta"],
body[data-mode="cse"] #targetCards [data-target="cdek"],
body[data-mode="cse"] #historyFilter [data-hfilter="pochta"],
body[data-mode="cse"] #historyFilter [data-hfilter="cdek"],
body[data-mode="cse"] #historyFilter [data-hfilter="all"] { display: none !important; }

/* выход в нижней части меню (кнопка видна в обычном режиме, в отличие от .sidebar-pin-btn) */
.sidebar-logout {
  appearance: none; display: block; width: 100%; margin: 0.5rem 0 0; padding: 0.5rem 0.7rem; cursor: pointer;
  border: 1px solid rgba(169, 130, 47, 0.35); border-radius: 8px; background: rgba(12, 107, 90, 0.22); color: #e8d7a4; font-weight: 650;
}
.sidebar-logout:hover { background: rgba(12, 107, 90, 0.4); }
.sidebar.is-collapsed .sidebar-logout { font-size: 0; padding: 0.5rem; }
.sidebar.is-collapsed .sidebar-logout::before { content: "⎋"; font-size: 1rem; }

/* «Закрепить меню» вверху открытой панели: видна только когда меню спрятано */
.sidebar-pin-top {
  appearance: none; display: none; flex: 0 0 auto; width: 32px; height: 32px; margin-left: auto; place-items: center; padding: 0; cursor: pointer;
  border: 1px solid rgba(169, 130, 47, 0.35); border-radius: 8px; background: rgba(12, 107, 90, 0.22); color: #e8d7a4;
}
.sidebar-pin-top:hover { background: rgba(12, 107, 90, 0.4); color: #fff; }
body.nav-hide .sidebar-pin-top { display: grid; }
body.nav-hide .sidebar-pin-top + .sidebar-close { margin-left: 0.4rem; }

/* настройки: допустимые тарифы СДЭК */
.mi-tariff-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 0.45rem 1rem; margin: 0.6rem 0; }
.mi-tariff-extra { display: grid; gap: 0.25rem; max-width: 24rem; margin: 0.6rem 0; }

/* поиск по строкам шага «Проверить» */
.row-search { flex: 1 1 16rem; min-width: 11rem; max-width: 24rem; }
.row-search-info { font-size: 0.8rem; white-space: nowrap; }

/* причина «нет тарифа» в ячейке тарифа — видна всегда (общее правило прячет .mi-src в таблице) */
.mass-import-table td .mi-tariff-error { display: block; min-width: 10rem; max-width: 18rem; white-space: normal; font-size: 0.72rem; line-height: 1.25; color: #9a3412; }

/* файл отгрузки для СДЭК */
.api-export { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.7rem; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.api-export-title { font-weight: 650; font-size: 0.85rem; }
.api-export input[type="date"], .api-export select { width: auto; min-width: 0; padding: 0.3rem 0.5rem; }
.api-docs-sep { width: 1px; align-self: stretch; margin: 0 0.3rem; background: var(--line); }
