/* CoffeeCustomCRM — базовые стили.
   Мобильные сначала, десктоп — с 960px.
   Свои стили без сборщика: один файл, никаких зависимостей. */

:root {
  color-scheme: light;
  --bg: #f4f0eb;
  --surface: #ffffff;
  --surface-2: #faf7f3;
  --text: #241f1b;
  --text-soft: #5c524a;
  --muted: #756a61;
  --border: #ddd3c9;
  --border-strong: #a08d7b;

  --brand: #6f4e37;
  --brand-strong: #5a3e2b;
  --brand-soft: #efe5dc;
  --brand-ink: #ffffff;

  --ok: #1f7a4d;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(36, 31, 27, .05), 0 10px 30px rgba(36, 31, 27, .05);
  --sidebar-w: 264px;
  --topbar-h: 61px;
  --bottom-nav-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17130f;
  --surface: #201a15;
  --surface-2: #262019;
  --text: #f2ece6;
  --text-soft: #cdbfb3;
  --muted: #9c8f83;
  --border: #3f342b;
  --border-strong: #7f6b58;

  --brand: #c79a74;
  --brand-strong: #dbae88;
  --brand-soft: #33271d;
  --brand-ink: #1b1511;

  --ok: #6fd39f;
  --ok-bg: #17301f;
  --warn: #f0c36b;
  --warn-bg: #33280f;
  --danger: #ff9c93;
  --danger-bg: #3a1916;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
}

/* iOS: светлая тема в духе iPhone и Mac. Меняются только токены оформления,
   разметка и логика общие с остальными темами. */
:root[data-theme="ios"] {
  color-scheme: light;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --text: #1c1c1e;
  --text-soft: #3a3a3c;
  --muted: #6e6e73;
  --border: #d8d8dd;
  --border-strong: #8e8e93;

  --brand: #0a6cff;
  --brand-strong: #0055cc;
  --brand-soft: #e7f0ff;
  --brand-ink: #ffffff;

  --ok: #248a3d;
  --ok-bg: #e8f7ee;
  --warn: #a35200;
  --warn-bg: #fff4e5;
  --danger: #d70015;
  --danger-bg: #ffecec;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 24px rgba(0, 0, 0, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Видимый фокус с клавиатуры. Мышью рамка не появляется, поэтому
   оформление не меняется, но Tab всегда показывает, где мы находимся. */
a:focus-visible,
.link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}
code { font-family: var(--mono); font-size: .9em; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

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

.app-shell { min-height: 100vh; }

.sidebar { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand--center { justify-content: center; }
.brand__name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }

/* Логотип CoffeeCustomCRM. В исходнике он белый (для тёмной темы),
   для светлых тем лежит перекрашенная версия — иначе знак пропадал бы
   на белом фоне. */
.brand__logo { display: block; width: 100%; max-width: 216px; height: auto; }
.brand__logo--for-dark { display: none; }
:root[data-theme="dark"] .brand__logo--for-light { display: none; }
:root[data-theme="dark"] .brand__logo--for-dark { display: block; }

.brand--logo { display: flex; justify-content: center; }
.brand--logo .brand__logo { max-width: 300px; }

.brand__mark-img {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.brand__mark-img--for-dark { display: none; }
:root[data-theme="dark"] .brand__mark-img--for-light { display: none; }
:root[data-theme="dark"] .brand__mark-img--for-dark { display: block; }
.brand--compact .brand__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.topbar__menu {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
.topbar__menu:hover { background: var(--brand-soft); }

.mobile-menu {
  position: fixed;
  inset: calc(var(--topbar-h) + env(safe-area-inset-top)) 0 0;
  z-index: 25;
  overflow-y: auto;
  padding: 16px 16px calc(var(--bottom-nav-h) + 24px);
  background: var(--bg);
}
.mobile-menu__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mobile-menu__section {
  grid-column: 1 / -1;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.mobile-menu__section:first-child { margin-top: 0; }
.mobile-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.mobile-menu__item:hover { text-decoration: none; border-color: var(--border-strong); }
.mobile-menu__item.is-active { border-color: var(--brand); color: var(--brand); }
.mobile-menu__icon { font-size: 18px; line-height: 1; }
.mobile-menu__label { min-width: 0; }
.mobile-menu__footer { display: grid; gap: 10px; margin-top: 16px; }
.mobile-menu__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.mobile-menu__user:hover { text-decoration: none; }
body.menu-open { overflow: hidden; }
.topbar__bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 18px;
  text-decoration: none;
}
.topbar__bell:hover { text-decoration: none; }
.topbar__bell-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.main {
  padding: 18px 16px calc(var(--bottom-nav-h) + 24px);
  max-width: 1180px;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--bottom-nav-h);
  padding: 6px 4px;
  color: var(--muted);
  font-size: 10.5px;
  text-decoration: none;
}
.bottom-nav__item:hover { text-decoration: none; }
.bottom-nav__item.is-active { color: var(--brand); }
.bottom-nav__item.is-disabled { opacity: .45; }
.bottom-nav__icon { position: relative; font-size: 19px; line-height: 1; }
.bottom-nav__badge {
  position: absolute;
  top: -7px;
  right: -13px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* ---------- Навигация (десктоп) ---------- */

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 22px; min-height: 0; overflow-y: auto; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14.5px;
  font-weight: 500;
}
.nav__item:hover { background: var(--surface-2); text-decoration: none; }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.nav__item.is-disabled { opacity: .5; }
.nav__item:focus-visible,
.nav__group-head:focus-visible,
.mobile-menu__item:focus-visible,
.topbar__menu:focus-visible,
.topbar__bell:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.bottom-nav__item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -3px;
  border-radius: 10px;
}
.nav__icon { width: 20px; text-align: center; font-size: 16px; }
.nav__label { flex: 1; }
.nav__group > summary {
  list-style: none;
  cursor: pointer;
}
.nav__group > summary::-webkit-details-marker { display: none; }
.nav__group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14.5px;
  font-weight: 500;
}
.nav__group-head:hover { background: var(--surface-2); }
.nav__group-head.is-active { color: var(--brand-strong); }
.nav__chevron {
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  transition: transform .15s ease;
}
.nav__group[open] .nav__chevron { transform: rotate(90deg); }
.nav__children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 22px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.nav__item--child { padding: 8px 10px; font-size: 14px; }
.nav__item--child .nav__icon { font-size: 14px; }
.nav__badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* ---------- Общие блоки ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 18px;
}
/* Заголовок и кнопки делят строку, но на планшете кнопки переносятся,
   а не вылезают за правый край страницы. */
