/* ==========================================================================
   DzivaProdTrek — дизайн-система прототипа
   Фирменные шрифты Gilroy · фирменная зелёная палитра · Apple-подход к UI
   ========================================================================== */

/* --- Шрифты ------------------------------------------------------------ */

@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Light.woff2') format('woff2');     font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Regular.woff2') format('woff2');   font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Medium.woff2') format('woff2');    font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Semibold.woff2') format('woff2');  font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Bold.woff2') format('woff2');      font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Extrabold.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gilroy'; src: url('/assets/fonts/Gilroy-Black.woff2') format('woff2');     font-weight: 900; font-style: normal; font-display: swap; }

/* --- Токены ------------------------------------------------------------ */

:root {
  /* Фирменные цвета DzivaProduct */
  --green-900: #214806;
  --green-800: #274C1D;
  --green-700: #37692A;
  --green-600: #518036;
  --green-500: #588847;
  --green-400: #88CA53;
  --green-300: #A1D42E;
  --green-vivid: #28C900;
  --ink: #252525;

  /* Поверхности */
  --bg: #F6F7F4;
  --surface: #FFFFFF;
  --surface-sunken: #FAFBF8;
  --surface-tint: #F1F6EC;

  /* Текст */
  --text: #252525;
  --text-2: #6C716C;
  --text-3: #9CA29C;
  --text-on-dark: #FFFFFF;
  --text-on-dark-2: rgba(255, 255, 255, 0.72);

  /* Линии */
  --line: rgba(37, 37, 37, 0.08);
  --line-strong: rgba(37, 37, 37, 0.14);
  --line-on-dark: rgba(255, 255, 255, 0.16);

  /* Статусы */
  --warn: #C98A16;
  --warn-bg: #FDF6E7;
  --danger: #C7412F;
  --danger-bg: #FCEFEC;
  --ok: #2E7D32;
  --ok-bg: #ECF6EC;

  /* Скругления */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-2xl: 32px;
  --r-full: 999px;

  /* Тени */
  --shadow-1: 0 1px 2px rgba(37, 37, 37, 0.05), 0 1px 1px rgba(37, 37, 37, 0.03);
  --shadow-2: 0 6px 20px -8px rgba(37, 37, 37, 0.14), 0 1px 3px rgba(37, 37, 37, 0.05);
  --shadow-3: 0 28px 60px -24px rgba(39, 76, 29, 0.30), 0 4px 12px -4px rgba(37, 37, 37, 0.08);
  --shadow-green: 0 10px 24px -10px rgba(81, 128, 54, 0.55);

  /* Движение (кривая из Apple HIG) */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t: 260ms;
  --t-slow: 480ms;

  /* Сетка */
  --sidebar-w: 264px;
  --gap: 24px;
}

/* --- Сброс ------------------------------------------------------------- */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Gilroy', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--green-600);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: rgba(136, 202, 83, 0.32); }

/* Скроллбары — тонкие, в стиле macOS */
* { scrollbar-width: thin; scrollbar-color: rgba(37, 37, 37, 0.18) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(37, 37, 37, 0.16);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(37, 37, 37, 0.28); background-clip: content-box; }

/* --- Типографика ------------------------------------------------------- */

.t-display { font-size: 42px; line-height: 1.06; font-weight: 800; letter-spacing: -0.032em; }
.t-title1  { font-size: 29px; line-height: 1.15; font-weight: 700; letter-spacing: -0.026em; }
.t-title2  { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.022em; }
.t-title3  { font-size: 18px; line-height: 1.32; font-weight: 600; letter-spacing: -0.016em; }
.t-headline{ font-size: 16px; line-height: 1.4;  font-weight: 600; letter-spacing: -0.012em; }
.t-body    { font-size: 15px; line-height: 1.52; font-weight: 500; }
.t-callout { font-size: 14px; line-height: 1.45; font-weight: 500; }
.t-caption { font-size: 12.5px; line-height: 1.4; font-weight: 500; letter-spacing: 0; }
.t-overline {
  font-size: 11px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-3);
}
.t-num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

.muted  { color: var(--text-2); }
.muted-2{ color: var(--text-3); }
.accent { color: var(--green-600); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: var(--r-full);
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), opacity var(--t-fast);
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn--primary {
  background: var(--green-600); color: #fff;
  box-shadow: var(--shadow-green);
}
.btn--primary:hover { background: var(--green-700); }

.btn--secondary {
  background: rgba(37, 37, 37, 0.05); color: var(--text);
}
.btn--secondary:hover { background: rgba(37, 37, 37, 0.09); }

.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: rgba(37, 37, 37, 0.05); color: var(--text); }

.btn--outline { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--outline:hover { background: var(--surface-sunken); }

.btn--onDark { background: rgba(255, 255, 255, 0.14); color: #fff; backdrop-filter: blur(12px); }
.btn--onDark:hover { background: rgba(255, 255, 255, 0.22); }

.btn--lg { height: 48px; padding: 0 26px; font-size: 16px; border-radius: var(--r-full); }
.btn--sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn--block { width: 100%; }

.btn--icon { width: 38px; height: 38px; padding: 0; border-radius: var(--r-full); }

/* --- Чипы и бейджи ----------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px;
  border-radius: var(--r-full);
  background: rgba(37, 37, 37, 0.05);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  letter-spacing: -0.005em; white-space: nowrap;
}
.chip--green   { background: var(--surface-tint); color: var(--green-700); }
.chip--warn    { background: var(--warn-bg); color: var(--warn); }
.chip--danger  { background: var(--danger-bg); color: var(--danger); }
.chip--ok      { background: var(--ok-bg); color: var(--ok); }
.chip--onDark  { background: rgba(255, 255, 255, 0.16); color: #fff; }

.chip svg { width: 13px; height: 13px; flex: none; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot--pulse { animation: pulse 2s var(--ease) infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

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

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card--pad { padding: 22px; }
.card--raised { box-shadow: var(--shadow-2); }

/* --- Аватар ------------------------------------------------------------ */

.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--r-full);
  background: linear-gradient(140deg, var(--green-500), var(--green-800));
  color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 0.01em;
}
.avatar--lg { width: 44px; height: 44px; font-size: 15px; }

/* --- Поля ввода -------------------------------------------------------- */

.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
  height: 48px; padding: 0 16px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 500;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast);
}
/* Многострочное поле: фиксированная высота и нулевые вертикальные отступы
   из .input для него не годятся. */
textarea.input {
  height: auto; min-height: 96px;
  padding: 13px 16px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}

.input::placeholder { color: var(--text-3); }
.input:focus {
  outline: none; background: var(--surface);
  border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(88, 136, 71, 0.14);
}

/* --- Сегментированный контрол (iOS-стиль) ------------------------------ */

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: rgba(37, 37, 37, 0.055);
  border-radius: var(--r-full);
}
.segmented button {
  height: 32px; padding: 0 13px;
  white-space: nowrap; min-width: 0;
  border-radius: var(--r-full);
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all var(--t-fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected='true'] {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1);
}

/* --- Прогресс ---------------------------------------------------------- */

