/* CRM «11 роз». Один файл стилей, всё своё: шрифт Golos Text (OFL) из static/crm/fonts, иконки — спрайт в base.html.
   Каркас: ≥ 1280 px — боковое меню 232 px; 768–1279 px — узкое меню 84 px (иконка и подпись под ней);
   < 768 px — шапка и нижняя панель вкладок.
   Цвета — только токены из :root; тёмная тема — те же токены под prefers-color-scheme: dark.
   CSP запрещает инлайн-стили: высоты столбцов графика — классами .h-0….h-100 (в конце файла). */

/* --- Шрифт ------------------------------------------------------------------------------------ */
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/golos-text-cyrillic.2b8fbbb33a14.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/golos-text-latin.f57df9832ab8.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Токены: светлая тема ------------------------------------------------------------------------ */
:root {
  color-scheme: light dark;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F1F3F6;
  --surface-3: #E7EAEF;
  --line: #E3E6EB;
  --line-strong: #C9CED6;     /* декоративные рамки: кнопки, пунктир пустых блоков */
  --field-border: #858C99;    /* рамка поля ввода: 3,4:1 к фону (WCAG 1.4.11 — поле видно и на плохом экране) */
  --text: #16181D;
  --muted: #5F6673;
  --placeholder: #6E7582;

  /* Роза — только бренд «11 роз»: словесный знак, бейдж, главная кнопка, серия графика. Проблемы — --danger. */
  --accent: #B8143F;
  --accent-soft: #FCE8EE;
  --accent-strong: #8E0F31;
  --accent-text: #8E0F31;     /* текст на мягком фоне акцента */
  --primary: #B8143F;         /* фон главной кнопки */
  --primary-hover: #8E0F31;
  --primary-shadow: 0 1px 2px rgba(142, 15, 49, .25);
  --primary-kbd: rgba(0, 0, 0, .18);
  --on-primary: #FFFFFF;
  --link: #B8143F;
  --ring: rgba(184, 20, 63, .30);
  --bar: #5F6673;             /* нейтральные полоски: источники, «день идёт» — не бренд и не проблема */

  --cd: #2F6FDB;              /* ЦД — синий */
  --cd-soft: #E8F0FD;
  --cd-text: #2257B8;
  --ok: #1A7F4B;
  --ok-soft: #E3F4EA;
  --ok-text: #15693E;
  --warn: #A15C00;
  --warn-soft: #FFF1D6;
  --warn-text: #8A5300;
  --warn-bar: #B06F00;        /* полоса «скоро собрать», жёлтая полоска: 4,1:1 к фону, 3,4:1 к дорожке */
  --warn-stripe: rgba(161, 92, 0, .07);
  --warn-code: rgba(161, 92, 0, .12);
  --danger: #C62828;
  --danger-soft: #FDECEC;
  --danger-text: #A12020;
  --on-danger: #FFFFFF;
  /* Место адреса (Эжва, Выльгорт…): метка у поля «Адрес», у курьера и диспетчера. Бирюзовый — не бренд и не проблема. */
  --place-soft: #DDF2EF;
  --place-text: #0A5E5A;      /* 6,5:1 к --place-soft (в тёмной теме 8,4:1) */
  /* Заказ из чата: поле, подставленное из переписки, — фиолетовый (не бренд, не проблема, не место). */
  --prefill-soft: #F1ECFD;
  --prefill-line: #7A5AD8;    /* рамка поля: 4,9:1 к --surface (в тёмной теме 5,7:1) */
  --prefill-text: #5B3DB5;    /* 6,5:1 к --prefill-soft (в тёмной теме 8:1) */

  /* Статусы заказа: цвет точки в чипе */
  --st-new: #6B7A99;
  --st-paid: #2F6FDB;
  --st-assembling: #B77700;
  --st-assembled: #7B4FD6;
  --st-courier: #0B8585;
  --st-done: #1A7F4B;
  --st-cancelled: #C62828;

  /* График: бренды и норма (проверено валидатором палитры: CVD и контраст к поверхности) */
  --chart-r11: #B8143F;
  --chart-cd: #2F6FDB;
  --chart-pc: #8A919E;
  --chart-norm: #16181D;
  --chart-hover: rgba(22, 24, 29, .04);

  --shadow-xs: 0 1px 1px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, .08), 0 16px 40px rgba(16, 24, 40, .16);
  --seg-shadow: 0 1px 2px rgba(16, 24, 40, .10), 0 0 0 1px rgba(16, 24, 40, .06);
  --sheet-shadow: 0 -4px 16px rgba(16, 24, 40, .08);
  --scrim: rgba(10, 12, 16, .32);

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F6673' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");

  --radius-sm: 8px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --sidebar-w: 232px;
  --tabbar-h: 60px;
  --gutter: 32px;
}

/* --- Токены: тёмная тема ------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1115;
    --surface: #171A20;
    --surface-2: #1E222A;
    --surface-3: #262B35;
    --line: #2A2F39;
    --line-strong: #3A404C;
    --field-border: #687080;
    --text: #E8EAEE;
    --muted: #9AA3B2;
    --placeholder: #7E8796;

    --accent: #FF5C84;
    --accent-soft: #3B1824;
    --accent-strong: #FF7A9A;
    --accent-text: #FF8FAB;
    --primary: #C92A56;
    --primary-hover: #B0224A;
    --on-primary: #FFFFFF;
    --link: #FF7A9A;
    --ring: rgba(255, 92, 132, .40);
    --primary-shadow: none;
    --bar: #9AA3B2;

    --cd: #6B9BFF;
    --cd-soft: #172338;
    --cd-text: #7DA7FF;
    --ok: #4ACB8A;
    --ok-soft: #13291E;
    --ok-text: #4ACB8A;
    --warn: #F2B04A;
    --warn-soft: #2E2310;
    --warn-text: #F2B04A;
    --warn-bar: #E9A93A;
    --warn-stripe: rgba(242, 176, 74, .06);
    --warn-code: rgba(242, 176, 74, .14);
    --danger: #FF7B7B;
    --danger-soft: #3A1818;
    --danger-text: #FF8A8A;
    --on-danger: #2A0A0A;
    --place-soft: #0F2A29;
    --place-text: #5ED3C9;
    --prefill-soft: #221A38;
    --prefill-line: #9B82F2;
    --prefill-text: #BBA8FF;

    --st-new: #8C9AB8;
    --st-paid: #6B9BFF;
    --st-assembling: #E9A93A;
    --st-assembled: #A68BFA;
    --st-courier: #2EC4C4;
    --st-done: #4ACB8A;
    --st-cancelled: #FF7B7B;

    --chart-r11: #E8456F;
    --chart-cd: #4F84E8;
    --chart-pc: #6B7280;
    --chart-norm: #E8EAEE;
    --chart-hover: rgba(232, 234, 238, .05);

    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 44px rgba(0, 0, 0, .55);
    --seg-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
    --sheet-shadow: 0 -4px 16px rgba(0, 0, 0, .45);
    --scrim: rgba(0, 0, 0, .5);

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA3B2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  }
}

/* --- Основа --------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { color: var(--text); }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -.015em; margin: 0 0 12px; }
h2 { font-size: 15px; line-height: 1.35; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; line-height: 1.35; font-weight: 600; color: var(--muted); margin: 16px 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--link); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
small, .hint { color: var(--muted); font-size: 13px; }
p.hint { margin: 6px 0 10px; }
b, strong { font-weight: 600; }
code { font: 500 .9em/1 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); padding: 2px 5px; border-radius: 5px; }
ul, ol { padding-left: 1.2rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }
.num, td.num, .tnum { font-variant-numeric: tabular-nums; }
.muted, .meta { color: var(--muted); }
.neg { color: var(--danger-text); font-weight: 600; }
.nowrap { white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }

.skip-link { position: absolute; left: 12px; top: 12px; z-index: 100; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.skip-link:not(:focus) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); box-shadow: none; }

/* Кнопка «Найти клиента» нужна только без JS; выбор интервала цифрой — только с JS. */
.js .nojs-only { display: none; }
html:not(.js) .js-only { display: none; }

/* --- Каркас: боковое меню, колонка контента --------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; z-index: 20; scrollbar-width: thin;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 16px 12px 12px max(12px, env(safe-area-inset-left));  /* iPhone боком: меню не под «чёлкой» */
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.wordmark {
  display: flex; align-items: center;
  min-height: 40px; padding: 0 10px; margin: 0 0 14px;
  color: var(--accent); font-size: 21px; font-weight: 700; letter-spacing: -.03em; line-height: 1;
  text-decoration: none;
}
.wordmark:hover { text-decoration: none; }
.wordmark-rose { flex: none; width: 22px; height: 22px; margin-right: 6px; }  /* роза из значка вкладки; высоту шапки не меняет */
.brand-short { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 38px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted);
  font: 500 14px/1.2 var(--font); text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot form { margin: 0; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 10px 8px; }
.avatar {
  flex: none; display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 13px; color: var(--muted); }
/* Имя в меню — ссылка на «Вход и пароль» */
.me-link { color: inherit; border-radius: var(--radius-sm); }
.me-link:hover { background: var(--surface-2); text-decoration: none; }
.me-link[aria-current="page"] { background: var(--accent-soft); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px max(var(--gutter), env(safe-area-inset-right)) 56px var(--gutter); }
.main:focus, .auth-main:focus { outline: none; }
.mobile-bar, .tabbar { display: none; }

/* Счётчики в меню: опаздывают / напоминания */
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-3); color: var(--text);
  font-size: 12px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.count.danger { background: var(--danger); color: var(--on-danger); }
.count.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; background: var(--danger); }

/* Плашка «ЕСТЬ ТЕСТОВЫЕ ДАННЫЕ»: спокойная, но заметная полоса предупреждения */
.test-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  padding: 9px var(--gutter);
  background: var(--warn-soft);
  background-image: repeating-linear-gradient(135deg, transparent 0 14px, var(--warn-stripe) 14px 28px);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn-text); font-size: 13px;
}
.test-banner b { letter-spacing: .06em; font-weight: 700; }
.test-banner .icon { width: 18px; height: 18px; }
.test-banner code { background: var(--warn-code); color: inherit; }

/* --- Заголовок страницы ------------------------------------------------------------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin: 0 0 20px; }
.page-head h1 { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.page-head h1 small { font-size: 15px; font-weight: 500; }
.page-title { min-width: 0; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.page-sub .badge { vertical-align: 1px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back-link .icon { width: 16px; height: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Меню кнопкой (<details class="menu">): «Печать» в карточке заказа, на сборке, доставке, в заказах.
   Щелчок мимо закрывает: прозрачная подложка summary::before на весь экран (как у меню аватара). */
.menu { position: relative; }
.menu[open] { z-index: 22; }  /* выше «липкой» шапки таблицы (2) и бокового меню (20), ниже плашек и шапки телефона */
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 1; cursor: default; }
.menu[open] > summary { background: var(--surface-2); }
.menu-sheet {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 2;
  display: flex; flex-direction: column; gap: 2px; width: max-content; min-width: 220px; max-width: min(320px, calc(100vw - 2 * var(--gutter)));
  padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-lg);
  animation: sheet-in .16s ease-out;
}
.menu-item {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  min-height: 40px; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.25; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; }
.menu-item small { color: var(--muted); font-size: 12px; font-weight: 400; }

/* «Нет связи с сервером» (автообновление, refresh.js): страница осталась прежней — видно, на какое время данные. */
.offline-banner {
  position: sticky; top: 0; z-index: 24;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  padding: 9px var(--gutter);
  background: var(--danger-soft); color: var(--danger-text);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  font-size: 14px;
}
.offline-banner > .icon { color: var(--danger); }
.offline-text { flex: 1 1 260px; display: flex; flex-direction: column; min-width: 0; }
.offline-more { font-size: 13px; }
/* «Нет связи: не отправлено» (app.js, floor.js): курьер или флорист нажал кнопку без связи — форма не ушла, страница та же. */
.net-banner {
  position: sticky; top: 0; z-index: 24;
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--gutter);
  background: var(--danger-soft); color: var(--danger-text);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  font-size: 15px;
}
.net-banner > .icon { flex: none; color: var(--danger); }
@media (max-width: 767px) { .net-banner { top: 52px; padding: 8px var(--gutter); } }  /* под шапкой телефона */
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 24px 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.section-title:first-child { margin-top: 0; }
.section-title .count { text-transform: none; letter-spacing: 0; }

