@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ---------- Дизайн-токены X.Stock (светлая тема) ---------- */
:root {
  --bg: #F8F7F5;            /* тёплый светло-серый фон страницы */
  --surface: #FFFFFF;        /* карточки, панели */
  --surface-2: #F3F4F6;      /* вторичные поверхности (бейджи, фон инпутов) */
  --text: #141414;           /* основной текст */
  --text-dim: #6B6B6B;       /* приглушённый текст */
  --text-dim2: #9CA3AF;      /* ещё бледнее (разделители, подписи) */
  --accent: #2563EB;         /* синий акцент */
  --accent-hover: #1D4ED8;   /* акцент при наведении */
  --danger: #B91C1C;         /* красный (текст ошибок/danger) */
  --danger-bg: #FEE2E2;      /* фон danger-бейджа */
  --success: #15803D;        /* зелёный текст */
  --success-bg: #DCFCE7;     /* фон success-бейджа */
  --warning: #92400E;        /* янтарный текст */
  --warning-bg: #FEF3C7;     /* фон warning-бейджа */
  --border: #E5E4E1;         /* основная граница */
  --border-soft: #F1F1EF;    /* мягкая граница (разделители внутри карточек) */
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 720px;
  margin: 0 auto;
  /* Bottom-nav фиксирован: оставляем место под него + safe-area iPhone. */
  padding: 12px 16px calc(96px + env(safe-area-inset-bottom, 0));
}

.muted { color: var(--text-dim); }
.small { font-size: 13px; }

/* ---------- Топбар ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  max-width: 720px;
  margin: 0 auto;
}
.topbar-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248, 247, 245, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 20px; color: var(--text); }
.brand.small { font-size: 16px; font-weight: 600; }
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: var(--text); font-size: 18px;
  border: 1px solid var(--border); background: var(--surface);
}
.back:hover { border-color: #D1D0CD; color: var(--text); }
.iconbtn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
}
.iconbtn:hover { border-color: #D1D0CD; }
.logout { color: var(--text-dim); font-size: 14px; padding: 6px 8px; }
.logout:hover { color: var(--text); }

/* ============================================================
   B1.2.m — Minimalist compact topbar (X.Stock style)
   ============================================================
   Одна полоса ~56px: [brand] · [search flex≤480] · [avatar→menu].
   Grid (a 1fr a) даёт центральной зоне поиска естественную ширину
   и автокомпрессию, когда левая часть длинная (focused-режим). */
.topbar-compact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 16px;
}

/* Поисковая зона в топбаре. Лупа абсолютно слева, ✕ — справа (только когда непусто). */
.topbar-search {
  position: relative;
  width: 100%;
  max-width: 480px;
  justify-self: center;
  display: flex;
  align-items: center;
}
.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}
/* Когда search-input живёт внутри .topbar-search — добавляем отступ слева под лупу
   и справа под ✕; снимаем нижнюю липкую полоску, чтобы не наследовалась от
   старого `.search-bar`-контекста (его больше нет в inbox.html). */
.topbar-search .search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 36px 8px 36px;
  min-height: 40px;
  border-radius: 10px;
  background: var(--surface);
}
.topbar-search .search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-search .search-clear:hover { background: var(--surface-2); color: var(--text); }