.progress {
  position: relative; height: 6px; border-radius: var(--r-full);
  background: rgba(37, 37, 37, 0.08); overflow: hidden;
}
.progress > i {
  position: absolute; inset: 0 auto 0 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--green-600), var(--green-400));
  transition: width var(--t-slow) var(--ease);
}
.progress--onDark { background: rgba(255, 255, 255, 0.2); }
.progress--onDark > i { background: linear-gradient(90deg, var(--green-300), #fff); }

/* ==========================================================================
   Экран входа
   ========================================================================== */

.login {
  display: grid; grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.login__brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  background-color: var(--green-900);
  color: #fff;
}

/* Фотография производства */
.login__brand::before {
  content: ''; position: absolute; inset: 0;
  background-image: url('/assets/img/login-cover.webp');
  background-size: cover;
  background-position: 58% center;
  transform: scale(1.02);
}

/* Оверлей: тонирует фото в фирменный зелёный и гарантирует контраст текста.
   Верх притемнён под логотип, низ — плотнее, под заголовок и описание. */
.login__brand::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(180deg,
      rgba(20, 40, 8, 0.78) 0%,
      rgba(20, 40, 8, 0.42) 22%,
      rgba(24, 48, 10, 0.62) 52%,
      rgba(20, 40, 8, 0.93) 82%,
      rgba(16, 33, 6, 0.97) 100%),
    linear-gradient(120deg, rgba(39, 76, 29, 0.72) 0%, rgba(33, 72, 6, 0.34) 55%, rgba(33, 72, 6, 0.62) 100%);
}
.login__brand > * { position: relative; z-index: 1; }
.login__logo { height: 34px; width: auto; }
.login__pitch { max-width: 460px; }
.login__pitch h1 {
  font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.032em;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.45);
}
.login__pitch p {
  margin-top: 16px; font-size: 16.5px; line-height: 1.55; color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.5);
}
.login__logo { filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.4)); }
.login__features .chip--onDark {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.login__features { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

.login__form {
  display: grid; place-items: center; padding: 48px;
  background: var(--surface);
}
.login__inner { width: 100%; max-width: 372px; }

.login__accounts { display: grid; gap: 10px; margin-top: 12px; }
.login__account {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 15px; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
}
.login__account:hover {
  border-color: var(--green-400);
  background: var(--surface-tint);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.login__account strong { display: block; font-size: 14px; font-weight: 600; }
.login__account span { font-size: 12.5px; color: var(--text-2); }

.divider {
  display: flex; align-items: center; gap: 14px;
  margin: 26px 0; color: var(--text-3); font-size: 12px; font-weight: 600;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.error-msg {
  margin-top: 14px; padding: 11px 14px;
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600;
}

/* ==========================================================================
   Каркас приложения менеджера
   ========================================================================== */

/* Высота фиксирована по экрану: список заказов и карточка прокручиваются независимо.
   dvh вместо vh — иначе на телефоне нижняя часть уходит под адресную строку. */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }

/* Кнопка меню и подложка — только для планшета и телефона */
.topbar__burger { display: none; }
.drawer-backdrop { display: none; }

/* Полоса «Назад» в карточке заказа — только на телефоне */
.detail__back { display: none; }

@keyframes pane-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

.sidebar {
  display: flex; flex-direction: column;
  padding: 24px 16px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
}
.sidebar__logo { padding: 0 10px 26px; }
.sidebar__logo img { height: 28px; width: auto; }

.nav { display: grid; gap: 2px; }
.nav__label { padding: 16px 12px 7px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 600; color: var(--text-2);
  transition: all var(--t-fast) var(--ease);
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.75; }
.nav a:hover { background: rgba(37, 37, 37, 0.045); color: var(--text); }
.nav a.is-active {
  background: var(--surface-tint); color: var(--green-700);
}
.nav a.is-active svg { opacity: 1; }
.nav a .count {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.sidebar__user {
  display: flex; align-items: center; gap: 11px;
  margin-top: auto; padding: 12px 10px 0;
  border-top: 1px solid var(--line);
}
.sidebar__user .name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.sidebar__user .role { font-size: 12px; color: var(--text-3); line-height: 1.3; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 68px; padding: 0 28px;
  background: rgba(246, 247, 244, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__spacer { flex: 1; }

.search {
  position: relative; width: 300px;
}
.search svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.search input {
  width: 100%; height: 38px; padding: 0 14px 0 37px;
  background: rgba(37, 37, 37, 0.05);
  border: 1px solid transparent; border-radius: var(--r-full);
  font-size: 14px; font-weight: 500;
  transition: all var(--t-fast) var(--ease);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
  outline: none; background: var(--surface);
  border-color: var(--green-400);
  box-shadow: 0 0 0 4px rgba(136, 202, 83, 0.16);
}

/* --- Рабочая область: список + карточка -------------------------------- */

.workspace {
  display: grid; grid-template-columns: 396px 1fr;
  flex: 1; min-height: 0;
}

.orders {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface-sunken);
  min-height: 0;
}
.orders__head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 14px;
}
.orders__list { flex: 1; overflow-y: auto; padding: 0 12px 20px; display: grid; gap: 8px; align-content: start; }

.order-card {
  position: relative; display: grid; gap: 11px;
  padding: 15px 16px; text-align: left; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
}
.order-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.order-card.is-active {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(88, 136, 71, 0.13), var(--shadow-2);
}
.order-card__top { display: flex; align-items: center; gap: 8px; }
.order-card__num { font-size: 11.5px; font-weight: 700; color: var(--text-3); letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.order-card__title { font-size: 15.5px; font-weight: 700; letter-spacing: -0.018em; line-height: 1.25; }
.order-card__brand { font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.order-card__meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.order-card__stage { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--green-700); }

/* --- Детальная карточка заказа ----------------------------------------- */

.detail { overflow-y: auto; min-height: 0; padding: 26px 30px 40px; }
.detail__inner { max-width: 880px; margin: 0 auto; display: grid; gap: 18px; }

.detail__head { display: grid; gap: 14px; }
.detail__crumbs { display: flex; align-items: center; gap: 9px; }
.detail__title { display: flex; align-items: flex-start; gap: 16px; }
.detail__title h1 { font-size: 30px; line-height: 1.12; font-weight: 800; letter-spacing: -0.03em; }

.facts {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.fact { padding: 16px 18px; border-right: 1px solid var(--line); }
.fact:last-child { border-right: none; }
.fact dt { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.fact dd { margin: 5px 0 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.014em; }

/* Панель текущего этапа — главный акцент экрана */
.stage-panel {
  position: relative; overflow: hidden;
  padding: 24px 26px;
  border-radius: var(--r-xl);
  background: linear-gradient(140deg, #2F5C23 0%, var(--green-800) 52%, var(--green-900) 100%);
  color: #fff;
  box-shadow: var(--shadow-3);
}
.stage-panel::after {
  content: ''; position: absolute; width: 420px; height: 420px;
  right: -140px; top: -200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(161, 212, 46, 0.28), transparent 62%);
  pointer-events: none;
}
.stage-panel > * { position: relative; z-index: 1; }
.stage-panel__row { display: flex; align-items: flex-end; gap: 24px; }
.stage-panel__now { flex: 1; min-width: 0; }
.stage-panel__now h2 { font-size: 27px; font-weight: 700; letter-spacing: -0.026em; line-height: 1.15; margin-top: 8px; }
.stage-panel__now p { margin-top: 7px; font-size: 14px; color: var(--text-on-dark-2); }
.stage-panel__progress { margin-top: 22px; display: grid; gap: 9px; }
.stage-panel__progress .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-on-dark-2); font-weight: 600; }
.stage-panel__actions { display: flex; gap: 10px; margin-top: 22px; }

.mirror {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px; padding: 12px 15px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-on-dark);
  border-radius: var(--r-md);
  font-size: 13px; color: #fff;
}
/* Тот же блок на светлом фоне — в модальном окне подтверждения. */
.mirror--light {
  margin-top: 0;
  background: var(--surface-tint);
  border-color: var(--green-400);
  color: var(--green-800);
}
.mirror svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.mirror b { font-weight: 700; }

/* --- Маршрут (степпер) -------------------------------------------------- */

.route { padding: 6px 0; }
.route__head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 6px; }
.route__head h3 { white-space: nowrap; }
.route__head .hint { text-align: right; }
@media (max-width: 1500px) { .route__head .hint { display: none; } }

.step {
  position: relative; display: grid;
  grid-template-columns: 34px 1fr auto; gap: 14px; align-items: start;
  padding: 11px 22px;
  transition: background var(--t-fast) var(--ease);
}
.step + .step { margin-top: -2px; }
.step__marker { position: relative; display: grid; place-items: center; padding-top: 1px; }
.step__bullet {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line-strong);
  color: #fff; transition: all var(--t) var(--ease); z-index: 1;
}
.step__bullet svg { width: 12px; height: 12px; }
.step:not(:last-child) .step__marker::after {
  content: ''; position: absolute; top: 24px; bottom: -24px; left: 50%;
  width: 2px; margin-left: -1px; background: var(--line-strong);
}
.step__title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.012em; }
.step__dept  { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.step__date  { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }

.step.is-done .step__bullet { background: var(--green-600); border-color: var(--green-600); }
.step.is-done .step__marker::after { background: var(--green-400); }
.step.is-done .step__title { color: var(--text-2); }

.step.is-current { background: var(--surface-tint); }
.step.is-current .step__bullet {
  background: #fff; border-color: var(--green-600);
  box-shadow: 0 0 0 5px rgba(136, 202, 83, 0.22);
}
.step.is-current .step__bullet i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green-600);
  animation: pulse 2s var(--ease) infinite;
}
.step.is-current .step__title { font-weight: 700; color: var(--green-800); }