/* --- Сообщения и ошибки ------------------------------------------------------------------------------------- */
.toasts { display: flex; flex-direction: column; gap: 8px; margin: 0 0 20px; }
.toast, .msg, .callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin: 0 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.toast { margin: 0; box-shadow: var(--shadow-md); animation: toast-in .2s ease-out; }
.toast > .icon { margin-top: 1px; color: var(--cd); }
.toast-text { flex: 1; min-width: 0; padding-top: 1px; }
.toast-close { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; margin: -4px -6px -4px 0; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-close .icon { width: 16px; height: 16px; }
.toast.success { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.toast.success > .icon { color: var(--ok); }
.toast.warning { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.toast.warning > .icon { color: var(--warn); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.toast.error > .icon { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* «Требует внимания»: накопленное (без чека за 30 дней, ссылка на «Контроль») — приглушённо под красными. */
.attention .attention-muted { margin-top: 8px; font-size: 13px; opacity: .85; }
.attention .attention-muted a, .attention-control a { color: var(--muted); font-weight: 500; }
.attention-control { margin: 0 0 16px; font-size: 14px; }

/* Скидка флориста больше лимита (app.js floristLimit): красная рамка у поля. */
#discount-box.over-limit input { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.hint.neg { color: var(--danger-text); }

/* Плашка «Выход через N мин — Остаться» (app.js): внизу экрана, над нижней панелью телефона. */
.session-bar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); font-size: 14px;
}
.session-text { flex: 1 1 220px; }
@media (max-width: 767px) { .with-shell .session-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); } }

/* .msg — сообщение внутри страницы (не тост): мягкий цветной фон */
.msg { display: block; box-shadow: none; }
.msg.info { background: var(--cd-soft); border-color: transparent; color: var(--text); }
.msg.success { background: var(--ok-soft); border-color: transparent; }
.msg.warning { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.msg.error { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.msg a { font-weight: 500; }
.callout > .icon { margin-top: 1px; }
.callout.danger { background: var(--danger-soft); border-color: transparent; }
.callout.danger > .icon { color: var(--danger); }
.callout.warning { background: var(--warn-soft); border-color: transparent; }
.callout.warning > .icon { color: var(--warn); }
.callout h2 { margin: 0 0 6px; }
.callout ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.callout-body { flex: 1; min-width: 0; }

.errors, .errorlist { color: var(--danger-text); }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; font-weight: 500; }
.errors { background: var(--danger-soft); padding: 12px 14px; border-radius: var(--radius-md); margin: 0 0 16px; color: var(--text); }
.errors > b:first-child { color: var(--danger-text); }
.errors ul { margin: 6px 0 0; padding-left: 1.1rem; }
.errors a { color: var(--danger-text); font-weight: 500; }
/* Форма заказа не сохранена: список ошибок в порядке полей, ссылка ставит курсор в поле */
.callout.form-errors { margin: 0 0 16px; }
.form-errors h2 { margin: 0 0 2px; color: var(--danger-text); }
.form-errors p { margin: 0 0 4px; }
.callout.form-errors ul { display: block; list-style: disc; padding-left: 1.1rem; }
.form-errors li + li { margin-top: 2px; }
.form-errors a { color: var(--danger-text); font-weight: 600; text-decoration: underline; }
/* Подсказка «Что здесь делать» (N32, crm/includes/hint.html): спокойная полоса над экраном, сворачивается по заголовку. */
.page-hint { margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--bar); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.page-hint > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; font-weight: 600; }
.page-hint > summary::-webkit-details-marker { display: none; }
.page-hint > summary .icon { color: var(--muted); }
.page-hint-list { margin: 6px 0 0; padding-left: 1.1rem; }
.page-hint-list li + li { margin-top: 4px; }
.page-hint-off { margin-top: 6px; }

/* --- Карточки и сетки ------------------------------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
fieldset.card { min-width: 0; }
fieldset.card > legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font-size: 15px; font-weight: 600; }
fieldset.card > legend ~ * { clear: both; }
.card > h2:first-child { margin-top: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 14px; }
.card-header h2 { margin: 0; }
.card-header .hint { font-size: 13px; }
.narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 0 0 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.big { font-size: 17px; }

/* Список «термин — значение» */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0 0 8px; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dl.sums { max-width: 340px; margin: 14px 0 0 auto; gap: 6px 20px; }
.dl.sums dd { text-align: right; font-variant-numeric: tabular-nums; }
.dl.sums dt:last-of-type, .dl.sums dd:last-of-type { padding-top: 8px; border-top: 1px solid var(--line); font-size: 16px; color: var(--text); }

/* --- Кнопки ---------------------------------------------------------------------------------------------------- */
.btn {
  --btn-h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 500 14px/1.2 var(--font); text-align: center; text-decoration: none;
  cursor: pointer; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .icon { width: 18px; height: 18px; margin-left: -3px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--primary-shadow); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { --btn-h: 32px; padding: 4px 10px; font-size: 13px; border-radius: var(--radius-sm); gap: 6px; }
.btn.small .icon { width: 16px; height: 16px; }
.btn.big { --btn-h: 52px; font-size: 16px; border-radius: var(--radius-md); }
.btn.wide { width: 100%; }
.btn[disabled], .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.primary[disabled]:hover { background: var(--primary); }
.btn[disabled]:hover { background: var(--surface); }
/* Форма отправлена, ждём ответа (submit_lock.js): кнопки выключены — курсор «ждём», а не «нельзя». */
form[aria-busy="true"] .btn:disabled { cursor: progress; }
.btn kbd { margin-left: 2px; }
.btn.primary kbd { background: var(--primary-kbd); border-color: transparent; color: inherit; }
/* Выбор фото одной кнопкой: сам <input type=file> скрыт внутри подписи (не display:none — остаётся в Tab). */
.file-btn { position: relative; }
.file-btn input[type=file] { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-btn.is-busy { opacity: .7; pointer-events: none; }
/* Фото одной кнопкой не ушло (нет связи, app.js): «Загрузить фото» — отправить то же фото ещё раз, без новой съёмки. */
.js .photo-auto.photo-retry .nojs-only { display: inline-flex; }
button.link { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { text-decoration: underline; }
form.inline { display: inline; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted);
  font: 500 12px/1 var(--font); white-space: nowrap; vertical-align: 1px;
}
.kbd-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.kbd-legend span { display: inline-flex; align-items: center; gap: 4px; }

/* --- Поля формы ------------------------------------------------------------------------------------------------- */
input[type=text], input[type=search], input[type=number], input[type=date], input[type=time], input[type=tel],
input[type=datetime-local], input[type=password], input[type=email], input[type=url], input:not([type]), select,
textarea {
  font: 400 15px/1.35 var(--font);
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 8px 12px;
  max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
/* Фокус поля: рамка 2 px акцента + мягкое кольцо — видно и без цвета (§10.2 «фокус всегда виден»). */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=date], input[type=time], input[type=datetime-local] { font-variant-numeric: tabular-nums; }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-2); color: var(--muted); cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 1px var(--danger), 0 0 0 4px color-mix(in srgb, var(--danger) 30%, transparent); }
textarea { width: 100%; min-height: 84px; resize: vertical; line-height: 1.45; }
select { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; cursor: pointer; }
select[multiple] { background-image: none; padding-right: 12px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer; }
input[type=file] { font: 400 14px/1.3 var(--font); color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  margin-right: 10px; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--font); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; margin: 0 0 14px; min-width: 0; }
.field > label, .field legend, .field-label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field > .helptext { order: 2; margin-top: 5px; }
.field > .errorlist { order: 3; }
.field > .hint { order: 4; margin-top: 5px; }
.field > input:not([type=checkbox]):not([type=radio]), .field > select, .field > textarea, .field .combo input { width: 100%; }
.helptext { font-size: 13px; color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 12px; }
.field-row > .btn { margin-top: 25px; }
.field-row > .field { flex: 1 1 150px; }
.field-row > .grow { flex: 2 1 220px; }
.field-row.top { align-items: flex-start; gap: 0 28px; }
.field-row > .radios { flex: 0 1 auto; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; min-height: 24px; }
.check label { color: var(--text); font-size: 15px; margin: 0; cursor: pointer; }
.checks ul, .checks div[id] { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.quick .btn { font-variant-numeric: tabular-nums; }

/* Строка фильтров/полей: подпись над полем */
.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 0; }
.row-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
.row-form label.check { flex-direction: row; align-items: center; color: var(--text); font-weight: 400; margin: 0; }
.row-form .btn { align-self: flex-end; }

/* Радиокнопки (бренд, тип заказа) — сегментированный переключатель. Django выводит ошибку поля над вариантами —
   порядок меняем, как у остальных полей: подпись → варианты → ошибка; при ошибке рамка переключателя красная. */
.radios fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.radios fieldset > .helptext { order: 2; margin-top: 5px; }
.radios fieldset > .errorlist { order: 3; }
.radios legend { padding: 0; }
.radios fieldset > div, .radios div[id] { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.radios div[id] label { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 14px; font-weight: 400; }
@supports selector(:has(*)) {
  .radios div[id] { display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
  .radios:has(.errorlist) div[id] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
  .radios div[id] > div { display: flex; }
  .radios div[id] label {
    position: relative; min-height: 34px; padding: 0 16px; border-radius: 7px;
    color: var(--muted); font-weight: 500; cursor: pointer;
    transition: background-color .12s, color .12s, box-shadow .12s;
  }
  .radios div[id] label:hover { color: var(--text); }
  .radios div[id] input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  .radios div[id] label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--seg-shadow); }
  .radios div[id] label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
  .radios div[id] label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
}

/* --- Сегментированные вкладки (Сегодня / Завтра / …) --------------------------------------------------------------- */
.tabs {
  display: inline-flex; gap: 2px; max-width: 100%; margin: 0 0 16px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 7px;
  color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, color .12s;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active, .tabs a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--seg-shadow); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.toolbar .tabs { margin: 0; }