.page-head > div { min-width: 0; }
.page-head > .form__actions {
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.page-title { font-size: 26px; letter-spacing: -.02em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
  background: var(--surface);
  /* Граница чуть темнее обычных линий: карточка отделяется от фона
     страницы даже там, где тень незаметна. */
  border: 1px solid color-mix(in srgb, var(--border) 45%, var(--border-strong));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--narrow { max-width: 560px; }
.card--muted { background: var(--surface-2); box-shadow: none; }
.card__title { font-size: 16px; margin-bottom: 12px; }
.card__subtitle { font-size: 15px; margin-bottom: 6px; }
.card--inset { background: var(--surface-2); padding: 14px; }
.card--inset .btn { margin-top: 10px; }

.muted { color: var(--muted); font-size: 14px; }
.link { color: var(--brand); }

.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: 1fr 1fr; }

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

.stat-card {
  display: grid;
  gap: 2px;
  color: var(--text);
  margin-bottom: 0;
}
.stat-card:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-card__label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.stat-card__value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.stat-card__hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  gap: 18px;
  border-left: 4px solid var(--brand);
}
.hero__title { font-size: 21px; margin-bottom: 6px; letter-spacing: -.01em; }
.hero__sub { color: var(--text-soft); font-size: 14.5px; max-width: 62ch; }
.hero__stats { display: flex; gap: 26px; flex-wrap: wrap; }
.hero__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.stat { display: flex; flex-direction: column; }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover .stat__label { color: var(--brand); }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat__label { font-size: 12px; color: var(--muted); }

/* ---------- Модули ---------- */

.module-card h3 { font-size: 16px; margin: 10px 0 4px; }
.module-card p { color: var(--text-soft); font-size: 13.5px; }
.module-card__head { display: flex; align-items: center; justify-content: space-between; }
.module-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 19px;
}

/* ---------- Списки ---------- */

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li {
  position: relative;
  padding-left: 28px;
  font-size: 14.5px;
  color: var(--text-soft);
}
.checklist li::before {
  content: "○";
  position: absolute;
  left: 4px;
  color: var(--muted);
}
.checklist li.is-done { color: var(--text); }
.checklist li.is-done::before { content: "✓"; color: var(--ok); font-weight: 700; }

/* ---------- Бейджи ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge--soon { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--off { background: var(--surface-2); color: var(--muted); }
.badge--role { background: var(--brand-soft); color: var(--brand-strong); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--status {
  background: var(--status-bg, #8C9597);
  color: var(--status-fg, #ffffff);
  border: 1px solid color-mix(in srgb, var(--status-bg, #8C9597) 70%, #000 30%);
}

/* ---------- Настройки статусов ---------- */

.status-note { margin-bottom: 14px; }
.status-note p { margin: 0; }
.status-groups { display: grid; gap: 14px; }
.status-group .card__head { margin-bottom: 0; }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.status-list .status-row:first-child { margin-top: 10px; }
.status-row__swatch {
  flex: none;
  width: 8px;
  height: 34px;
  border-radius: 4px;
}
.status-row__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1 1 220px;
}
.status-row__meta { color: var(--muted); font-size: 12.5px; }
/* Конфигуратор вкладок: галочка и название статуса в одной строке. */
.status-tab-check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}
.status-tab-check input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}
.status-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.status-row__actions .btn { min-height: 36px; padding: 6px 12px; }
.status-row__actions .btn:disabled { opacity: .4; cursor: default; transform: none; }
.status-row__actions form { margin: 0; }
.color-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-field__input {
  width: 64px;
  min-width: 64px;
  height: 44px;
  padding: 4px;
}
.color-field .input.color-field__input {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}
.color-field__preview { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .status-row__actions { width: 100%; margin-left: 0; }
  .status-row__actions .btn { flex: 1 1 auto; }
}

/* Статус в шапке заказа: бейдж-выпадающий список, меняется сразу. */
.order-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}
.status-quick { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.status-quick__select {
  appearance: none;
  border: 0;
  padding: 3px 24px 3px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 11px) 50%,
    calc(100% - 7px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.status-quick__select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Быстрая смена статуса: бейдж-кнопка и окно со списком статусов. */
.status-picker__trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.status-picker__trigger:hover .badge--status { filter: brightness(.96); }
.status-picker__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
.status-picker__chevron {
  flex: none;
  width: 7px;
  height: 7px;
  margin: -3px 2px 0 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: .5;
  transform: rotate(45deg);
}
.status-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 14, 9, .55);
}
.status-modal[hidden] { display: none; }
.status-modal__card {
  display: flex;
  flex-direction: column;
  width: min(430px, 100%);
  max-height: min(84vh, 680px);
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.status-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.status-modal__title { font-size: 20px; }
.status-modal__close {
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.status-modal__close:hover { border-color: var(--brand); }
.status-modal__form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.status-modal__list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
}
.status-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.status-option:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
}
.status-option:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.status-option.is-active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.status-option .badge--status {
  max-width: 100%;
  white-space: normal;
  line-height: 1.35;
}
.status-option__mark {
  flex: none;
  color: var(--brand);
  font-weight: 700;
  opacity: 0;
}
.status-option.is-active .status-option__mark { opacity: 1; }

:root[data-theme="ios"] .status-modal__card {
  border: 1px solid rgba(60, 60, 67, .12);
  background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
  box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
}
:root[data-theme="ios"] .status-option {
  border-radius: 15px;
  background-image: linear-gradient(180deg, #fbfbfe 0%, #f2f3f8 100%);
}
@media (max-width: 640px) {
  .status-modal { align-items: flex-end; padding: 10px; }
  .status-modal__card {
    width: 100%;
    max-height: 82vh;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    border-radius: 22px;
  }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn--danger:focus-visible { outline-color: var(--danger); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { background: var(--brand-strong); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }
.btn--ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; }
.btn--block { width: 100%; }
.btn.is-disabled, .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

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

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13.5px; font-weight: 600; color: var(--text-soft); }
.field__error { color: var(--danger); font-size: 13px; }
.field__hint { color: var(--muted); font-size: 12px; }
.field:focus-within .field__label { color: var(--text); }

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px — без автозума на iOS */
}
.input:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--brand);
}
/* Неактивное и доступное только для чтения поле видно сразу: фон
   приглушён, но текст остаётся читаемым. */