.step.is-todo .step__title { color: var(--text-3); }

/* Разделители клиентских этапов внутри маршрута */
.route__group {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px 6px;
}
.route__group span { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.route__group i { flex: 1; height: 1px; background: var(--line); }

/* --- Секции ------------------------------------------------------------ */

.section__head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px 12px;
}
.doc-row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 22px; border-top: 1px solid var(--line);
  transition: background var(--t-fast) var(--ease);
}
.doc-row:hover { background: var(--surface-sunken); }
.doc-row__icon {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); background: var(--surface-tint); color: var(--green-700);
}
.doc-row__icon svg { width: 17px; height: 17px; }
.doc-row__name { font-size: 14px; font-weight: 600; }
.doc-row__meta { font-size: 12px; color: var(--text-3); }

/* ==========================================================================
   Личный кабинет клиента
   ========================================================================== */

.portal { min-height: 100vh; background: var(--surface); }

.portal__bar {
  display: flex; align-items: center; gap: 16px;
  height: 72px; padding: 0 40px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.portal__bar img { height: 26px; width: auto; }
.portal__bar .sep { width: 1px; height: 22px; background: var(--line-strong); }

.portal__wrap { max-width: 1120px; margin: 0 auto; padding: 40px 40px 80px; }

.portal__hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.portal__hello h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.portal__hello p { margin-top: 8px; font-size: 16px; color: var(--text-2); }

/* Главная карточка активного заказа */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-2xl);
  background: linear-gradient(145deg, #325F25 0%, var(--green-800) 50%, var(--green-900) 100%);
  color: #fff; padding: 34px 38px 32px;
  box-shadow: var(--shadow-3);
}
.hero::before {
  content: ''; position: absolute; width: 620px; height: 620px;
  right: -200px; top: -280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(161, 212, 46, 0.26), transparent 62%);
}
.hero > * { position: relative; z-index: 1; }
.hero__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.hero__title { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-top: 10px; }
.hero__sub { margin-top: 9px; font-size: 15px; color: var(--text-on-dark-2); }

.ring { position: relative; flex: none; width: 116px; height: 116px; }
.ring svg { transform: rotate(-90deg); width: 116px; height: 116px; }
.ring circle { fill: none; stroke-linecap: round; }
.ring .track { stroke: rgba(255, 255, 255, 0.18); stroke-width: 9; }
.ring .bar {
  stroke: url(#ringGrad); stroke-width: 9;
  transition: stroke-dashoffset 900ms var(--ease);
}
.ring__label {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.ring__label b { display: block; font-size: 27px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.ring__label span { font-size: 10.5px; font-weight: 600; color: var(--text-on-dark-2); letter-spacing: 0.04em; }

/* Клиентский таймлайн из 7 этапов */
.timeline {
  /* 10 этапов дорожной карты. На узком экране раскладка ниже переносит их
     в несколько рядов — горизонтальной прокрутки быть не должно. */
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr));
  margin-top: 34px; padding-top: 30px;
  border-top: 1px solid var(--line-on-dark);
}
.tl {
  position: relative; padding-right: 12px;
}
.tl__dot {
  position: relative; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid transparent;
  transition: all var(--t) var(--ease);
}
.tl__dot svg { width: 13px; height: 13px; color: var(--green-900); }
.tl:not(:last-child)::before {
  content: ''; position: absolute; left: 26px; right: 0; top: 13px; height: 2px;
  background: rgba(255, 255, 255, 0.18);
}
.tl.is-done .tl__dot { background: var(--green-300); }
.tl.is-done::before { background: var(--green-300); }
.tl.is-current .tl__dot {
  background: #fff; border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.14);
}
.tl.is-current .tl__dot i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green-700);
  animation: pulse 2s var(--ease) infinite;
}
.tl__title {
  margin-top: 13px; min-height: 36px;
  font-size: 12px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.32;
  color: rgba(255, 255, 255, 0.55);
}
.tl__date { margin-top: 3px; font-size: 11.5px; color: rgba(255, 255, 255, 0.42); font-variant-numeric: tabular-nums; }
.tl.is-done .tl__title, .tl.is-current .tl__title { color: #fff; }
.tl.is-current .tl__date { color: var(--green-300); }

.hero__foot {
  display: flex; align-items: center; gap: 22px;
  margin-top: 30px; padding-top: 22px;
  border-top: 1px solid var(--line-on-dark);
}
.hero__stat span { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.5); }
.hero__stat b { display: block; margin-top: 5px; font-size: 16px; font-weight: 700; letter-spacing: -0.016em; }

/* Список заказов клиента */
.portal__section { margin-top: 46px; }
.portal__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 18px; }

.p-card {
  display: grid; gap: 14px; text-align: left; padding: 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: all var(--t) var(--ease);
}
.p-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--green-400); }
.p-card.is-active { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(88, 136, 71, 0.12); }
.p-card__title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.p-card__row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-2); }

/* --- Тост -------------------------------------------------------------- */