/* Панель фильтров */
.filters { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.filters .row-form input, .filters .row-form select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
.filters .row-form .btn { --btn-h: 36px; }
.filters .msg { margin: 0; }
.filters-sep { height: 1px; background: var(--line); margin: 0 -16px; }

/* --- Показатели вверху списков (счётчики) --------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 20px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm);
}
a.stat { transition: border-color .12s, box-shadow .12s; }
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.stat.danger .stat-value, .stat.danger .stat-label { color: var(--danger-text); }
.stat.warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.stat.warning .stat-value, .stat.warning .stat-label { color: var(--warn-text); }

/* --- Чипы: статус заказа, бренд, метки ------------------------------------------------------------------------------------- */
.chip {
  --chip: var(--st-new);
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px 0 8px; border-radius: 999px;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--chip) 13%, var(--surface));
  color: var(--text); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  vertical-align: middle;
}
.chip::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--chip); }
.chip.st-new { --chip: var(--st-new); }
.chip.st-paid { --chip: var(--st-paid); }
.chip.st-assembling { --chip: var(--st-assembling); }
.chip.st-assembled { --chip: var(--st-assembled); }
.chip.st-with_courier { --chip: var(--st-courier); }
.chip.st-delivered, .chip.st-issued { --chip: var(--st-done); }
.chip.st-cancelled { --chip: var(--st-cancelled); color: var(--muted); }
.chip.lg { height: 28px; padding: 0 12px 0 10px; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin: 0 4px 4px 0;
  border-radius: 999px; background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle;
}
td .badge:last-child { margin-right: 0; }
.badge.brand { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.badge.brand-cd { background: var(--cd-soft); color: var(--cd-text); font-weight: 600; }
.badge.test { background: transparent; color: var(--warn-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 55%, transparent); font-weight: 700; letter-spacing: .04em; font-size: 11px; }
.badge.warning { background: var(--warn-soft); color: var(--warn-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge.info { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.badges { display: inline-flex; flex-wrap: wrap; align-items: center; }

/* --- Таблицы -------------------------------------------------------------------------------------------------------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); margin: 0 0 16px;
  overflow-x: auto;           /* без JS — прокрутка широкой таблицы внутри рамки */
}
.table-wrap.fits { overflow: clip; }  /* app.js: таблица помещается — шапка «прилипает» к верху окна */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 2;
  padding: 11px 12px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.table td { height: 48px; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; }
/* Ссылки в таблицах (номер заказа, имя клиента) — цветом текста: роза остаётся за брендом, красный — за проблемами. */
.table a { color: var(--text); font-weight: 600; }
.table a:hover { text-decoration: underline; }
.table.compact td { height: 40px; padding-top: 7px; padding-bottom: 7px; }
.table.compact th { padding-top: 8px; padding-bottom: 8px; }
.card .table th { position: static; background: transparent; }
.card .table th:first-child, .card .table td:first-child { padding-left: 0; }
.card .table th:last-child, .card .table td:last-child { padding-right: 0; }
.card .table tbody tr:hover { background: transparent; }
.card > .table-scroll { overflow-x: auto; }
.clickable { cursor: pointer; }
/* Опаздывает или «проблема»: красная полоса слева и метка — без заливки строки (в час пик их много, розовая
   таблица перестала бы что-то значить). */
tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
/* Список заказов на «Сегодня» / «Завтра»: выполненные и отменённые — внизу и приглушены, рабочие — на виду (N27). */
.table.orders tr.row-done > td { opacity: .55; }
/* «Допы → Отправка»: собран, допы ещё не проверены. */
tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn-bar); }
.table .subtotal td { color: var(--muted); font-style: italic; }
.table .total td { font-weight: 600; border-top: 1px solid var(--line-strong); }
/* «не опл.» — не серым: неоплаченный заказ флорист не видит, это самое важное в строке (N16). */
.pay-unpaid { color: var(--warn-text); font-weight: 600; }
/* «возврат» у отменённого заказа — обычное состояние, не тревога: серым, как раньше. */
.pay-refunded { color: var(--muted); }
.pay-ok { color: var(--ok-text); }
.cell-sub, .staff-courier { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.no { color: var(--muted); font-weight: 500; }
.yes { color: var(--ok-text); font-weight: 600; }

/* Пустое состояние */
.empty { padding: 40px 16px !important; text-align: center !important; color: var(--muted); height: auto !important; }
.empty .icon, .empty-state .icon { display: block; width: 28px; height: 28px; margin: 0 auto 8px; color: var(--line-strong); stroke-width: 1.5; }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.empty-state p, .empty p { margin: 0; }
.empty-state p + p, .empty p + .btn { margin-top: 10px; }
.empty-state b { color: var(--text); }
.cards > .empty-state { grid-column: 1 / -1; }

/* Пагинация */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.pager-info { font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; gap: 8px; }

/* --- Форма заказа --------------------------------------------------------------------------------------------------- */
.order-form .card { padding: 18px 20px; }
.order-form .radios { margin-bottom: 14px; }
.client-panel:empty { display: none; }
.lookup { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 14px; }
.lookup p { margin: 0 0 6px; }
.lookup p:last-child { margin-bottom: 0; }
.lookup.new { background: var(--cd-soft); }
.lookup .table { margin-top: 8px; font-size: 13px; }
.lookup .table td { height: 34px; padding-top: 5px; padding-bottom: 5px; }
.lookup .notes { color: var(--muted); }
.consents { padding: 12px 14px 2px; margin: 0 0 4px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.items { width: 100%; border-collapse: separate; border-spacing: 0; margin: 0 0 8px; }
.items th { padding: 0 6px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; }
.items td { padding: 4px 6px; vertical-align: top; }
.items th:first-child, .items td:first-child { padding-left: 0; }
.items .col-bundle { width: 52px; }
.items .col-bundle input { padding-left: 8px; padding-right: 4px; }
.items .item-qty { min-width: 60px; }
.items .item-price { min-width: 84px; }
.items th:last-child, .items td:last-child { padding-right: 0; width: 36px; }
.items input { width: 100%; }
.items .item-sum { padding-top: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Пожелание к строке и подсказки («свободно 44», «вне учёта», «возможно: …») — под названием товара. */
.items .item-note { margin-top: 4px; min-height: 32px; font-size: 13px; }
.items .item-hint { display: block; margin-top: 4px; }
.items .item-hint.neg { color: var(--danger-text); }
.items-cost { margin: 4px 0 0; }
/* Конструктор букета в форме заказа (order_kit.js). */
.kit { margin: 0 0 12px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.kit > summary { cursor: pointer; font-weight: 600; }
.kit-body { display: grid; gap: 10px; margin-top: 10px; }
.kit-qty, .kit-extras { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kit-qty input { width: 90px; }
/* Выбранное в конструкторе — цветок, количество, допы. */
#kit .btn[aria-pressed="true"] { background: var(--accent-soft, var(--surface-2)); border-color: var(--accent); }
#kit-free.neg { color: var(--danger-text); }
/* Витрина в форме заказа (E18): карточки готовых букетов. */
.showcase-cards { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.showcase-card { display: flex; gap: 8px; align-items: center; text-align: left; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--surface); color: var(--text); cursor: pointer; max-width: 100%; }
.showcase-card span { display: grid; gap: 2px; }
.showcase-card[aria-pressed="true"] { opacity: .55; cursor: default; }
/* Приход: позиция — поиском, под ней «сорт, плантация» и «+ брак к поставке»; коробки · кол-во · вес — столбиком. */
#lines { table-layout: fixed; }
#lines th:nth-child(2) { width: 112px; }
#lines th:nth-child(3) { width: 96px; }
#lines th:nth-child(4) { width: 100px; }
#lines th:nth-child(5) { width: 150px; }
#lines th:nth-child(6) { width: 64px; }
#lines th:nth-child(7) { width: 36px; }
#lines td:nth-child(2) input + input, #lines td:nth-child(2) .line-pack + input { margin-top: 4px; }
#lines td:nth-child(5) select { margin-top: 4px; }
#lines .line-more { margin-top: 4px; font-size: 13px; }
#lines .line-more input { margin-top: 4px; }
#lines .line-pack { display: block; margin-top: 2px; }
@media (min-width: 768px) {
  #items td:nth-child(3) { width: 76px; }
  #items td:nth-child(4) { width: 104px; }
  #items td:nth-child(5) { width: 88px; text-align: right; }
}
.label-sr > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.items tr.deleted td { opacity: .4; }
.items tr.deleted input { text-decoration: line-through; }
.item-del { display: inline-grid; place-items: center; width: 32px; height: 40px; border-radius: var(--radius-sm); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; position: relative; }
.item-del:hover { background: var(--danger-soft); color: var(--danger-text); }
.item-del input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.item-del:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.items-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 8px 16px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.items-foot .field { margin-bottom: 0; flex: 0 1 170px; }
.items-foot .add-row { align-self: center; margin-right: auto; }
.item-below { display: inline-block; margin-top: 4px; }
/* Закрытие смены: пять итогов касс — сеткой, на телефоне столбиком */
.shift-amounts { border: 0; padding: 0; margin: 4px 0 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }
.shift-amounts legend { padding: 0; margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.shift-amounts input { text-align: right; font-variant-numeric: tabular-nums; }
.table.shift-lines td.num, .table.shift-lines th.num { white-space: nowrap; }
.discount-reason { margin-top: 12px; }
.discount-reason .field { margin-bottom: 0; }
.quick-pay { margin: 0 0 14px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.hall-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Итог справа: липкий на десктопе, на узком экране — панель внизу */
.of-summary .sum-rows { margin: 0 0 12px; }
.of-summary .sum-rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--muted); font-size: 14px; }
.of-summary .sum-rows dt, .of-summary .sum-rows dd { margin: 0; }
.of-summary .sum-rows dd { font-variant-numeric: tabular-nums; color: var(--text); }
.sum-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 0 14px; border-top: 1px solid var(--line); }
.sum-total span { font-weight: 500; }
.sum-total b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.of-summary .form-actions > span { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.of-summary .form-actions .btn { width: 100%; }
.of-summary .kbd-legend { margin-top: 12px; gap: 4px 12px; font-size: 13px; }
.stock-form .form-actions, .card > .form-actions, form.card .form-actions { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.of-summary > .form-actions { margin: 0; padding: 0; border: 0; }

/* --- Подсказка улиц под полем «Адрес» (app.js: streetCombobox) ------------------------------------------------------- */
.combo { position: relative; }
.combo-pop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 15;  /* выше панели «Сохранить», ниже меню телефона */
  margin-top: 6px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.combo-pop ul { position: relative; list-style: none; margin: 0; padding: 6px; max-height: 22rem; overflow-y: auto; overscroll-behavior: contain; }
.combo-pop ul:empty { display: none; }
.combo-option { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.combo-option b { font-weight: 600; }
.combo-place { padding: 1px 8px; border-radius: 999px; background: var(--place-soft); color: var(--place-text); font-size: 13px; font-weight: 600; }
.combo-option small { color: var(--muted); font-size: 13px; }
.combo-option[aria-selected=true] { background: var(--accent-soft); }
.combo-option[aria-selected=true] b { color: var(--accent-text); }
.combo-empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }
.combo-note { padding: 6px 14px 7px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 12px; }

/* --- Адрес одной строкой: метка места слева от поля, под полем — что понято (app.js: setupAddress) ------------------ */
.addr-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.addr-line > input, .addr-line > .combo { flex: 1 1 auto; min-width: 0; width: 100%; }
.addr-place, .place-badge {
  display: inline-flex; align-items: center; flex: none; border-radius: 999px;
  background: var(--place-soft); color: var(--place-text); font-weight: 600; white-space: nowrap;
}
.addr-place { height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.addr-place:hover { box-shadow: inset 0 0 0 1px var(--place-text); }
.addr-place:focus-visible { outline: 2px solid var(--place-text); outline-offset: 2px; }
.addr-place-more { margin-left: 4px; font-size: 0.85em; }
.place-badge { height: 22px; padding: 0 8px; margin-right: 2px; font-size: 13px; vertical-align: 1px; }
.huge-address .place-badge { height: 28px; padding: 0 10px; font-size: 17px; vertical-align: 2px; }
.addr-preview { color: var(--text); }
.addr-preview.warn { color: var(--warn-text); font-weight: 500; }
@media (max-width: 559px) {
  /* Телефон: метка места — над полем, поле во всю ширину (длинные посёлки не съедают поле) */
  .addr-line { flex-wrap: wrap; gap: 6px; }
  .addr-line > input, .addr-line > .combo { flex-basis: 100%; }
  .addr-place { height: 26px; padding: 0 10px; border-radius: 999px; font-size: 13px; }
}

/* --- Карточка заказа ------------------------------------------------------------------------------------------------- */
.actions-card .buttons { gap: 8px 10px; }
.actions-card .row-form { margin: 0; }
.actions-card .buttons > form { margin: 0; }
/* «Что дальше» под заголовком «Действия» и «Скопировать текст для клиента» (N27); себестоимость заказа (N33). */
.next-step { margin: 0 0 14px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: var(--radius-sm); }
.client-copy { margin-top: 14px; }
.client-copy details.sub { margin-top: 8px; }
.client-text { margin: 8px 0; white-space: pre-wrap; font: inherit; }
.order-cost { margin: 10px 0 0; }
details.sub { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
details.sub > summary {
  display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 500;
}
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary::before { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.75px 1.75px 0; transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
details.sub[open] > summary::before { transform: rotate(45deg); }
details.sub > summary:hover { color: var(--text); }
details.sub > form, details.sub > div { margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 0 10px; padding: 0 0 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-dot { --chip: var(--st-new); position: relative; z-index: 1; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--chip); }
.tl-dot::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--chip); }
.tl-dot.st-paid { --chip: var(--st-paid); }
.tl-dot.st-assembling { --chip: var(--st-assembling); }
.tl-dot.st-assembled { --chip: var(--st-assembled); }
.tl-dot.st-with_courier { --chip: var(--st-courier); }
.tl-dot.st-delivered, .tl-dot.st-issued { --chip: var(--st-done); }
.tl-dot.st-cancelled { --chip: var(--st-cancelled); }
.tl-dot.rollback { --chip: var(--muted); }
.tl-title { font-weight: 500; }
.tl-title .muted { font-weight: 400; }
.tl-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tl-comment { margin: 4px 0 0; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 0 0 14px; }
.photos figure { margin: 0; min-width: 0; }
.photos a, .photos img { display: block; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.photos a:hover img { border-color: var(--line-strong); }
.photos figcaption { margin-top: 5px; color: var(--muted); font-size: 13px; }
.photos > .hint { grid-column: 1 / -1; margin: 0; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--line); }
/* Эталонное фото позиции каталога на экране сборки: флорист сверяет букет с ним */
.reference-photo { margin: 8px 0 10px; max-width: 320px; }
.reference-photo a, .reference-photo img { display: block; }
.reference-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-2); }
.reference-photo figcaption { margin-top: 5px; color: var(--muted); font-size: 13px; }
/* Стандарты работы: простой текст из админки, переносы строк сохраняются */
.standard-text { margin: 0; white-space: pre-wrap; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.card-text { margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 16px; white-space: pre-wrap; }

/* --- Очередь флориста, мои доставки: карточки для телефона ----------------------------------------------------------------- */
.order-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0;
  color: var(--text); text-decoration: none;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.order-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.order-card.warning { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--warn-bar); }
.order-card.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--danger); background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface)); }
.oc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.oc-head .oc-no { font-size: 16px; font-weight: 600; margin-right: auto; }
.oc-head .badge { margin: 0; }
.oc-time { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.oc-time .icon { width: 20px; height: 20px; color: var(--muted); }
.oc-time small { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.order-card.danger .oc-time { color: var(--danger-text); }
.order-card.warning .oc-time { color: var(--warn-text); }
.oc-row { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 14px; }
.oc-row .icon { width: 18px; height: 18px; margin-top: 1px; }
.oc-row.strong { color: var(--text); font-size: 15px; }
.oc-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.items-short { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 15px; }
.items-short li { display: flex; justify-content: space-between; gap: 12px; }
.items-short li b { font-variant-numeric: tabular-nums; }
.item-block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item-block:first-of-type { padding-top: 0; }
.item-block:last-child { border-bottom: 0; padding-bottom: 0; }
.item-block .big { margin: 0 0 4px; font-weight: 600; }
.bundle-head { margin: 14px 0 8px; font-size: 15px; color: var(--text); }
h2 + .bundle-head { margin-top: 0; }
.components { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }
.components li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.big-time { font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 0 0 14px; }
.big-day { font-size: 22px; letter-spacing: 0; white-space: nowrap; }  /* у курьера: «сегодня», «завтра, 10.11» */
/* Экран сборки: комментарий к заказу и пожелания к строкам — заметно, сразу под «собрать к» */
.florist-notes { margin: 0 0 14px; padding: 10px 14px; border-left: 4px solid var(--cd); border-radius: var(--radius-md); background: var(--cd-soft); font-size: 16px; overflow-wrap: anywhere; }
.florist-notes p { margin: 0; }
.florist-notes p + p { margin-top: 6px; }
.huge-address { font-size: 19px; font-weight: 600; line-height: 1.35; }
.contact-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 16px; }
/* «Скопировать адрес» без буфера обмена (app.js): старый способ — через невидимое поле; не вышло — поле под кнопкой с
   выделенным текстом («Выделено — нажмите „Копировать“»). */
.copy-buffer { position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; }
.copy-select { width: 100%; grid-column: 1 / -1; }
/* Заказ курьера: «Что везём» — без цен, места как на наклейке, фото букета — и причины «Проблемы» одним нажатием. */
.carry h2 .badge { margin-left: 6px; vertical-align: middle; }
.carry .items-short { margin: 0 0 10px; }
.carry .carry-head { margin-top: 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.carry .carry-head:first-child { margin-top: 0; }
.carry .thumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.carry .thumb { width: 88px; height: 88px; }
.problem-reasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 14px; }
.totals { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline; }
.totals p { margin: 0; }
.totals .t-item { display: flex; flex-direction: column; gap: 2px; }
.totals .t-label { color: var(--muted); font-size: 13px; }
.totals .t-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.refresh-note { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.refresh-note .icon { width: 16px; height: 16px; }

/* --- Сводка --------------------------------------------------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 0 0 16px; }
.kpi { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.kpi-label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-label .badge { margin: 0; }
.kpi-value { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.kpi-value.md { font-size: 26px; }
.kpi-meta { margin: 0; color: var(--muted); font-size: 13px; }
.kpi-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.kpi-row b { color: var(--text); }
.kpi .progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.kpi-list { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.kpi-list li { display: flex; justify-content: space-between; gap: 8px; }
.kpi-list b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Оплаты и возвраты в карточке заказа: строка — что, когда, способ и чек; справа сумма (возврат — красным). */
.payment-list { list-style: none; margin: 12px 0 0; padding: 0; }
.payment-list > li { padding: 10px 0 2px; border-top: 1px solid var(--line); }
.payment-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.payment-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payment-list details.sub.row-actions { margin: 2px 0 6px; }
.tax-reserve { margin-top: 12px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok-text); }
.delta.down { color: var(--danger-text); }
.delta.flat { color: var(--muted); }

/* Полоска к цели в плитках сводки (crm_tags.goal_bar, SVG): день идёт — нейтральная, цель достигнута — зелёная;
   итог — зелёная / жёлтая / красная. Больше 100 % — отметка там, где было 100 %. */
.goal { display: block; width: 100%; height: 12px; overflow: visible; }
.goal-track { fill: var(--surface-3); }
.goal-fill { fill: var(--bar); }
.goal-ok .goal-fill { fill: var(--ok); }
.goal-warn .goal-fill { fill: var(--warn-bar); }
.goal-bad .goal-fill { fill: var(--danger); }
.goal-mark { fill: var(--text); }

/* <meter> — % нормы по дням в таблице периода (зелёный/жёлтый/красный по low/high/optimum) */
meter {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  display: block; width: 100%; height: 8px; border: 0; border-radius: 999px;
  background: var(--surface-3); overflow: hidden;
}
meter::-webkit-meter-bar { height: 8px; border: 0; border-radius: 999px; background: var(--surface-3); }
meter::-webkit-meter-optimum-value { background: var(--ok); border-radius: 999px; }
meter::-webkit-meter-suboptimum-value { background: var(--warn-bar); border-radius: 999px; }
meter::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: 999px; }
meter:-moz-meter-optimum::-moz-meter-bar { background: var(--ok); border-radius: 999px; }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warn-bar); border-radius: 999px; }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); border-radius: 999px; }
.pct-cell { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.days meter { width: 120px; flex: none; }

/* Столбчатый график выручки за 14 дней (данные и высоты считает сервер) */
.chart-card .card-header { align-items: flex-start; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw-r11, .seg-r11 { --seg: var(--chart-r11); background: var(--seg); }
.sw-cd, .seg-cd { --seg: var(--chart-cd); background: var(--seg); }
.sw-pc, .seg-pc { --seg: var(--chart-pc); background: var(--seg); }
/* Бренд без нормы: светлая заливка и контур — с линией нормы сравнивается только закрашенная часть столбца */
.sw.sw-ghost, .chart-seg.seg-ghost { background: color-mix(in srgb, var(--seg) 22%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--seg); }
.sw-norm { width: 16px; height: 2px; border-radius: 1px; background: var(--chart-norm); }
.chart { display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 8px; margin-top: 18px; }
.chart-y { position: relative; height: 200px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-y span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; white-space: nowrap; }
.chart-y .y0 { bottom: 0; }
.chart-y .y1 { bottom: 25%; }
.chart-y .y2 { bottom: 50%; }
.chart-y .y3 { bottom: 75%; }
.chart-y .y4 { bottom: 100%; }
.chart-plot {
  position: relative; height: 200px;
  border-bottom: 1px solid var(--line-strong);
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
}
.chart-cols { position: absolute; inset: 0; display: flex; }
.chart-col { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; justify-content: center; }
.chart-col:hover { background: var(--chart-hover); }
.chart-bar { display: flex; flex-direction: column-reverse; gap: 2px; width: 62%; max-width: 24px; border-radius: 4px 4px 0 0; overflow: hidden; }
.chart-seg { flex: 0 1 auto; min-height: 0; }
/* Сегодня день идёт — штриховка (цвет столбца остаётся полным: контраст к фону не падает) */
.chart-col.is-partial .chart-seg { background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--surface) 3px 5px); }
.chart-norm { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-norm path { fill: none; stroke: var(--chart-norm); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .75; }
.chart-x { grid-column: 2; display: flex; }
.chart-x span { flex: 1 1 0; min-width: 0; padding-top: 6px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.chart-x small { display: block; font-size: 10.5px; }
.chart-x .is-today { color: var(--text); font-weight: 600; }
.chart-tip {
  display: none; position: absolute; z-index: 5; left: 50%; top: -6px; transform: translate(-50%, -100%);
  min-width: 170px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow-lg); color: var(--text);
  font-size: 12px; line-height: 1.45; white-space: nowrap; pointer-events: none;
}
.chart-col:hover .chart-tip { display: block; }
.chart-col:nth-child(-n+3) .chart-tip { left: 0; transform: translate(0, -100%); }
.chart-col:nth-last-child(-n+3) .chart-tip { left: auto; right: 0; transform: translate(0, -100%); }
.chart-tip b { display: block; margin-bottom: 4px; font-weight: 600; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row span { flex: 1; color: var(--muted); }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip .tip-row .tip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.chart-tip .tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.chart-empty { padding: 32px 0; text-align: center; color: var(--muted); }

/* Источники — горизонтальные полоски */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 5px; font-size: 14px; }
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-val { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar-val b { color: var(--text); font-weight: 600; }
.hbar { display: block; width: 100%; height: 6px; }
.hbar-track { fill: var(--surface-3); }
.hbar-fill { fill: var(--bar); }

.summary-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 16px; align-items: start; }
.control-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.control-links li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 14px; }
.late-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.late-list a { display: inline-flex; align-items: center; height: 26px; padding: 0 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* --- Вход ------------------------------------------------------------------------------------------------------------------ */
.auth-main { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-main .toasts { width: 100%; max-width: 400px; }
.auth-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow-md); }
/* Логотип магазина (crm/includes/auth_logo.html): роза, «11 РОЗ», «Доставка цветов»; тёмный вариант — через <picture>. */
.auth-logo { display: block; margin: 0 0 24px; }
.auth-logo img { display: block; width: 112px; height: auto; margin: 0 auto; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .page-sub { margin: 0 0 24px; }
.auth-card .btn { margin-top: 6px; }
.auth-foot { margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.auth-foot code { white-space: nowrap; }
.auth-card.wide-auth { max-width: 520px; }
.auth-alt { margin: 12px 0 0; }

/* --- Вход и пароль, код из приложения ------------------------------------------------------------------------------------ */
.steps { margin: 0 0 18px; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 10px; }
.steps li::marker { color: var(--muted); font-weight: 600; }
.secret { margin: 8px 0 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font: 600 17px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
.secret-uri code { display: block; padding: 8px 10px; line-height: 1.45; overflow-wrap: anywhere; user-select: all; }
.backup-codes { margin: 16px 0; padding-left: 1.6rem; columns: 2; column-gap: 32px; }
.backup-codes li { margin: 0 0 8px; break-inside: avoid; }
.backup-codes code { font-size: 16px; letter-spacing: .04em; background: none; padding: 0; }
.plain-list { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 6px; }
.plain-text { white-space: pre-wrap; font: inherit; margin: 8px 0; }
/* Приём по поставке с телефона (склад v2, E14): строка — карточка, поля переносятся. */
.accept-form { display: grid; gap: 10px; }
.acc-line { display: grid; gap: 8px; }
.acc-line.done { border-left: 3px solid var(--ok, var(--accent)); }
.acc-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.acc-expect { margin-left: auto; }
.acc-fields { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.acc-field { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.acc-field input { width: 110px; }
.acc-status.neg { color: var(--danger-text); }
.acc-actions { flex-wrap: wrap; }
/* Телефон клиента: последние 4 цифры и кнопка «Показать» (каждый показ — в журнал просмотров) */
.phone-reveal { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; }
.cell-sub .phone-reveal { margin-top: 2px; }
.phone-line { display: flex; align-items: center; gap: 6px; }

/* --- Прочее -------------------------------------------------------------------------------------------------------------------- */
.export-row { padding: 14px 0; border-top: 1px solid var(--line); gap: 10px 12px; }
.export-row:first-of-type { border-top: 0; padding-top: 0; }
.export-row .export-title { flex: 1 0 100%; font-weight: 600; }
.date-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.date-row:last-of-type { border-bottom: 0; }
.date-row input[type=number] { width: 76px; }
.date-row input[type=text] { width: 150px; }
.date-row .check { align-self: center; margin-top: 18px; }
.consents-table td { vertical-align: top; }

.kpi-grid > .card { margin: 0; }
.kpi-value a { color: inherit; }
.kpi-value a:hover { color: var(--link); text-decoration: none; }
.kpi-value small { font-size: 15px; font-weight: 500; letter-spacing: 0; }
.kpi details.sub { margin-top: 4px; padding-top: 8px; }
.divided { margin-top: 14px !important; padding-top: 14px; border-top: 1px solid var(--line); }
.error-page { margin: 8vh auto 0; text-align: center; padding: 36px 28px; }
.error-page > .icon { width: 32px; height: 32px; color: var(--muted); margin-bottom: 10px; }
.error-page h1 { font-size: 22px; }
.btn .icon:last-child:not(:first-child) { margin-left: 0; margin-right: -3px; }
.nowrap-form { flex-wrap: nowrap; }
.dispatch-action { margin-top: 6px; }
.table.dispatch .col-address { min-width: 8rem; }
.period-custom { margin: -4px 0 16px; }
.nowrap-form select { max-width: 150px; }
.nowrap-form input[type=number] { width: 80px; }
.table .row-form input, .table .row-form select { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 14px; }
.table .row-form select { padding-right: 30px; background-position: right 6px center; }
.lookup .table tbody tr:hover { background: transparent; }

/* --- Пики: фильтры, группы у диспетчера, действия пачкой, лимиты интервалов ---------------------------------------------- */
.peak-filters { margin: 0 0 16px; }
.interval-filter { margin: 0; }
.interval-filter .btn .n { margin-left: 2px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; line-height: 18px; }
.interval-filter .btn.primary .n { background: var(--primary-kbd); color: inherit; }
.peak-note { display: flex; align-items: center; gap: 6px; margin: -8px 0 12px; }
.batch-bar { margin: 0 0 16px; padding: 12px 16px; }
/* Отмечено хоть что-то — панель пачкой прилипает к низу экрана (app.js), листать наверх не нужно. */
.batch-bar.floating {
  position: fixed; z-index: 30; left: calc(var(--sidebar-w) + var(--gutter)); right: var(--gutter);
  bottom: calc(12px + env(safe-area-inset-bottom)); margin: 0; box-shadow: var(--shadow-md);
}
.dispatch .group-head .badge { margin-left: 10px; }
/* Пока панель пачкой прилипла к низу — место под ней, чтобы она не закрывала последние строки. */
main:has(.batch-bar.floating) { padding-bottom: 180px; }
@media (max-width: 767px) { main:has(.batch-bar.floating) { padding-bottom: 300px; } }
.row-check { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; margin: -12px 0; cursor: pointer; }
.batch-count { flex: 1 1 100%; display: flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; font-weight: 500; }
.batch-count .icon { color: var(--muted); }
.table.dispatch .col-check { width: 44px; padding-right: 0; }
.table.dispatch .col-check input { width: 20px; height: 20px; }
.table .group-head th { position: static; padding: 14px 16px 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }
.table .zone-head td { height: auto; padding: 8px 16px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.table .zone-head .icon { width: 16px; height: 16px; margin-right: 4px; }
.table tbody tr.group-head:hover, .table tbody tr.zone-head:hover { background: transparent; }
.table .group-head:hover th { background: var(--surface-2); }
.group-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.group-check input { width: 20px; height: 20px; }
.count-note { margin-left: 8px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.count-note::before { content: "· "; }
/* Лимиты интервалов: «37/40» у кнопок интервалов формы заказа, на экране «Пиковые даты» */
.quick .btn .load { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; line-height: 18px; }
.quick .btn.load-near .load, .load-chip.near { background: var(--warn-soft); color: var(--warn-text); }
.quick .btn.load-full .load, .load-chip.full { background: var(--danger-soft); color: var(--danger-text); }
.quick .btn.load-full { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.load-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--ok-soft); color: var(--ok-text); font-weight: 600; }
.interval-load { margin: -6px 0 14px; padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 14px; }
.interval-load.is-closed { background: var(--danger-soft); }
.limit-box { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--danger-soft); }
.limit-box .limit-text { margin: 0 0 8px; font-weight: 500; color: var(--danger-text); }
.limit-box .check { margin: 0; }
.limit-box .hint { margin: 6px 0 0; }
.dup-warning { margin: 0 0 14px; }
.peak-menu-note { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.peak-day .card-header h2 .icon, .peak-menu .card-header h2 .icon, .soon-block .card-header h2 .icon { margin-right: 6px; color: var(--muted); }
.peak-loads td:first-child { width: 9rem; }
.items.limits th:first-child, .items.limits td:first-child { width: auto; }
.items.limits input[type=number] { max-width: 150px; }
/* Очередь сборки: «Собрать в ближайшие 2 часа» */
.soon-block { margin: 0 0 16px; }
.soon-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }
.soon-grid h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.soon-block .items-short a { color: var(--text); font-weight: 500; }
.item-filter { margin: 0 0 16px; }
.item-filter label { min-width: min(100%, 320px); }
.input-short { width: 90px; }
.row-actions { display: inline-block; margin: 0 8px 0 0; padding: 0; border: 0; }
.row-actions > summary { font-size: 13px; }

/* --- Контроль и отчёты: теплокарта нагрузки по часам, недельный отчёт ---------------------------------------------------- */
/* Теплокарта: чем больше в часе, тем гуще синий (--cd: не бренд и не проблема). Текст на густых клетках — основным
   цветом (контраст AA и в тёмной теме). Не .table: на телефоне остаётся таблицей с прокруткой внутри карточки. */
.heat { border-collapse: separate; border-spacing: 3px; margin: 0 -3px; font-size: 13px; font-variant-numeric: tabular-nums; }
.heat th { padding: 4px 8px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.heat thead th { text-align: center; }
.heat thead small { display: block; font-size: 11px; font-weight: 500; }
.heat td { min-width: 64px; height: 32px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); text-align: center; line-height: 1.15; }
.heat td b { font-weight: 600; }
.heat td small { display: block; color: var(--muted); font-size: 11px; }
.heat .heat-1 { background: color-mix(in srgb, var(--cd) 10%, var(--surface)); }
.heat .heat-2 { background: color-mix(in srgb, var(--cd) 18%, var(--surface)); }
.heat .heat-3 { background: color-mix(in srgb, var(--cd) 27%, var(--surface)); }
.heat .heat-4 { background: color-mix(in srgb, var(--cd) 36%, var(--surface)); }
.heat .heat-5 { background: color-mix(in srgb, var(--cd) 46%, var(--surface)); }
.heat .heat-3 small, .heat .heat-4 small, .heat .heat-5 small { color: var(--text); }
.heat .heat-total td, .heat .heat-total th { height: auto; padding-top: 8px; background: transparent; box-shadow: inset 0 1px 0 var(--line); border-radius: 0; }
.hourly-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 0 16px; align-items: start; }
.hourly-peaks { margin: 0 0 12px; }
.hourly-peaks li { flex-wrap: wrap; justify-content: flex-start; column-gap: 12px; }
.hourly-peaks b { font-weight: 600; }
.control-stats .stat { scroll-margin-top: 16px; }
.control-section { scroll-margin-top: 16px; }
.weekly-control li { justify-content: flex-start; }
.weekly-text { margin: 0; overflow-wrap: anywhere; }
.weekly-read .msg { margin: 0; }

/* --- Касса, выплаты, жалобы, склад ---------------------------------------------------------------------------------- */
.callout.info { background: var(--surface-2); border-color: transparent; }
.callout.info > .icon { color: var(--muted); }
.remake-box { margin: 8px 0 12px; padding: 12px 14px 4px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.remake-box .check { margin-top: 0; }
.items.count-lines th:first-child, .items.count-lines td:first-child { width: auto; }
.items.count-lines input { max-width: 140px; }
.items.count-lines td:first-child label { display: block; padding-top: 10px; color: var(--text); font-size: 15px; }
.items.count-lines tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.items.count-lines .item-sum { text-align: right; }
.items.count-lines span[data-count-price] { display: inline-block; padding-top: 10px; }
.items-foot b { font-size: 18px; }
.kpi-list li.total { padding-top: 4px; border-top: 1px solid var(--line); color: var(--text); }

/* =============================================================================================================================
   Адаптивность
   ============================================================================================================================= */

/* Форма заказа: две колонки (слева клиент, доставка и состав; справа оплата и липкий итог) — от 1200 px */
@media (min-width: 1200px) {
  .order-form > .grid-2 { grid-template-columns: minmax(0, 1fr) 360px; gap: 0 20px; align-items: stretch; }
  .of-side { min-width: 0; }
  .of-summary { position: sticky; top: 16px; }
}
@media (max-width: 1199px) {
  .order-form > .grid-2 { display: block; }
  .of-side { display: contents; }
  .of-summary {
    position: sticky; bottom: 0; z-index: 12;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
    margin: 0; padding: 10px 16px 12px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--sheet-shadow);
  }
  .of-summary .of-summary-title, .of-summary .sum-rows, .of-summary .kbd-legend { display: none; }
  .of-summary .sum-total { flex: 1 1 auto; border: 0; padding: 0; justify-content: flex-start; }
  .of-summary .sum-total b { font-size: 20px; }
  .of-summary .form-actions { flex: 0 1 auto; }
  .of-summary .form-actions > span { flex-direction: row; flex-wrap: wrap; width: auto; }
  .of-summary .form-actions .btn { width: auto; }
  /* «Когда» у кнопки «Сохранить» и на узком экране: из строк «Итога» в нижней панели — только она, своей строкой над
     «Итого» и кнопкой; у зала её нет — нет и пустой строки. Селектор с «.sum-rows >» — иначе общее правило строк
     «Итога» (.of-summary .sum-rows > div) весит больше и дата уезжает к правому краю. */
  .of-summary .sum-rows { display: block; flex: 1 1 100%; margin: 0; }
  .of-summary .sum-rows > div:not(.sum-when-row) { display: none; }
  .of-summary .sum-rows:not(:has(> .sum-when-row:not([hidden]))) { display: none; }
  .of-summary .sum-rows > .sum-when-row { justify-content: flex-start; gap: 6px; padding: 0; font-size: 13px; }
}

/* Список заказов: уже 1360 px флорист прячется (он есть в карточке заказа), курьер виден всегда */
@media (max-width: 1359px) {
  .table .xl-only { display: none; }
}
@media (min-width: 768px) and (max-width: 1359px) {
  .table.orders .staff-courier { color: var(--text); font-size: inherit; }
}
/* Уже 1180 px прячется «Зона» (она есть в карточке заказа и в карточке на телефоне) — таблица помещается с 1024 px */
@media (min-width: 768px) and (max-width: 1179px) {
  .table.orders .col-zone { display: none; }
}
.table.orders td, .table.dispatch td { padding: 8px 10px; }
.table.orders th, .table.dispatch th { padding-left: 10px; padding-right: 10px; }
.table.orders .col-client { min-width: 9rem; }
.table.orders th:first-child, .table.orders td:first-child, .table.dispatch th:first-child, .table.dispatch td:first-child { padding-left: 16px; }
.table.orders th:last-child, .table.orders td:last-child, .table.dispatch th:last-child, .table.dispatch td:last-child { padding-right: 16px; }
.table.orders .cell-sub .badge { margin: 3px 0 0; }

/* Сводка и сетки: одна колонка раньше, чем прячется меню */
@media (max-width: 1279px) {
  .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Ноутбук и планшет (768–1279 px): узкое меню — иконка и короткая подпись под ней (как в нижней панели телефона;
   на сенсорном планшете всплывающих подсказок нет). Освободившееся место — таблицам: список заказов помещается с 1024 px. */
@media (max-width: 1279px) {
  :root { --sidebar-w: 84px; }
  .sidebar { padding: 14px 4px 10px max(4px, env(safe-area-inset-left)); align-items: stretch; }
  .wordmark { justify-content: center; padding: 0; }
  .brand-full, .me-text { display: none; }
  .brand-short { display: inline; font-size: 20px; }
  .nav-item { flex-direction: column; justify-content: center; gap: 3px; min-height: 56px; padding: 6px 0; text-align: center; }
  .nav-label { flex: none; max-width: 100%; font-size: 10.5px; line-height: 1.15; letter-spacing: -.01em; }
  .nav-item .count { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 10.5px; }
  .me { justify-content: center; padding: 6px 0 8px; }
}
@media (max-width: 1023px) {
  :root { --gutter: 24px; }
}

/* Телефон (< 768 px): шапка, нижняя панель вкладок, карточки вместо таблиц, кнопки ≥ 44 px */
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .shell { display: block; }
  .sidebar { display: none; }
  /* Поле, куда перешёл фокус (Tab, «Далее» на клавиатуре), не прячется под шапкой и нижними панелями */
  html { scroll-padding-top: 64px; scroll-padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
  .main {
    padding: 16px max(var(--gutter), env(safe-area-inset-right)) calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom))
      max(var(--gutter), env(safe-area-inset-left));
  }
  /* Нижней панели нет: у курьера один раздел; на форме заказа её место занимает панель «Итого» */
  .no-tabbar .main, .page-order-form .main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .page-order-form .tabbar { display: none; }
  .mobile-bar {
    position: sticky; top: 0; z-index: 25;
    display: flex; align-items: center; justify-content: space-between;
    height: 52px; padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mobile-bar .wordmark { margin: 0; padding: 0; font-size: 20px; min-height: 44px; }
  .mobile-me { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--muted); }
  .mobile-me .avatar { width: 30px; height: 30px; font-size: 12px; }
  /* Меню аватара: имя, роль, «Выйти» */
  .me-menu { position: relative; }
  .me-menu > summary { list-style: none; cursor: pointer; border-radius: var(--radius-sm); -webkit-tap-highlight-color: transparent; }
  .me-menu > summary::-webkit-details-marker { display: none; }
  .me-menu[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 1; background: var(--scrim); cursor: default; }
  .me-sheet {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 2;
    display: flex; flex-direction: column; gap: 8px; width: min(280px, calc(100vw - 2 * var(--gutter)));
    padding: 10px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); box-shadow: var(--shadow-lg);
    animation: sheet-in .16s ease-out;
  }
  .me-sheet .me { justify-content: flex-start; padding: 2px 2px 4px; }
  .me-sheet .me-text { display: flex; }
  .me-sheet form { margin: 0; }
  .test-banner { padding: 7px var(--gutter); font-size: 13px; }
  .test-banner-text { display: none; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab-item, .tab-more { flex: 1 1 0; min-width: 0; }
  .tab-item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 100%; min-height: 44px; padding: 6px 0 4px;
    color: var(--muted); font-size: 10.5px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; text-decoration: none; cursor: pointer;
    list-style: none; -webkit-tap-highlight-color: transparent;
  }
  .tab-item::-webkit-details-marker { display: none; }
  .tab-item .icon { width: 22px; height: 22px; }
  .tab-item:hover { text-decoration: none; color: var(--text); }
  .tab-item[aria-current="page"], .tab-item.is-active, .tab-more[open] > .tab-item { color: var(--accent); }
  .tab-label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tab-item .count { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; font-size: 10.5px; }
  .tab-item .count.dot { min-width: 8px; width: 8px; height: 8px; top: 7px; left: calc(50% + 9px); padding: 0; }
  .tab-more { position: static; }
  .tab-more[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 1; background: var(--scrim); cursor: default; }
  .more-sheet {
    position: fixed; left: 8px; right: 8px; z-index: 2;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); overflow-y: auto;
    padding: 8px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); box-shadow: var(--shadow-lg);
    animation: sheet-in .16s ease-out;
  }
  .more-sheet .nav-item { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 48px; padding: 0 12px; font-size: 15px; text-align: left; }
  .more-sheet .nav-label { display: flex; flex: 1; font-size: inherit; line-height: 1.2; letter-spacing: 0; }
  .more-sheet .nav-item .count { position: static; min-width: 20px; height: 20px; font-size: 12px; }

  h1 { font-size: 22px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .page-head .actions .menu { flex: 1 1 auto; }
  .page-head .actions .menu > summary { width: 100%; }
  .menu-sheet { left: 0; right: 0; width: auto; max-width: none; }
  .menu-item { min-height: 44px; font-size: 15px; }
  .offline-banner { top: 52px; padding: 8px var(--gutter); }  /* под шапкой телефона */
  .btn { --btn-h: 44px; }
  .btn.small { --btn-h: 44px; }
  .toast-close { width: 40px; height: 40px; margin: -8px -8px -8px 0; }
  .item-del { width: 44px; height: 44px; }
  .btn.big { --btn-h: 54px; }
  .btn kbd { display: none; }
  input[type=text], input[type=search], input[type=number], input[type=date], input[type=time], input[type=tel],
  input[type=datetime-local], input[type=password], input[type=email], input:not([type]), select, textarea {
    min-height: 44px; font-size: 16px;
  }
  /* Галочки с подписью и раскрывашки — цель касания 44 px («Чек пробит» флорист жмёт на каждой продаже). */
  .check { min-height: 44px; margin-top: 0; margin-bottom: 4px; }
  .check label { display: flex; align-items: center; min-height: 44px; flex: 1; }
  details > summary { min-height: 44px; display: flex; align-items: center; }
  .batch-bar.floating { left: var(--gutter); bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom)); }
  .filters .row-form input, .filters .row-form select { min-height: 44px; font-size: 16px; }
  .filters .row-form .btn { --btn-h: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  /* Цели касания ≥ 44 px (§6.0): ссылка «назад», вкладки, сегменты, выбор файла, цифры-ссылки в сводке */
  .radios div[id] label { min-height: 44px; }
  .back-link { min-height: 44px; margin-bottom: 0; }
  input[type=file]::file-selector-button { min-height: 44px; }
  .kpi-value a { display: inline-flex; align-items: center; min-height: 44px; }
  .card { padding: 16px; border-radius: var(--radius-md); }
  .order-form .card { padding: 16px; }
  .kbd-legend, .kbd-hint { display: none !important; }
  .row-form > label { flex: 1 1 140px; }
  .row-form > label:not(.check) input, .row-form > label select { width: 100%; }  /* галочка не растягивается */
  .tabs { display: flex; flex-wrap: wrap; overflow: visible; }
  /* Вкладки, которые листаются вбок (период в сводке): край затухает — видно, что есть ещё */
  .tabs.tabs-scroll {
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .tabs.tabs-scroll a { flex: 0 0 auto; }
  .hide-sm { display: none !important; }
  .tabs a { flex: 1 0 auto; justify-content: center; padding: 0 8px; min-height: 44px; font-size: 13px; }
  .toolbar .tabs { width: 100%; }
  /* Сводка на телефоне: сразу период и цифры, даты периода — во вкладке */
  .summary-head .page-sub { display: none; }
  /* Счётчики — одна прокручиваемая строка, страница вбок не едет; тревожные — первыми */
  .stats { display: flex; gap: 8px; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 0 var(--gutter) 2px; scrollbar-width: none; }
  /* «Контроль»: плитки сеткой в 2 колонки, только ненулевые — красные не уходят за край экрана. */
  .stats.control-stats { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; margin: 0 0 16px; padding: 0; }
  .control-stats .stat { min-width: 0; }
  .control-stats .stat.zero { display: none; }
  .control-stats .stat-label { white-space: normal; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: 0 0 auto; min-width: 116px; padding: 10px 12px; }
  .stat.danger, .stat.warning { order: -1; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 13px; white-space: nowrap; }

  /* Заказ в списке — карточка: № и статус, когда и зона, клиент и сумма, оплата и курьер, метки */
  .table.orders tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
  .table.orders td { width: auto; }
  .table.orders td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .table.orders td:nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  .table.orders td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .table.orders td:nth-child(5) { grid-column: 2; grid-row: 2; justify-self: end; color: var(--muted); font-size: 14px; }
  .table.orders td:nth-child(4) { grid-column: 1; grid-row: 3; }
  .table.orders td:nth-child(6) { grid-column: 2; grid-row: 3; justify-self: end; font-size: 17px; }
  .table.orders td:nth-child(7) { grid-column: 1; grid-row: 4; font-size: 14px; }
  .table.orders td:nth-child(8) { grid-column: 2; grid-row: 4; justify-self: end; font-size: 14px; color: var(--muted); }
  .table.orders td:nth-child(9) { grid-column: 1 / -1; }
  .table.orders td:nth-child(9):not(:has(.badge:not(.test))) { display: none; }  /* только «ТЕСТ» (скрыт) — без пустой полосы */
  .table.orders .cell-sub, .table.orders .staff-courier { display: inline; margin-left: 6px; }
  .table.orders .cell-sub.m-hide { display: none; }
  .table.orders .cell-sub .badge { margin: 0; }
  .table.orders td.empty { grid-column: 1 / -1; }

  /* Таблицы → карточки */
  .table-wrap, .table-wrap.fits { background: transparent; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
  .nowrap-form { flex-wrap: wrap; }
  .nowrap-form select { max-width: none; flex: 1 1 160px; }
  .table .row-form input, .table .row-form select { min-height: 44px; font-size: 16px; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { margin: 0 0 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
  .table tbody tr:hover { background: var(--surface); }
  .table td { height: auto; padding: 2px 0 !important; border: 0; }
  .table td:empty { display: none; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .table.compact tr, .card .table tr { margin: 0; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
  .table.compact tr:last-child, .card .table tr:last-child { border-bottom: 0; }
  tr.row-danger, .table tr.row-danger { box-shadow: inset 3px 0 0 var(--danger); }
  tr.row-danger td:first-child { box-shadow: none; }
  tr.row-warn, .table tr.row-warn { box-shadow: inset 3px 0 0 var(--warn-bar); }
  tr.row-warn td:first-child { box-shadow: none; }
  /* В карточке строки без отступа слева: красная полоса налезала на первые буквы («Кто», «Причина»). */
  .card .table tr.row-danger, .table.compact tr.row-danger, .table.compact tr.row-warn { padding-left: 10px; }
  /* «Всего» — линия над строкой целиком, а не над каждой ячейкой (на телефоне ячейки в строку — линия рвалась). */
  .table .total td { border-top: 0; }
  .table tr.total { border-top: 1px solid var(--line-strong); }
  /* Компактные строки: ячейки в строку с переносом — 2–3 строки на запись */
  .table.compact tr, .table.dispatch tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .table.compact td, .table.dispatch td { width: auto; }
  .table.compact td.empty, .table .m-full { width: 100%; flex-basis: 100%; }
  .table .row-title, .table .m-strong { font-weight: 600; }
  .table .m-hide, .table.orders .badge.test { display: none; }
  .table .m-push { margin-left: auto; }
  .table.days td.pct-cell { justify-content: flex-start; }
  .num, .table .num { text-align: left !important; }
  .days meter { width: 80px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dt { margin-top: 8px; font-size: 13px; }
  .dl dt:first-child { margin-top: 0; }
  .dl.sums { grid-template-columns: 1fr auto; max-width: none; gap: 6px 12px; }
  .dl.sums dt { margin-top: 0; }

  .items thead { display: none; }
  .items, .items tbody { display: block; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr auto 44px; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td, .items td:first-child, .items td:last-child { display: block; width: auto; padding: 0; }
  .items td:first-child { grid-column: 1 / -1; }
  /* Состав заказа: первая колонка — «Букет» (узкая), товар — на всю ширину сверху. */
  #items tr { grid-template-columns: 56px 1fr 1fr auto 44px; }
  #items td:first-child { grid-column: auto; }
  #items td:nth-child(2) { display: block; width: auto; padding: 0; grid-column: 1 / -1; order: -1; }
  #lines { table-layout: auto; }
  /* Приход на телефоне: позиция; коробки · кол-во · вес | цена; с расходами; брак и причина; возмещён | ×. */
  #lines tr { grid-template-columns: 1fr 1fr; }
  #lines td:nth-child(5) { grid-column: 1 / -1; }
  #lines td:last-child { justify-self: end; }
  .items .item-sum { padding-top: 0; text-align: right; }
  .items-foot .field { flex: 1 1 130px; }
  /* Числа строки состава подписаны («Букет», «Кол-во», «Цена» — data-label): шапки таблицы на телефоне нет. Поля,
     сумма и «×» — по нижнему краю, сумма — посередине высоты поля. */
  #items tr { align-items: end; }
  #items td[data-label]::before { content: attr(data-label); display: block; margin: 0 0 2px; color: var(--muted); font-size: 12px; line-height: 1.3; }
  #items .item-sum { line-height: 44px; }

  /* Итог формы заказа — одна строка у нижнего края: «Итого» и главная кнопка. «Сохранить и новый» — на компьютере
     (Ctrl+Shift+Enter). Нижней панели вкладок на форме нет. */
  .of-summary {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    flex-wrap: nowrap; gap: 12px;
    margin: 0 calc(-1 * var(--gutter)); padding: 8px var(--gutter); border-radius: 0; border-left: 0; border-right: 0;
  }
  .page-order-form .of-summary { bottom: 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .of-summary .sum-total { flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 0; }
  .of-summary .sum-total span { color: var(--muted); font-size: 13px; }
  .of-summary .form-actions { flex: 1 1 auto; min-width: 0; }
  .of-summary .form-actions > span { flex: 1 1 auto; width: auto; }
  .of-summary .form-actions .btn { flex: 1 1 auto; }
  .of-summary button[name="save_new"] { display: none; }
  /* Строка «Когда» — своей строкой над «Итого» и кнопкой; «Итого» и кнопка, как и раньше, — в одну строку. */
  .of-summary { flex-wrap: wrap; row-gap: 4px; }
  .of-summary .form-actions { flex-basis: 0; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-grid.main-kpis { grid-template-columns: 1fr; }
  .kpi-value { font-size: 24px; }
  .chart { grid-template-columns: 40px minmax(0, 1fr); column-gap: 6px; }
  .chart-y, .chart-plot { height: 160px; }
  .chart-x small { display: none; }
  .chart-tip { min-width: 150px; }
  .cards { grid-template-columns: 1fr; }
  .big-time { font-size: 30px; }
  .contact-actions { grid-template-columns: 1fr; }
  .photos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Пики на телефоне: заголовки групп «интервал → зона» — полосой между карточками, галочка — крупно */
  .table .group-head, .table .zone-head { margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .table .group-head th { display: block; padding: 12px 2px 6px !important; background: transparent; border: 0; font-size: 16px; }
  .table .zone-head td { padding: 4px 2px !important; }
  .table.dispatch .col-check { width: auto; }
  .soon-grid { grid-template-columns: 1fr; }
  .interval-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .interval-filter .btn { flex: 0 0 auto; }
  /* Контроль и отчёты: строки-карточки без высоты строки таблицы — поля идут плотно */
  .control-section .table.compact td, .table.staff td { height: auto; }
  .auth-card { padding: 24px 20px; }
  .auth-logo { margin-bottom: 20px; }
  .auth-logo img { width: 96px; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Сенсорный экран любой ширины — планшет флориста, телефон: кнопки, поля, ссылка «назад» и ссылки-отборы «Собрать в
   ближайшие…» — цель касания не меньше 44 px (на узком экране то же задаёт блок max-width: 767px выше). И всё, что там
   же увеличено для пальца, а своим правилом перебивает общие поля и кнопки: галочка с подписью («Чек пробит» — продажа
   в зале из очереди флориста), раскрывашки, сегменты, вкладки (страницы печати), поля в фильтрах и строках таблиц,
   «удалить строку», «закрыть сообщение». Раскладка (ширина вкладок, отступы) — только на узком экране. */
@media (pointer: coarse) {
  .btn, .btn.small { --btn-h: 44px; }
  .btn.big { --btn-h: 54px; }
  input[type=text], input[type=search], input[type=number], input[type=date], input[type=time], input[type=tel],
  input[type=datetime-local], input[type=password], input[type=email], input:not([type]), select, textarea {
    min-height: 44px; font-size: 16px;
  }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  input[type=file]::file-selector-button { min-height: 44px; }
  .back-link { min-height: 44px; margin-bottom: 0; }
  .menu-item { min-height: 44px; }
  .soon-block .items-short a { display: inline-flex; align-items: center; min-height: 44px; }
  .check { min-height: 44px; }
  .check label { display: flex; align-items: center; min-height: 44px; flex: 1; }
  details > summary { min-height: 44px; display: flex; align-items: center; }
  .radios div[id] label { min-height: 44px; }
  .tabs a { min-height: 44px; }
  .filters .row-form input, .filters .row-form select { min-height: 44px; font-size: 16px; }
  .filters .row-form .btn { --btn-h: 44px; }
  .table .row-form input, .table .row-form select { min-height: 44px; font-size: 16px; }
  .item-del { width: 44px; height: 44px; }
  .toast-close { width: 40px; height: 40px; margin: -8px -8px -8px 0; }
}

/* Меньше движения — по настройке системы */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Высокая контрастность Windows: рамки остаются видимыми */
@media (forced-colors: active) {
  .chip::before, .count, .sw, .chart-seg, .goal, .hbar { forced-color-adjust: none; }
  .nav-item[aria-current="page"] { outline: 2px solid CanvasText; }
  /* Выбранный сегмент и вкладка отличаются только фоном — в этом режиме фон не виден, нужна рамка */
  .radios div[id] label:has(input:checked), .tabs a[aria-current], .tabs a.active { outline: 2px solid Highlight; outline-offset: -2px; }
  /* Метка места (Эжва, Выльгорт) — тоже только фон */
  .addr-place, .place-badge, .combo-place { outline: 1px solid CanvasText; outline-offset: -1px; }
}

/* Печать: без меню и панелей */
@media print {
  .sidebar, .tabbar, .mobile-bar, .test-banner, .offline-banner, .toasts, .actions, .of-summary .form-actions, .form-actions { display: none !important; }
  .toolbar, .filters, .period-custom, .back-link, .weekly-comment .buttons, .weekly-read form { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}

/* --- Окно переписки «Чаты» (docs/inbox-design.md, раздел 4.1) ------------------------------------------------------
   ≥ 1440 px — три колонки: список 300 px, диалог, панель клиента; 768–1439 px — список и диалог, панель выезжает по
   кнопке «Клиент»; < 768 px — список, диалог и клиент отдельными экранами, кнопки не меньше 44 px. На «Чатах» до
   1600 px меню слева узкое (иконки). Высота — от оставшегося места (flex), а не константа: полосы над колонками не
   выталкивают поле ответа за край. Цвета — токены (светлая и тёмная тема). */
:root {
  /* Каналы: фон и текст значка (буквы остаются — для тех, кто не различает цвета) */
  --ch-vk-bg: #E8F0FD; --ch-vk-fg: #1D4ED8;
  --ch-hub-bg: #E3F4EA; --ch-hub-fg: #15693E;
  --ch-telegram-bg: #E0F2FE; --ch-telegram-fg: #0B5E8E;
  --ch-avito-bg: #DDF2EF; --ch-avito-fg: #0A5E5A;
  --ch-max-bg: #EEE8FD; --ch-max-fg: #5B35C4;
  --ch-sms-bg: #EEF0F3; --ch-sms-fg: #4B5361;
  --ch-call-bg: #FFEBDD; --ch-call-fg: #9A3D00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ch-vk-bg: #172338; --ch-vk-fg: #7DA7FF;
    --ch-hub-bg: #13291E; --ch-hub-fg: #4ACB8A;
    --ch-telegram-bg: #0F2533; --ch-telegram-fg: #5CC1F0;
    --ch-avito-bg: #0F2A29; --ch-avito-fg: #5ED3C9;
    --ch-max-bg: #231A3B; --ch-max-fg: #A68BFA;
    --ch-sms-bg: #22262E; --ch-sms-fg: #AEB6C2;
    --ch-call-bg: #2E1C10; --ch-call-fg: #F2A36B;
  }
}
body.page-chat .main-col { height: 100vh; height: 100dvh; }
.page-chat .main { flex: 1; min-height: 0; display: flex; flex-direction: column; max-width: none; padding-top: 16px; padding-bottom: 16px; }
.page-chat .main > * { flex: none; }
.page-chat .chat-top { align-items: center; margin-bottom: 10px; }
.page-chat .chat-top h1 { margin: 0; }
.chat-problems {
  margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius-md);
  background: var(--danger-soft); color: var(--danger-text); font-size: 14px; font-weight: 500;
}
.chat-problems > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.chat-problems > summary::-webkit-details-marker { display: none; }
.chat-problems-first { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-problems[open] .chat-problems-first { white-space: normal; }
.chat-problems-more { flex: none; padding: 1px 8px; border-radius: 999px; background: var(--surface); font-size: 12px; }
.chat-problems ul { margin: 6px 0 0; padding-left: 28px; }
.chat-alarm {
  position: sticky; top: 0; z-index: 26;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  padding: 10px var(--gutter);
  background: var(--danger); color: var(--on-danger); font-size: 14px; font-weight: 600;
}
.chat-alarm .btn { margin-left: auto; }
.page-chat .main > .chat-layout { flex: 1 1 auto; }
.chat-layout {
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; gap: 12px;
  min-height: 420px;
}
.chat-list, .chat-dialog, .chat-panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.chat-list { padding: 10px 10px 0; overflow: hidden; }
.chat-sound-bar {
  flex: none; display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 8px; padding: 8px 10px;
  border: 0; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn-text);
  font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.chat-sound-bar:hover { box-shadow: inset 0 0 0 1px var(--warn); }
.chat-tabs { flex: none; display: flex; flex-wrap: wrap; margin: 0 0 8px; }  /* не обрезаются: лишняя — строкой ниже */
.chat-tabs a { padding-left: 8px; padding-right: 8px; font-size: 13px; }
.tab-count { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--danger-soft); color: var(--danger-text); font-size: 11px; font-weight: 700; }
.chat-search { flex: none; display: flex; gap: 6px; margin: 0 0 8px; }
.chat-filter-box { flex: none; margin: -2px 0 8px; font-size: 13px; }
.chat-filter-box > summary { cursor: pointer; color: var(--muted); }
.chat-filter-box[open] > summary { margin-bottom: 6px; }
.chat-search input { flex: 1; min-width: 0; min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.chat-search .btn { flex: none; min-height: 34px; }
.chat-filters { flex: none; gap: 6px 8px; margin: 0 0 8px; }
.chat-filters label { font-size: 12px; }
.chat-filters input, .chat-filters select { min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.chat-filters .grow { flex: 1 1 100%; }
#chat-rows { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -10px; }
.chat-summary { margin: 0; padding: 4px 14px 8px; color: var(--muted); font-size: 12.5px; }
.chat-summary b { color: var(--text); }
.chat-photo-queue { margin: 0 0 6px; background: var(--warn-soft); }
.chat-photo-queue h3 { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 14px 4px; color: var(--warn-text); }
.chat-photo-queue .chat-row { border-top-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.chat-photo-queue .chat-row:hover { background: color-mix(in srgb, var(--warn) 10%, transparent); }
.chat-rows { list-style: none; margin: 0; padding: 0; }
.chat-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  color: var(--text); text-decoration: none;
}
.chat-row:hover { background: var(--surface-2); text-decoration: none; }
.chat-row.is-open { background: var(--accent-soft); }
.chat-row.brand-cd-row { box-shadow: inset 3px 0 0 var(--cd); }
.chat-row-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.chat-row-phone { flex: none; font-size: 12px; }
.chat-row.unread .chat-row-name { font-weight: 700; }
.chat-row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.chat-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); font-size: 12px; }
.chat-row-meta .badge { font-size: 11px; }
.chat-rows-empty { padding: 28px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center; }
.send-flag { padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.send-flag.failed { background: var(--danger-soft); color: var(--danger-text); }
.send-flag.uncertain { background: var(--warn-soft); color: var(--warn-text); }
.ch-badge {
  flex: none; display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  white-space: nowrap; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .01em;
}
.ch-vk { background: var(--ch-vk-bg); color: var(--ch-vk-fg); box-shadow: none; }
.ch-hub { background: var(--ch-hub-bg); color: var(--ch-hub-fg); box-shadow: none; }
.ch-telegram { background: var(--ch-telegram-bg); color: var(--ch-telegram-fg); box-shadow: none; }
.ch-avito { background: var(--ch-avito-bg); color: var(--ch-avito-fg); box-shadow: none; }
.ch-max { background: var(--ch-max-bg); color: var(--ch-max-fg); box-shadow: none; }
.ch-sms { background: var(--ch-sms-bg); color: var(--ch-sms-fg); box-shadow: none; }
.ch-call { background: var(--ch-call-bg); color: var(--ch-call-fg); box-shadow: none; }
.chat-timer { flex: none; color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chat-timer.warn { color: var(--warn-text); }
.chat-timer.alert { color: var(--danger-text); }
/* Непрочитанное — жирное имя и точка цвета акцента; красный остаётся только таймеру: в пик приоритеты читаются. */
.unread-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.avatar.xs { width: 20px; height: 20px; font-size: 10px; }
.chat-viewing { padding: 1px 6px; border-radius: 6px; background: var(--warn-soft); color: var(--warn-text); font-size: 11px; font-weight: 600; }

.chat-dialog { overflow: hidden; }
.chat-empty { margin: auto; border: 0; background: transparent; }
.chat-head {
  flex: none; display: flex; align-items: center; gap: 8px 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.chat-head.is-cd { box-shadow: inset 4px 0 0 var(--cd); }
.chat-head-main { flex: 1 1 auto; min-width: 0; }
.chat-name { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0; font-size: 16px; }
.chat-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .page-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 3px 0 0; font-size: 12.5px; }
.chat-head-actions { flex: none; flex-wrap: nowrap; gap: 6px; }
.chat-head-actions form { margin: 0; }
.chat-more .menu-sheet { min-width: 260px; }
.chat-more .menu-sheet form { margin: 0; }
.chat-more .menu-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.chat-more .row-form { padding: 6px 10px 4px; }
.chat-back { display: none; }
/* «Закрыть без ответа» частая кнопка: в шапке, пока помещается в одну строку (от 1280 px), иначе — в меню «⋯». */
.chat-head form.wide-only { display: inline-block; }
.chat-head .narrow-only, .chat-head .phone-only { display: none; }
@media (max-width: 1279px) { .chat-head form.wide-only { display: none; } .chat-head .narrow-only { display: block; } }
.chat-item-card { flex: none; margin: 8px 14px 0; padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 14px; }
.chat-photo-ready { flex: none; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin: 8px 14px 0; }
.chat-photo-ready .callout-body { flex: 1 1 220px; min-width: 0; }
.chat-photo-ready .hint { margin: 2px 0 6px; }
.chat-photo-thumb { flex: none; display: block; width: 64px; height: 64px; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.chat-photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-photo-form { margin: 4px 0 0; }
.chat-caption { margin: 2px 0; font-size: 13px; }
.chat-caption > summary { cursor: pointer; color: var(--muted); }
.chat-caption .link { color: var(--link); }
.chat-caption textarea { width: 100%; margin-top: 4px; }
.chat-photo-manual { gap: 6px; margin-top: 4px; }
.chat-photo-manual form { margin: 0; }
[data-copy-image].is-done { box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok-text); }
[data-copy-image].is-failed { box-shadow: inset 0 0 0 1px var(--warn); }
.chat-feed { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: var(--bg); }
.chat-feed-empty { margin: auto; }
.msg-row { display: flex; justify-content: flex-start; }
.msg-row.out { justify-content: flex-end; }
.msg-row.note, .msg-row.system { justify-content: center; }
.bubble {
  max-width: min(560px, 82%); padding: 8px 12px; overflow-wrap: anywhere;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs);
}
.msg-row.out .bubble { background: var(--surface-2); border-color: var(--line-strong); }
.msg-row.note .bubble { background: var(--warn-soft); border-color: transparent; }
.msg-row.st-failed .bubble { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.msg-row.st-uncertain .bubble { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
@media (prefers-color-scheme: dark) {
  /* В тёмной теме входящие и исходящие почти одного цвета — исходящим оттенок акцента. */
  .msg-row.out .bubble { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
}
.msg-system { margin: 4px 0; padding: 3px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; }
.msg-text { margin: 0; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.msg-state.ok { color: var(--ok-text); }
.msg-photo img { display: block; max-width: 240px; max-height: 240px; margin: 2px 0 4px; border-radius: 10px; }
.msg-ref { margin: 0 0 4px; }
.msg-audio { display: block; width: 260px; max-width: 100%; margin: 2px 0 4px; }
.msg-card { margin: 2px 0 6px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.msg-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 2px 0 4px; font-size: 14px; }
.msg-quote { margin: 0 0 6px; padding: 4px 10px; border-left: 3px solid var(--line-strong); color: var(--muted); font-size: 13px; }
.msg-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; padding: 6px 8px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.msg-alert.danger { background: var(--danger-soft); color: var(--danger-text); }
.msg-alert.warning { background: var(--warn-soft); color: var(--warn-text); cursor: help; }
.msg-alert form { margin: 0; }

.chat-reply { position: relative; flex: none; padding: 10px 14px 12px; border-top: 1px solid var(--line); background: var(--surface); }
/* Подсказка ИИ тестового диалога (docs/ai-assist.md): над полем ответа, сворачивается; тело — со своей прокруткой. */
.chat-ai { flex: none; padding: 0 14px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-ai-box { margin: 8px 0; }
.chat-ai-box.is-off p { margin: 0 0 6px; font-size: 14px; }
.chat-ai-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; cursor: pointer; font-size: 14px; }
.chat-ai-body { display: flex; flex-direction: column; gap: 8px; max-height: 32vh; margin-top: 8px; overflow-y: auto; font-size: 14px; }
.chat-ai-body > p, .chat-ai-body .callout { margin: 0; }
.chat-ai-summary { color: var(--text); }
.chat-ai-draft { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--accent-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-ai-subs { margin: 0; padding-left: 1.1rem; font-size: 13px; }
.chat-ai-crm { padding: 0 2px; border-radius: 4px; background: var(--ok-soft); color: var(--text); }
.chat-ai-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; }
.chat-ai-actions .hint { margin: 0; }
.chat-ai-fields dl { margin: 6px 0; }
.chat-ai-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.chat-ai-foot .hint { margin: 0; }
.chat-reply .callout { margin: 0 0 8px; }
.chat-viewing-note { margin: 0 0 6px; color: var(--warn-text); font-weight: 500; }
.chat-form textarea { width: 100%; min-height: 64px; max-height: 40vh; resize: vertical; }
.chat-form.is-busy textarea { opacity: .7; }
.chat-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.chat-counter { margin-left: auto; color: var(--muted); font-size: 12px; }
.chat-counter.over { color: var(--danger-text); font-weight: 600; }
.chat-photo-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 8px 0 0; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.chat-photo-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.chat-photo-preview .hint { flex: 1 1 160px; margin: 0; }
.chat-replies {
  position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); z-index: 5;
  max-height: 280px; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.chat-reply-item {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.chat-reply-item:hover, .chat-reply-item[aria-selected="true"] { background: var(--surface-2); }
.chat-reply-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.chat-note-box { margin: 0; }

.chat-panel { overflow-y: auto; padding: 12px 14px; }
.chat-panel-close { display: none; margin: 0 0 8px auto; }
.panel-block { margin: 0 0 12px; padding: 0 0 12px; border-bottom: 1px solid var(--line); }
.panel-block:last-child { border-bottom: 0; }
.panel-block h3 { margin: 0 0 8px; }
.panel-block .card-header { margin: 0 0 8px; }
.panel-block .card-header h3 { margin: 0; }
.panel-order { margin: 0 0 8px; font-size: 14px; }
.panel-suggest { margin: 0 0 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 14px; }
.panel-suggest p { margin: 0 0 6px; }
.chat-panel .inline { display: inline-block; margin: 0 6px 6px 0; }
.chat-panel .row-form { margin: 0 0 8px; }
.chat-panel .lookup { display: flex; flex-direction: column; gap: 6px; }
.chat-panel .lookup label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.chat-panel .lookup label.check { flex-direction: row; color: var(--text); }
.nav-item[data-sound="off"] .count, .tab-item[data-sound="off"] .count { box-shadow: 0 0 0 2px var(--warn); }

/* Заказ из чата и карточки: короткая переписка, образцы от клиента, «Отправьте фото в приложении» */
.order-chat-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; }
.order-chat-list li { overflow-wrap: anywhere; }
.order-chat-list li.out { color: var(--muted); }
.order-chat-block .order-chat-list { max-height: 360px; overflow-y: auto; }
.chat-ref-photos { margin: 10px 0 0; padding: 0; border: 0; }
.chat-ref-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-ref-photo { display: flex; flex-direction: column; gap: 4px; width: 88px; font-size: 13px; }
.chat-ref-photo img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; }
.order-photo-send { margin-top: 10px; }
.order-photo-send .radios div { flex-direction: column; align-items: flex-start; }
.order-photo-manual { margin-top: 10px; }
.order-photo-manual-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.order-photo-manual form { margin: 0 0 6px; }

/* Заказ из чата: пометка «из переписки · 14:02» у поля, подсказки «Из переписки: … [Вставить]» под полем,
   блок «Переписка» (цитаты, геометки, карточки товара) и панель «Выделенное → в поле». */
input.from-chat, select.from-chat, textarea.from-chat {
  background-color: var(--prefill-soft); border-color: var(--prefill-line);
}
.chat-summary { margin: 0 0 16px; }
.chat-slot { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 0; min-width: 0; }
.field > .chat-slot { order: 5; }
.field-row + .chat-slot, .check + .chat-slot { margin: -6px 0 10px; }
.from-chat-note {
  display: flex; align-items: center; gap: 4px; margin: 0; color: var(--prefill-text); font-size: 12.5px;
}
.from-chat-note a { color: inherit; text-decoration: underline dotted; }
.from-chat-clear {
  min-width: 24px; min-height: 24px; padding: 0 6px; border: 0; border-radius: 6px;
  background: none; color: var(--prefill-text); font: inherit; line-height: 1; cursor: pointer;
}
.from-chat-clear:hover, .from-chat-clear:focus-visible { background: var(--prefill-soft); outline: none; }
.chat-chip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 8px;
  border: 1px dashed var(--prefill-line); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 13px; overflow-wrap: anywhere;
}
.chat-chip.warn { border-style: solid; border-color: var(--warn); background: var(--warn-soft); }
.chat-chip.is-used { opacity: .6; }
.chat-chip-text a { color: inherit; text-decoration: underline dotted; }
.chat-chip-note { color: var(--muted); }
.chat-chip.warn .chat-chip-note { color: var(--warn-text); }
.chat-chip-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.chat-slot-warn { margin: 0; color: var(--warn-text); font-size: 12.5px; }
.order-chat-list .msg-quote { margin: 2px 0 4px; }
.order-chat-list .msg-geo, .order-chat-list .msg-card { display: block; margin: 2px 0 4px; }
.order-chat-list .msg-card { padding: 4px 8px; }
.order-chat-list .msg-geo .icon { vertical-align: -2px; }
.order-chat-list li { padding: 2px 4px; border-radius: 6px; transition: background-color .3s; }
.order-chat-list li.is-target { background: var(--prefill-soft); }
.chat-window { margin: 6px 0 0; }
.chat-select-bar {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 8px 0 0; padding: 8px; border: 1px solid var(--prefill-line); border-radius: var(--radius);
  background: var(--prefill-soft); box-shadow: var(--shadow-md);
}
.chat-select-title { color: var(--prefill-text); font-size: 13px; font-weight: 500; }
/* Время, «Мы:», «Пересланное:», координаты — не в выделение (тройной клик по сообщению → только текст). */
.order-chat-list .chat-meta { -webkit-user-select: none; user-select: none; }
/* Уже 1200 px «Итог / Сохранить» прилипает к низу экрана (z-index 12): панель выделения — над ним, а не под ним. */
@media (max-width: 1199px) {
  .chat-select-bar { bottom: 92px; z-index: 13; }
}
@media (max-width: 767px) {
  .chat-select-bar { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
.client-chat { margin: 0 0 10px; padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.client-chat:last-of-type { border-bottom: 0; }

/* Страница фото по ссылке из SMS (/p/<токен>/) — без меню */
.photo-link-page { min-height: 100vh; display: grid; place-items: center; }
.photo-link { max-width: 720px; padding: 24px 16px; text-align: center; }
.photo-link .wordmark { justify-content: center; margin: 0 0 16px; }
.photo-link img { display: block; max-width: 100%; margin: 0 auto 12px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }

/* 1280–1599 px (ноутбук 1366×768 — вероятный экран магазина): на «Чатах» меню слева — узкое, как на планшете. */
@media (min-width: 1280px) and (max-width: 1599px) {
  body.page-chat { --sidebar-w: 84px; }
  .page-chat .sidebar { padding: 14px 4px 10px max(4px, env(safe-area-inset-left)); align-items: stretch; }
  .page-chat .wordmark { justify-content: center; padding: 0; }
  .page-chat .brand-full, .page-chat .me-text { display: none; }
  .page-chat .brand-short { display: inline; font-size: 20px; }
  .page-chat .nav-item { flex-direction: column; justify-content: center; gap: 3px; min-height: 56px; padding: 6px 0; text-align: center; }
  .page-chat .nav-label { flex: none; max-width: 100%; font-size: 10.5px; line-height: 1.15; letter-spacing: -.01em; }
  .page-chat .nav-item .count { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 10.5px; }
  .page-chat .me { justify-content: center; padding: 6px 0 8px; }
  .page-chat .main { padding-left: 16px; padding-right: 16px; }
}
@media (min-width: 1440px) {
  .chat-panel-toggle { display: none; }
}
@media (max-width: 1439px) {
  .chat-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .chat-panel {
    display: none; position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(380px, 100%);
    border-radius: 0; box-shadow: var(--shadow-lg);
  }
  .chat-layout.panel-open .chat-panel { display: flex; }
  .chat-panel-close { display: inline-flex; }
}
@media (max-width: 1279px) {
  .chat-head-actions .btn-label { display: none; }  /* иконки с подсказками — шапка в одну строку */
}
@media (max-width: 1023px) {
  .chat-layout { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 767px) {
  body.page-chat .main-col { height: 100vh; height: 100dvh; }
  .page-chat .main { padding: 8px max(var(--gutter), env(safe-area-inset-right)) calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
  /* Открыт диалог — заголовок «Чаты» не нужен (уведомлений на телефоне всё равно нет, раздел 3.9 п. 9): место ленте. */
  .chat-has-open .chat-top { display: none; }
  .chat-has-open .chat-problems { margin-bottom: 6px; }
  .chat-layout { display: flex; flex-direction: column; min-height: 0; gap: 0; }
  .chat-layout > * { flex: 1 1 auto; }
  .chat-layout.has-open .chat-list { display: none; }
  .chat-layout:not(.has-open) .chat-dialog { display: none; }
  .chat-back { display: inline-flex; flex: none; margin: 0; min-height: 44px; }
  .chat-back .btn-label { display: none; }
  .chat-head { padding: 6px 8px; gap: 6px; }
  .chat-head-actions { flex: 0 1 auto; min-width: 0; }
  .chat-head .head-open { display: none; }            /* «Открыть в VK» — в меню «⋯»: шапка в одну строку */
  .chat-head .phone-only { display: flex; }
  .chat-photo-ready .callout-body { flex-basis: 180px; }
  .chat-photo-ready .hint { display: none; }          /* плашка фото компактная: лента важнее */
  .chat-photo-thumb { width: 48px; height: 48px; }
  .chat-caption > summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-name { font-size: 15px; }
  .chat-head .page-sub { display: none; }  /* статус, номер и таймер — в панели «Клиент» и в строке списка */
  .chat-head-actions .btn-label { display: none; }
  .chat-head-actions .btn { min-width: 44px; justify-content: center; }
  .chat-item-card { margin: 6px 8px 0; }
  .chat-photo-ready { margin: 6px 8px 0; padding: 8px 10px; }
  .chat-photo-ready .btn { width: 100%; justify-content: center; }
  .chat-feed { padding: 8px 10px; }
  .chat-reply { position: sticky; bottom: 0; padding: 8px 10px 10px; }
  .chat-form textarea { min-height: 48px; }
  .bubble { max-width: 90%; }
  .chat-row { padding: 12px; }
  .chat-head-actions .btn, .chat-form-actions .btn, .msg-alert .btn, .chat-panel .btn { min-height: 44px; }
  .chat-form-actions .btn-label { display: none; }
  .chat-form-actions .btn.primary .icon { margin: 0; }
  .chat-counter { margin-left: 0; }
}

/* --- «Имитатор клиента» (только DJANGO_DEBUG=1, views/devsim.py): лента глазами клиента — свои справа ---------------- */
.sim-tabs { margin: 0 0 16px; }
.sim-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.sim-layout > .card { margin: 0; }
.sim-clients h2 { font-size: 15px; }
.sim-client-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sim-client-list a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); }
.sim-client-list a:hover { background: var(--surface-2); text-decoration: none; }
.sim-client-list a[aria-current] { background: var(--accent-soft); }
.sim-mirror { margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.sim-mirror .hint { margin: 0 0 8px; }
.sim-phone { display: flex; flex-direction: column; gap: 12px; }
.sim-phone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.sim-feed {
  display: flex; flex-direction: column; gap: 6px; height: min(56vh, 520px); overflow-y: auto; padding: 12px;
  border-radius: var(--radius-md); background: var(--surface-2);
}
.sim-row { display: flex; justify-content: flex-start; }
.sim-row.mine { justify-content: flex-end; }
.sim-bubble {
  max-width: min(440px, 82%); padding: 8px 12px; overflow-wrap: anywhere; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs);
}
.sim-row.mine .sim-bubble { background: var(--ok-soft); border-color: transparent; }
.sim-text { margin: 0; }
.sim-text .icon { vertical-align: -2px; }
.sim-meta { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.sim-photo img { display: block; max-width: 220px; max-height: 220px; margin: 2px 0 4px; border-radius: 10px; }
.sim-empty { margin: auto; }
.sim-compose { display: flex; flex-direction: column; gap: 8px; }
.sim-compose textarea { min-height: 56px; }
.sim-compose-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sim-file { cursor: pointer; }
.sim-extra summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.sim-extra .row-form input { flex: 1; min-width: 180px; }
.sim-note { margin: 0; }
.sim-call { margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.sim-call .hint { margin: 0 0 8px; }
.sim-help h2 { font-size: 15px; }
.sim-help ol { margin: 0 0 12px; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
@media (max-width: 1279px) {
  .sim-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .sim-help { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  .sim-layout { grid-template-columns: minmax(0, 1fr); }
  .sim-phone { order: -1; }
  .sim-feed { height: 50vh; }
}

/* --- ИИ-стенд (docs/ai-lab.md, views/ai_lab.py): модели и цены, слепые карточки A, B, C…, итоги ------------------ */
.lab-models td:first-child, .lab-dialogs td:first-child { width: 40px; }
.lab-start { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.lab-start .hint { flex-basis: 100%; margin: 0; }
.lab-estimate { margin: 0; font-weight: 600; }
.lab-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.lab-progress progress { width: min(420px, 100%); height: 10px; accent-color: var(--accent); }
.lab-split { display: grid; grid-template-columns: minmax(280px, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.lab-split > .card { margin: 0; }
.lab-split > *, .lab-side { min-width: 0; }
.lab-transcript h2 small, .lab-card small { font-weight: 400; }
.lab-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 72vh; overflow-y: auto; }
.lab-transcript .lab-line { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; overflow-wrap: anywhere; }
.lab-transcript .lab-line.is-shop { background: var(--ok-soft); }
.lab-transcript .lab-line.is-new { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.lab-stamp { display: block; color: var(--muted); font-size: 12px; }
.lab-new-mark { margin: 4px 0 0; color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.lab-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 12px; margin: 0 0 16px; }
.lab-card { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.lab-card.is-empty { background: var(--surface-2); box-shadow: none; }
.lab-card h3 { margin: 0 0 8px; font-size: 17px; }
.lab-card h4 { margin: 12px 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.lab-card p { margin: 0 0 8px; overflow-wrap: anywhere; }
.lab-card ul { margin: 0; padding-left: 1.1rem; font-size: 14px; }
.lab-fields { gap: 4px 12px; font-size: 14px; }
.lab-draft { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.lab-raw { max-height: 240px; margin: 0; padding: 8px; overflow-y: auto; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.lab-ph { padding: 0 2px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); }
.lab-bad { color: var(--danger-text); font-weight: 600; text-decoration: underline wavy var(--danger); text-underline-offset: 3px; }
.lab-vote h2 { margin-top: 0; }
.lab-vote fieldset { margin: 0 0 12px; padding: 0; border: 0; }
.lab-vote legend { margin: 0 0 6px; padding: 0; font-weight: 600; }
.lab-options { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.lab-options label { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; cursor: pointer; }
.lab-vote textarea { width: 100%; min-height: 64px; margin: 6px 0 12px; }
.lab-vote .form-error { margin: 0 0 10px; color: var(--danger-text); font-weight: 600; }
.lab-reveal { margin-top: 16px; }
.lab-reveal tr.is-best td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.lab-reveal-more { margin-top: 16px; }
.lab-reveal-more h3 { margin: 0 0 8px; font-size: 15px; }
.lab-nav { display: flex; justify-content: space-between; gap: 8px; margin: 16px 0 0; }
.lab-summary-table th, .lab-summary-table td { white-space: nowrap; }
.lab-summary-table td:first-child { white-space: normal; min-width: 180px; }
.lab-help { margin-top: 16px; }
.lab-who { margin: 0 0 12px; }
.lab-voters { margin-top: 16px; gap: 16px 20px; }
.lab-voters > .card { margin: 0; }
.lab-voter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lab-comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 480px; overflow-y: auto; }
.lab-comments p { margin: 0; overflow-wrap: anywhere; }
.lab-howto-card summary { cursor: pointer; }
.lab-howto { margin: 10px 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 6px; }
.lab-help summary { cursor: pointer; }
.lab-help .dl { margin-top: 12px; }
@media (max-width: 1023px) {
  .lab-split { grid-template-columns: minmax(0, 1fr); }
  .lab-lines { max-height: none; }
}
@media (max-width: 767px) {
  .lab-reveal-more { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .lab-summary-table th, .lab-summary-table td { white-space: normal; }
}

/* --- Высоты столбцов графика (0…100 % высоты области), CSP не пускает инлайн-стили ------------------------------------ */
.h-0{height:0} .h-1{height:1%} .h-2{height:2%} .h-3{height:3%} .h-4{height:4%} .h-5{height:5%} .h-6{height:6%} .h-7{height:7%} .h-8{height:8%} .h-9{height:9%}
.h-10{height:10%} .h-11{height:11%} .h-12{height:12%} .h-13{height:13%} .h-14{height:14%} .h-15{height:15%} .h-16{height:16%} .h-17{height:17%} .h-18{height:18%} .h-19{height:19%}
.h-20{height:20%} .h-21{height:21%} .h-22{height:22%} .h-23{height:23%} .h-24{height:24%} .h-25{height:25%} .h-26{height:26%} .h-27{height:27%} .h-28{height:28%} .h-29{height:29%}
.h-30{height:30%} .h-31{height:31%} .h-32{height:32%} .h-33{height:33%} .h-34{height:34%} .h-35{height:35%} .h-36{height:36%} .h-37{height:37%} .h-38{height:38%} .h-39{height:39%}
.h-40{height:40%} .h-41{height:41%} .h-42{height:42%} .h-43{height:43%} .h-44{height:44%} .h-45{height:45%} .h-46{height:46%} .h-47{height:47%} .h-48{height:48%} .h-49{height:49%}
.h-50{height:50%} .h-51{height:51%} .h-52{height:52%} .h-53{height:53%} .h-54{height:54%} .h-55{height:55%} .h-56{height:56%} .h-57{height:57%} .h-58{height:58%} .h-59{height:59%}
.h-60{height:60%} .h-61{height:61%} .h-62{height:62%} .h-63{height:63%} .h-64{height:64%} .h-65{height:65%} .h-66{height:66%} .h-67{height:67%} .h-68{height:68%} .h-69{height:69%}
.h-70{height:70%} .h-71{height:71%} .h-72{height:72%} .h-73{height:73%} .h-74{height:74%} .h-75{height:75%} .h-76{height:76%} .h-77{height:77%} .h-78{height:78%} .h-79{height:79%}
.h-80{height:80%} .h-81{height:81%} .h-82{height:82%} .h-83{height:83%} .h-84{height:84%} .h-85{height:85%} .h-86{height:86%} .h-87{height:87%} .h-88{height:88%} .h-89{height:89%}
.h-90{height:90%} .h-91{height:91%} .h-92{height:92%} .h-93{height:93%} .h-94{height:94%} .h-95{height:95%} .h-96{height:96%} .h-97{height:97%} .h-98{height:98%} .h-99{height:99%}
.h-100{height:100%}