/* Аватар + выпадающее меню. */
.topbar .topbar-right { justify-self: end; }
.avatar-wrap { position: relative; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font: inherit; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.avatar:hover { background: #E8E7E3; border-color: #D1D0CD; }
.avatar-wrap[data-open="true"] .avatar { border-color: var(--accent); }
.avatar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-hover);
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.avatar-menu[hidden] { display: none; }
.avatar-menu-user {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar-menu-link {
  display: block;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  border-radius: 6px;
  text-decoration: none;
}
.avatar-menu-link:hover { background: var(--bg); color: var(--text); }

/* Mobile: brand слева, аватар справа, поиск — второй компактной строкой. */
@media (max-width: 640px) {
  .topbar-compact {
    grid-template-columns: auto auto;
    grid-template-areas:
      "brand avatar"
      "search search";
    row-gap: 6px;
    min-height: auto;
    padding: 8px 12px;
  }
  .topbar-compact > .topbar-left  { grid-area: brand; }
  .topbar-compact > .topbar-right { grid-area: avatar; }
  .topbar-compact > .topbar-search {
    grid-area: search;
    max-width: none;
    justify-self: stretch;
  }
}

/* ---------- Карточки / логин ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card { margin-top: 12vh; }
.alert {
  background: var(--danger-bg);
  border: 1px solid #FCA5A5;
  color: var(--danger);
  padding: 12px 14px; border-radius: 10px; margin: 16px 0; font-size: 14px;
}
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field span { color: var(--text-dim); }
.field input, .field select {
  background: #FFFFFF; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 12px 14px; font: inherit; min-height: 44px;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.btn {
  background: var(--accent); color: #FFFFFF; border: 0;
  border-radius: 10px; padding: 12px 16px; min-height: 44px;
  font: inherit; font-weight: 600; cursor: pointer;
  touch-action: manipulation;
  transition: background 120ms, transform 80ms, box-shadow 120ms, opacity 120ms;
}
.btn:hover { background: var(--accent-hover); }
.btn:active:not(:disabled) { transform: scale(0.97); background: var(--accent-hover); }

/* ---------- Инбокс ---------- */
.ib-stack { display: flex; flex-direction: column; gap: 22px; padding-top: 6px; }
.ib-section { display: flex; flex-direction: column; gap: 10px; }
.ib-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 2px 2px;
}
.ib-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: 0.01em;
  text-transform: uppercase;
}
.ib-section-ico { font-size: 16px; }
.ib-section-count { color: var(--text-dim); font-weight: 500; }
.ib-section-toggle {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.ib-section-toggle:hover { color: var(--text); border-color: #D1D0CD; }
.ib-section-body[data-collapsed="true"] { display: none; }
.ib-empty {
  padding: 14px 4px; font-size: 13px; color: var(--text-dim);
  border-top: 1px dashed var(--border);
}
.ib-list { display: flex; flex-direction: column; gap: 10px; }

.ib-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
  min-height: 80px;
}
.ib-card:hover { border-color: #D1D0CD; box-shadow: var(--shadow-hover); }
.ib-card:active { transform: scale(0.997); }
.ib-row1 { display: flex; align-items: center; gap: 8px; }
.ib-row2, .ib-row3 { display: flex; align-items: center; gap: 6px; }
.ib-num { font-weight: 600; font-size: 15px; color: var(--text); }
.ib-total { font-weight: 600; color: var(--text); }
.ib-time {
  margin-left: auto; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; color: var(--text-dim);
}
.ib-name { font-weight: 500; font-size: 14px; color: var(--text); }
.ib-phone { font-size: 14px; color: var(--text-dim); }
.ib-row3 { font-size: 13px; color: var(--text-dim); }
.ib-sep { color: var(--text-dim2); }

/* ---------- Блоки карточки заказа ---------- */
.od-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.od-h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); font-weight: 600; margin-bottom: 12px;
}