.toasts {
  position: fixed; right: 26px; bottom: 26px; z-index: 100;
  display: grid; gap: 10px; justify-items: end;
}
.toast {
  display: flex; align-items: center; gap: 13px;
  min-width: 300px; max-width: 420px; padding: 15px 19px;
  background: rgba(37, 37, 37, 0.94);
  backdrop-filter: blur(20px);
  color: #fff; border-radius: var(--r-lg);
  box-shadow: 0 20px 44px -16px rgba(0, 0, 0, 0.45);
  animation: toast-in 460ms var(--ease-out) both;
}
.toast.is-leaving { animation: toast-out 300ms var(--ease) both; }
.toast__icon {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 50%; background: var(--green-vivid); color: #fff;
}
.toast__icon svg { width: 18px; height: 18px; }
.toast strong { display: block; font-size: 14.5px; font-weight: 700; letter-spacing: -0.012em; }
.toast span { display: block; font-size: 13px; color: rgba(255, 255, 255, 0.66); margin-top: 1px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.97); }
}

/* --- Подсветка обновления ---------------------------------------------- */

@keyframes flash {
  0%   { box-shadow: var(--shadow-3), 0 0 0 0 rgba(161, 212, 46, 0.6); }
  60%  { box-shadow: var(--shadow-3), 0 0 0 16px rgba(161, 212, 46, 0); }
  100% { box-shadow: var(--shadow-3), 0 0 0 0 rgba(161, 212, 46, 0); }
}
.is-flashing { animation: flash 1400ms var(--ease-out); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise 420ms var(--ease-out) both; }

/* --- Индикатор соединения ---------------------------------------------- */

.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-3);
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green-vivid); }
.live.is-live i { animation: pulse 2.4s var(--ease) infinite; }
.live.is-off i { background: var(--text-3); animation: none; }

/* --- Пустое состояние -------------------------------------------------- */

.empty { display: grid; place-items: center; gap: 10px; padding: 80px 20px; text-align: center; color: var(--text-3); }

/* ==========================================================================
   Разделы менеджера: общие блоки
   ========================================================================== */

.view { flex: 1; overflow-y: auto; min-height: 0; padding: 34px 40px 64px; }
/* minmax(0, 1fr), а не 1fr: иначе широкая таблица внутри растягивает дорожку
   и весь раздел начинает ездить по горизонтали на узком экране. */
.view__inner { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.view__head { display: flex; align-items: flex-end; gap: 16px; }
.view__head p { margin-top: 6px; }

.row-gap { display: grid; gap: 14px; }
.flex { display: flex; align-items: center; gap: 12px; }
.flex-1 { flex: 1; }

/* Две равные колонки, схлопывающиеся в одну на узких экранах.
   Раньше это было инлайновым стилем — медиа-запросы его не перебивали. */
.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

/* Плитки показателей */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  padding: 18px 20px; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.stat span { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.stat b { display: block; margin-top: 7px; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat em { display: block; margin-top: 7px; font-size: 12.5px; font-style: normal; color: var(--text-2); }
.stat--accent { background: linear-gradient(140deg, var(--green-700), var(--green-900)); color: #fff; }
.stat--accent span, .stat--accent em { color: rgba(255, 255, 255, 0.66); }

/* Таблица */
.table-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 13px 18px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-sunken);
  border-bottom: 1px solid var(--line);
}
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-sunken); }
.table .strong { font-weight: 600; }

/* Доска производства */
.board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.board__col { background: rgba(37, 37, 37, 0.035); border-radius: var(--r-lg); padding: 10px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.board__head { display: flex; align-items: center; gap: 6px; padding: 3px 5px 1px; }
.board__head b { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.board__head span { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--text-3); }
.bcard {
  display: grid; gap: 7px; padding: 11px 12px; text-align: left; width: 100%; min-width: 0;
  background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1);
  transition: all var(--t-fast) var(--ease);
}
.bcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.bcard__title { font-size: 13px; font-weight: 700; letter-spacing: -0.014em; line-height: 1.25; }
.bcard__meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); min-width: 0; }
.bcard__meta > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Диаграмма загрузки цехов */
.gantt { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.gantt__row { display: grid; grid-template-columns: 196px 1fr; border-bottom: 1px solid var(--line); }
.gantt__row:last-child { border-bottom: none; }
.gantt__row--head { background: var(--surface-sunken); }
.gantt__side { padding: 14px 18px; border-right: 1px solid var(--line); }
.gantt__side b { display: block; font-size: 14px; font-weight: 700; letter-spacing: -0.014em; }
.gantt__side span { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--text-3); }
.gantt__side span + span { font-size: 11px; color: var(--text-3); opacity: 0.8; }
.gantt__track { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; min-height: 78px; }
.gantt__cell { border-left: 1px solid var(--line); }
.gantt__cell--weekend { background: rgba(37, 37, 37, 0.028); }
.gantt__cell--today { background: rgba(136, 202, 83, 0.12); }
.gantt__day { padding: 11px 0 10px; text-align: center; border-left: 1px solid var(--line); }
.gantt__day b { display: block; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.gantt__day span { display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-top: 1px; }
.gantt__day.is-today b { color: var(--green-700); }
.gantt__bar {
  position: absolute; top: 14px; height: 38px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border-radius: 10px; overflow: hidden; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  box-shadow: var(--shadow-1);
  transition: transform var(--t-fast) var(--ease);
}
.gantt__bar:hover { transform: translateY(-1px); z-index: 3; }
.gantt__bar--planned { background: var(--surface-tint); color: var(--green-800); box-shadow: inset 0 0 0 1px var(--green-400); }
.gantt__bar--done { background: rgba(37, 37, 37, 0.09); color: var(--text-2); }
.gantt__bar--service {
  background: repeating-linear-gradient(45deg, #EDF0EA, #EDF0EA 7px, #E2E7DE 7px, #E2E7DE 14px);
  color: var(--text-2);
}
.gantt__now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--green-vivid); z-index: 2; pointer-events: none; }
.gantt__now::before {
  content: ''; position: absolute; top: -4px; left: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--green-vivid);
}

/* Очередь контроля качества */
.qc {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 15px; align-items: center;
  padding: 17px 22px; border-bottom: 1px solid var(--line);
}
.qc:last-child { border-bottom: none; }
.qc__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--surface-tint); color: var(--green-700); }
.qc__icon svg { width: 20px; height: 20px; }
.qc__icon--warn { background: var(--warn-bg); color: var(--warn); }
.qc__title { font-size: 15px; font-weight: 700; letter-spacing: -0.016em; }
.qc__detail { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.qc__checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qc__checks .chip { height: 22px; font-size: 11.5px; padding: 0 9px; }

/* Карточки клиентов */
.companies { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.company { padding: 22px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); display: grid; gap: 16px; min-width: 0; text-align: left; transition: all var(--t) var(--ease); }
.company:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.company__logo {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--green-500), var(--green-800));
  color: #fff; font-size: 16px; font-weight: 800;
}
.company__nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.company__nums div span { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.company__nums div b { display: block; margin-top: 3px; font-size: 16px; font-weight: 700; letter-spacing: -0.018em; }

/* Рецептуры */
.formulation__head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.bom-total { display: flex; align-items: center; gap: 14px; padding: 14px 22px; background: var(--surface-sunken); font-size: 13px; }
.bom-total svg { width: 18px; height: 18px; flex: none; color: var(--green-600); }

/* ==========================================================================
   Модальное окно и мастер создания заказа
   ========================================================================== */

.backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 32px;
  background: rgba(22, 30, 18, 0.42);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade 240ms var(--ease) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(900px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--r-2xl);
  box-shadow: 0 48px 96px -32px rgba(0, 0, 0, 0.45);
  animation: modal-in 380ms var(--ease-out) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 30px 20px; border-bottom: 1px solid var(--line);
}
.modal__head > div { min-width: 0; }
/* Кнопка закрытия не должна сжиматься под длинным названием бренда. */
.modal__head > .btn { flex: none; margin-top: -4px; }
.modal__body { flex: 1; overflow-y: auto; padding: 28px 30px; }
.modal__foot { display: flex; align-items: center; gap: 12px; padding: 18px 30px; border-top: 1px solid var(--line); background: var(--surface-sunken); }