.input:disabled,
select.input:disabled {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.input:disabled::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input[readonly] {
  background: var(--surface-2);
  color: var(--text-soft);
  border-color: var(--border-strong);
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-soft); }
.check--stack { align-items: flex-start; }
.check--stack input[type="checkbox"] { margin-top: 3px; flex: none; }
.check__input { width: 18px; height: 18px; accent-color: var(--brand); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field--wide { grid-column: 1 / -1; }

.input--area { min-height: 90px; resize: vertical; }
.input--filter { margin-bottom: 6px; min-height: 38px; font-size: 14px; }
.input--auto { width: auto; min-width: 0; max-width: 100%; }

/* Даты в панели периода. Нативный календарь на телефоне шире, чем кажется:
   разрешаем полю сжиматься и переносить пару «с / по» на новую строку,
   чтобы блок не выходил за карточку. */
.date-range {
  display: flex;
  flex: 1 1 320px;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
.date-range__field {
  display: flex;
  flex: 1 1 130px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.date-range__field .input {
  flex: 1 1 110px;
  width: auto;
  min-width: 0;
  max-width: 100%;
}
.date-range__label { flex: 0 0 auto; }
@media (max-width: 719px) {
  /* Подписи «С» и «по» встают над полями: пара дат занимает две колонки
     и не выходит за карточку даже на 320 px. */
  .date-range { flex: 1 1 100%; }
  .date-range__field {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .date-range__field .input {
    flex: 0 0 auto;
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    font-size: 14px;
  }
}
@media (max-width: 359px) {
  .date-range__field { flex: 1 1 100%; }
}
input[type="date"],
input[type="time"],
input[type="month"] { min-width: 0; max-width: 100%; }

/* Выбор клиента с подсказками: одно поле вместо пары «поиск + список» */
.combobox { position: relative; }
.combobox__select { display: none; }
.combobox__list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.combobox__item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.combobox__item:hover,
.combobox__item.is-active { background: var(--surface-2); }
.combobox__name { display: block; font-weight: 600; }
.combobox__hint { display: block; margin-top: 2px; font-size: 12px; color: var(--text-soft); }
.combobox__empty { padding: 10px; color: var(--muted); }
.combobox__list--suggest { max-height: 260px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
}
.toolbar .input[type="search"] { flex: 1 1 220px; }
.toolbar__quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-basis: 100%;
}
.toolbar--inset {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.form__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Flash ---------- */

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
}
.flash--success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash--warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash--info { background: var(--brand-soft); color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.flash__close {
  border: 0;
  background: none;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: .7;
}

/* ---------- Таблицы ---------- */

.table-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table__right { text-align: right !important; }
.table th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cell-main { font-weight: 600; }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions .btn { vertical-align: middle; }
.table__sort {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-decoration: none;
}
.table__sort:hover { color: var(--brand); }
.table__sort.is-active { color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px !important; }
/* У ячейки таблицы своя специфичность селектора, поэтому центрирование
   пустой строки задаём отдельно — иначе текст прилипает влево. */
.table td.empty { text-align: center; }

/* Номенклатура и работы: слева дерево групп, справа обычная таблица.
   Группы с подгруппами видно целиком, поэтому не нужно листать список,
   чтобы понять, что где лежит. */
.catalog-browser {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  align-items: start;
}
.catalog-browser__aside { padding: 14px 12px; }
.catalog-browser__aside-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 0 6px 8px;
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.catalog-browser__aside-head .card__title { margin: 0; font-size: 15px; }
.catalog-browser__aside-head .muted { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.catalog-browser__main { min-width: 0; }
/* Ширины колонок: наименование забирает больше всего места, служебные
   цифры стоят ровно, чтобы строки не плясали. */
.table--browser { table-layout: fixed; }
.table--browser th,
.table--browser td { padding: 10px 12px; }
.table--browser td { overflow-wrap: anywhere; }
.table--products th:nth-child(1) { width: 32%; }
.table--products th:nth-child(2) { width: 12%; }
.table--products th:nth-child(3) { width: 10%; }
.table--products th:nth-child(4) { width: 9%; }
.table--products th:nth-child(5) { width: 12%; }
.table--products th:nth-child(6) { width: 12%; }
.table--products th:nth-child(7) { width: 13%; }
.table--works th:nth-child(1) { width: 40%; }
.table--works th:nth-child(2) { width: 17%; }
.table--works th:nth-child(3) { width: 14%; }
.table--works th:nth-child(4) { width: 16%; }
.table--works th:nth-child(5) { width: 13%; }

.group-tree {
  display: grid;
  gap: 1px;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.group-tree__item {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 7px 9px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.3;
}
.group-tree__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.group-tree__item--sub {
  padding-left: 22px; font-size: 13px; color: var(--text-soft);
}
.group-tree__item--sub .group-tree__name::before {
  content: "↳"; margin-right: 6px; color: var(--muted);
}
.group-tree__item.is-active {
  background: var(--brand-soft); color: var(--text); font-weight: 600;
}
.group-tree__name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.group-tree__count {
  flex: 0 0 auto; font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.group-tree__item.is-active .group-tree__count { color: var(--brand-strong); }

/* ---------- Настраиваемая таблица ---------- */

.table--fixed { table-layout: fixed; width: max-content; min-width: 100%; }
.table--fixed th { position: relative; }
.table--fixed td { overflow-wrap: anywhere; }

/* Заказы: каждый заказ — отдельная плитка с зазором, чтобы соседние
   строки с несколькими строками текста не сливались в одну простыню. */
.table--orders { border-collapse: separate; border-spacing: 0 10px; }
.table-wrap--orders { padding: 10px; background: var(--bg); }
.table--orders thead th { background: var(--surface-2); }
.table--orders thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table--orders thead th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.table--orders tbody td {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.table--orders tbody td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.table--orders tbody td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.table--orders tbody tr:hover td { background: var(--brand-soft); }
/* У последней плитки нижняя граница тоже нужна — иначе она «растворяется». */
.table--orders tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}
.col-resizer::after {
  content: "";
  position: absolute;
  top: 25%;
  right: 5px;
  width: 1px;
  height: 50%;
  background: transparent;
  transition: background .15s;
}
.col-resizer:hover::after,
.is-resizing .col-resizer::after { background: var(--brand); }
.is-resizing { cursor: col-resize; user-select: none; }
.due--overdue { color: var(--danger); font-weight: 600; }

.column-settings { display: grid; gap: 2px; }
.column-setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.column-setting:last-child { border-bottom: 0; }
.column-setting__show {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  flex: 1 1 220px;
  cursor: pointer;
}
.column-setting__show input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
.column-setting__width {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.column-setting__width .input { width: 96px; padding: 8px 10px; }

/* Выбор темы оформления: три крупные карточки вместо мелких радиокнопок. */
.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.theme-option {
  position: relative;
  display: block;
  cursor: pointer;
}
.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.theme-option__body {
  display: grid;
  gap: 4px;
  height: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.theme-option:hover .theme-option__body { border-color: var(--border-strong); }
.theme-option input:checked + .theme-option__body {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.theme-option input:focus-visible + .theme-option__body {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.theme-option__icon { font-size: 22px; line-height: 1; }
.theme-option__title { font-weight: 600; }
.theme-option__hint { font-size: 12.5px; color: var(--muted); }
.theme-option__swatches { display: flex; gap: 4px; margin-top: 8px; }
.theme-option__swatches i {
  width: 20px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .08);
}
.theme-option--system .theme-option__swatches i:nth-child(1) {
  background: linear-gradient(90deg, #f4f0eb 50%, #17130f 50%);
}
.theme-option--system .theme-option__swatches i:nth-child(2) {
  background: linear-gradient(90deg, #6f4e37 50%, #c79a74 50%);
}
.theme-option--system .theme-option__swatches i:nth-child(3) {
  background: linear-gradient(90deg, #ffffff 50%, #201a15 50%);
}
.theme-option--light .theme-option__swatches i:nth-child(1) { background: #f4f0eb; }
.theme-option--light .theme-option__swatches i:nth-child(2) { background: #6f4e37; }
.theme-option--light .theme-option__swatches i:nth-child(3) { background: #ffffff; }
.theme-option--dark .theme-option__swatches i:nth-child(1) { background: #17130f; }
.theme-option--dark .theme-option__swatches i:nth-child(2) { background: #c79a74; }
.theme-option--dark .theme-option__swatches i:nth-child(3) { background: #201a15; }
.theme-option--ios .theme-option__swatches i:nth-child(1) { background: #f2f2f7; }
.theme-option--ios .theme-option__swatches i:nth-child(2) { background: #0a6cff; }
.theme-option--ios .theme-option__swatches i:nth-child(3) { background: #ffffff; }
@media (max-width: 720px) {
  .theme-options { grid-template-columns: 1fr; }
}
.table tfoot th {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--surface-2);
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
  white-space: nowrap;
}
.table tfoot th:first-child { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.card__head .card__title { margin: 0; }

.qty { font-weight: 600; font-variant-numeric: tabular-nums; }
.qty--low { color: var(--warn); }
.money--out { color: var(--danger); }

/* ---------- Задачи и уведомления ---------- */

.task-title { display: block; font-weight: 600; color: var(--text); }
.task-title:hover { text-decoration: none; color: var(--brand-strong); }
.task-title--done { color: var(--muted); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.task-due { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; }
.task-due--overdue { color: var(--danger); font-weight: 600; }
.task-due--today { color: var(--warn); font-weight: 600; }
.task-inline-form { display: inline; }
.task-check {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  font-size: 16px;
  cursor: pointer;
}
.task-check:hover { border-color: var(--ok); color: var(--ok); }
.task-check--done { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.task-description { white-space: pre-line; color: var(--text-soft); }
.task-panel { display: grid; gap: 12px; }
.task-panel__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.notification-list { display: grid; gap: 10px; }
.notification-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.notification-item.is-unread { border-color: var(--brand); background: var(--brand-soft); }
.notification-item__body { min-width: 0; }
.notification-item__title { font-weight: 600; }
.notification-item__text { margin-top: 2px; font-size: 13.5px; color: var(--text-soft); }
.notification-item__time { margin-top: 4px; font-size: 12px; color: var(--muted); }
.notification-item__actions { display: flex; flex-shrink: 0; gap: 6px; }
.push-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.push-status__text { font-size: 13.5px; color: var(--text-soft); }

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

[hidden] { display: none !important; }

.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.detail-list dd { margin: 0; text-align: right; font-weight: 600; font-size: 14px; }

/* Правка блока прямо в карточке заказа: раскрывается по «Изменить» */
.block-edit { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.block-edit > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
  user-select: none;
}
.block-edit > summary::-webkit-details-marker { display: none; }
.block-edit > summary::before { content: "+"; font-size: 16px; line-height: 1; }
.block-edit[open] > summary::before { content: "−"; }
.block-edit[open] > summary { margin-bottom: 12px; }
.block-edit .form-grid { gap: 10px 14px; }
.block-edit .form__actions { margin-top: 12px; }

/* Быстрое добавление строки: поиск с подсказками */
.quick-add {
  display: grid;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}
.quick-add__search { position: relative; }
.quick-add > .btn { justify-self: start; }
@media (min-width: 720px) {
  .quick-add { grid-template-columns: minmax(0, 1fr) auto; }
  .quick-add > .btn { justify-self: end; }
}

.quick-results {
  position: absolute;
  z-index: 110;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quick-results[hidden] { display: none; }
.quick-results__empty { padding: 8px 10px; margin: 0; }
.quick-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.quick-result:hover:not(:disabled),
.quick-result:focus-visible { background: var(--surface-2); }
.quick-result.is-empty { opacity: .55; cursor: not-allowed; }
.quick-result__name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.quick-result__price { font-size: 14px; white-space: nowrap; }
.quick-result__stock { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* Строки заказа: количество и цену можно править прямо в таблице.
   Изменение сохраняется само, кнопка «Сохранить» не нужна. */
.table--items td { vertical-align: middle; }
.input--compact {
  min-height: 38px;
  width: 96px;
  padding: 6px 8px;
  font-size: 14px;
}
.input--compact.input--qty { width: 76px; text-align: center; }
.input--compact.input--price { width: 112px; text-align: right; }
.input--compact.is-saving { opacity: .55; }
.input--compact.input--error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}
/* Формы прямо в строке банковской операции: категория, поставщик и действие.
   Ширину держим узкой, иначе таблица уезжает вправо на ноутбуке. */
.bank-op__inline {
  display: grid;
  gap: 6px;
  width: 168px;
}
.bank-op__inline .input,
.bank-op__inline .btn {
  width: 100%;
}
.bank-op__unpost { margin-top: 6px; }
.bank-op__unpost .btn { width: 100%; }
.bank-op__purpose {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 460px;
  overflow-wrap: anywhere;
}

/* На широком экране фиксируем ширины колонок: иначе длинные названия
   контрагентов растягивают таблицу и статус уезжает за край. */
@media (min-width: 1024px) {
  .bank-operations { table-layout: fixed; }
  .bank-operations th:nth-child(1) { width: 104px; }
  .bank-operations th:nth-child(2) { width: 136px; }
  .bank-operations th:nth-child(3) { width: 190px; }
  .bank-operations th:nth-child(5) { width: 108px; }
  .bank-operations th:nth-child(6) { width: 176px; }
  .bank-operations th:nth-child(7) { width: 156px; }
  .bank-operations td { overflow-wrap: anywhere; }
}
.cell-note { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.cell-note:empty { display: none; }

/* Кнопки-иконки в строке: изменить и удалить. На телефоне крупнее и дальше
   друг от друга, чтобы не промахнуться пальцем. */
.row-actions { display: inline-flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-btn--danger { color: var(--danger); }
.icon-btn--danger:hover { background: var(--danger-bg); color: var(--danger); }

@media (max-width: 720px) {
  .row-actions { gap: 18px; }
  .icon-btn { width: 46px; height: 46px; }
  .icon-btn svg { width: 24px; height: 24px; }
}

/* Ошибка сохранения строки — прямо над таблицей */
.items-error {
  margin: 0 22px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13.5px;
}
.items-error[hidden] { display: none; }

/* Итог заказа под таблицей */
.items-summary {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.items-summary__value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Окно подбора нескольких работ или товаров */
.modal .modal__card--wide { width: min(760px, 100%); }
.picker__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.picker-list {
  display: grid;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 4px;
}
.picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.picker-row.is-empty { opacity: .55; }
.picker-row__check {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}
.picker-row__name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.picker-row__sku {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.picker-row__price { font-weight: 600; white-space: nowrap; }
.picker-row__stock { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.picker-row__qty { width: 72px; padding: 7px 8px; }
.picker__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
@media (min-width: 720px) {
  .picker-row { grid-template-columns: minmax(0, 1fr) 100px 110px 78px; }
  .picker-row__check { grid-column: auto; }
  .picker-row__qty { width: 100%; justify-self: end; }
}

/* Подбор одной позиции на складе */
.picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.picker-trigger__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-trigger__hint {
  font-size: 12.5px;
  color: var(--brand);
  white-space: nowrap;
}
.wh-picker {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 4px;
  min-height: 260px;
}
.wh-picker__groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}
.wh-picker__group,
.wh-picker__subgroup {
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.wh-picker__group:hover,
.wh-picker__subgroup:hover { background: var(--surface-2); }
.wh-picker__group.is-active,
.wh-picker__subgroup.is-active {
  background: var(--brand-soft, var(--surface-2));
  border-color: var(--brand);
  font-weight: 600;
}
.wh-picker__subgroups {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 10px;
}
.wh-picker__subgroup { font-size: 12.5px; padding: 5px 8px; }
.wh-picker__results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}
.wh-picker__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.wh-picker__row:hover { border-color: var(--brand); }
.wh-picker__name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.wh-picker__sku { font-size: 12px; font-weight: 400; color: var(--muted); }
.wh-picker__meta {
  grid-column: 1;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.wh-picker__stock {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.wh-picker__stock.is-empty { color: var(--muted); font-weight: 400; }
@media (max-width: 719px) {
  .wh-picker { grid-template-columns: minmax(0, 1fr); }
  .wh-picker__groups {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    border-right: 0;
    padding-right: 0;
  }
  .wh-picker__subgroups { flex-direction: row; flex-wrap: wrap; margin-left: 0; }
}

/* ---------- Приходная накладная ---------- */

.receipt-lines { display: grid; gap: 10px; }
.receipt-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 40px;
  gap: 10px;
  align-items: end;
}
.receipt-line__remove { align-self: end; min-width: 40px; padding-inline: 0; }
.receipt-total { margin-left: auto; align-self: center; font-size: 15px; }

@media (max-width: 720px) {
  .receipt-line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .receipt-line__product { grid-column: 1 / -1; }
  .receipt-line__remove { grid-column: 2; justify-self: end; }
  .receipt-total { display: block; width: 100%; margin-left: 0; }
}

.summary-rows { display: grid; gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.summary-rows > div { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; }
.summary-rows .is-total { font-size: 18px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
.summary-rows .is-debt { color: var(--danger); font-weight: 600; }

.status-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.status-form .field { flex: 1 1 180px; }

.item-actions { text-align: right; }
.inline-form { display: inline; }
.dict-row { display: flex; gap: 8px; align-items: center; }
.dict-row .input { min-width: 0; }
.section-gap { margin-top: 16px; }

/* ---------- Справочник оборудования: три связанные колонки ---------- */

.device-mobile-nav {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.device-mobile-nav__title {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.device-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.device-column__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.device-column__title { margin: 0; font-size: 14px; }
.device-column__hint { color: var(--muted); font-size: 11.5px; }
.device-list {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 2px;
  margin: 0;
  padding: 6px;
  list-style: none;
}
.device-row { display: flex; align-items: center; gap: 2px; min-width: 0; border-radius: 8px; }
.device-row:hover { background: var(--surface-2); }
.device-row.is-selected { background: var(--brand-soft); }
.device-row__main {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 9px 8px 9px 10px;
  color: inherit;
  text-decoration: none;
}
.device-row__main:hover { text-decoration: none; }
.device-row__label {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  min-width: 0;
}
.device-row__name {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}
.device-row.is-selected .device-row__name { color: var(--brand-strong); }
.device-row__badge {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
}
.device-row__count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.device-row__check { flex: 0 0 auto; color: var(--brand); font-weight: 700; }
.device-row__pick {
  flex: 0 0 auto;
  align-self: center;
  width: 16px;
  height: 16px;
  margin: 0 0 0 8px;
  accent-color: var(--brand);
}
.device-row__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 1px; padding-right: 4px; }
.device-row__action {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.device-row__action:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.device-row__action--danger:hover { background: var(--danger-bg); color: var(--danger); }
.device-empty { padding: 16px 14px; color: var(--muted); font-size: 13.5px; }
.device-hint {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}
.device-add { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.device-add .input { flex: 1; min-width: 0; }
.device-add .btn { flex: 0 0 auto; }
.device-move {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
}
.device-move__row { display: flex; gap: 6px; }
.device-move__row .input { flex: 1; min-width: 0; }
.device-move__row .btn { flex: 0 0 auto; }
.device-move__hint { color: var(--muted); font-size: 11.5px; }
.dict-edit { margin-bottom: 14px; }
.dict-edit__form { display: grid; gap: 12px; }

@media (max-width: 959px) {
  .device-columns { grid-template-columns: minmax(0, 1fr); }
  .device-columns[data-step="type"] .device-column--brand,
  .device-columns[data-step="type"] .device-column--model,
  .device-columns[data-step="brand"] .device-column--type,
  .device-columns[data-step="brand"] .device-column--model,
  .device-columns[data-step="model"] .device-column--type,
  .device-columns[data-step="model"] .device-column--brand { display: none; }
  .device-mobile-nav { display: flex; }
}


/* ---------- Вкладки и раскладка ---------- */

/* Вкладки переносятся на новую строку. Горизонтальная прокрутка на телефоне
   прятала первый раздел за левым краем и создавала ощущение «уехавшей»
   страницы. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.tabs__item {
  padding: 10px 14px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
/* Выбор статуса списком вместо вкладок на телефоне. */
.status-filter-mobile { display: none; }
@media (max-width: 719px) {
  .tabs { gap: 0; }
  .tabs__item { padding: 9px 10px; font-size: 13px; }
  .tabs--statuses { display: none; }
  .status-filter-mobile { display: flex; }
  .status-filter-mobile .input { flex: 1 1 160px; min-width: 0; }
}
.tabs__item:hover { text-decoration: none; color: var(--text); }
.tabs__item.is-active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tabs__item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -3px;
  border-radius: 8px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-block; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-2, #f6f7f9);
  font-family: var(--mono); font-size: 12px; }

/* ---------- Личные фильтры списка ---------- */

.saved-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
}
.saved-filters__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
}
.saved-filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
}
.filter-chip a { color: var(--text-soft); }
.filter-chip:hover { border-color: var(--border-strong); }
.filter-chip:hover a { text-decoration: none; color: var(--text); }
.filter-chip.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.filter-chip.is-active a { color: var(--brand-strong); }

@media (max-width: 719px) {
  .saved-filters__actions { width: 100%; margin-left: 0; }
}

/* Строка таблицы, открывающая карточку по нажатию */
.table tr[data-href] { cursor: pointer; }

.split { display: grid; gap: 16px; }
/* На телефоне склад показывает остатки первыми: их проверяют чаще, чем оприходуют. */
@media (max-width: 959px) {
  .split--warehouse > .split__aside { order: 2; }
}

/* ---------- Блоки страницы: перестановка перетаскиванием ---------- */

/* Блоки лежат в ровной сетке: на телефоне в один столбец, на компьютере —
   в два. Порядок запоминается у пользователя. */
.blocks { display: grid; gap: 16px; }
.blocks > [data-block] { position: relative; min-width: 0; }
.blocks > [data-block-wide] { grid-column: 1 / -1; }
.blocks > .card { margin-bottom: 0; }
.blocks > .grid { margin-bottom: 0; }
.blocks[data-columns="2"] { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .blocks[data-columns="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  /* Дерево групп закреплено слева и прокручивается вместе со страницей:
     в длинной номенклатуре группа всегда под рукой. */
  .catalog-browser { grid-template-columns: 264px minmax(0, 1fr); }
  .catalog-browser__aside { position: sticky; top: 16px; }
  .group-tree { max-height: calc(100vh - 260px); }
}

/* Видимой ручки нет: на компьютере блок тянется за любое свободное место
   карточки, на телефоне — после короткого удержания пальцем. */
@media (pointer: coarse) {
  .blocks > [data-block] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Ячейка, из которой блок взяли: держит его место, пока ищем новое. */
.block-placeholder {
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: var(--brand-soft);
  opacity: 0.55;
}

/* Сам блок, пока его тащат: висит над сеткой и следует за курсором. */
[data-block].is-dragging {
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgb(0 0 0 / 24%);
  opacity: 0.97;
}
body.is-block-dragging { user-select: none; -webkit-user-select: none; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 10px;
}
.pagination__info { font-size: 13px; color: var(--muted); }

/* ---------- Профиль в сайдбаре ---------- */

.user { display: flex; align-items: center; gap: 10px; color: var(--text); }
.user:hover { text-decoration: none; }
.user__meta { display: flex; flex-direction: column; min-width: 0; }
.user__name { font-size: 14px; font-weight: 600; }
.user__role { font-size: 12px; color: var(--muted); }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 15px;
  flex: 0 0 auto;
}
.avatar--sm { width: 32px; height: 32px; font-size: 13px; }

/* ---------- Вход и служебные страницы ---------- */

.plain-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.plain-main { width: 100%; max-width: 420px; display: grid; gap: 18px; justify-items: center; }
.plain-footer { font-size: 12px; color: var(--muted); }
.auth-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  display: grid;
  gap: 16px;
}
.auth-card__title { font-size: 24px; letter-spacing: -.02em; }
.auth-card__sub { color: var(--text-soft); font-size: 14px; }
.auth-card__hint { color: var(--muted); font-size: 12.5px; text-align: center; }
.auth-card .btn { margin-top: 4px; }

.page-footer { margin-top: 28px; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------- Десктоп ---------- */

@media (min-width: 960px) {
  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }

  .sidebar .brand { padding: 4px 8px 0; }

  .sidebar__footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding: 14px 8px 4px;
    border-top: 1px solid var(--border);
  }

  .topbar, .bottom-nav, .mobile-menu { display: none !important; }

  .main {
    padding: 28px 32px 40px;
    width: 100%;
  }

  .page-title { font-size: 30px; }
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1.6fr 1fr; align-items: center; }
  .hero__stats { justify-content: flex-end; }
  .card { padding: 22px; }
  .card--flush { padding: 0; }
  .card__head { padding: 18px 22px 14px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
  .auth-card { padding: 30px 28px; }
}

/* ---------- Планшет/телефон: таблица в карточки ---------- */

@media (max-width: 720px) {
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head > .form__actions { width: 100%; justify-content: flex-start; }
  /* Четыре счётчика на телефоне стоят по два в ряд: крупная сумма
     с копейками и знаком рубля иначе переносится на вторую строку. */
  .grid--4 .stat-card__value { font-size: 24px; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .table tr:last-child { border-bottom: 0; }
  .table td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
    border: 0;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 600;
    flex: 0 0 auto;
  }
  .table tr:hover td { background: transparent; }
  .table__hide-sm { display: none !important; }
  .table--fixed { width: 100%; }
  .col-resizer { display: none; }
  .table td { flex-wrap: wrap; align-items: baseline; }
  .table td .cell-main { flex: 1 1 auto; text-align: right; }
  .table td .cell-sub { flex-basis: 100%; text-align: right; }
  .table--items td { flex-wrap: wrap; }
  /* Формы прямо в строке банковской операции на телефоне — во всю ширину. */
  .bank-op__inline { width: 100%; }
  .table td .cell-note { flex-basis: 100%; text-align: right; }
  /* Пустая таблица — одна центрированная строка, а не две колонки:
     иначе текст и ссылка «Поставить задачу» разъезжаются по краям. */
  .table td.empty { display: block; }

  /* Дерево групп на телефоне — прокручиваемая панель над таблицей:
     целиком оно занимало бы весь экран. */
  .catalog-browser__aside { padding: 12px 10px; }
  .group-tree { max-height: 240px; }

  /* В карточке позиции название — заголовок, а не пара «подпись: значение»:
     длинные наименования так читаются слева направо. */
  .table--browser td[data-label="Наименование"] { display: block; }
  .table--browser td[data-label="Наименование"]::before { content: none; }
  .table--browser td[data-label="Наименование"] .cell-main,
  .table--browser td[data-label="Наименование"] .cell-sub { text-align: left; }

  /* Заказы на телефоне — отдельные карточки-плитки с небольшим зазором. */
  .table--orders tbody tr {
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .table--orders tbody tr:last-child { margin-bottom: 0; }
  .table--orders tbody td {
    background: transparent;
    border: 0;
    border-radius: 0;
  }
  .table--orders tbody tr:last-child td { border: 0; }
  .table--orders tbody td:first-child,
  .table--orders tbody td:last-child { border: 0; border-radius: 0; }
  .table--orders tbody tr:hover td { background: transparent; }
  .input--compact { width: 120px; }
  .table__actions { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Кабинет клиента ---------- */

.portal-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.portal-top__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
/* Логотип не сжимается вместе с именем клиента: иначе знак становится
   нечитаемым. Имя переносится на новую строку. */
.portal-top .brand { flex: 0 0 auto; }
.portal-top .brand__logo { width: 210px; max-width: 210px; }
.portal-top__client {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  font-size: 13px;
  color: var(--text-soft);
}
.portal-top__client strong {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}
.portal-top__client a {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
}
.portal-top__client a:hover { color: var(--brand); }
.portal-main { padding-top: 14px; padding-bottom: 32px; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 720px) {
  /* В кабинете клиента на телефоне главное — имя клиента, а не название CRM. */
  .portal-top .brand__logo { width: 150px; max-width: 150px; }
  .portal-top__client { align-items: flex-start; flex: 1 1 auto; padding-left: 10px; }
  .portal-top__client strong { max-width: 100%; white-space: normal; text-align: left; }
  .portal-top__client a { text-align: left; }
}

@media (max-width: 380px) {
  .portal-top .brand__logo { width: 120px; max-width: 120px; }
}

/* На узком телефоне длинное название рядом со знаком не помещается:
   оставляем логотип-метку, полное имя есть в заголовке страницы. */
@media (max-width: 560px) {
  .brand--compact .brand__name { display: none; }
}

/* ---------- Мастер приёмки ---------- */

.wizard__head { padding-bottom: 16px; }
.wizard__head-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-top: 10px;
}
.wizard__title { font-size: 18px; font-weight: 700; color: var(--text); }
.wizard__progress {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin-top: 4px;
}
.wizard__progress-bar {
  display: block; height: 100%; width: 16.666%;
  background: var(--brand); border-radius: inherit;
  transition: width .2s ease;
}
.wizard__nav {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border);
}
.wizard__nav .btn { min-width: 120px; }

.client-found {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 14px; padding: 14px;
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
  border-radius: var(--radius-sm); background: var(--ok-bg);
}
.client-found__icon {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  color: var(--ok); background: var(--surface);
}
.client-found__label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ok); }
.client-found__name { font-size: 17px; font-weight: 700; }

.input-with-action { display: flex; gap: 8px; align-items: stretch; }
.input-with-action .input { flex: 1 1 auto; min-width: 0; }
.input-with-action .btn { flex: 0 0 auto; white-space: nowrap; }

.inspection-grid,
.completion-grid {
  display: grid; gap: 8px; grid-template-columns: 1fr;
}
.inspection-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
  cursor: pointer;
}
.inspection-item span { display: flex; flex-direction: column; gap: 2px; }
.completion-item { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Поиск комплектации: выбранные пункты — чипами, варианты — списком. */
.completion-picker { display: grid; gap: 8px; }
.completion-picker__selected { display: flex; flex-wrap: wrap; gap: 6px; }
.completion-picker__selected:empty { display: none; }
.completion-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 10px; border: 1px solid var(--border-strong);
  border-radius: 999px; background: var(--brand-soft); color: var(--text);
  font-size: 14px; line-height: 1.2;
}
.completion-chip__remove {
  padding: 0 2px; border: 0; background: transparent; color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.completion-chip__remove:hover { color: var(--danger); }
.completion-picker__list {
  display: grid; gap: 3px; max-height: 280px; overflow-y: auto;
  padding: 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.completion-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 10px; border: 1px solid transparent;
  border-radius: var(--radius-sm); background: transparent; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.completion-option:hover,
.completion-option:focus-visible { border-color: var(--border); background: var(--surface-2); }
.completion-option[hidden] { display: none; }
.completion-option__mark { color: var(--brand); font-weight: 700; }
.completion-picker__empty { margin: 0; color: var(--muted); }
.is-muted { opacity: .55; }
.input.is-invalid,
.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.photo-upload-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.photo-upload {
  padding: 12px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.photo-upload__preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-upload__img {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}
.photo-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.photo-card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo-card__link { display: block; }
.photo-card__img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2);
}
.photo-card__cap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12px; color: var(--text-soft);
}
.photo-card__video {
  width: 100%; aspect-ratio: 4 / 3; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #000;
}

/* ---------- Файлы и хранилище ---------- */

.code-inline {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px; padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); overflow-wrap: anywhere;
}
.notice {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 14px; line-height: 1.5;
}
.notice--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.notice--info { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, var(--border)); }

.disk-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.disk-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; text-align: left; font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.disk-card:hover { border-color: var(--brand); background: var(--surface-2); }
.disk-card__path { font-weight: 600; overflow-wrap: anywhere; }

.files-breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 14px;
}
.files-breadcrumb__sep { color: var(--muted); }
.files-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.files-upload { display: grid; gap: 10px; }
.files-upload input[type="file"] { width: 100%; }

/* Свой вид выбора файлов: нативная кнопка браузера не влезает в узкие поля. */
.file-picker { position: relative; }
.file-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.file-picker__label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.file-picker__label:hover { border-color: var(--brand); }
.file-picker__input:focus-visible + .file-picker__label {
  border-color: var(--brand);
  outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent);
  outline-offset: 2px;
}
.file-picker__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}
.file-picker__name {
  min-width: 0;
  color: var(--text-soft);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.file-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-name__icon { flex: 0 0 auto; }
.file-name__text { overflow-wrap: anywhere; }
.file-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file-actions form { margin: 0; }
.file-rename { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file-rename .input { min-width: 160px; flex: 1 1 160px; }

.loaner-preview,
.accept-summary {
  margin-top: 14px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.accept-summary .detail-list { margin-top: 6px; }

.scanner__video {
  width: 100%; max-height: 60vh; background: #000;
  border-radius: var(--radius-sm); object-fit: cover;
}
.scanner__video[hidden] { display: none; }
.scanner__actions { margin-top: 14px; }
.scanner__file { position: relative; overflow: hidden; }

/* ---------- Модальные окна ---------- */

.modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(20, 14, 9, .55);
}
.modal[hidden] { display: none; }
.modal__card {
  width: min(520px, 100%); max-height: 90vh; overflow-y: auto;
  padding: 22px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.modal__title { font-size: 20px; }

@media (min-width: 720px) {
  .inspection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .completion-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-upload-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .disk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- iOS: объём, градиенты и цветные иконки ---------- */

/* Фон и поверхности: мягкие световые пятна вместо ровной заливки. */
:root[data-theme="ios"] body {
  letter-spacing: -.01em;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 92% -8%, rgba(10, 108, 255, .12), transparent 62%),
    radial-gradient(760px 520px at 0% 6%, rgba(122, 77, 255, .08), transparent 58%);
}
:root[data-theme="ios"] .card {
  border-color: rgba(60, 60, 67, .18);
  background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 14px 30px rgba(60, 60, 67, .10);
}
:root[data-theme="ios"] .card--inset {
  background-color: #f2f3f8;
  background-image: linear-gradient(180deg, #f8f9fc 0%, #f1f2f7 100%);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, .04);
}
:root[data-theme="ios"] .hero {
  background-image: linear-gradient(135deg, #ffffff 0%, #f1f7ff 100%);
}
:root[data-theme="ios"] .modal__card {
  border: 1px solid rgba(60, 60, 67, .12);
  background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
  box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
}
:root[data-theme="ios"] .plain-body {
  background-image:
    radial-gradient(900px 600px at 50% -10%, rgba(10, 108, 255, .14), transparent 65%),
    linear-gradient(180deg, #f7f9ff 0%, var(--bg) 55%);
}

/* Боковая панель и панели навигации: свет сверху, тень снизу. */
:root[data-theme="ios"] .sidebar {
  background: linear-gradient(180deg, #fcfcfe 0%, #f1f2f7 100%);
}
:root[data-theme="ios"] .topbar,
:root[data-theme="ios"] .bottom-nav {
  background: linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(247, 248, 252, .88));
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-color: rgba(60, 60, 67, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 10px 28px rgba(16, 24, 40, .06);
}
:root[data-theme="ios"] .nav__item.is-active {
  background: linear-gradient(180deg, #eaf2ff 0%, #dce8ff 100%);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px rgba(10, 108, 255, .12), 0 1px 2px rgba(10, 108, 255, .08);
}
:root[data-theme="ios"] .mobile-menu__item.is-active,
:root[data-theme="ios"] .tabs__item.is-active { color: var(--brand); }
:root[data-theme="ios"] .mobile-menu__item.is-active {
  border-color: rgba(10, 108, 255, .45);
  background-image: linear-gradient(180deg, #ffffff, #eef5ff);
}
:root[data-theme="ios"] .topbar__menu,
:root[data-theme="ios"] .topbar__bell {
  background-image: linear-gradient(180deg, #ffffff, #f1f3f9);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 1px 0 #fff;
}
:root[data-theme="ios"] .avatar {
  background-image: linear-gradient(160deg, #57a9ff 0%, #0a6cff 70%, #005ee8 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px rgba(10, 108, 255, .28);
}

/* Кнопки: объёмная заливка с бликом и мягкой тенью. */
:root[data-theme="ios"] .btn { border-radius: 12px; }
:root[data-theme="ios"] .btn--primary {
  background: linear-gradient(180deg, #3f9bff 0%, #0a6cff 55%, #0060e6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), 0 2px 6px rgba(10, 108, 255, .28);
}
:root[data-theme="ios"] .btn--primary:hover {
  background: linear-gradient(180deg, #57a9ff 0%, #1a78ff 55%, #0068f0 100%);
}
:root[data-theme="ios"] .btn--primary:active,
:root[data-theme="ios"] .btn--danger:active {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18);
}
:root[data-theme="ios"] .btn--danger {
  background: linear-gradient(180deg, #ff6259 0%, #e53935 55%, #c62828 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 2px 6px rgba(229, 57, 53, .25);
}
:root[data-theme="ios"] .btn--ghost {
  background: linear-gradient(180deg, #ffffff 0%, #f4f5f9 100%);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05), inset 0 1px 0 #fff;
}

/* Поля, бейджи и выбор темы: тонкий блик вместо плоской заливки. */
:root[data-theme="ios"] .input {
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  border-color: #8e8e93;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, .05);
}
:root[data-theme="ios"] .input:disabled {
  background: #f2f2f7;
  border-color: #c7c7cc;
  box-shadow: none;
}
:root[data-theme="ios"] .input[readonly] {
  background: #f2f2f7;
  border-color: #8e8e93;
  box-shadow: none;
}
:root[data-theme="ios"] .badge {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
:root[data-theme="ios"] .theme-option__body {
  background-image: linear-gradient(180deg, #ffffff 0%, #f5f6fa 100%);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
:root[data-theme="ios"] .theme-option input:checked + .theme-option__body {
  background-image: linear-gradient(180deg, #f3f8ff 0%, #e6f0ff 100%);
  box-shadow: 0 0 0 2px rgba(10, 108, 255, .16), 0 6px 16px rgba(10, 108, 255, .12);
}
:root[data-theme="ios"] .table th {
  text-transform: none;
  letter-spacing: .01em;
  font-size: 12px;
  background-image: linear-gradient(180deg, #fafafd 0%, #f2f3f7 100%);
}

/* Цветные плитки иконок, как в «Настройках» iPhone. */
:root[data-theme="ios"] .tone--blue { --tone-1: #5aa7ff; --tone-2: #0a63e6; }
:root[data-theme="ios"] .tone--green { --tone-1: #64d68a; --tone-2: #168a43; }
:root[data-theme="ios"] .tone--orange { --tone-1: #ffb15c; --tone-2: #d96c00; }
:root[data-theme="ios"] .tone--amber { --tone-1: #e6bd7a; --tone-2: #a66a1f; }
:root[data-theme="ios"] .tone--cyan { --tone-1: #5fd3e4; --tone-2: #0d8fa8; }
:root[data-theme="ios"] .tone--purple { --tone-1: #b18cff; --tone-2: #6c3fe0; }
:root[data-theme="ios"] .tone--teal { --tone-1: #5fd6c8; --tone-2: #0d8f83; }
:root[data-theme="ios"] .tone--indigo { --tone-1: #93a5ff; --tone-2: #4054cc; }
:root[data-theme="ios"] .tone--pink { --tone-1: #ff93b9; --tone-2: #d62f6e; }
:root[data-theme="ios"] .tone--red { --tone-1: #ff8a80; --tone-2: #cc2b26; }
:root[data-theme="ios"] .tone--gray { --tone-1: #b9bdc7; --tone-2: #6f7580; }

:root[data-theme="ios"] .nav__icon.tone,
:root[data-theme="ios"] .mobile-menu__icon.tone,
:root[data-theme="ios"] .module-card__icon.tone,
:root[data-theme="ios"] .theme-option__icon.tone {
  display: grid;
  place-items: center;
  background-image: linear-gradient(160deg, var(--tone-1) 0%, var(--tone-2) 100%);
  background-color: var(--tone-2);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 1px 3px rgba(20, 30, 50, .18);
}
:root[data-theme="ios"] .nav__icon.tone {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 26px;
}
:root[data-theme="ios"] .nav__icon.tone .ui-icon { width: 15px; height: 15px; }
:root[data-theme="ios"] .mobile-menu__icon.tone {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex: 0 0 30px;
}
:root[data-theme="ios"] .mobile-menu__icon.tone .ui-icon { width: 18px; height: 18px; }
:root[data-theme="ios"] .module-card__icon.tone { border-radius: 11px; }
:root[data-theme="ios"] .module-card__icon.tone .ui-icon { width: 22px; height: 22px; }
:root[data-theme="ios"] .theme-option__icon.tone {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  margin-bottom: 4px;
}
:root[data-theme="ios"] .theme-option__icon.tone .ui-icon { width: 19px; height: 19px; }

/* Справочник оборудования: те же мягкие поверхности, что у карточек. */
:root[data-theme="ios"] .device-column {
  border-color: rgba(60, 60, 67, .10);
  background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 24px rgba(60, 60, 67, .06);
}
:root[data-theme="ios"] .device-column__head {
  background-image: linear-gradient(180deg, #fafafd 0%, #f2f3f7 100%);
}
:root[data-theme="ios"] .device-row.is-selected {
  background-image: linear-gradient(180deg, #eaf2ff 0%, #dce8ff 100%);
  box-shadow: inset 0 0 0 1px rgba(10, 108, 255, .10);
}

/* ---------- Линейные иконки темы iOS ---------- */

/* Спрайт лежит в начале body и не занимает места. В обычных темах
   показываются прежние эмодзи, в iOS — линейные SVG в стиле SF Symbols. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon {
  display: none;
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
  vertical-align: -.2em;
}
.glyph-emoji { display: inline; }
:root[data-theme="ios"] .ui-icon { display: inline-block; }
:root[data-theme="ios"] .glyph-emoji { display: none; }

/* Плитки заказов и колокольчик в iOS-теме тоже получают лёгкий объём. */
:root[data-theme="ios"] .table--orders tbody td {
  background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
}
:root[data-theme="ios"] .table--orders thead th {
  background-image: linear-gradient(180deg, #fafafd 0%, #f2f3f7 100%);
}
:root[data-theme="ios"] .topbar__bell { color: var(--brand); }

/* ---------- Импорт и экспорт ---------- */

.import-steps {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.import-steps__item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
}
.import-steps__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.import-steps__item p { margin: 2px 0 0; font-size: 13px; }

.import-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
}
.import-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.import-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.import-card__step {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.import-card__title { font-size: 16px; margin: 0; }
.import-card__hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.import-card__form {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.import-card__form .btn { justify-self: start; }
.input--file { padding: 8px; font-size: 13px; }

.import-exports { display: flex; flex-wrap: wrap; gap: 8px; }

.card__head--pad { padding: 16px 16px 0; margin-bottom: 10px; }

.import-mapping select { min-width: 210px; width: 100%; }
.import-required {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: 1px;
}
.import-sample { color: var(--muted); max-width: 320px; overflow-wrap: anywhere; }
.import-preview td { max-width: 220px; overflow-wrap: anywhere; font-size: 13px; }

.import-options { display: grid; gap: 14px; }
.import-options .check { align-items: flex-start; }
.import-options .check > span { display: grid; gap: 2px; }
.import-options .check .muted { font-size: 12.5px; }
.import-option-field { max-width: 560px; }

.import-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.import-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.import-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.import-kind .input { width: auto; min-width: 190px; }

.import-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-bottom: 16px;
}
.import-stat {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.import-stat__value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.import-stat__label { font-size: 12.5px; color: var(--muted); }
.import-stat--danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.import-stat--danger .import-stat__value { color: var(--danger); }
.import-stat--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.import-stat--warn .import-stat__value { color: var(--warn); }

.import-facts {
  display: grid;
  gap: 10px 18px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.import-facts > div { display: flex; flex-direction: column; gap: 2px; }
.import-facts strong { font-size: 15px; overflow-wrap: anywhere; }
.import-fact--wide { grid-column: 1 / -1; }

@media (max-width: 860px) {
  .import-steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .import-steps { grid-template-columns: 1fr; }
  .import-mapping select { min-width: 0; }
  .import-secondary { flex-direction: column; align-items: stretch; }
  .import-kind { flex-direction: column; align-items: stretch; }
  .import-kind .input { width: 100%; }
}

.input--file::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.input--file::file-selector-button:hover { background: var(--border); }