/* Блок 1: баннер статуса */
.od-status { padding: 0; overflow: hidden; }
.od-status-banner {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.od-status-name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.od-status-meta { margin-top: 4px; }
/* Лёгкие тинты для светлой темы — сильно ослаблены по сравнению с тёмной */
.od-bg-blue   { background: linear-gradient(180deg, rgba(37,99,235,.08),  rgba(37,99,235,.02)); }
.od-bg-yellow { background: linear-gradient(180deg, rgba(245,158,11,.10), rgba(245,158,11,.02)); }
.od-bg-green  { background: linear-gradient(180deg, rgba(34,197,94,.08),  rgba(34,197,94,.02)); }
.od-bg-red    { background: linear-gradient(180deg, rgba(239,68,68,.08),  rgba(239,68,68,.02)); }
.od-bg-gray   { background: linear-gradient(180deg, rgba(150,150,150,.06), rgba(150,150,150,.01)); }
.od-manual { padding: 12px 16px 16px; }
.od-manual > summary {
  cursor: pointer; color: var(--text-dim); font-size: 13px;
  list-style: none; user-select: none;
}
.od-manual > summary::before { content: "▸ "; color: var(--text-dim2); }
.od-manual[open] > summary::before { content: "▾ "; }
.od-manual-body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

/* Статусный бейдж (используется макросами) — пастельный стиль X.Stock */
.status-badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.status-blue   { color: #1D4ED8; background: #DBEAFE; }
.status-yellow { color: var(--warning); background: var(--warning-bg); }
.status-green  { color: var(--success); background: var(--success-bg); }
.status-red    { color: var(--danger);  background: var(--danger-bg); }
.status-gray   { color: #6B7280; background: #F3F4F6; }

/* Блок 2: клиент */
.od-client-name {
  display: inline-block; font-size: 18px; font-weight: 600;
  color: var(--text); margin-bottom: 12px;
}
.od-client-name:hover { color: var(--accent); }
.od-delivery { margin-top: 10px; color: var(--text-dim); }
.od-address { margin-top: 4px; color: var(--text-dim); }

.contact-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; margin-top: 4px;
}
.contact-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 56px; padding: 6px 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.contact-btn:hover { border-color: #D1D0CD; box-shadow: var(--shadow); color: var(--text); }
.contact-btn.disabled { color: var(--text-dim2); opacity: .55; }
.contact-ico { font-size: 18px; line-height: 1; }
.contact-cap { font-size: 11px; color: var(--text-dim); }

/* Блок 3: позиции */
.od-items { display: flex; flex-direction: column; gap: 10px; list-style: none; }
.od-item {
  padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 10px;
  background: #FAFAF9;
}
.od-item-main { display: flex; gap: 8px; align-items: baseline; }
.od-item-qty { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.od-item-name { font-size: 14px; font-weight: 500; color: var(--text); }
.od-item-meta { margin-top: 4px; }
.tag-warn {
  display: inline-block; margin-left: 8px;
  background: var(--warning-bg); color: var(--warning);
  border-radius: var(--radius-sm); padding: 1px 6px; font-size: 11px;
}
.tag {
  display: inline-block; margin-left: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1px 6px; font-size: 11px; color: var(--text-dim);
}
.od-stock-note { margin-top: 10px; }

/* Блок 4: финансы */
.od-finance .fin-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-variant-numeric: tabular-nums;
  padding: 4px 0;
}
.od-finance .fin-row > span:first-child { color: var(--text-dim); }
.od-finance .fin-row > span:last-child  { color: var(--text); }
.fin-divider { height: 1px; background: var(--border); margin: 8px 0; }
.fin-margin { font-weight: 600; font-size: 17px; }
.margin-green  > span:last-child { color: #15803D; }
.margin-yellow > span:last-child { color: #92400E; }
.margin-red    > span:last-child { color: #B91C1C; }
.margin-black  > span:last-child { color: #7F1D1D; font-weight: 700; }

/* Блок 5: шаги по поставщику */
.sup-steps { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.sup-step { display: flex; gap: 12px; align-items: flex-start; }
.sup-marker {
  font-size: 16px; line-height: 1.2; padding-top: 1px;
  flex-shrink: 0;
}
.sup-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sup-label { font-size: 14px; color: var(--text); }
.sup-current .sup-label { font-weight: 600; color: var(--text); }
.sup-pending .sup-label { color: var(--text-dim); }
.sup-done .sup-label { color: var(--text); }
.sup-ts { font-size: 12px; color: var(--text-dim); }

/* Блок 6: плейсхолдер действий (для legacy-fallback) */
.od-actions-placeholder {
  padding: 14px 14px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: #FAFAF9;
  color: var(--text-dim);
}

/* Блок 6: реальные кнопки действий.
   Primary/secondary — полноширинные сверху, danger — снизу через тонкий разделитель. */
.actions-list { display: flex; flex-direction: column; gap: 10px; }
.actions-banner {
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--warning-bg); color: var(--warning);
  font-weight: 500;
}
.action-btn {
  display: block; width: 100%; min-height: 48px;
  border-radius: var(--radius); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 12px 16px;
  text-align: center;
}
.btn-primary {
  background: var(--accent); color: #FFFFFF; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { border-color: #D1D0CD; }
.btn-secondary:active:not(:disabled) { transform: scale(0.98); background: var(--bg); }
/* Danger-блок: тонкий разделитель сверху, кнопки уменьшенной высоты с приглушённой красной обводкой. */
.od-actions-danger {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.btn-danger {
  width: 100%; min-height: 40px; padding: 8px 12px;
  font-size: 14px; font-weight: 500;
  color: var(--danger); background: transparent;
  border: 1px solid #FECACA; border-radius: var(--radius-sm);
}
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger:active:not(:disabled) { transform: scale(0.98); background: var(--danger-bg); }

/* Модалки */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,20,20,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 520px;
  padding: 18px 18px 20px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.18);
  display: flex; flex-direction: column; gap: 12px;
  max-height: 90vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.modal-title { font-size: 17px; font-weight: 600; color: var(--text); }
.modal-close {
  background: transparent; border: 0; font-size: 22px; color: var(--text-dim);
  cursor: pointer; line-height: 1; padding: 4px 8px;
}
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-body .field { display: flex; flex-direction: column; gap: 4px; }
.modal-body input, .modal-body select, .modal-body textarea {
  background: #FFFFFF; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 10px 12px; font: inherit; min-height: 42px;
  resize: vertical;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px;
}
.modal-actions button {
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; min-height: 42px;
}
.modal-error {
  padding: 8px 12px; border-radius: 8px;
  background: var(--danger-bg); color: var(--danger);
  font-size: 13px;
}
.modal-tabs, .modal-radio {
  display: flex; gap: 14px; padding: 4px 0;
}
.modal-tabs label, .modal-radio label {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}

/* Icon-кнопки (lock-toggle и т.п.) */
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 16px;
}
.iconbtn:hover { border-color: #D1D0CD; }

/* SVG-иконки в контакт-кнопках */
.contact-svg { width: 20px; height: 20px; display: inline-block; }

/* Stock badge (живые остатки в Block 3) */
.stock-badge {
  display: inline-block; margin-left: 8px;
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim);
}
.stock-badge.stock-ok      { background: var(--success-bg); color: var(--success); }
.stock-badge.stock-low     { background: var(--warning-bg); color: var(--warning); }
.stock-badge.stock-out     { background: var(--danger-bg);  color: var(--danger); }
.stock-badge.stock-pending,
.stock-badge.stock-unknown { background: var(--surface-2);  color: var(--text-dim); }

/* Линки-кнопки в Block 8 */
.att-actions { display: flex; gap: 12px; align-items: center; }
.btn-link {
  background: transparent; border: 0; padding: 4px 0;
  color: var(--accent); cursor: pointer; font: inherit; font-weight: 500;
}
.btn-link:hover { color: var(--accent-hover); }
.btn-link-danger { color: var(--danger); }
.btn-link-danger:hover { color: #7F1D1D; }

/* Блок 7: история */
.od-history { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.od-history-item { display: flex; gap: 10px; }
.hist-icon { font-size: 16px; line-height: 1.4; flex-shrink: 0; }
.hist-body { flex: 1; min-width: 0; }
.hist-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.hist-action { font-size: 13px; font-weight: 600; color: var(--text); }
.hist-diff { margin-top: 2px; word-break: break-word; color: var(--text-dim); }
.hist-actor { margin-top: 2px; color: var(--text-dim); }

/* Блок 8: вложения */
.od-attachments { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.od-att {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; background: #FAFAF9; border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.att-name { font-weight: 500; color: var(--text); }
.att-meta { margin-top: 2px; color: var(--text-dim); }

/* ---------- 403 / 404 ---------- */
.empty-hint { text-align: center; font-size: 13px; padding: 22px 12px; color: var(--text-dim); }

/* ---------- Bottom navigation ----------
   Жёстко прибит к низу вьюпорта; внутренний контейнер ограничен 720px по ширине,
   как .container — чтобы пункты не растягивались на десктопе. */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bn-inner {
  max-width: 720px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 56px; padding: 6px 4px;
  color: var(--text-dim);
  text-decoration: none;
}
.bn-item:hover { color: var(--text); }
.bn-item:active { background: var(--bg); color: var(--text); }
.bn-item.is-active { color: var(--accent); }
.bn-item { touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background 100ms, color 120ms; }
.bn-ico { width: 22px; height: 22px; display: block; }
.bn-label { font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }

/* ---------- Clients: список ---------- */
.clients-list { display: flex; flex-direction: column; gap: 8px; list-style: none; padding-top: 4px; }
.client-list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
  min-height: 64px;
}
.client-list-row:hover { border-color: #D1D0CD; box-shadow: var(--shadow-hover); color: var(--text); }
.cl-main { min-width: 0; flex: 1; }
.cl-name { font-weight: 600; font-size: 15px; }
.cl-phone { margin-top: 2px; }
.cl-meta { text-align: right; }
.cl-count { font-weight: 500; font-size: 13px; color: var(--text); }
.cl-revenue { font-variant-numeric: tabular-nums; }

/* ---------- Client card: inline-edit ---------- */
.cl-edit-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cl-edit-field {
  background: #FAFAF9; border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 8px 12px;
}
.cl-edit-label { margin-bottom: 2px; }
.cl-edit-display {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 32px; cursor: text; outline: none;
}
.cl-edit-display:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.cl-edit-value { color: var(--text); flex: 1; white-space: pre-wrap; word-break: break-word; }
.cl-edit-pencil {
  color: var(--text-dim2); font-size: 13px; opacity: 0;
  transition: opacity .12s ease;
}
.cl-edit-field:hover .cl-edit-pencil,
.cl-edit-display:focus-visible + .cl-edit-pencil { opacity: 1; }
.cl-edit-display:hover .cl-edit-pencil { opacity: 1; }
.cl-edit-raw { margin-top: 2px; font-variant-numeric: tabular-nums; }
.cl-edit-input {
  width: 100%; background: #FFFFFF; border: 1px solid var(--accent);
  color: var(--text); border-radius: 8px;
  padding: 8px 10px; font: inherit; min-height: 36px;
  outline: 2px solid rgba(37,99,235,.15);
}
.cl-edit-field.editing .cl-edit-display { display: none; }
.cl-edit-field.saved-flash {
  background: var(--success-bg); transition: background .35s ease;
}

/* Flash-сообщение об успехе/ошибке внизу карточки клиента */
.cl-flash {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom, 0));
  padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-hover);
  z-index: 60;
}
.cl-flash-ok   { background: var(--success-bg); color: var(--success); }
.cl-flash-warn { background: var(--warning-bg); color: var(--warning); }
.cl-flash-err  { background: var(--danger-bg);  color: var(--danger); }

/* ---------- Client card: юр.лицо ---------- */
.legal-grid {
  display: grid; grid-template-columns: max-content 1fr;
  gap: 4px 12px; font-size: 14px;
}
.legal-grid dt { color: var(--text-dim); }
.legal-grid dd { color: var(--text); }

/* ---------- Client card: список заказов ---------- */
.client-orders-list { display: flex; flex-direction: column; gap: 6px; list-style: none; }
.client-order-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #FAFAF9;
  border: 1px solid var(--border-soft); border-radius: 10px;
  color: var(--text); font-size: 14px;
}
.client-order-row:hover { border-color: #D1D0CD; color: var(--text); }
.co-num { font-weight: 600; }
.co-total { font-variant-numeric: tabular-nums; margin-left: 4px; }
.co-date { margin-left: auto; white-space: nowrap; }

/* ---------- Client card: сводка ---------- */
.client-summary .cs-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-variant-numeric: tabular-nums; padding: 4px 0;
}
.client-summary .cs-row > span:first-child { color: var(--text-dim); }
.client-summary .cs-row > span:last-child  { color: var(--text); font-weight: 500; }

/* ---------- Профиль / Алерты ---------- */
.profile-block { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.profile-name { font-size: 20px; font-weight: 600; }
.role-chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.role-chip.role-admin   { background: #DBEAFE; color: #1D4ED8; }
.role-chip.role-manager { background: var(--surface-2); color: var(--text-dim); }
.profile-actions { margin-top: 8px; width: 100%; }
.profile-actions .action-btn { max-width: 240px; }
.profile-version { margin-top: 12px; }

.alerts-stub {
  margin-top: 60px; text-align: center;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
}
.alerts-stub-ico { font-size: 48px; opacity: .6; }
.alerts-stub-text { font-size: 15px; color: var(--text); line-height: 1.5; }

/* ---------- Адаптив ---------- */
@media (max-width: 420px) {
  .topbar { padding: 8px 12px; }
  .container { padding: 10px 12px calc(96px + env(safe-area-inset-bottom, 0)); }
  .od-status-name { font-size: 19px; }
  .ib-card { padding: 10px 12px; }
}

/* ===== B1.2.e: pin / archive / long-press menu / multi-select ===== */

/* Карточка Inbox с поддержкой длинного нажатия и multi-select. */
.ib-card { position: relative; display: flex; align-items: stretch; gap: 0; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ib-card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ib-card.pressing { background: #F3F2EE; transform: scale(0.995); transition: background 120ms, transform 120ms; }

/* 🔥 закреплено */
.pin-flame { margin-right: 4px; line-height: 1; }
.ib-card.is-pinned { border-color: #F5C36B; box-shadow: 0 0 0 1px #F5C36B inset, var(--shadow); }
.ib-card.is-pinned:hover { border-color: #E5A933; }

/* Архивные карточки чуть приглушённые */
.ib-section.archive .ib-card { opacity: 0.85; }
.ib-section.archive .ib-section-title { color: var(--text-dim); }

/* Кнопка «Восстановить» в архивной карточке */
.btn-restore {
  align-self: center; flex: 0 0 auto; margin-left: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.btn-restore:hover { border-color: #D1D0CD; }

/* Чекбокс multi-select — скрыт по умолчанию, появляется только когда .ms-on */
.ib-checkbox-wrap {
  flex: 0 0 0; width: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: width 180ms ease, margin-right 180ms ease;
  margin-right: 0;
}
body.ms-on .ib-checkbox-wrap { width: 28px; margin-right: 10px; }
.ib-checkbox {
  width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 6px;
  background: #FFFFFF; display: inline-flex; align-items: center; justify-content: center;
  color: #FFFFFF; transition: background 150ms, border-color 150ms;
}
.ib-check-ico { width: 16px; height: 16px; opacity: 0; transition: opacity 120ms; }
.ib-card.selected .ib-checkbox { background: var(--accent); border-color: var(--accent); }
.ib-card.selected .ib-check-ico { opacity: 1; }
.ib-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }

/* Bottom-sheet меню одиночного заказа */
.order-menu-sheet {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.order-menu-sheet .om-backdrop {
  position: absolute; inset: 0; background: rgba(20,20,20,0.0);
  transition: background 200ms ease; pointer-events: auto;
}
.order-menu-sheet.open .om-backdrop { background: rgba(20,20,20,0.4); }
.order-menu-sheet .om-panel {
  position: relative; width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.12);
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0));
  transform: translateY(100%); transition: transform 220ms ease;
  pointer-events: auto;
}
.order-menu-sheet.open .om-panel { transform: translateY(0); }
.om-handle { width: 36px; height: 4px; background: #D1D0CD; border-radius: 2px; margin: 6px auto 10px; }
.om-head { display: flex; flex-direction: column; gap: 2px; padding: 0 6px 8px; border-bottom: 1px solid var(--border-soft); }
.om-title { font-weight: 600; font-size: 15px; color: var(--text); }
.om-sub { font-size: 13px; color: var(--text-dim); }
.om-rows { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; max-height: 60vh; overflow-y: auto; }
.om-loading { padding: 12px; text-align: center; font-size: 14px; }
.om-loading.danger { color: #B91C1C; }
.order-menu-row {
  background: transparent; border: none; text-align: left;
  padding: 14px 10px; font-size: 15px; color: var(--text);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
}
.order-menu-row:hover { background: var(--bg); }
.order-menu-row:active { background: #ECEBE7; }
.order-menu-row[disabled] { color: var(--text-dim2); cursor: default; }
.order-menu-row.danger { color: #B91C1C; }
.order-menu-row.has-submenu .om-chev { color: var(--text-dim); font-size: 18px; line-height: 1; }
.om-cancel {
  width: 100%; margin-top: 6px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; font-size: 14px; cursor: pointer;
}
.om-cancel:hover { border-color: #D1D0CD; }

/* Multi-select bottom bar — над bottom-nav */
.multiselect-bar {
  position: fixed; left: 0; right: 0; z-index: 60;
  bottom: calc(56px + env(safe-area-inset-bottom, 0));
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.ms-inner {
  max-width: 720px; margin: 0 auto; padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ms-count { font-size: 14px; color: var(--text); font-weight: 500; }
.ms-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ms-btn, .ms-cancel {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.ms-btn:disabled { color: var(--text-dim2); cursor: not-allowed; }
.ms-btn:not(:disabled):hover, .ms-cancel:hover { border-color: #D1D0CD; }
.ms-cancel { color: var(--text-dim); }

/* Тост */
.ib-toast {
  position: fixed; left: 50%; bottom: 120px; transform: translate(-50%, 20px);
  background: rgba(20,20,20,0.92); color: #FFFFFF;
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  z-index: 300; opacity: 0; transition: opacity 200ms, transform 200ms;
  pointer-events: none; max-width: 80vw; text-align: center;
}
.ib-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Подсветка успешной мгновенной смены статуса (select#manualStatusSelect). */
.flash-ok { border-color: #10B981 !important; box-shadow: 0 0 0 2px rgba(16,185,129,0.25); transition: border-color 200ms, box-shadow 200ms; }

/* ===================================================================
   B1.2.f — Order card: 2-col desktop layout, mobile sticky CTA,
            inline manual status, collapsible blocks.
   =================================================================== */

/* Карточка — расширяем контейнер на десктопе. */
.order-card-container { max-width: 1100px; }

/* Двухколоночная раскладка карточки (B1.2.g+):
   Замена прежней CSS-grid на ДВА независимых flex-flow контейнера —
   .card-col-left и .card-col-right. Раньше grid выравнивал блоки по
   строкам сетки → под коротким status'ом образовывалась пустая высота,
   пока правая колонка дорастала до высоты Клиент+Поставщик+Действия.
   Теперь каждая колонка течёт сама по себе, без row-alignment.

   Мобайл (<900px): .card-col-* становятся display:contents, и все
   8 секций становятся прямыми flex-children внешнего .card-cols
   (flex-direction: column). Желаемый порядок задаётся `order` на каждой
   секции (см. ниже) — статус → клиент → поставщик → действия → состав
   → финансы → история → файлы. */
.card-cols {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-cols > .card-col {
  /* Сами обёртки на мобайле "прозрачные" — потомки участвуют во внешнем flex. */
  display: contents;
}
/* Порядок секций на мобайле (внутри display:flex column). */
.card-cols [data-block="status"]      { order: 1; }
.card-cols [data-block="client"]      { order: 2; }
.card-cols [data-block="supplier"]    { order: 3; }
.card-cols [data-block="actions"]     { order: 4; }
.card-cols [data-block="items"]       { order: 5; }
.card-cols [data-block="finance"]     { order: 6; }
.card-cols [data-block="history"]     { order: 7; }
.card-cols [data-block="attachments"] { order: 8; }

@media (min-width: 900px) {
  .card-cols {
    flex-direction: row;
    /* Колонки разной высоты — не растягиваем правую под левую (и наоборот). */
    align-items: flex-start;
    gap: 20px;
  }
  .card-cols > .card-col {
    /* На десктопе включаем обёртки обратно: каждая колонка — свой flex-column. */
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0; /* предотвращаем overflow от длинных названий товаров/ссылок */
  }
  .card-cols > .card-col-left  { flex: 1 1 62%; }
  .card-cols > .card-col-right {
    flex: 0 0 360px;
    /* Правая колонка целиком — sticky (Клиент/Поставщик/Действия едут со скроллом). */
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  /* На десктопе `order` сбрасываем — порядок берётся из DOM внутри своей колонки. */
  .card-cols [data-block]:not(:root) { order: 0; }

  /* Заголовок (topbar) выравниваем по ширине двухколоночной раскладки. */
  body.order-card-page .topbar { max-width: 1100px; }
}

/* Inline-селект ручной смены статуса внутри блока статуса.
   Блок .od-status имеет padding:0 (баннер во всю ширину), поэтому
   возвращаем горизонтальные отступы именно этому контейнеру,
   чтобы лейбл и select были выровнены с текстом баннера. */
.od-manual-inline {
  margin-top: 0;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.od-manual-inline select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 36px 10px 14px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
  cursor: pointer;
  /* Кастомный chevron (SVG-data-uri) — единый вид в Safari/Chrome/FF. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%236B6B6B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  transition: border-color 120ms, box-shadow 120ms;
}
.od-manual-inline select:focus,
.od-manual-inline select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
}
.od-manual-inline select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Лёгкая подсветка успешной мгновенной смены статуса. */
.flash-ok {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 2px rgba(21, 128, 61, 0.25);
  transition: border-color 200ms, box-shadow 200ms;
}

/* Сворачиваемые блоки (история/вложения на мобайле). */
.od-collapsible > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.od-collapsible > summary::-webkit-details-marker { display: none; }
.od-collapsible > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--text-dim);
  font-size: 18px;
  transition: transform 150ms;
}
.od-collapsible[open] > summary::after { transform: rotate(90deg); }
.od-h3.inline { display: inline; font-size: inherit; }

/* Мобильная sticky CTA: фиксированная панель внизу с back + основным CTA. */
.card-sticky-cta { display: none; }
@media (max-width: 899px) {
  /* Скрываем bottom-nav на карточке заказа (CTA вместо вкладок). */
  body.order-card-page .bottom-nav { display: none; }
  /* Уменьшаем нижний паддинг контейнера — bottom-nav отсутствует. */
  body.order-card-page .container {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }
  /* Тайтер вертикальных промежутков между блоками. */
  .card-cols { gap: 8px; }
  .od-block { padding: 12px 14px; }

  .card-sticky-cta {
    display: flex;
    gap: 8px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0));
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 40;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }
  .card-sticky-cta .csc-back {
    flex: 0 0 auto;
    min-width: 56px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    text-decoration: none;
  }
  .card-sticky-cta .csc-primary {
    flex: 1 1 auto;
    min-height: 48px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* B1.2.g: блок «Клиент» в карточке заказа — заголовок + ссылка на карточку. */
.od-client-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.od-client-head .od-h3 { margin: 0; }
.od-client .cl-edit-grid { margin-top: 12px; }
.od-client .od-delivery { margin-top: 10px; }

/* B1.2.h: артикул в составе заказа — серая мини-метка между brand и tag. */
.od-item-sku { white-space: nowrap; }

/* ============================================================
   B1.2.h — Глобальный поиск (Inbox sticky bar + результаты)
   ============================================================ */

/* Полоска поиска: липкая, сразу под topbar. top вычисляется по высоте topbar
   (~52px на мобайле, чуть выше на десктопе — оставляем компромисс 52px). */
.search-bar {
  position: sticky;
  top: 52px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(248, 247, 245, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin: 0 -12px 12px; /* вытягиваем в ширину container'а (у которого padding 12px) */
}
.search-input {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  min-height: 40px;
  transition: border-color 120ms, box-shadow 120ms;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus,
.search-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
}
/* iOS Safari рендерит лупу/крестик внутри type="search" поверх appearance:none —
   глушим обе декорации, плюс input всё равно сделан type="text". */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration { display: none; -webkit-appearance: none; }
.search-clear {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  background: var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { background: var(--text-dim); color: #fff; }

/* Сгруппированные результаты. */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.search-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}
.search-group-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 2px 0 8px;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  border-top: 1px solid var(--border-soft, var(--border));
  min-height: 48px;
}
.search-row:first-of-type { border-top: none; }
.search-row:hover,
.search-row:focus-visible { background: rgba(0, 0, 0, 0.03); outline: none; }
.search-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-row-title {
  font-weight: 500;
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.search-row-meta {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-row-status {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 13px;
}
.search-row-tag {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  white-space: nowrap;
}
.search-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.search-badge.cancelled { background: #FEE2E2; color: #991B1B; }
.search-badge.archived  { background: #E5E7EB; color: #374151; }
.search-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* На десктопе search-bar выровнен по ширине container'а (max-width 800 / 1100). */
@media (min-width: 900px) {
  .search-bar { margin-left: 0; margin-right: 0; top: 56px; }
}

/* ============================================================
   B1.2.i — Тактильная отзывчивость (мгновенный отклик на тап)
   ============================================================ */

/* 1) Глобально убираем 300мс задержку double-tap и серую вспышку iOS/Android. */
html { -webkit-tap-highlight-color: transparent; }
a, button, summary, [role="button"], .ib-card, .search-row, .order-menu-row,
.bn-item, .cl-edit-display, .btn-restore, .btn-link, .om-cancel {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 2) Active-состояния для часто-нажимаемых рядов/ссылок. */
.btn-link:active { color: var(--accent-hover); opacity: 0.7; }
.btn-restore:active { background: var(--bg); transform: scale(0.98); }
.search-row { transition: background 100ms, transform 80ms; }
.search-row:active { background: var(--bg); transform: scale(0.995); }
.order-menu-row { transition: background 100ms; }
.cl-edit-display { transition: background 100ms; }
.cl-edit-display:active { background: var(--bg); }

/* 3) Усиленный visual press для карточек Inbox — заметнее на мобайле. */
.ib-card { transition: background 100ms, transform 80ms, border-color 120ms, box-shadow 120ms; }
.ib-card:active:not(.selected) { background: #F3F2EE; transform: scale(0.995); }
.ib-card.pressing { background: #ECEBE7; transform: scale(0.99); }

/* 4) Кнопки в состоянии загрузки: спиннер справа от текста, opacity, no-pointer.
      Совместимо с button[disabled] (selector :disabled тоже сработает). */
.btn.is-loading, .btn-primary.is-loading, .btn-secondary.is-loading,
.btn-danger.is-loading, .btn-restore.is-loading {
  position: relative;
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}
.btn.is-loading::after, .btn-primary.is-loading::after,
.btn-secondary.is-loading::after, .btn-danger.is-loading::after,
.btn-restore.is-loading::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: xcrm-spin 0.7s linear infinite;
}
@keyframes xcrm-spin {
  to { transform: rotate(360deg); }
}

/* 5) Карточка в процессе оптимистичного действия (короткая визуальная подсказка). */
.ib-card.is-pending {
  opacity: 0.65;
  pointer-events: none;
  transition: opacity 120ms;
}

/* ============================================================
   B1.2.k — Copy-to-clipboard buttons (для СДЭК polям)
   Маленькая инлайн-кнопка 📋 рядом со значением. На клик
   меняется на ✅ (state .copied) на ~1.5s; при ошибке — ✕ (.failed).
   ============================================================ */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 120ms, color 120ms, transform 80ms;
}
.copy-btn:hover { color: var(--text); background: var(--border); }
.copy-btn:active { transform: scale(0.92); }
.copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.copy-btn.copied { color: var(--success, #16a34a); }
.copy-btn.copied::before { content: '✅'; }
.copy-btn.copied { font-size: 0; }
.copy-btn.copied::before { font-size: 14px; }
.copy-btn.failed { color: var(--danger, #dc2626); font-size: 0; }
.copy-btn.failed::before { content: '✕'; font-size: 14px; }

/* ============================================================
   B1.2.l — Tracking display block (Блок 1b «Доставка»)
   ============================================================ */
.od-tracking { /* секция-обёртка — наследует .od-block */ }
.od-tracking-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.od-tracking-carrier {
  font-weight: 600;
}
.od-tracking-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}
.od-tracking-link { /* кнопка «Отследить →» */
  margin-left: 4px;
}
.btn-link {
  background: transparent;
  border: none;
  color: var(--accent, #2563eb);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-sm { font-size: 13px; padding: 4px 10px; }