/* Шаги мастера */
.wsteps { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.wstep { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.wstep i {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(37, 37, 37, 0.07); font-size: 11.5px; font-style: normal; font-weight: 700;
  transition: all var(--t) var(--ease);
}
.wstep i svg { width: 12px; height: 12px; }
.wstep.is-done { color: var(--green-700); }
.wstep.is-done i { background: var(--surface-tint); color: var(--green-700); }
.wstep.is-active { color: var(--green-800); }
.wstep.is-active i { background: var(--green-600); color: #fff; box-shadow: 0 0 0 4px rgba(136, 202, 83, 0.22); }
.wsep { flex: 1; height: 1px; background: var(--line); }

/* Карточки-переключатели вместо радиокнопок */
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.choice {
  display: grid; gap: 3px; padding: 14px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
}
.choice:hover { border-color: var(--green-400); background: var(--surface-tint); }
.choice.is-on { border-color: var(--green-600); background: var(--surface-tint); box-shadow: 0 0 0 3px rgba(88, 136, 71, 0.13); }
.choice b { font-size: 14.5px; font-weight: 700; letter-spacing: -0.014em; }
.choice span { font-size: 12.5px; color: var(--text-2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* Итоговая сводка мастера */
.summary { background: var(--surface-sunken); border-radius: var(--r-lg); padding: 20px 22px; display: grid; gap: 12px; }
.summary__row { display: flex; align-items: baseline; gap: 14px; font-size: 14px; }
.summary__row dt { width: 190px; flex: none; color: var(--text-2); font-size: 13px; }
.summary__row dd { margin: 0; font-weight: 600; }

/* ==========================================================================
   Чат
   ========================================================================== */

.chat { display: flex; flex-direction: column; min-height: 0; }

/* Шапка чата: собеседник и номер заказа */
.chat__peer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 13px;
  padding: 18px 22px 16px; border-bottom: 1px solid var(--line);
}
.chat__peer-info { flex: 1 1 140px; min-width: 0; }
.chat__feed {
  flex: 1; overflow-y: auto; padding: 20px 22px;
  display: grid; gap: 14px; align-content: start;
  max-height: 440px;
}
.chat__day { justify-self: center; font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 3px 12px; background: rgba(37, 37, 37, 0.045); border-radius: var(--r-full); }

.msg { display: grid; gap: 5px; max-width: 78%; animation: rise 320ms var(--ease-out) both; }
.msg__bubble {
  padding: 11px 15px; border-radius: 18px;
  font-size: 14.5px; line-height: 1.45; font-weight: 500;
}
.msg__meta { font-size: 11.5px; color: var(--text-3); }

.msg--in .msg__bubble { background: rgba(37, 37, 37, 0.055); border-bottom-left-radius: 6px; }
.msg--out { justify-self: end; }
.msg--out .msg__bubble {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: #fff; border-bottom-right-radius: 6px;
}
.msg--out .msg__meta { text-align: right; }

.chat__composer { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); }
.chat__composer input {
  flex: 1; height: 44px; padding: 0 16px;
  background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--r-full);
  font-size: 14.5px; font-weight: 500;
  transition: all var(--t-fast) var(--ease);
}
.chat__composer input:focus {
  outline: none; background: var(--surface); border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(88, 136, 71, 0.13);
}
.chat__send { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--green-600); color: #fff; flex: none; transition: all var(--t-fast) var(--ease); }
.chat__send:hover { background: var(--green-700); }
.chat__send:active { transform: scale(0.93); }
.chat__send svg { width: 19px; height: 19px; }

/* Индикатор непрочитанных */
.unread {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: var(--r-full); background: var(--green-vivid); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1;
}

/* ==========================================================================
   РОП и Админ: команда, отделы, статистика
   ========================================================================== */

/* Небольшой значок «Руководитель» поверх аватара в карточке команды */
.lead-dot {
  position: absolute; right: -2px; bottom: -2px;
  display: grid; place-items: center; width: 17px; height: 17px;
  border-radius: 50%; background: var(--green-vivid); color: #fff;
  box-shadow: 0 0 0 2px var(--surface);
}
.lead-dot svg { width: 10px; height: 10px; }
.avatar-wrap { position: relative; flex: none; }

/* Горизонтальное сравнение (менеджеры / отделы по объёму) */
.hbar-list { display: grid; gap: 15px; }
.hbar-row { display: grid; grid-template-columns: 200px 1fr 96px; align-items: center; gap: 14px; }
.hbar-row__label { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; font-weight: 600; }
.hbar-row__label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row__track { height: 10px; border-radius: var(--r-full); background: rgba(37, 37, 37, 0.06); overflow: hidden; }
.hbar-row__track i {
  display: block; height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--green-600), var(--green-400));
  transition: width 640ms var(--ease);
}
.hbar-row__value { text-align: right; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-row__value span { font-weight: 500; color: var(--text-3); font-size: 11.5px; }

/* Динамика: мини-график по неделям, реальные данные из заказов */
.trend__bars { display: flex; align-items: flex-end; gap: 9px; height: 104px; padding-top: 22px; }
.trend__bar { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.trend__bar i {
  display: block; width: 100%; max-width: 30px; margin: 0 auto; min-height: 3px;
  border-radius: 7px 7px 3px 3px; background: rgba(37, 37, 37, 0.09);
  transition: height 560ms var(--ease);
}
.trend__bar.is-peak i { background: linear-gradient(180deg, var(--green-500), var(--green-700)); }
.trend__bar b {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 700; color: var(--text-2); white-space: nowrap;
}
.trend__foot { display: flex; justify-content: space-between; margin-top: 9px; font-size: 11px; color: var(--text-3); }

/* Карточка отдела (Админ) */
.dep-card { padding: 22px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); display: grid; gap: 16px; min-width: 0; }
.dep-card__icon {
  display: grid; place-items: center; flex: none; width: 46px; height: 46px;
  border-radius: var(--r-md); background: var(--surface-tint); color: var(--green-700);
}
.dep-card__icon svg { width: 21px; height: 21px; }
.dep-card__members { display: grid; gap: 8px; min-width: 0; }

/* Строка сотрудника/клиента с действием справа. flex-wrap — если кнопка не
   помещается рядом с именем, она аккуратно переносится на вторую строку,
   а не вылезает за границы карточки. */
.dep-member {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 9px 11px; border-radius: var(--r-sm); background: var(--surface-sunken); min-width: 0;
}
.dep-member .flex-1 { flex: 1 1 120px; min-width: 0; }
.dep-member .name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-member .meta { font-size: 11.5px; color: var(--text-3); }
.dep-member .btn { flex: none; margin-left: auto; }

/* Компактный модал для действий переназначения */
.modal--sm { width: min(480px, 100%); }
.modal--sm .modal__body { padding: 22px 26px 6px; }

/* ==========================================================================
   РАБОЧИЙ КОНТУР: вход, приглашение, регистрация
   ========================================================================== */

/* Подсказка под формой входа — не ошибка и не акцент, просто спокойный блок. */
.login__help {
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
}
.login__help a { color: var(--green-600); font-weight: 600; }

/* Экран «готово»: заявка отправлена, приглашение принято. */
.empty-state { display: grid; justify-items: center; text-align: center; padding: 28px 0; }
.empty-state__icon {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green-600); color: #fff;
}
.empty-state__icon svg { width: 28px; height: 28px; }

/* Текстовый документ: политика обработки персональных данных. */
.doc-page { background: var(--bg); }
.doc {
  max-width: 720px; margin: 0 auto;
  padding: 48px 20px max(64px, env(safe-area-inset-bottom));
  line-height: 1.65;
}
.doc__back {
  display: inline-block; margin-bottom: 24px;
  font-size: 14px; font-weight: 600; color: var(--green-600);
}
.doc h2 {
  margin: 34px 0 10px;
  font-size: 19px; font-weight: 700; letter-spacing: -0.018em;
}
.doc p { margin: 10px 0; font-size: 15px; color: var(--text-2); }
.doc ul { margin: 10px 0 10px 20px; font-size: 15px; color: var(--text-2); }
.doc li { margin: 5px 0; }

/* Незаполненный реквизит. Красным и намеренно заметно: пока такие метки
   есть на странице, документ юридически не готов, и это должно быть видно
   без чтения исходника. */
.todo {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 600;
  padding: 1px 6px; border-radius: 6px;
  white-space: nowrap;
}

/* Одноразовая ссылка приглашения: её копируют и передают человеку вручную. */
.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field input {
  flex: 1 1 0; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

/* ==========================================================================
   РАБОЧИЙ КОНТУР: дорожная карта, параллельные дорожки, формы
   ========================================================================== */

/* Раздел, который выкладывает карточки вертикальной лентой. */
.view--stack > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
.view--stack > * + * { margin-top: 22px; }

/* --- Строка этапа дорожной карты --- */

.stage-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center; gap: 13px;
  /* Те же 22px, что у .step и .doc-row: .card в этой системе — голая
     поверхность, отступы несут компоненты внутри неё. */
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
}
.stage-row:last-child { border-bottom: none; }

.stage-row__num {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
  background: rgba(37, 37, 37, 0.05); color: var(--text-3);
  transition: all var(--t) var(--ease);
}
.stage-row__num svg { width: 14px; height: 14px; }
.stage-row__title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.014em; }
.stage-row__meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

.stage-row.is-done .stage-row__num { background: var(--green-600); color: #fff; }
.stage-row.is-done .stage-row__title { color: var(--text-2); }
.stage-row.is-current .stage-row__num { background: var(--green-vivid); color: #fff; box-shadow: 0 0 0 4px rgba(40, 201, 0, 0.16); }
.stage-row.is-current .stage-row__title { color: var(--green-800); font-weight: 700; }
.stage-row.is-todo { opacity: 0.62; }

/* Плановая или фактическая дата этапа. */
.plan-chip {
  flex: none;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(37, 37, 37, 0.05); color: var(--text-3);
  white-space: nowrap;
}
.plan-chip--ok { background: var(--ok-bg); color: var(--ok); }
.plan-chip--danger { background: var(--danger-bg); color: var(--danger); }

/* --- Параллельные дорожки --- */

/* Две колонки на десктопе — единственный честный способ показать, что
   этикетка и производство идут одновременно, а не одно за другим. */
.tracks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 4px 22px 16px;
}
.track {
  padding: 4px 16px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  min-width: 0;
}
.track.is-done { background: var(--surface-tint); border-color: var(--green-400); }
.track__head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3);
}
.track .stage-row { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; padding: 11px 0; }
.track .stage-row__num { width: 26px; height: 26px; font-size: 11.5px; }

.parallel-note {
  display: flex; align-items: center; gap: 9px;
  margin: 16px 22px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--green-600);
}
.parallel-note svg { width: 16px; height: 16px; flex: none; }

/* --- Чек-лист этапа --- */

.checklist { margin: 4px 0 0; padding: 0 22px; list-style: none; display: grid; gap: 8px; }
.checklist li {
  position: relative; padding-left: 24px;
  font-size: 14px; color: var(--text-2); line-height: 1.5;
}
.checklist li::before {
  content: ''; position: absolute; left: 6px; top: 8px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--green-400);
}

/* --- Карточка заказчика и заявки --- */

.company__main { min-width: 0; }
.company__title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.company__title b { font-size: 16px; font-weight: 700; letter-spacing: -0.018em; }
.company__meta { margin-top: 7px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.company__note {
  margin-top: 10px; padding: 10px 12px;
  border-radius: var(--r-sm); background: var(--surface-sunken);
  font-size: 13px; color: var(--text-2); line-height: 1.5;
  white-space: pre-line;
}
.company__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Вариант карточки-переключателя с настоящим input: подпись справа,
   а не под ним. Базовый .choice — это grid для кликабельной карточки без
   input внутри, и для галочки он не годится. */
.choice--check { display: flex; align-items: center; gap: 11px; }
.choice--check input { flex: none; width: 17px; height: 17px; accent-color: var(--green-600); }
.choice--check > span { min-width: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); }
.choice--check > .choice__text { display: grid; gap: 2px; }
.choice--check > .choice__text > b { font-size: 14.5px; font-weight: 700; }
.choice--check > .choice__text > span { font-size: 12.5px; color: var(--text-2); }
.choice--check a { color: var(--green-600); font-weight: 600; }

/* --- Уведомления --- */

/* Точка на колокольчике: заказчик заходит редко и должен сразу видеть,
   что по заказу что-то произошло. */
.btn.has-dot { position: relative; }
.btn.has-dot::after {
  content: ''; position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-vivid);
  box-shadow: 0 0 0 2px var(--surface);
}

.notif { padding: 14px 0; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: none; }
.notif__title { font-size: 14.5px; font-weight: 700; letter-spacing: -0.014em; }
.notif__text { margin-top: 4px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.notif__date { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }
.notif.is-new .notif__title { color: var(--green-700); }
.notif.is-new { border-left: 3px solid var(--green-400); padding-left: 12px; }

/* Шапка списка заказов, когда под вкладками есть ещё и фильтр
   руководителя. Базовая .orders__head — горизонтальная строка, и второй
   элемент в узкой колонке выдавливал вкладки в две строки. */
.orders__head--stack { flex-direction: column; align-items: stretch; gap: 12px; }
.orders__head--stack .segmented { width: 100%; }
.orders__head--stack .segmented button { flex: 1 1 0; padding: 0 8px; }

/* Свободное содержимое карточки — текст, графики, подписи — кладём в
   .card card--pad: модификатор уже есть в дизайн-системе. Компоненты вроде
   .section__head, .step и .doc-row несут свои 22px сами и в нём не нуждаются. */
.card--pad > h3 + p { margin-top: 4px; }
/* Карточка с заголовком-шапкой: у шапки свои отступы, дублировать не надо. */
.card--pad .section__head, .card--pad .route__head { padding-left: 0; padding-right: 0; padding-top: 0; }

/* Свободная строка внутри карточки — подпись, пояснение, ряд кнопок.
   Повторяет боковые отступы .section__head, включая мобильные: .card в этой
   системе голая поверхность, отступы несут компоненты внутри. */
.card-line { padding: 0 22px 20px; }

/* Ряд кнопок, который переносится, а не уезжает за край. */
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Позиция заказа в форме --- */

.item-row {
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.item-row__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
/* minmax(0, 1fr), а не 1fr: иначе длинное название продукта растягивает дорожку
   и форма уезжает по горизонтали на телефоне. */
.item-row__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Подпись под числом в плитке статистики. */
.stat__delta.is-up { color: var(--ok); }
.stat__delta.is-down { color: var(--danger); }

/* ==========================================================================
   АДАПТИВ

   Три уровня:
     ≤1180px — узкий десктоп и планшет в альбомной ориентации;
     ≤1023px — планшет: боковое меню превращается в выдвижную панель;
     ≤767px  — телефон: одноколоночные экраны, таблицы-карточки,
               модальные окна снизу, вертикальный таймлайн.
   ========================================================================== */

/* --- Узкий десктоп ----------------------------------------------------- */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 340px 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .fact:nth-child(2) { border-right: none; }
  .fact:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   ≤1023px — планшет: боковое меню становится выдвижной панелью
   ========================================================================== */

@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }

  /* Панель выезжает слева поверх содержимого */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw); height: 100dvh;
    z-index: 320;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    box-shadow: 0 24px 60px -12px rgba(37, 37, 37, 0.28);
    transform: translateX(-100%);
    transition: transform 320ms var(--ease);
    overflow-y: auto;
    will-change: transform;
  }
  .app.is-drawer-open .sidebar { transform: none; }

  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 310;
    background: rgba(22, 30, 18, 0.38);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none;
    transition: opacity 320ms var(--ease);
  }
  .app.is-drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  .topbar__burger { display: grid; place-items: center; flex: none; }

  /* Поиск переносится на вторую строку шапки и занимает всю ширину */
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 18px; row-gap: 10px; }
  .topbar > h1 { font-size: 19px; }
  .search { order: 10; width: 100%; }

  .view { padding: 26px 24px 48px; }
  .detail { padding: 22px 20px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }

  /* Доска серий и диаграмма загрузки прокручиваются по горизонтали */
  .board {
    grid-template-columns: none;
    grid-auto-flow: column; grid-auto-columns: 250px;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
  }
  .board__col { scroll-snap-align: start; }

  .gantt { overflow-x: auto; overscroll-behavior-x: contain; }
  .gantt__row { min-width: 780px; }
  .gantt__side { position: sticky; left: 0; z-index: 4; background: var(--surface); }
  .gantt__row--head .gantt__side { background: var(--surface-sunken); }

  /* Экран входа: на две колонки места уже нет — остаётся только форма */
  .login { grid-template-columns: 1fr; }
  .login__brand { display: none; }

  /* Клиентский таймлайн: 7 шагов в строку не помещаются — переносим в две */
  .timeline { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 24px; }
  .tl:nth-child(4)::before { display: none; }
}

/* ==========================================================================
   ≤767px — телефон
   ========================================================================== */

@media (max-width: 767px) {

  /* --- Базовое ----------------------------------------------------------- */

  body { font-size: 15px; }

  /* Убираем серую вспышку при нажатии и задержку 300 мс */
  a, button, .order-card, .p-card, .choice, .company, .bcard, [data-goto], [data-id] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* На тач-экране нет курсора — hover-эффекты только мешают */
  .order-card:hover, .p-card:hover, .company:hover, .choice:hover,
  .login__account:hover, .gantt__bar:hover {
    transform: none; box-shadow: var(--shadow-1);
  }
  .table tbody tr:hover { background: transparent; }

  .t-display { font-size: 34px; }
  .t-title1 { font-size: 24px; }
  .t-title2 { font-size: 19px; }

  /* --- Шапка и рабочая область ------------------------------------------- */

  .topbar {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
  }
  /* Заголовок ужимается многоточием, чтобы кнопки остались в одной строке.
     Именно flex-basis: 0 — при flex-wrap элементы переносятся на новую строку
     раньше, чем начинают сжиматься, и с basis:auto кнопка уезжала бы вниз. */
  .topbar > h1 {
    font-size: 18px; letter-spacing: -0.02em;
    flex: 1 1 0; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar .live, .topbar__spacer { display: none; }
  .topbar .btn--primary, .topbar .btn--secondary {
    height: 38px; padding: 0 13px; font-size: 13px; flex: none;
  }

  .view { padding: 18px 14px 40px; }
  .view__inner { gap: 16px; }
  .view__head { flex-direction: column; align-items: stretch; gap: 12px; }
  .view__head .btn { align-self: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* .board намеренно не трогаем — он остаётся лентой с горизонтальной прокруткой */
  .companies, .portal__grid { grid-template-columns: minmax(0, 1fr); }

  /* Переключатели периодов/фильтров прокручиваются, а не ломают вёрстку */
  .segmented {
    display: flex; width: 100%; overflow-x: auto;
    overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex: none; }

  /* --- Мастер-деталь: список и карточка как два экрана -------------------- */

  .workspace { grid-template-columns: 1fr; position: relative; }

  .orders { border-right: none; }
  .orders__head { padding: 14px 14px 10px; }
  .orders__list { padding: 0 14px 24px; }

  /* Показываем ровно один экран: список либо карточку заказа */
  .workspace[data-pane='list'] .detail { display: none; }
  .workspace[data-pane='detail'] .orders { display: none; }
  .workspace[data-pane='detail'] .detail { animation: pane-in 280ms var(--ease-out) both; }

  .detail { padding: 0 0 32px; }
  .detail__inner { gap: 14px; padding: 0 14px; }

  /* Полоса «Назад» поверх карточки заказа */
  .detail__back {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 15;
    margin: 0 -14px 4px; padding: 10px 14px;
    background: rgba(246, 247, 244, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    font-size: 14.5px; font-weight: 600; color: var(--green-700);
    width: calc(100% + 28px);
  }
  .detail__back svg { width: 18px; height: 18px; }

  .detail__title h1 { font-size: 23px; }
  .detail__crumbs { flex-wrap: wrap; gap: 7px; }

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

  .facts { grid-template-columns: repeat(2, 1fr); }
  .fact { padding: 13px 14px; }
  .fact dd { font-size: 14.5px; }

  .stage-panel { padding: 20px 18px; border-radius: var(--r-lg); }
  .stage-panel__row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .stage-panel__now h2 { font-size: 22px; }
  .stage-panel__row .t-display { font-size: 34px !important; }
  .stage-panel__actions { flex-direction: column; }
  .stage-panel__actions .btn { width: 100%; }
  .mirror { align-items: flex-start; font-size: 12.5px; }

  .route__head { flex-wrap: wrap; padding: 16px 16px 4px; }
  .step { grid-template-columns: 28px 1fr; padding: 10px 16px; row-gap: 2px; }
  .step__date { grid-column: 2; font-size: 12px; }
  .route__group { padding: 14px 16px 4px; }

  .section__head { padding: 16px 16px 10px; flex-wrap: wrap; }
  .card-line { padding: 0 16px 16px; }
  .doc-row { padding: 12px 16px; }

  /* --- Таблицы превращаются в карточки ----------------------------------- */

  .table-card { background: transparent; box-shadow: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--surface); border-radius: var(--r-md);
    box-shadow: var(--shadow-1); padding: 14px 16px; margin-bottom: 10px;
  }
  .table td { padding: 0; border: none; font-size: 13.5px; }
  /* Первая ячейка — заголовок карточки */
  .table td:first-child {
    font-size: 15.5px; font-weight: 700; letter-spacing: -0.016em;
    padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
  }
  /* Остальные — пара «подпись → значение».
     flex-wrap: длинное значение переносится под подпись, а не рвёт карточку. */
  .table td:not(:first-child) {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 4px 14px; min-height: 30px; text-align: right;
  }
  .table td:not(:first-child)::before {
    content: attr(data-label);
    flex: none; font-size: 12px; font-weight: 600; color: var(--text-3);
  }
  /* Ячейка с многострочным содержимым: подпись сверху, текст под ней */
  .table td.td--block:not(:first-child) { display: block; padding: 4px 0; }
  .table td.td--block:not(:first-child)::before { display: block; margin-bottom: 4px; }
  .table td:empty { display: none; }

  /* --- Контроль качества --------------------------------------------------- */

  .qc { grid-template-columns: 40px 1fr; gap: 12px; padding: 16px; align-items: start; }
  .qc > div:last-child { grid-column: 1 / -1; text-align: left !important; justify-items: stretch !important; }
  .qc > div:last-child .btn { width: 100%; }
  .qc__icon { width: 40px; height: 40px; }

  /* --- Справочники и статистика -------------------------------------------- */

  .companies { grid-template-columns: 1fr; }
  .company, .dep-card { padding: 18px; }
  .company__nums { gap: 6px; }
  .company__nums div b { font-size: 15px; }

  .formulation__head { flex-wrap: wrap; padding: 16px; }
  .bom-total { padding: 14px 16px; align-items: flex-start; }

  .split-2 { grid-template-columns: 1fr; }

  /* Сравнение по сотрудникам: подпись и значение сверху, полоса под ними */
  .hbar-row { grid-template-columns: 1fr auto; row-gap: 8px; column-gap: 12px; }
  .hbar-row__track { grid-column: 1 / -1; grid-row: 2; }

  .trend__bars { gap: 6px; height: 92px; }
  .trend__bar b { font-size: 10px; }

  /* --- Модальные окна как «шторка» снизу ---------------------------------- */

  .backdrop { padding: 0; place-items: end stretch; }

  .modal, .modal--sm {
    width: 100%; max-height: 92dvh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    animation: sheet-in 340ms var(--ease-out) both;
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* Полоска-«ручка», как в системных шторках iOS */
  .modal::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: var(--r-full);
    background: rgba(37, 37, 37, 0.18); z-index: 2;
  }
  .modal__head { padding: 22px 20px 16px; }
  .modal__body, .modal--sm .modal__body { padding: 20px; }
  .modal__foot { padding: 14px 20px; flex-wrap: wrap; }
  .modal__foot .btn { flex: 1 1 auto; justify-content: center; }

  /* Развёрнутый степпер не нужен — шаг назван в подзаголовке окна */
  .wsteps { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .summary__row { flex-direction: column; gap: 3px; }
  .summary__row dt { width: auto; }

  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* --- Чат ---------------------------------------------------------------- */

  .chat__feed { padding: 16px 14px; max-height: 60dvh; }
  .msg { max-width: 88%; }
  .chat__composer { padding: 12px 14px; }
  /* Номер заказа уходит на свою строку — иначе имя менеджера сжимается в столбик */
  .chat__peer { padding: 14px; gap: 10px; }
  .chat__peer .chip { order: 3; flex: 1 1 100%; justify-content: flex-start; }
  /* 16px — минимум, при котором Safari не зумит страницу при фокусе */
  .chat__composer input, .input, .search input { font-size: 16px; }

  /* --- Уведомления -------------------------------------------------------- */

  .toasts {
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    justify-items: stretch;
  }
  .toast { min-width: 0; max-width: none; }

  /* --- Экран входа --------------------------------------------------------- */

  .login__form { padding: 28px 20px max(28px, env(safe-area-inset-bottom)); align-items: start; }
  .login__inner { max-width: none; }

  /* --- Личный кабинет клиента ---------------------------------------------- */

  .portal__bar {
    height: 60px; padding: 0 14px;
    padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top));
    gap: 10px;
  }
  .portal__bar img { height: 22px; }
  /* Логотип уже говорит, где мы находимся — подпись и разделитель лишние */
  .portal__bar .sep, .portal__bar .live, .portal__bar > .t-headline { display: none; }
  /* Имя и компанию прячем — остаётся аватар, этого достаточно */
  .portal__bar > div:last-of-type > div { display: none; }

  .portal__wrap { padding: 22px 14px 60px; }
  .portal__hello { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 20px; }
  .portal__hello h1 { font-size: 26px; }
  .portal__hello p { font-size: 15px; }
  .portal__hello .btn { align-self: flex-start; }
  .portal__section { margin-top: 32px; }
  .portal__grid { grid-template-columns: 1fr; }

  .hero { padding: 24px 20px; border-radius: var(--r-xl); }
  .hero__top { flex-direction: column; align-items: flex-start; gap: 18px; }
  .hero__title { font-size: 25px; }
  .hero__sub { font-size: 14px; }
  .ring, .ring svg { width: 96px; height: 96px; }
  .ring__label b { font-size: 23px; }

  /* Таймлайн вертикальный: 7 этапов в строку на телефоне нечитаемы */
  .timeline { grid-template-columns: 1fr; margin-top: 26px; padding-top: 22px; }
  .tl {
    display: grid; grid-template-columns: 26px 1fr;
    column-gap: 14px; padding: 0 0 18px;
  }
  .tl:last-child { padding-bottom: 0; }
  .tl__dot { grid-column: 1; grid-row: 1 / span 2; }
  .tl__title { grid-column: 2; grid-row: 1; margin-top: 3px; min-height: 0; }
  .tl__date { grid-column: 2; grid-row: 2; margin-top: 1px; }
  /* Соединительная линия идёт сверху вниз через центр точки */
  .tl:not(:last-child)::before {
    left: 12px; right: auto; top: 30px; bottom: 4px;
    width: 2px; height: auto;
  }

  .hero__foot { flex-direction: column; align-items: flex-start; gap: 16px; margin-top: 24px; }
  .hero__foot > div[style*="width:1px"] { display: none; }
  .hero__stat { text-align: left !important; }
}

/* Совсем узкие экраны — 320–340 px. На 375 px (iPhone SE/13 mini)
   две колонки ещё читаются, поэтому порог намеренно ниже. */
@media (max-width: 340px) {
  .stats { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .fact { border-right: none; border-bottom: 1px solid var(--line); }
  .fact:last-child { border-bottom: none; }
}

/* --- Крупные тач-цели на устройствах без мыши -------------------------- */

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn--sm { min-height: 38px; }
  .btn--icon { width: 44px; height: 44px; }
  .nav a { height: 46px; }
  .segmented button { height: 38px; }
  .table tr[data-goto] { cursor: default; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
