/* ==========================================================================
   Дизайн-система: токены, светлая/тёмная тема, компоненты, раскладка.
   ========================================================================== */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f3;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-soft: #dcfce7;
  --accent-text: #15803d;
  --blue: #2563eb;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --tone-ink: #000;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --radius: 8px;
  --radius-sm: 6px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Cascadia Mono', Consolas, ui-monospace, 'SF Mono', monospace;
  --page: 1600px;
  color-scheme: light;
}

/* ТЕСТ (2026-11-03): тёмная тема светлее — графит вместо почти чёрного. Не понравится — вернуть прежние значения:
   --bg #16181d; --surface #1e2127; --surface-2 #23262d; --surface-3 #2a2e36; --border #2e323b;
   --border-strong #3a404a; --text #e8eaed; --muted #9aa1ac; --faint #6b7280 (в обоих блоках: dark и auto).
   Копия файла до правки: D:\база\правки внесены\app.css.до_светлой_тёмной_темы
   ТЕСТ, вариант 2 (2026-11-04): ещё на ступень светлее, карточки заметнее отделены от фона.
   Вариант 1 был: --bg #24272e; --surface #2c3038; --surface-2 #32363f; --surface-3 #3a3f49; --border #3e434d;
   --border-strong #4c525e; --text #eef0f3; --muted #a9b0bb; --faint #7d8592.
   Копия файла с вариантом 1: D:\база\правки внесены\app.css.тёмная_вариант1 */
:root[data-theme="dark"] {
  --bg: #2b2f37;
  --surface: #363b45;
  --surface-2: #3c424c;
  --surface-3: #454b57;
  --border: #4a505c;
  --border-strong: #5a616e;
  --text: #f2f4f6;
  --muted: #b6bdc7;
  --faint: #8b939f;
  --accent-soft: rgba(22, 163, 74, .16);
  --accent-text: #4ade80;
  --danger-soft: rgba(220, 38, 38, .16);
  --tone-ink: #fff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #2b2f37;
    --surface: #363b45;
    --surface-2: #3c424c;
    --surface-3: #454b57;
    --border: #4a505c;
    --border-strong: #5a616e;
    --text: #f2f4f6;
    --muted: #b6bdc7;
    --faint: #8b939f;
    --accent-soft: rgba(22, 163, 74, .16);
    --accent-text: #4ade80;
    --danger-soft: rgba(220, 38, 38, .16);
    --tone-ink: #fff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* Цвета этапов: задаётся только --dot, фон и текст вычисляются */
.tone-gray { --dot: #8b95a3; }
.tone-blue { --dot: #2563eb; }
.tone-violet { --dot: #8b5cf6; }
.tone-amber { --dot: #d97706; }
.tone-yellow { --dot: #eab308; }
.tone-orange { --dot: #f97316; }
.tone-pink { --dot: #ec4899; }
.tone-teal { --dot: #14b8a6; }
.tone-cyan { --dot: #06b6d4; }
.tone-green { --dot: #16a34a; }
.tone-red { --dot: #dc2626; }

/* ---------- база ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
a[data-href] { cursor: pointer; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--accent-text); }
.text-blue { color: var(--blue); }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- полосы прокрутки: тонкие, в цветах темы (вместо системных серых со стрелками) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); background-clip: padding-box; border: 3px solid transparent; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
/* уголок «потянуть, чтобы растянуть» у полей — две тонкие косые черты */
::-webkit-resizer { background: linear-gradient(135deg, transparent 0 52%, var(--faint) 52% 58%, transparent 58% 72%, var(--faint) 72% 78%, transparent 78%); }
@supports (-moz-appearance: none) { * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; } }

/* ---------- раскладка: шапка сверху, контент по центру ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: var(--page); margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 24px; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; min-width: 0; }
.brand-text { min-width: 0; }
.brand b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 38px; padding: 0 12px; border-radius: 6px;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active, .nav a.active:hover { background: transparent; color: var(--accent-text); } /* текущий раздел — только зелёный текст и иконка, без плашки */
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 6px; background: var(--danger); color: #fff; font: 600 11px/18px var(--font); text-align: center; }
.search { position: relative; flex: 0 1 280px; min-width: 160px; }
.search .input { height: 38px; padding-left: 36px; background: var(--surface-2); }
/* поиск в шапке: свёрнут — одна кнопка-лупа; открыт (.open) — поле, лупа слева внутри него */
.search-btn { position: absolute; left: 0; top: 0; z-index: 1; width: 38px; height: 38px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: text; }
.search:not(.open) { flex: 0 0 38px; min-width: 0; margin-left: auto; }
.search:not(.open) .input { display: none; }
.search:not(.open) .search-btn { position: static; cursor: pointer; color: var(--muted); }
.search:not(.open) .search-btn:hover { background: var(--surface-3); color: var(--text); }
.search.open { animation: search-open .14s ease-out; }
@keyframes search-open { from { opacity: .4; } to { opacity: 1; } }
.user-menu { position: relative; flex: none; }
.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 8px 0 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.user-pill:hover { border-color: var(--border-strong); }
.user-pill b { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pill svg { color: var(--faint); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 270px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.dropdown-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; color: var(--muted); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: none; font-weight: 500; text-align: left; }
.dropdown-item:hover { background: var(--surface-2); }
/* меню пользователя — со скруглениями, как было */
.dropdown .seg, .dropdown .seg button { border-radius: 999px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.muted { background: var(--surface-3); color: var(--muted); }
.content { max-width: var(--page); margin: 0 auto; padding: 22px 24px 48px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.mobile-no { display: none; }
.field > .seg { align-self: flex-start; }
.toolbar .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }

/* ---------- заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
/* счётчик — в одну строку с заголовком */
.page-head .ph-inline { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.page-head .ph-inline .sub { margin-top: 0; white-space: nowrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.back:hover { color: var(--text); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
/* полоса заголовка карточки: везде одна высота 37 px и свой тон (--surface-2), чтобы не сливалась с содержимым;
   кнопки, поиск и переключатели в ней — компактные 28 px, иначе полоса росла бы под них */
.card-h { display: flex; align-items: center; gap: 10px; min-height: 37px; padding: 4px 20px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); }
.card > .card-h:first-child { border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.card-h .btn-sm { height: 28px; padding: 0 10px; }
.card-h .icon-btn.sm { width: 28px; height: 28px; }
.card-h .input.sm { height: 28px; }
.card-h .seg { padding: 2px; }
.card-h .seg button { height: 24px; padding: 0 10px; font-size: 12.5px; }
.card-h h2 { flex: 1; min-width: 0; }
.card-h .muted { font-size: 13px; }
.card-b { padding: 18px 20px; }
.card-b.tight { padding: 8px 20px; }
.card-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card + .card { margin-top: 16px; }
.kpis .card + .card { margin-top: 0; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin: 0 0 10px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .seg button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(22, 163, 74, .25); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 11px; border-radius: 6px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 6px;
  border: 1px solid transparent; background: var(--surface-3); color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 6px; }
.icon-btn.ghost { background: transparent; }
.icon-btn.ghost:hover { background: var(--surface-3); }
/* «Удалить»: при наведении краснеет сама иконка, без красной заливки и обводки */
.icon-btn.danger:hover { background: var(--surface-3); color: var(--danger); }
.icon-btn.ghost.danger:hover { background: transparent; }

/* ---------- сегментный переключатель (тема, вкладки) ---------- */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 6px;
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s, box-shadow .12s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.square { border-radius: 8px; }
.seg.square button { border-radius: 5px; } /* 8 − 3 (отступ) — углы кнопки параллельны углам рамки */
.seg.block { display: flex; }
.seg.block button { flex: 1; justify-content: center; white-space: nowrap; }
/* новый заказ: выбор этапа «В работе / Запись» — цветная точка этапа перед названием */
.ns-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
/* приход — зелёный, расход — красный (как кнопка удаления) */
.seg button.in { color: var(--accent-text); }
.seg button.out { color: var(--cost-text); } /* расход — оранжевым, как кошелёк и плашка «Расход» */
.seg button.in.on { background: var(--accent); color: #fff; }
.seg button.out.on { background: var(--cost-strong); color: #fff; }

/* ---------- чипы и бейджи ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 34px; padding: 0 13px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
button.chip:hover, a.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip .n { font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
/* «Закрытые | Выполнены | Отказы» — слитной группой */
.chip-group { display: inline-flex; flex: none; }
.chip-group .chip { border-radius: 0; }
.chip-group .chip + .chip { margin-left: -1px; }
.chip-group .chip:first-child { border-radius: 5px 0 0 5px; }
.chip-group .chip:last-child { border-radius: 0 5px 5px 0; }
.chip-group .chip:only-child { border-radius: 5px; }
.chip-group .chip.on { position: relative; z-index: 1; }
/* выбранный фильтр: при наведении текст не должен сливаться со светлым фоном */
.chip.on, button.chip.on:hover, a.chip.on:hover { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip.on .n { color: color-mix(in srgb, var(--surface) 70%, transparent); }
/* «Новый заказ» — в ряду фильтров после «Все», того же размера */
.chip.chip-new { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
a.chip.chip-new:hover { color: #fff; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 88%, #000); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--faint)); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  height: 26px; padding: 0; border-radius: 5px;
  /* ВРЕМЕННО без цветной плашки (2026-11-04): точка + цветной текст, левый край ровно по дате.
     Вернуть: padding: 0 10px; background: color-mix(in srgb, var(--dot) 15%, transparent);
     и у .pill.lg — padding: 0 13px. */
  background: none;
  color: color-mix(in srgb, var(--dot) 72%, var(--tone-ink));
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex: none; }
.pill.lg { height: 32px; padding: 0; font-size: 13.5px; }
/* закрытый — нейтрально, как «Оплачен»: без плашки и обводки, серый замочек и текст; левый край ровно по дате под ним */
.pill.kind-done { background: none; padding: 0; color: var(--muted); font-size: 12.5px; font-weight: 500; }
/* закрытый заказ — залитый замочек вместо точки, 15 px — как иконка «Отказ» и кошелёк у «Оплачен» */
.pill.kind-done::before { background: var(--muted); width: 15px; height: 15px; border-radius: 0; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='3 2.5 18 19' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3' stroke-width='2.2'/%3E%3Crect x='5' y='10.5' width='14' height='10.5' rx='2.5' fill='%23000' stroke='none'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='3 2.5 18 19' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3' stroke-width='2.2'/%3E%3Crect x='5' y='10.5' width='14' height='10.5' rx='2.5' fill='%23000' stroke='none'/%3E%3C/svg%3E") center / contain no-repeat; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 5px;
  background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600;
}
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--accent-soft); color: var(--accent-text); }
/* в шапке заказа — того же размера, что плашка этапа (.pill.lg) */
.badge.lg { height: 32px; padding: 0 13px; gap: 6px; font-size: 13.5px; }

/* ---------- формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* подсказки марки и модели (вместо белого списка браузера) */
/* настройки → этапы: добавление над списком */
.stage-add { gap: 10px; }
/* три оттенка, чтобы зоны не сливались: заголовок чуть светлее, подсказка с добавлением — темнее
   (поле и кнопка на ней читаются светлыми), список этапов — обычный фон карточки */
.stage-card { overflow: hidden; }
/* узкая полоса заголовка тоном --surface-2: этапы и карточки услуг (45 → 37 px); скругление — у самой полосы,
   чтобы фон не выходил за углы карточки */

.stage-intro { display: grid; gap: 12px; padding: 14px 20px 16px; background: color-mix(in srgb, var(--bg) 96%, var(--text));
  border-bottom: 1px solid var(--border); }
.stage-intro p { font-size: 13px; }
.stage-intro .input, .stage-intro .btn { background: var(--surface-2); /* тот же тон, что у полосы заголовка */ border-color: var(--border-strong); }
.stage-intro .btn:hover { background: color-mix(in srgb, var(--surface-2) 90%, var(--text)); }
.combo-pop { position: fixed; z-index: 120; max-height: 280px; overflow-y: auto; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .12s ease-out; }
.combo-opt { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.combo-opt:hover, .combo-opt.on { background: var(--surface-3); }
.combo-logo { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3);
  border: 1px solid var(--border); font-weight: 700; font-size: 13px; color: var(--text); }
.combo-opt.on .combo-logo, .combo-opt:hover .combo-logo { background: var(--surface); }
.combo-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.combo-t b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-t small { font-size: 12px; color: var(--muted); }
.combo-tag { flex: none; font-size: 12px; color: var(--muted); padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s, background .12s;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:-webkit-autofill, .textarea:-webkit-autofill, .input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; -webkit-text-fill-color: var(--text); caret-color: var(--text); transition: background-color 9999s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
/* в окнах поле растёт под текст (до 260px), прокрутка — только у очень длинного */
.modal .textarea { field-sizing: content; max-height: 260px; }
.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input.sm, .select.sm { height: 34px; font-size: 13px; border-radius: 6px; }
.input.inline { border-color: transparent; background: transparent; padding: 0 8px; height: 34px; }
.input.inline:hover { border-color: var(--border); background: var(--surface); }
.input.inline:focus { background: var(--surface); }
.input.right { text-align: right; }
.input-group { position: relative; }
.input-group .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; font-size: 13px; }
.input-group .input { padding-right: 34px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grid-form .span-all { grid-column: 1 / -1; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  width: 46px; height: 28px; border-radius: 999px; flex: none;
  background: var(--border-strong); position: relative; transition: background .18s;
}
.toggle .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle.sm { font-size: 13px; }
.toggle.sm .track { width: 38px; height: 22px; }
.toggle.sm .track::after { width: 16px; height: 16px; }
.toggle.sm input:checked + .track::after { transform: translateX(16px); }

/* ---------- госномер: просто текстом ---------- */
.plate { flex: none; font-weight: 600; white-space: nowrap; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
/* регион — тем же шрифтом, что и номер */
.plate small { margin-left: 5px; font-size: 1em; font-weight: inherit; color: inherit; }
.plate-none { color: var(--faint); font-weight: 400; letter-spacing: 0; }

.plate-input { display: flex; gap: 8px; align-items: stretch; }
.plate-input .num { flex: 1; min-width: 0; text-transform: uppercase; }
.plate-input .num::placeholder { text-transform: none; }
.plate-input .reg { width: 80px; flex: none; }

/* ---------- KPI ---------- */
/* плашки итогов кассы — компактные: иконка 15 px у подписи (без фона), сумма, пояснение */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
/* цвет плашки — тонкая скруглённая полоска у левого края, с отступом сверху и снизу.
   Полоска — рамкой, а не фоном: толщину рамки браузер округляет до целых точек экрана, поэтому при масштабе
   Windows 125 % / 150 % все полоски одинаковые (фон шириной 3 px давал то 3, то 4 точки). */
.kpi { padding: 12px 16px 12px 20px; display: flex; flex-direction: column; gap: 3px; min-width: 0; position: relative; }
.kpi::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 0; border-left: 3px solid var(--dot); border-radius: 0 3px 3px 0; }
.kpi .label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-width: 0; }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .foot { font-size: 12px; color: var(--muted); } /* на узком экране переносится, суммы не обрезаются */
.kpi .bars { flex: 0 1 120px; height: 24px; margin: 0 0 4px; }
/* компактные плитки (карточка клиента) */
.kpis.kpis-sm { display: flex; flex-wrap: nowrap; gap: 8px; margin-bottom: 14px; }
@media (max-width: 720px) { .kpis.kpis-sm { flex-wrap: wrap; } }
/* плашки карточки клиента: одна строка, по ширине содержимого */
.kpi-sm { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; height: 34px; padding: 0 12px 0 5px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13px; }
.kpi-sm .ico { flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: color-mix(in srgb, var(--dot) 14%, transparent); color: var(--dot); }
.kpi-sm .ico svg { width: 14px; height: 14px; }
.kpi-sm .label { flex: none; color: var(--muted); }
.kpi-sm .value { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-sm .foot { min-width: 0; color: var(--faint, var(--muted)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- настройки → сервер ---------- */
.srv-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.srv-id { min-width: 0; }
.srv-title { font-family: var(--mono); font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.srv-sub { margin-top: 1px; font-size: 13px; color: var(--muted); }
.srv-up { flex: none; display: flex; gap: 28px; text-align: right; }
.srv-up b { display: block; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srv-up span { font-size: 12px; color: var(--muted); }
.srv-meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 10px 18px 12px; border-bottom: 1px solid var(--border); }
.srv-mh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; font-size: 13px; color: var(--muted); }
.srv-mh b { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.srv-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.srv-bar i { display: block; height: 100%; border-radius: inherit; background: var(--dot); }
.srv-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.srv-fact + .srv-fact { border-left: 1px solid var(--border); }
.srv-fact { position: relative; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px 18px; overflow: hidden; }
.srv-fact span { font-size: 12px; color: var(--muted); }
.srv-fact b { font-size: 13.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; position: relative; }
.srv-fact small { font-size: 12px; color: var(--muted); position: relative; }
.srv-spark { position: absolute; right: 0; bottom: 0; width: 120px; height: 22px; opacity: .55; pointer-events: none; }
.srv-spark polyline { fill: none; stroke: var(--dot); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.srv-spark polygon { fill: color-mix(in srgb, var(--dot) 16%, transparent); stroke: none; }
.srv-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 7px 18px; font-size: 12px; }
.srv-ver { margin-left: auto; }
/* настройки → компания: на всю ширину — слева шапка акта (живой предпросмотр), справа реквизиты, ниже два текста актов */
.co .card-h { gap: 12px; }
.co-top { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 24px; padding: 20px; border-bottom: 1px solid var(--border); }
.co-preview { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 16px 18px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); }
.co-cap { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 6px; }
.co-preview > b { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.co-preview > span:not(.co-cap) { color: var(--muted); font-size: 13.5px; }
.co-contacts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.co-contacts span { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.co-contacts svg { flex: none; margin-top: 2px; color: var(--muted); }
.co-contacts i { font-style: normal; overflow-wrap: anywhere; }
.co-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-content: start; }
.co-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 20px; }
.co-nh { display: flex; align-items: center; gap: 6px; }
.co-nh svg { color: var(--muted); }
.co-nh small { margin-left: auto; font-weight: 400; color: var(--faint); font-size: 12px; }
.co-note .textarea { min-height: 120px; }
.co-state { font-size: 13px; }
.text-warn { color: var(--warn); }
/* метка вида оплаты в заказе: предоплата / доплата / оплата / возврат */
.pay-kind { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; vertical-align: 2px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.pay-kind.prepay { background: color-mix(in srgb, var(--warn) 18%, transparent); color: color-mix(in srgb, var(--warn) 75%, var(--tone-ink)); }
.pay-kind.final, .pay-kind.full { background: var(--accent-soft); color: var(--accent-text); }
@media (max-width: 900px) { .co-top, .co-notes { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; } }
@media (max-width: 560px) { .co-fields { grid-template-columns: minmax(0, 1fr); } }
/* история нагрузки */
.srv-hist { margin-top: 12px; }
.srv-hist .card-h { flex-wrap: wrap; gap: 10px; }
.sh-sum { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.sh-sum > div { display: flex; flex-direction: column; gap: 1px; padding: 8px 18px; min-width: 0; }
.sh-sum > div + div { border-left: 1px solid var(--border); }
.sh-sum span { font-size: 12px; color: var(--muted); }
.sh-sum b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-sum small { font-size: 12px; color: var(--faint); }
.sh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sh-chart { padding: 10px 18px 8px; min-width: 0; border-bottom: 1px solid var(--border); }
.sh-chart:nth-child(odd) { border-right: 1px solid var(--border); }
.sh-ch { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.sh-ch > b { font-size: 13.5px; }
.sh-legend { display: flex; gap: 12px; color: var(--muted); font-size: 12px; }
.sh-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sh-now { margin-left: auto; color: var(--muted); font-size: 12px; }
.sh-now b { color: var(--text); font-variant-numeric: tabular-nums; }
.sh-sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--dot); flex: none; }
.sh-sw.dash { background: repeating-linear-gradient(90deg, var(--dot) 0 3px, transparent 3px 5px); }
.sh-plot { position: relative; height: 110px; }
.sh-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sh-plot .sh-gl { fill: none; stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sh-line { fill: none; stroke: var(--dot); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sh-line.dash { stroke-width: 1.25; stroke-dasharray: 3 3; opacity: .75; }
.sh-area { fill: color-mix(in srgb, var(--dot) 14%, transparent); stroke: none; }
.sh-y { position: absolute; left: 0; transform: translateY(2px); font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; pointer-events: none; }
.sh-x { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sh-rx { --dot: #2563eb; }
.sh-tx { --dot: #ea580c; }
.sh-hover { position: absolute; inset: 0; pointer-events: none; }
.sh-cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }
.sh-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px var(--surface); }
.sh-tip { position: absolute; top: 4px; margin-left: 12px; min-width: 150px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12px; z-index: 2; white-space: nowrap; }
.sh-tip.left { transform: translateX(-100%); margin-left: -12px; }
.sh-tip > div { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.sh-tip > div + div { margin-top: 3px; }
.sh-tip b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.sh-tip > .sh-tt { color: var(--text); font-weight: 600; margin-bottom: 4px; }
/* широкий экран: все 4 графика в один ряд — блок помещается на экран без прокрутки */
@media (min-width: 1280px) {
  .sh-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sh-chart:nth-child(n) { border-right: 1px solid var(--border); }
  .sh-chart:last-child { border-right: 0; }
  /* заголовок с легендой может переноситься — графики всё равно на одной линии внизу колонки */
  .sh-chart { display: flex; flex-direction: column; }
  .sh-ch { flex: 1 0 auto; align-content: flex-start; }
}
@media (max-width: 1100px) { .sh-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); } .sh-sum > div:nth-child(4) { border-left: 0; } .sh-sum > div:nth-child(n+4) { border-top: 1px solid var(--border); } }
@media (max-width: 760px) { .sh-grid { grid-template-columns: minmax(0, 1fr); } .sh-chart:nth-child(odd) { border-right: 0; }
  .sh-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sh-sum > div:nth-child(n) { border-left: 0; border-top: 1px solid var(--border); } .sh-sum > div:nth-child(-n+2) { border-top: 0; } .sh-sum > div:nth-child(even) { border-left: 1px solid var(--border); } }
@media (max-width: 720px) {
  .srv-head { flex-direction: column; }
  .srv-up { text-align: left; gap: 20px; }
  .srv-meters { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .srv-ver { margin-left: 0; }
}
@media (max-width: 900px) {
  .srv-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .srv-fact:nth-child(3) { border-left: 0; }
  .srv-fact:nth-child(n+3) { border-top: 1px solid var(--border); }
}
.bars { display: flex; align-items: flex-end; gap: 3px; height: 34px; margin-top: 4px; }
.bars span { flex: 1; min-height: 2px; border-radius: 3px 3px 1px 1px; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.bars span.today { background: var(--accent); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-grid .card + .card { margin-top: 0; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- списки ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); min-width: 0; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); }
.list-item .meta { font-size: 12.5px; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
/* «+ Клиент» — в строке вкладок справа, вровень с ними */
.toolbar .tb-add { margin-left: auto; height: 38px; }

/* таблица заказов */
/* № | Автомобиль | Клиент | Этап | Сумма | действия (адрес выезда — только в карточке заказа) */
.olist-head, .orow {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) minmax(0, 1.4fr) minmax(170px, .7fr) 224px 68px;
  gap: 18px; align-items: center; padding: 12px 20px;
}
.olist-head { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; padding-top: 7px; padding-bottom: 6px; line-height: 1.4; border-bottom: 1px solid var(--border); }
.orow { border-top: 1px solid var(--border); position: relative; transition: background .1s; height: 68px; overflow: hidden; }
.orow:first-of-type { border-top: 0; }
.orow:hover { background: var(--surface-2); }
/* полоска слева — цвет этапа заказа */
.stripe { position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--dot); pointer-events: none; }
.orow.closed .stripe { opacity: .5; }
.stripe.wr { background: var(--cost); } /* гарантийный заказ — оранжевая, как значок гарантии */
.om-card { overflow: hidden; }
.om-row { padding: 12px 18px; gap: 14px; }
.om-ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--dot) 15%, transparent); color: var(--dot); }
.om-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.om-sum { font-size: 14px; font-variant-numeric: tabular-nums; }
.orow .c-no b { display: block; font-variant-numeric: tabular-nums; }
/* время записи — справа от этапа, крупно */
.orow .st-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.orow .st-time { font-size: 16px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.orow .st-time.text-danger { color: var(--danger); }
/* разделитель дня в расписании */
/* разделитель дней — заметно светлее строк */
.oday { display: block; font-size: 14px; font-weight: 650; color: var(--text); padding: 6px 20px; background: color-mix(in srgb, var(--text) 10%, var(--surface)); border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.oday.today { background: color-mix(in srgb, var(--text) 16%, var(--surface)); }
.oday.late { color: var(--danger); }
.oday + .orow { border-top: 0; }
.orow small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orow .plate small { display: inline; font-size: 1em; }
/* закрытые заказы (закрыт, отказ) — притемнённые строки */
.orow.closed { background: var(--bg); }
.orow.closed:hover { background: var(--surface-3); }
.orow.closed b, .orow.closed .plate { color: var(--muted); }
.orow.closed small { color: var(--faint); }
.orow .c-car { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.orow .c-car > div, .orow .c-client { min-width: 0; }
.orow .c-car b, .orow .c-client b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
/* «Задача» в карточке заказа — компактно, это не главное */
/* «Задача» | «Заключение мастера» — второй ряд карточек под клиентом/автомобилем; текстом, правка — в окне */
/* по размеру — как карточки клиента/автомобиля: текст не длиннее 2 строк (целиком — в подсказке и в окне правки) */
.task-strip { display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 16px 14px 18px; }
.ts-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; cursor: pointer; }
/* «Выезд» рядом с автомобилем */
.os-main { cursor: default; gap: 8px; }
.os-top { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.os-main .toggle.sm { color: var(--muted); }
.os-main .toggle.sm input:checked ~ span:last-child { color: var(--text); font-weight: 500; }
.os-addr { display: flex; align-items: center; gap: 6px; min-width: 0; }
.os-dt { gap: 0; flex: 0 1 auto; }
.os-dt .dt-btn { width: auto; max-width: 100%; height: 34px; font-size: 13.5px; font-weight: 500; }
.os-dt .dt-btn .faint { font-weight: 400; }
/* пробег: одно поле-«плашка» — значок спидометра, число, «км» внутри; правится прямо в нём */
.ot-km { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 12px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 13px; cursor: text; transition: border-color .12s, background .12s; }
.ot-km:hover { border-color: var(--border-strong); }
.ot-km:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ot-km svg { flex: none; width: 15px; height: 15px; color: var(--faint); }
.ot-km:focus-within svg, .ot-km:not(.km-empty) svg { color: var(--muted); }
.ot-km input { width: auto; field-sizing: content; min-width: 4.5ch; max-width: 11ch; padding: 0; border: 0; outline: 0; background: none;
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
@supports not (field-sizing: content) { .ot-km input { width: 8ch; } } /* Safari/Firefox: ширина под 7–8 цифр */
.ot-km input::placeholder { color: var(--faint); font-weight: 400; }
.ot-km span { font-size: 12px; color: var(--faint); }
.os-addr .input { flex: 1; min-width: 0; }
.os-addr .icon-btn { flex: none; color: var(--accent); }
.orow .c-stage { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; max-width: 100%; }
.orow .c-sum { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; text-align: right; }
/* «Закрыт», «Оплачен» и сумма — ровно по середине строки, на одной линии; подписи («закрыт 17 дек 2024»,
   «предоплата …») не сдвигают их вверх — висят под ними */
@media (min-width: 641px) {
  .orow .c-stage, .orow .sum-v { position: relative; }
  .orow .c-stage > small { position: absolute; left: 0; top: calc(100% - 2px); white-space: nowrap; }
  .orow .sum-v > small { position: absolute; right: 0; top: calc(100% - 1px); }
}
.orow .c-sum > .sum-v:only-child { margin-left: auto; }
/* сумма фиксированной ширины — кнопки «Оплатить» стоят ровно в столбик */
.orow .sum-v { flex: none; min-width: 88px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.orow .sum-paid { font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.orow .sum-paid.part { color: color-mix(in srgb, var(--warn) 75%, var(--tone-ink)); font-weight: 600; }
.orow .sum-paid.over { color: var(--cost); font-weight: 600; } /* «по акту …» — акт не совпадает с оплатой, стоит поправить */
/* отказ и удаление в строке */
.orow .c-act { display: flex; justify-content: flex-end; gap: 2px; }
.orow .c-sum b { font-variant-numeric: tabular-nums; }
/* «Оплатить» — без рамки и фона, как «Оплачен»: иконка и текст с того же левого края; при наведении — подложка */
.pay-btn { flex: none; gap: 6px; width: 100px; height: 26px; padding: 0 0 0 13px; border-radius: 5px; font-size: 12.5px; font-weight: 600;
  justify-content: flex-start; border-color: transparent; background: transparent; box-shadow: none; }
.pay-btn:hover { background: var(--surface-3); border-color: transparent; color: var(--accent-text); }
.pay-btn svg { width: 15px; height: 15px; color: var(--accent); }
.pay-slot { flex: none; width: 100px; display: flex; }
/* «Оплачен» — без зелёной плашки: спокойный текст и галочка */
/* иконки «Оплачен» / «Отказ» стоят в одну линию (левый край общий), текст — сразу за иконкой */
.pay-slot .pay-ok { width: 100%; height: 26px; display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px;
  padding-left: 14px; color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.pay-slot .pay-ok svg { flex: none; width: 15px; height: 15px; color: var(--accent-text); }
/* «Отказ» — как «Оплачен»: без плашки и обводки, обычный текст, оранжевый перечёркнутый круг */
.pay-slot .pay-no svg { color: var(--cost); }
.orow .narrow-only { display: none; }
.more { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--border); }
/* итог внизу списка заказов: сумма — под колонкой «Сумма» */
.olist-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 56px 9px 20px;
  border-top: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 0 0 8px 8px; }
.olist-foot > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.olist-foot .of-l b { font-size: 14px; }
.olist-foot .of-r { flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.olist-foot .of-r em { font-style: normal; font-size: 13px; color: var(--muted); margin-left: 8px; }
.olist-foot .of-r b { font-size: 21px; font-variant-numeric: tabular-nums; }
.olist-foot span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .olist-foot { padding: 9px 16px; } .olist-foot .of-l span, .olist-foot .of-r > span { display: none; } .olist-foot .of-r b { font-size: 18px; } }

/* ---------- карточка заказа ---------- */
/* автомобиль и клиент — полосой под заголовком заказа */
.order-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.order-top > .card { margin: 0; }
.ot-card { display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 16px 14px 18px; }
.ot-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--muted); }
.ot-card > .avatar { width: 40px; height: 40px; font-size: 14px; flex: none; }
.ot-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ot-main.faint { align-self: center; }
.ot-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 16px; line-height: 1.25; }
.ot-title .muted { font-size: 13.5px; }
.ot-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.ot-link svg { color: var(--faint); }
/* телефон клиента — крупно: по нему звонят чаще всего */
.ot-phone { flex: none; height: 40px; padding: 0 16px; font-size: 16.5px; font-weight: 650; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
/* оба номера — одного размера и без рамки: просто крупный номер, при наведении — лёгкая подложка */
.ot-phones .ot-phone { height: 32px; padding: 0 10px; border-color: transparent; background: transparent; box-shadow: none; justify-content: flex-start; }
.ot-phones .ot-phone:hover { background: var(--surface-3); }
.ot-nophone { flex: none; font-size: 13px; }
/* оба номера клиента справа: основной крупно, второй под ним поменьше */
.ot-phones { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.crow .c-phone small { display: block; font-size: inherit; color: inherit; } /* второй номер того же размера и цвета, что и первый */
.add-phone2 { margin-top: 8px; }
/* новый заказ: поля клиента одно под другим — карточка узкая, ряды совпадают с рядами «Автомобиля» */
.nc-form { grid-template-columns: minmax(0, 1fr); }
/* сводка под именем клиента: заказы, с какого времени, сколько оплатил, почта */
/* «·» стоит перед каждым пунктом; полоса 20px слева обрезана — точка в начале строки (и после переноса) не видна */
.ot-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin-left: -20px; clip-path: inset(-4px -4px -4px 20px); font-size: 13px; color: var(--muted); }
/* точка-разделитель — внутри пункта, в его левом отступе: если пункт переносится на 2 строки (телефон),
   вторая строка начинается после отступа и не попадает под обрезку слева («по 3 заказам», а не «по 3 азам») */
.ot-sub > * { position: relative; display: inline-block; max-width: 100%; padding-left: 20px; }
.ot-sub > *::before { content: '·'; position: absolute; left: 0; top: 0; width: 20px; text-align: center; color: var(--faint); }
.ot-sub a { color: var(--muted); overflow-wrap: anywhere; }
.ot-sub a:hover { color: var(--text); }
.ot-sub .i { vertical-align: -2px; margin-right: 4px; }
.ot-new { color: var(--accent-text); font-weight: 600; }
/* узкий экран: телефон клиента — отдельной строкой под именем, на всю ширину */
@media (max-width: 560px) {
  .ot-card[data-s="client"] { flex-wrap: wrap; }
  .ot-card[data-s="client"] > .icon-btn { order: 1; }
  .ot-card[data-s="client"] > .ot-phones, .ot-card[data-s="client"] > .ot-nophone { order: 2; flex: 1 1 100%; margin-left: 54px; }
  .ot-phones .ot-phone { justify-content: center; }
}
.ot-facts { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; font-size: 13.5px; }
.ot-vin { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.ot-vin .mono { letter-spacing: .02em; }
.ot-note { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.order-grid .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.order-grid .card + .card { margin-top: 0; }
/* карточка заказа плотнее — меньше листать */
.order-grid .card-h { padding-left: 18px; padding-right: 18px; }
.order-grid .card-b { padding: 14px 18px; }
.order-grid .card-b.tight { padding: 4px 18px; }
/* «Автомобиль | Запись и выезд» — ряд внутри левой колонки */
.order-grid .order-top { margin-bottom: 0; }
/* этап заказа: плашка в заголовке открывает список этапов */
.stage-menu { position: relative; }
.stage-btn { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.stage-btn:hover { color: var(--text); } /* при наведении без плашки-фона — светлеет только стрелка */
/* в шапке карточки заказа замок «Закрыт» — оранжевый (в списке заказов — серый) */
.stage-btn .pill.kind-done::before { background: var(--cost); }
.stage-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 210px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); }
.stage-pop .step { width: 100%; }
.stage-pop .step.cancel { margin-left: 0; }
.stage-pop .step-sep { width: auto; height: 1px; margin: 4px 6px; }
.step {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 36px; padding: 0 13px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.step:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.step:disabled { cursor: not-allowed; opacity: .55; }
/* закрытый заказ: оплата не принимается */
.closed-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.closed-note svg { flex: none; margin-top: 1px; color: var(--cost); }
.step .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); flex: none; }
.step .ic svg { width: 11px; height: 11px; stroke-width: 3; }
.step.passed { color: var(--text); }
.step.passed .ic { background: var(--dot); border-color: var(--dot); color: #fff; }
.step.current { background: color-mix(in srgb, var(--dot) 14%, transparent); color: color-mix(in srgb, var(--dot) 72%, var(--tone-ink)); font-weight: 650; border-color: color-mix(in srgb, var(--dot) 35%, transparent); }
.step.current .ic { border-color: var(--dot); background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 25%, transparent); }
.step.cancel { margin-left: auto; color: var(--danger); }
.step.cancel.current { color: #fff; background: var(--danger); }
.step-sep { width: 1px; background: var(--border); margin: 6px 4px; flex: none; }

.big-contact { display: flex; flex-direction: column; gap: 14px; }
.ct-phones { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ct-phone { height: 48px; padding: 0 20px; gap: 10px; font-size: 20px; font-weight: 650; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.ct-phone .i { width: 20px; height: 20px; color: var(--accent); }
.ct-phone2 { height: 48px; padding: 0 16px; gap: 8px; font-size: 15.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.ct-phone2 small { font-size: 11.5px; font-weight: 500; color: var(--faint); }
.ct-line { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.ct-line > .i { flex: none; }
.ct-note { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.ct-note > .i { flex: none; margin-top: 2px; }

.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.items td { padding: 2px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.items .input.inline { height: 30px; }
.items textarea.item-name { display: block; width: 100%; height: 30px; min-height: 30px; padding: 5px 8px; resize: none; overflow: hidden;
  line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.items tr:last-child td { border-bottom: 0; }
.items .c-kind { width: 40px; } .items .c-qty { width: 82px; } .items .c-price { width: 120px; } .items .c-sum { width: 112px; text-align: right; padding-right: 10px; font-weight: 600; font-variant-numeric: tabular-nums; } .items .c-del { width: 40px; }
.items th.c-sum { text-align: right; }
.items .kind { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; background: var(--surface-3); color: var(--muted); }
.items .kind.part { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #d97706; }
/* работы: добавление — в заголовке карточки, «своя позиция» раскрывается под ним */
.items-head { flex-wrap: wrap; row-gap: 8px; }
.items-add { display: flex; gap: 8px; }
.items-add .svc-btn { width: 250px; }
.svc-btn > span { flex: 1; text-align: left; }
.svc-btn > .i:last-child { color: var(--faint); }
.svc-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* выбор услуги из каталога: окно, все услуги плитками */
.modal.wide.svc-modal { max-width: 940px; }
.svc-modal .modal-b { padding-top: 14px; }
/* плитки услуг: цвет категории — тонкая полоска слева (как у плашек кассы) */
.svc-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.svc-tile { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: 86px; padding: 10px 12px 10px 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background .12s, border-color .12s; }
.svc-tile::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 0; border-left: 3px solid var(--dot); border-radius: 0 3px 3px 0; }
.svc-tile:hover, .svc-tile:focus-visible { outline: 0; background: color-mix(in srgb, var(--dot) 10%, var(--surface-2)); border-color: color-mix(in srgb, var(--dot) 45%, transparent); }
.svc-cat-name { font-size: 11.5px; color: var(--muted); }
.svc-name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.svc-foot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.svc-foot small { margin-right: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--accent-text); }
.svc-foot small .i { width: 12px; height: 12px; }
.svc-price { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.svc-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 16px; color: var(--muted); font-size: 13.5px; text-align: center; }
@media (max-width: 900px) { .svc-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .svc-tiles { grid-template-columns: minmax(0, 1fr); } .svc-tile { min-height: 0; } }
/* затраты по заказу: список, прибыль; окно добавления — плитки статей */
/* «+ Затрата»: мягкая оранжевая плашка, плюс в залитом кружке; при наведении — заливка */
:root { --cost-text: #c2410c; }
:root[data-theme="dark"] { --cost-text: #fb923c; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --cost-text: #fb923c; } }
.cost-add-btn { margin-left: auto; gap: 7px; padding: 0 12px 0 5px; border-radius: 999px; font-weight: 600;
  background: var(--cost-soft); border-color: color-mix(in srgb, var(--cost) 35%, transparent); color: var(--cost-text); }
.cost-add-plus { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--cost-strong); color: #fff; transition: transform .15s; }
.cost-add-btn:hover { background: var(--cost-strong); border-color: var(--cost-strong); color: #fff; box-shadow: 0 2px 8px rgba(234, 88, 12, .3); }
.cost-add-btn:hover .cost-add-plus { background: #fff; color: var(--cost-strong); transform: rotate(90deg); }
.cost-list { padding: 2px 18px; }
/* файлы заказа (архивы .zip) */
.files-card { transition: box-shadow .12s, border-color .12s; }
.files-card > .mc-h:last-of-type { padding-bottom: 14px; }
.files-card.drop { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.files-card.uploading { opacity: .7; pointer-events: none; }
.file-list { padding: 0 20px 8px; }
/* фото заказа: только значки без подписей; клик — просмотр на весь экран, крестик в углу (при наведении) — удалить */
.photo-icons { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.photo-cell { position: relative; }
.photo-ic { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--blue); cursor: zoom-in; transition: background .12s, border-color .12s; }
.photo-ic:hover { background: color-mix(in srgb, var(--blue) 12%, var(--surface-2)); border-color: color-mix(in srgb, var(--blue) 45%, var(--border)); }
.photo-ic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; display: grid; place-items: center; padding: 0; border: 1px solid var(--border-strong);
  border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s; }
.photo-x svg { width: 11px; height: 11px; }
.photo-cell:hover .photo-x, .photo-x:focus-visible { opacity: 1; }
.photo-x:hover { color: var(--danger); border-color: var(--danger); }
@media (hover: none) { .photo-x { opacity: 1; } }
.file-th { padding: 0; overflow: hidden; border: 1px solid var(--border); cursor: zoom-in; }
.file-th img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* просмотр фото */
.iv-open { overflow: hidden; }
.iv { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: rgb(8 9 12 / .94); color: #f2f4f6; animation: fade .14s ease-out; }
.iv-bar { display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 20px; }
.iv-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.iv-t b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-t small { font-size: 12px; color: #aab1bb; }
.iv-n { margin-right: 8px; font-size: 13px; color: #aab1bb; font-variant-numeric: tabular-nums; }
.iv .icon-btn { color: #e6e9ed; }
.iv .icon-btn:hover { background: rgb(255 255 255 / .1); }
.iv .icon-btn.danger:hover { color: #ff7b72; }
.iv-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 64px 20px; }
.iv-stage img { flex: none; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgb(0 0 0 / .5); transition: opacity .15s; user-select: none; }
.iv-stage img.loading { opacity: .35; }
.iv-nav { position: absolute; top: 50%; width: 44px; height: 44px; margin-top: -32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgb(255 255 255 / .08); color: #fff; cursor: pointer; }
.iv-nav:hover { background: rgb(255 255 255 / .18); }
.iv-nav.prev { left: 12px; }
.iv-nav.next { right: 12px; }
.iv.single .iv-nav { display: none; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.file-ic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--muted); }
.file-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.file-t a { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-t small { font-size: 12px; color: var(--faint); }
/* Настройки → Файлы */
.fl-h { flex-wrap: wrap; gap: 6px 14px; }
.fl-h h2 { flex: none; }
.fl-h .muted { flex: 1; min-width: 0; font-size: 13px; }
.fl-q { width: 300px; }
.fl-row { display: grid; grid-template-columns: 30px minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border); }
.fl-order { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.fl-order b { flex: none; font-variant-numeric: tabular-nums; }
.fl-order .pill { flex: none; }
.fl-order span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.fl-act { display: flex; gap: 2px; }
@media (max-width: 760px) {
  .fl-q { width: 100%; }
  .fl-row { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 10px 16px; }
  .fl-order { grid-column: 2 / 4; grid-row: 2; }
}
/* «Оплата» и «Затраты» — одна карточка: затраты отдельным разделом под оплатой */
.pay-h { justify-content: space-between; }
.pay-h > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pay-h h2 { display: inline-flex; align-items: center; gap: 7px; }
.pay-h small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pay-h > b { flex: none; font-size: 20px; font-variant-numeric: tabular-nums; }
.pay-h.ok h2 { color: var(--accent-text); }
.pay-h.ok > b { color: var(--text); } /* сумма — светлым, зелёная только надпись */
/* первый платёж сразу под заголовком — без лишней линии */
.money-card .pay-h + .card-b > div:first-child > .row:first-child { border-top: 0 !important; padding-top: 0 !important; }
.money-card .mc-costs { border-top: 1px solid var(--border); }
.mc-h { display: flex; align-items: center; gap: 10px; padding: 14px 20px 6px; }
.mc-costs > .mc-h:last-child { padding-bottom: 14px; } /* затрат нет — только строка с кнопкой */
.mc-h h3 { flex: 1; min-width: 0; margin: 0; font-size: 14.5px; font-weight: 600; }
.mc-h h3 .faint { font-weight: 500; }
.mc-h .cost-add-btn { height: 30px; }
.money-card .cost-list { padding: 2px 20px; }
.money-card .cost-total { margin: 0 20px; }
.money-card .profit-box { margin: 0 20px 8px; }
/* «Итого затрат» — оранжевая плашка в пару к зелёной «Прибыли» */
.cost-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 18px; padding: 12px 0 10px; border-top: 1px solid var(--border-strong); color: var(--cost-text); }
.cost-total > div { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.cost-total small { font-size: 12px; font-weight: 400; opacity: .8; }
.cost-total > b { font-size: 18px; font-variant-numeric: tabular-nums; }
.cost-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cost-item:last-child { border-bottom: 0; }
:root { --cost: #f97316; --cost-strong: #ea580c; --cost-soft: color-mix(in srgb, #f97316 15%, transparent); }
.btn-cost { background: var(--cost-strong); border-color: var(--cost-strong); color: #fff; box-shadow: 0 1px 2px rgba(234, 88, 12, .25); }
.btn-cost:hover { background: #c2410c; border-color: #c2410c; }
.cost-ic { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--cost-soft); color: var(--cost); }
.cost-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.cost-t b { font-size: 14px; }
.cost-t span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.cost-t small { font-size: 12px; color: var(--faint); }
.cost-sum { flex: none; font-variant-numeric: tabular-nums; color: var(--cost); }
.cost-del { flex: none; margin-right: -6px; }
@media (hover: hover) { .cost-del { opacity: 0; } .cost-item:hover .cost-del, .cost-del:focus-visible { opacity: 1; } }
.profit-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 18px 6px; padding: 10px 0 12px; border-top: 1px solid var(--border); color: var(--accent-text); }
.profit-box > div { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.profit-box small { font-size: 12px; font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; }
.profit-box > b { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--text); } /* сумма прибыли — белым (основной цвет текста) */
.profit-box.neg, .profit-box.neg > b { color: var(--danger); } /* убыток — красным */
.cost-amount .input { height: 52px; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cost-amount .suffix { font-size: 18px; }
.cost-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cost-cat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.cost-cat:hover { border-color: var(--border-strong); color: var(--text); }
.cost-cat.on { border-color: var(--cost); background: var(--cost-soft); color: var(--cost); }
.cost-amount .input:focus { border-color: var(--cost); box-shadow: 0 0 0 3px var(--cost-soft); }
.cost-cat .i { width: 20px; height: 20px; }
.cost-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 9px; background: var(--surface-2); font-size: 13.5px; color: var(--muted); }
.cost-preview b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .cost-cats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; } }
/* кнопка «Реклама» в шапке заказа и её меню */
/* как соседние кнопки; источник виден только по цвету иконки-метки и подписи */
.ad-btn[class*="tone-"] > .i { color: var(--dot); }
.ad-pop { left: auto; right: 0; min-width: 220px; }
.ad-pop-h { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.ad-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.ad-opt:hover, .ad-opt:focus-visible { background: var(--surface-3); outline: 0; }
.ad-opt .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.ad-opt.tone-gray .dot { background: transparent; border: 1.5px solid var(--faint); }
.ad-opt.on { font-weight: 600; }
.ad-opt .i { color: var(--accent); }
.items-lock { display: inline-flex; align-items: center; gap: 6px; }
.items-lock .i { color: var(--cost); }
.items-empty { padding: 14px 18px; color: var(--muted); font-size: 13.5px; }
.add-custom { display: grid; grid-template-columns: auto minmax(0, 1fr) 80px 110px auto; gap: 8px; align-items: center; padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }

.due-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 0; font-weight: 600; }
.due-banner.ok { color: var(--accent-text); }
.due-banner > span { display: inline-flex; align-items: center; gap: 7px; }
.due-banner > span > .i { flex: none; width: 18px; height: 18px; }
.due-banner b { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--text); }
.due-banner > div { display: flex; flex-direction: column; gap: 2px; }
.due-banner small { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.pay-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding-top: 4px; }
.pay-form .span { grid-column: 1 / -1; }

.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 6px 0; position: relative; }
.tl::before { content: ''; position: absolute; left: 12.5px; top: 32px; bottom: -6px; width: 1px; background: var(--border); }
.tl:last-of-type::before { display: none; }
.tl .tl-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.tl .tl-ic svg { width: 14px; height: 14px; }
.tl-more { align-self: flex-start; margin: 4px 0 0 30px; }
.tl.comment .tl-ic { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.tl .tl-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-link { color: var(--blue); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); }
.tl-link:hover { border-bottom-color: var(--blue); }
/* комментарий — нейтральный серый «пузырь», на ступень светлее карточки, чтобы не сливался с тёмной страницей */
.tl.comment .tl-text {
  background: var(--surface-3); border: 1px solid var(--border-strong);
  padding: 7px 12px; border-radius: 4px 8px 8px 8px; margin-top: 3px;
}
.tl .tl-meta { font-size: 12px; color: var(--faint); }
/* удалить комментарий (только админ): корзинка в строке автора, видна при наведении на комментарий */
.tl.comment .tl-meta { display: flex; align-items: center; gap: 4px; color: var(--muted); }
/* корзинка — в конце самого комментария (справа в пузыре, по центру по высоте), видна при наведении на комментарий */
.tl.comment .tl-text.has-del { position: relative; padding-right: 40px; }
.tl-text .tl-del { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); }
.tl-del { margin-left: auto; display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px;
  background: none; color: var(--faint); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s, background .12s; }
.tl-del svg { width: 13px; height: 13px; }
.tl:hover .tl-del, .tl-del:focus-visible { opacity: 1; }
.tl-del:hover { color: var(--danger); }
@media (hover: none) { .tl-del { opacity: 1; } }
/* пробный вид комментариев (вариант 1, 2026-11-04): лента с аватарами, текст без рамки.
   Прежний вид (.tl выше) не удалён — переключатель COMMENT_FEED в order.js */
.cfeed { gap: 2px; }
.cf { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; margin: 0 -10px; padding: 7px 10px; border-radius: 8px; transition: background .12s; }
.cf:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.cf-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  --c: #3b82f6; background: color-mix(in srgb, var(--c) 20%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.cf-av.c0 { --c: #f59e0b; } .cf-av.c1 { --c: #10b981; } .cf-av.c2 { --c: #3b82f6; }
.cf-av.c3 { --c: #a855f7; } .cf-av.c4 { --c: #ec4899; } .cf-av.c5 { --c: #14b8a6; }
.cf-body { min-width: 0; }
.cf-meta { display: flex; align-items: baseline; gap: 8px; line-height: 1.3; }
.cf-meta b { font-size: 13.5px; font-weight: 600; }
.cf-meta time { font-size: 12px; color: var(--faint); }
.cf-meta .tl-del { align-self: center; }
.cf:hover .tl-del { opacity: 1; }
.cf-text { margin-top: 2px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cfeed .tl-more { margin-left: 30px; }
.comment-box { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
/* заголовок блока «Комментарии» — ниже обычного */
.comment-box .textarea { flex: 1; min-height: 40px; height: 40px; max-height: 180px; padding-top: 9px; padding-bottom: 9px; resize: none; }
.comment-box .btn { height: 34px; padding: 0 12px; flex: none; font-size: 13px; margin-bottom: 3px; } /* компактная, как «Добавить» в настройках; по нижнему краю поля */

/* ---------- новый заказ ---------- */
/* новый заказ: Клиент | Автомобиль, ниже Выезд и реклама | Дата записи и «Создать заказ»; в ряду карточки одной высоты */
.new-order { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 16px; align-items: stretch; max-width: 1180px; }
.new-order > .card:nth-child(1) { grid-column: span 10; }
.new-order > .card:nth-child(2) { grid-column: span 14; }
.new-order > .card:nth-child(3) { grid-column: span 13; }
.new-order > .card:nth-child(4) { grid-column: span 11; }
.new-order > .card { display: flex; flex-direction: column; margin: 0; }
.new-order > .card > .card-b { flex: 1; }
.new-order-go > .card-b { display: flex; flex-direction: column; gap: 14px; }
.nog-row { display: flex; align-items: center; gap: 8px; }
.nog-row .dt-btn { flex: 0 1 260px; min-width: 0; }
.nog-hint { font-size: 12.5px; }
.new-order-go [data-submit] { flex: none; margin-left: auto; height: 40px; padding: 0 14px; gap: 6px; }
.sugg:not(:empty) { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.sugg-h { padding: 8px 14px; font-size: 12.5px; background: var(--surface-2); }
.sugg .list-item { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: var(--surface); text-align: left; padding: 10px 14px; }
.sugg .list-item:hover { background: var(--surface-2); }
.sugg .plates { display: flex; gap: 6px; flex: none; }
.picked { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 8px; border: 1.5px solid var(--accent); background: var(--accent-soft); }
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px 6px 8px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 500; }
.pick:hover { border-color: var(--border-strong); }
.pick.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- клиенты ---------- */
.crow-head, .crow { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr) minmax(0, 1.8fr) 100px 110px; gap: 14px; align-items: center; padding: 11px 20px; }
.crow-head { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.crow { border-top: 1px solid var(--border); transition: background .1s; }
.crow-head + .crow { border-top: 0; }
.crow:hover { background: var(--surface-2); }
.crow .c-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crow .c-name b { font-weight: 600; }
.crow .c-cars { display: flex; flex-wrap: nowrap; gap: 4px 16px; min-width: 0; overflow: hidden; }
.crow .c-cars .more-cars { flex: none; padding: 0 8px; border-radius: 5px; background: var(--surface-3); color: var(--muted); font-size: 13px; }
.crow .c-cars > span { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crow .c-orders, .crow .c-last, .crow-head .c-orders, .crow-head .c-last { text-align: right; white-space: nowrap; }
.vehicle-tile { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.vehicle-tile:first-child { border-top: 0; }
/* список автомобилей: машина · госномер · владелец · заказы — имя владельца целиком, без обрезки */
.veh-row { display: grid; grid-template-columns: 36px minmax(0, 1.2fr) 150px minmax(0, 1fr) 110px; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--text); }
.veh-row:first-child { border-top: 0; }
.veh-row:hover { background: var(--surface-2); }
.veh-ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--muted); }
.veh-car { min-width: 0; }
.veh-car b { display: block; font-size: 14.5px; }
.veh-car .muted, .veh-owner .muted { font-size: 12.5px; }
.veh-car .mono { letter-spacing: .02em; }
.veh-owner { display: flex; align-items: center; gap: 10px; min-width: 0; }
.veh-owner .avatar { flex: none; width: 30px; height: 30px; font-size: 11px; }
.veh-name { line-height: 1.3; overflow-wrap: anywhere; }
.veh-orders { justify-self: end; padding: 3px 10px; border-radius: 99px; background: var(--surface-3); font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.veh-orders.zero { background: transparent; color: var(--faint); font-weight: 500; }
@media (max-width: 900px) {
  .veh-row { grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "i c c" "i p n" "i o o"; gap: 8px 14px; padding: 12px 16px; }
  .veh-ic { grid-area: i; align-self: start; } .veh-car { grid-area: c; } .veh-plate { grid-area: p; }
  .veh-owner { grid-area: o; } .veh-orders { grid-area: n; }
}

/* ---------- касса ---------- */
.pay-row { display: grid; grid-template-columns: 62px 36px 140px minmax(0, 260px) minmax(0, 1fr) 130px 34px; gap: 14px; align-items: center; height: 64px; padding: 0 20px; border-top: 1px solid var(--border); }
/* строки одной высоты: всё в одну строку, лишнее — многоточием */
.pay-row .p-date, .pay-row .p-date > div, .pay-row .p-amount { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* авто по заказу или комментарий к расходу; комментарий — до двух строк */
.pay-row .p-info { min-width: 0; }
.pay-row .p-note { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pay-row:first-child { border-top: 0; }
/* номер заказа — первым столбцом, белым и крупно */
.pay-row .p-no { font-size: 17px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* журнал действий: заказ и Настройки → Журнал */
.alog-filters { display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); }
.alog-filters .select { width: 200px; }
.alog-day { padding: 8px 20px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.alog-day:first-child { border-top: 0; }
.alog-row { display: grid; grid-template-columns: 44px 28px minmax(0, 1fr) 150px 110px; gap: 12px; align-items: center; padding: 9px 20px; border-top: 1px solid var(--border); font-size: 13.5px; }
.alog-day + .alog-row { border-top: 0; }
.alog-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.alog-ic { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: color-mix(in srgb, var(--dot) 14%, transparent); color: var(--dot); }
.alog-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.alog-no { font-weight: 650; color: var(--text); }
.alog-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alog-ip { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.alog-row.is-view, .alog-row.is-view .alog-who { color: var(--muted); }
@media (max-width: 720px) {
  .alog-row { grid-template-columns: 40px 26px minmax(0, 1fr); grid-template-areas: "t i x" "t i w"; row-gap: 2px; padding: 9px 16px; }
  .alog-time { grid-area: t; } .alog-ic { grid-area: i; } .alog-text { grid-area: x; }
  .alog-who { grid-area: w; font-size: 12px; color: var(--muted); } .alog-ip { display: none; }
  .alog-day { padding: 8px 16px; }
  .alog-filters .select { width: 100%; }
  .alog-filters .row { flex-wrap: wrap; }
}
.pay-ic { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; }
/* без фона-плашки: только цветной кошелёк — приход зелёный, расход оранжевый (как «Расходы» заказа) */
.pay-ic.in { color: var(--accent-text); }
.pay-ic.out { color: var(--cost); }
/* суммы в списке кассы: приход — обычным (белым) текстом, расход — оранжевым, как кошелёк расхода */
.amount-in { color: var(--text); font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.amount-out { color: var(--cost-text); font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- настройки ---------- */
/* этапы: плоский список — без рамок у полей; название и тип правятся по клику, порядок — перетаскиванием за ручку */
.stage-row { display: grid; grid-template-columns: 24px 12px minmax(0, 1fr) auto auto 30px; grid-template-areas: "g d n k t x";
  gap: 12px; align-items: center; height: 42px; padding: 0 14px 0 12px; border-top: 1px solid var(--border); background: var(--surface); }
.stage-row:first-child { border-top: 0; }
.stage-grip { grid-area: g; width: 24px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--muted); cursor: grab; touch-action: none; opacity: .6; }
.stage-row:hover .stage-grip, .stage-grip:focus-visible { opacity: 1; }
.stage-grip:hover { color: var(--text); }
.stage-row.dragging { position: relative; z-index: 2; background: var(--surface-2); box-shadow: 0 6px 18px rgb(0 0 0 / .25); border-top-color: transparent; }
.stage-row.dragging, .stage-row.dragging .stage-grip { cursor: grabbing; }
.stage-dot { grid-area: d; width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%; background: var(--dot); cursor: pointer; transition: box-shadow .12s; }
.stage-dot:hover, .stage-dot:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot) 30%, transparent); outline: none; }
.stage-name { grid-area: n; min-width: 0; height: 30px; margin-left: -8px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: text; }
.stage-name:hover { border-color: var(--border); }
.stage-name:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.stage-kind { grid-area: k; appearance: none; height: 28px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12.5px; text-align: right; cursor: pointer; }
.stage-kind:hover, .stage-kind:focus-visible { background: var(--surface-3); color: var(--text); outline: none; }
.stage-kind option { background: var(--surface); color: var(--text); }
.stage-on { grid-area: t; } .stage-del { grid-area: x; }
.stage-row.off .stage-name, .stage-row.off .stage-dot, .stage-row.off .stage-kind { opacity: .45; }
/* услуги: добавление сверху, категории карточками в два столбца */
.newsvc { display: grid; grid-template-columns: minmax(0, 1fr) 112px 118px; gap: 6px; padding: 10px 12px 12px 16px; }
.svc-add .card-h h2 { display: flex; align-items: center; gap: 8px; }
/* поля новой услуги — как в строках услуг: та же высота, цена той же ширины и ровно над ценами в списке
   (118px справа = переключатель + две кнопки строки) */
.newsvc [name=category] { grid-column: 1 / 3; }
.newsvc [data-add] { height: 34px; width: 100%; grid-column: 3; grid-row: 1; }
.svc-cols { columns: 2 460px; column-gap: 16px; }
/* марки и модели */
.newcm { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 118px; gap: 6px; padding: 10px 12px 4px 16px; }
.newcm [data-add] { height: 34px; width: 100%; }
.cm-hint { margin: 0; padding: 6px 16px 14px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.cm-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 14px; }
.cm-chip { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 11px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; font-weight: 500; }
.cm-chip button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--faint); cursor: pointer; }
.cm-chip button:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.cm-chip button .i { width: 13px; height: 13px; }
.svc-cols > .card { break-inside: avoid; margin: 0 0 16px; }
.svc-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px 46px 30px 30px; gap: 6px; align-items: center; padding: 7px 12px 7px 16px; border-top: 1px solid var(--border); }
.svc-cat .card-h + .svc-row { border-top: 0; }
.svc-row .toggle { margin: 0 4px; }
.svc-row.off .s-name, .svc-row.off .input-group { opacity: .5; }

/* отметки заказа: реклама и гарантия */
.ad-chips { display: inline-flex; flex-wrap: wrap; gap: 2px; align-self: flex-start; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.ad-chips .chip { height: 30px; padding: 0 12px; gap: 7px; justify-content: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.ad-chips .chip:hover { background: var(--surface-3); color: var(--text); }
.ad-chips .chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.ad-chips .chip.on, .ad-chips .chip.on:hover { background: color-mix(in srgb, var(--dot) 24%, var(--surface)); color: var(--text); }
.wr-badge svg { color: var(--cost); }
/* «Открыть по гарантии» в шапке заказа — щит оранжевым, как замок у закрытого заказа */
.btn[data-act="warranty"] > .i { color: var(--cost); }
.wr-tag { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--cost); }
.wr-tag svg { width: 14px; height: 14px; }

/* настройки → реклама */
.ads-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.ads-kpis .card + .card { margin-top: 0; }
.ads-kpi { padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.ads-kpi span { font-size: 12.5px; color: var(--muted); }
.ads-kpi b { font-size: 20px; font-weight: 700; }
.ads-kpi small { font-size: 13px; font-weight: 500; color: var(--muted); }
.ads-table { overflow-x: auto; }
.ads-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(170px, 1.6fr) repeat(4, minmax(90px, 1fr)); gap: 12px; align-items: center; padding: 10px 20px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; min-width: 760px; }
.ads-row.head { border-top: 0; padding-top: 4px; padding-bottom: 6px; font-size: 12px; color: var(--muted); }
.ads-row small { color: var(--muted); font-size: 12px; margin-left: 2px; }
.ads-row.zero { color: var(--faint); }
.ads-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ads-name .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex: none; }
.ads-n { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 6px; }
.ads-bar { display: block; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ads-bar i { display: block; height: 100%; border-radius: inherit; background: var(--dot); }
.ads-row.m { grid-template-columns: minmax(130px, 1.2fr) repeat(5, minmax(80px, 1fr)); min-width: 620px; }
.ads-cnt { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 6px; text-align: center; background: color-mix(in srgb, var(--dot) 16%, transparent); }
@media (max-width: 720px) { .ads-kpis { grid-template-columns: minmax(0, 1fr); } }
.color-pick { display: flex; gap: 5px; flex-wrap: wrap; }
.color-pick button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; background: var(--dot); padding: 0; }
.color-pick button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--dot); }
.dot-btn { width: 26px; height: 26px; border-radius: 50%; background: var(--dot); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); padding: 0; }
.user-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 150px 130px auto; gap: 14px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); }
.user-row:first-child { border-top: 0; }
.perm-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.perm-list .section-title { margin: 0; }

/* журнал ошибок */
.chip .n.text-danger { color: var(--danger); }
.err { display: flex; flex-direction: column; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.card-h + .err { border-top: 0; }
.err-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.err-head .mono { font-size: 13px; }
.err-msg { font-weight: 600; overflow-wrap: anywhere; }
.err-hint { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: 6px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: color-mix(in srgb, var(--warn) 70%, var(--tone-ink)); font-size: 13px; }
.err-hint svg { margin-top: 2px; }
.err-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--muted); }
.err-meta > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.err-more summary { cursor: pointer; color: var(--blue); font-size: 13px; width: fit-content; }
.err-more .section-title { margin: 12px 0 6px; }
.err-more pre { margin: 0; padding: 10px 12px; max-height: 280px; overflow: auto; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- модальные окна, тосты ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 12, 16, .5);
  animation: fade .14s ease-out;
}
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.modal.wide { max-width: 720px; }
/* боковая панель (журнал действий заказа): выезжает справа во всю высоту, на телефоне — снизу */
.modal-backdrop.drawer { place-items: stretch end; padding: 0; }
.modal.drawer { max-width: 640px; height: 100vh; max-height: none; border-width: 0 0 0 1px; border-radius: 0; animation: drawer-in .22s cubic-bezier(.2, .8, .2, 1); }
.modal.drawer .modal-h { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal.drawer .modal-b { padding: 0; }
@keyframes drawer-in { from { transform: translateX(48px); opacity: 0; } to { transform: none; opacity: 1; } }
.alog-tabs { position: sticky; top: 0; z-index: 1; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.alog-more { padding: 12px 20px; border-top: 1px solid var(--border); }
.drawer .loading-block, .drawer .empty { padding: 20px; }
@media (min-width: 721px) {
  .drawer .alog-row { grid-template-columns: 44px 28px minmax(0, 1fr) 140px; grid-template-areas: "t i x w" "t i x p"; row-gap: 0; }
  .drawer .alog-time { grid-area: t; } .drawer .alog-ic { grid-area: i; } .drawer .alog-text { grid-area: x; }
  .drawer .alog-who { grid-area: w; text-align: right; } .drawer .alog-ip { grid-area: p; }
}
/* поле даты: кнопка вместо системного календаря */
.dt-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer; font: inherit; }
.dt-btn svg { flex: none; color: var(--muted); }
.dt-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* окно выбора даты и времени */
/* выбор периода: кнопка + всплывающий календарь */
.drp-btn { display: inline-flex; align-items: center; gap: 8px; width: auto; min-width: 210px; cursor: pointer; font-weight: 500; text-align: left; }
.drp-btn > span { flex: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.drp-btn > .i { flex: none; color: var(--muted); }
.drp-btn > .i:last-child { width: 14px; height: 14px; transition: transform .15s; }
.drp-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* в ряду фильтров (касса) — как соседние переключатели: та же высота 38 px, фон и скругление, без рамки */
.toolbar .drp-btn { height: 38px; padding: 0 12px; border-radius: 8px; border-color: transparent; background: var(--surface-3); font-size: 13px; }
.toolbar .drp-btn:hover { border-color: var(--border-strong); }
.drp-btn[aria-expanded="true"] > .i:last-child { transform: rotate(180deg); }
.drp { position: fixed; z-index: 1000; width: 300px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: drp-in .14s ease-out; }
@keyframes drp-in { from { opacity: 0; transform: translateY(-4px); } }
.drp-h { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px; }
.drp-h b { font-size: 15px; font-weight: 650; }
.drp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 3px; }
.drp-grid .wd { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 2px 0 6px; text-transform: uppercase; letter-spacing: .03em; }
.drp-grid .wd.we { color: color-mix(in srgb, var(--danger) 60%, var(--faint)); }
.drp-d { height: 38px; padding: 0; border: 0; background: transparent; font: inherit; cursor: pointer; display: grid; place-items: center; }
.drp-d > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; transition: background .1s; }
.drp-d:hover > span { background: var(--surface-3); }
.drp-d:focus-visible { outline: none; }
.drp-d:focus-visible > span { box-shadow: 0 0 0 2px var(--accent); }
.drp-d.future > span { color: var(--faint); }
.drp-d.today > span { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 650; color: var(--accent-text); }
.drp-d.in { background: var(--accent-soft); }
.drp-grid > :nth-child(7n + 1).in, .drp-grid > :nth-child(7n + 1).end:not(.start) { border-radius: 6px 0 0 6px; }
.drp-grid > :nth-child(7n).in, .drp-grid > :nth-child(7n).start:not(.end) { border-radius: 0 6px 6px 0; }
.drp-d.start:not(.end) { background: linear-gradient(90deg, transparent 50%, var(--accent-soft) 50%); }
.drp-d.end:not(.start) { background: linear-gradient(90deg, var(--accent-soft) 50%, transparent 50%); }
.drp-d.start > span, .drp-d.end > span, .drp-d.start:hover > span, .drp-d.end:hover > span { background: var(--accent); color: #fff; font-weight: 650; box-shadow: none; }
.drp-f { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.drp-hint { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.drp-hint.wait { font-weight: 500; color: var(--accent-text); }
@media (max-width: 560px) { .drp { width: auto; right: 8px; left: 8px !important; } .drp-btn { flex: 1; } }
.dtp { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px 24px; }
.dtp-sum { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 15px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); flex-wrap: wrap; }
.dtp-sum svg { color: var(--muted); }
.dtp-sum b { font-weight: 600; }
.dtp-quick { grid-column: 1 / -1; }
.dtp-mh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dtp-mh b { font-weight: 600; }
.dtp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dtp-grid .wd { text-align: center; font-size: 11.5px; color: var(--faint); padding: 4px 0 6px; }
.dtp-d { position: relative; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; }
.dtp-d:hover { background: var(--surface-3); }
.dtp-d.past { color: var(--faint); }
.dtp-d.today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 600; }
.dtp-d.on, .dtp-t.on { background: var(--text); color: var(--surface); font-weight: 600; box-shadow: none; }
.dtp-cap { font-size: 12px; color: var(--muted); margin: 6px 0 8px; }
.dtp-times { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.dtp-t { height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums; cursor: pointer; }
.dtp-t:hover { border-color: var(--border-strong); background: var(--surface-2); }
.dtp-t.on:hover, .dtp-d.on:hover { background: var(--text); border-color: var(--text); }
/* занятое время и дни с записями */
.dtp-t.busy { border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 600; }
.dtp-t.busy.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.dtp-cnt { position: absolute; top: 2px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; font-size: 10px; font-style: normal; font-weight: 700; line-height: 15px; background: color-mix(in srgb, var(--danger) 85%, transparent); color: #fff; }
.dtp-clash { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--danger); font-size: 13px; font-weight: 500; }
.dtp-custom { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; }
.dtp-custom .input { width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .dtp { grid-template-columns: 1fr; }
  .dtp-quick { flex-wrap: nowrap; overflow-x: auto; }
  .dtp-times { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@keyframes drawer-up { from { transform: translateY(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px 12px; }
.modal-h h2 { flex: 1; font-size: 18px; }
.modal-b { padding: 6px 22px 18px; overflow-y: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--border); }
/* окно «Отказ» */
.cx { gap: 14px; }
.cx-order { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.cx-ico { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); }
.cx-t { display: flex; flex-direction: column; min-width: 0; }
.cx-t b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-t small { color: var(--muted); font-size: 13px; }
.cx-q { font-weight: 600; display: flex; flex-direction: column; gap: 2px; }
.cx-q small { font-weight: 400; font-size: 12.5px; color: var(--faint); }
.cx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cx-opt { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 10px; text-align: left; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; font-size: 13.5px;
  transition: background .12s, border-color .12s; }
.cx-opt:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cx-opt:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cx-oi { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); transition: background .12s, color .12s; }
.cx-ol { flex: 1; min-width: 0; line-height: 1.25; }
.cx-ok { flex: none; display: flex; color: var(--danger); opacity: 0; transform: scale(.6); transition: opacity .12s, transform .12s; }
.cx-opt.on { border-color: color-mix(in srgb, var(--danger) 70%, var(--border)); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.cx-opt.on .cx-oi { background: var(--danger); color: #fff; }
.cx-opt.on .cx-ok { opacity: 1; transform: none; }
.cx-warn { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; font-size: 13px;
  background: color-mix(in srgb, #f59e0b 13%, var(--surface)); color: color-mix(in srgb, #f59e0b 75%, var(--text)); }
.cx-warn svg { flex: none; margin-top: 1px; }
.cx-kbd { margin-right: auto; align-self: center; font-size: 12px; }
@media (max-width: 560px) { .cx-grid { grid-template-columns: 1fr; } .cx-kbd { display: none; } }
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 8px;
  background: #111827; color: #fff; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out; transition: opacity .3s, transform .3s;
}
:root[data-theme="dark"] .toast { background: #f3f4f6; color: #111827; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .toast { background: #f3f4f6; color: #111827; } }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- пустые состояния, загрузка ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.empty b { color: var(--text); font-size: 15px; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-block { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { padding-bottom: 8px; }
.login-theme { position: fixed; top: 16px; right: 16px; }

/* ==========================================================================
   Адаптив
   ========================================================================== */
@media (max-width: 1360px) {
  .brand small { display: none; }
  .olist-head, .orow { grid-template-columns: 74px minmax(0, 1fr) minmax(0, 1.35fr) minmax(160px, .7fr) 214px 68px; gap: 16px; }
}
@media (max-width: 1200px) {
  .user-pill b { display: none; }
  .search { flex-basis: 220px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .order-grid { display: flex; flex-direction: column; align-items: stretch; }
  .order-grid .col { display: contents; }
  .order-top { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .order-grid .money-card { order: 5; } .order-grid [data-s="log"] { order: 7; }
  .olist-head, .orow { grid-template-columns: 66px minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, .85fr) 214px 68px; gap: 14px; }
}

@media (max-width: 900px) {
  .topbar-in { flex-wrap: wrap; gap: 8px 10px; padding: max(8px, env(safe-area-inset-top)) 12px 0; }
  .topbar .brand { display: none; }
  .search { flex: 1; min-width: 0; }
  .nav { order: 10; flex-basis: 100%; margin: 0 -12px; padding: 0 8px 8px; }
  .nav a { height: 34px; padding: 0 11px; font-size: 13.5px; }
  .nav a svg.i { width: 16px; height: 16px; }
  .user-pill { padding: 0 4px; gap: 4px; }
  .user-pill svg { display: none; }
  .content { padding: 16px 14px calc(32px + env(safe-area-inset-bottom)); }
  h1 { font-size: 21px; }
  .page-head { margin: 0 0 14px; align-items: flex-start; }
  .page-head .actions .btn-label { display: none; }

  .new-order { grid-template-columns: minmax(0, 1fr); }
  .new-order > .card:nth-child(n) { grid-column: auto; }
  .nog-row { flex-wrap: wrap; }
  .nog-row .dt-btn, .new-order-go [data-submit] { flex: 1 1 100%; width: 100%; margin: 0; }
  .ad-chips { display: grid; grid-template-columns: 1fr 1fr; align-self: stretch; }
  .new-order [data-stage-start] { align-self: stretch; } /* «В работе / Запись» — во всю ширину, как реклама */

  .kpis { gap: 10px; }
  .kpi { padding: 10px 14px 10px 18px; }
  .kpi .value { font-size: 20px; }
  .card-h { padding-left: 16px; padding-right: 16px; }
  .iv-bar { padding: calc(6px + env(safe-area-inset-top)) 4px 6px 14px; }
  .iv-stage { padding: 0 0 calc(12px + env(safe-area-inset-bottom)); }
  .iv-stage img { border-radius: 0; }
  .iv-nav { width: 38px; height: 38px; margin-top: -25px; background: rgb(0 0 0 / .35); }
  .iv-nav.prev { left: 6px; }
  .iv-nav.next { right: 6px; }
  .card-b { padding: 16px; }
  .card-f { padding: 12px 16px; }
  .list-item { padding: 12px 16px; }

  .olist-head, .orow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) 140px 68px; gap: 12px; padding: 11px 16px; }
  .olist-head { padding-top: 7px; padding-bottom: 6px; }
  .pay-btn { width: 30px; min-width: 0; padding: 0; justify-content: center; }
  .pay-btn span { display: none; }
  .pay-slot { width: 30px; justify-content: center; } .pay-slot .t { display: none; }
  .pay-slot .pay-ok { padding-left: 0; justify-content: center; }
  .olist-head .c-no, .orow .c-no { display: none; }
  .orow .mobile-no { display: inline; }

  .grid-form { grid-template-columns: minmax(0, 1fr); }
  .items, .items tbody { display: block; }
  .items thead { display: none; }
  .items tr {
    display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) 36px;
    grid-template-areas: "k n n d" ". q p d" ". s s s";
    gap: 4px 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  .items tr:last-child { border-bottom: 0; }
  .items td { border: 0 !important; padding: 0; width: auto !important; }
  .items td.c-kind { grid-area: k; } .items td.c-name { grid-area: n; } .items td.c-del { grid-area: d; align-self: start; }
  .items td.c-qty { grid-area: q; } .items td.c-price { grid-area: p; }
  .items td.c-sum { grid-area: s; text-align: right; padding-right: 6px; }
  .items .input.inline { border-color: var(--border); background: var(--surface); }
  .card-b.tight { padding: 0 16px; }
  .add-custom { grid-template-columns: minmax(0, 1fr); padding-left: 16px; padding-right: 16px; }
  .items-add { flex-basis: 100%; min-width: 0; }
  .items-add .svc-btn { flex: 1; width: auto; min-width: 0; }
  .add-custom .seg { justify-self: start; }
  .newsvc, .newcm { grid-template-columns: minmax(0, 1fr); }
  .newsvc [name=category] { grid-column: auto; }

  .pay-row { grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "i t a" "i x x" "i m m"; gap: 2px 12px; height: 108px; padding: 0 16px; }
  .pay-row .p-ic { grid-area: i; } .pay-row .p-text { grid-area: t; } .pay-row .p-amount { grid-area: a; }
  .pay-row .p-info { grid-area: x; font-size: 13px; } .pay-row .p-note { -webkit-line-clamp: 1; } .pay-row .p-info .muted { display: none; }
  .pay-row .p-date { grid-area: m; font-size: 12px; } .pay-row .p-del, .pay-row .p-no { display: none; }
  .pay-row .mobile-no { display: inline; color: var(--text); font-weight: 600; }

  /* этапы на телефоне: тип — второй строкой под названием */
  .stage-row { grid-template-columns: 24px 12px minmax(0, 1fr) auto 30px; grid-template-areas: "g d n t x" "g d k t x";
    row-gap: 0; height: auto; padding: 6px 10px 6px 8px; }
  .stage-grip { opacity: 1; }
  .stage-intro { padding: 12px 16px 14px; }
  .stage-kind { justify-self: start; height: 24px; margin-left: -8px; text-align: left; }
  .svc-row { grid-template-columns: minmax(0, 1fr) auto auto auto; padding: 10px 12px; }
  .svc-row .s-name { grid-column: 1 / -1; }
  .user-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 12px 16px; }
  .user-row .u-role, .user-row .u-phone { display: none; }
  .err { padding: 14px 16px; }
  .crow-head { display: none; }
  .crow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name orders" "phone last" "cars cars"; gap: 4px 12px; padding: 12px 16px; }
  .crow .c-name { grid-area: name; } .crow .c-phone { grid-area: phone; color: var(--muted); }
  .crow .c-cars { grid-area: cars; } .crow .c-orders { grid-area: orders; } .crow .c-last { grid-area: last; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 12px 12px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-backdrop.drawer { place-items: end stretch; }
  .modal.drawer { height: 88vh; border-width: 1px 0 0; border-radius: 12px 12px 0 0; animation: drawer-up .22s cubic-bezier(.2, .8, .2, 1); }
  .alog-tabs { padding: 10px 16px; }
  .toasts { bottom: calc(20px + env(safe-area-inset-bottom)); width: calc(100% - 28px); }
  .toast { width: 100%; justify-content: center; }
}

@media (max-width: 640px) {
  .olist-head { display: none; }
  .orow { height: 82px; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "car sum" "client stage"; gap: 6px 10px; }
  .orow .c-car { grid-area: car; } .orow .c-client { grid-area: client; }
  .orow .c-sum { grid-area: sum; } .orow .c-stage { grid-area: stage; align-items: flex-end; } .orow .c-act { display: none; }
  .orow .c-stage small, .orow .c-sum small, .orow .c-car > div > small, .orow .pay-btn, .orow .pay-slot { display: none; }
  .orow .wide-only { display: none; } .orow .narrow-only { display: inline-flex; }
  .orow .c-client { display: flex; gap: 6px; align-items: baseline; }
  .orow .c-client b { font-weight: 500; }
}

/* телефон: меню — четыре равные вкладки «значок над подписью», влезают целиком (раньше «Настройки» обрезались) */
@media (max-width: 480px) {
  .nav { gap: 0; padding: 0 4px 6px; margin: 0 -12px; overflow: visible; }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; height: 46px; padding: 0 2px; font-size: 11.5px; }
  .nav a svg.i { width: 19px; height: 19px; }
  .nav a { position: relative; }
  .nav-badge { position: absolute; top: 2px; left: calc(50% + 6px); height: 16px; min-width: 16px; padding: 0 4px; font-size: 11px; line-height: 16px; }
  /* шапка заказа: «Заказ №36» и кнопки в одну строку, этап и «Создан …» — во всю ширину под ними */
  .page-head[data-s="head"] { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; }
  .page-head[data-s="head"] > .grow, .page-head[data-s="head"] > .grow > .row { display: contents; }
  .page-head[data-s="head"] h1 { grid-column: 1; grid-row: 1; }
  .page-head[data-s="head"] > .actions { grid-column: 2; grid-row: 1; flex-wrap: nowrap; gap: 6px; }
  .page-head[data-s="head"] > .actions > .btn, .page-head[data-s="head"] > .actions > .icon-btn,
  .page-head[data-s="head"] > .actions > * > .btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .page-head[data-s="head"] > .grow > .row > :not(h1), .page-head[data-s="head"] .sub { grid-column: 1 / -1; justify-self: start; margin: 0; }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi.total { grid-column: 1 / -1; } /* «Итого» — во всю ширину под приходом и расходом */
  .kpi .value { font-size: 18px; }
  .kpi .bars { display: none; }
}

/* ==========================================================================
   Телефон: полировка (проверка всех экранов 05.11)
   ========================================================================== */
/* iPhone увеличивает страницу при нажатии на поле со шрифтом меньше 16 px — на сенсорных экранах поля 16 px */
@media (max-width: 900px) and (hover: none) {
  input.input, select.input, textarea.input, textarea.textarea, .input-group input, .ot-km input, .search input { font-size: 16px; }
}
@media (max-width: 900px) {
  .order-grid .files-card { order: 6; } /* оплата сразу после работ, файлы — после оплаты */
  .dtp-quick { scrollbar-width: none; } .dtp-quick::-webkit-scrollbar { display: none; }
  /* своя позиция: тип и название во всю ширину, количество и цена — рядом */
  .add-custom { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .add-custom .seg, .add-custom [data-c="name"], .add-custom [data-act="add-custom"] { grid-column: 1 / -1; }
  .add-custom .seg { justify-self: stretch; display: flex; } .add-custom .seg button { flex: 1; justify-content: center; }
  .add-custom input, .add-custom .btn { height: 38px; }
}
@media (max-width: 640px) {
  /* фильтры заказов — одна строка с прокруткой вбок, «Новый заказ» — круглая кнопка внизу справа */
  .chips[data-chips] { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 12px !important; padding: 0 14px 2px; scrollbar-width: none; }
  .chips[data-chips]::-webkit-scrollbar { display: none; }
  .chips[data-chips] .chip-group { display: flex; flex: none; }
  .chip.chip-new { position: fixed; z-index: 25; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); height: 50px; padding: 0 20px 0 16px;
    border-radius: 25px; font-size: 15px; box-shadow: 0 6px 18px rgb(0 0 0 / .35); }
  .chip.chip-new svg { width: 18px; height: 18px; }
  .view:has(.chip-new) { padding-bottom: 72px; }
  /* строка заказа: телефон клиента прячем — имя целиком, рядом номер заказа */
  .orow .cl-phone { display: none; }
  .orow .c-client b { flex: 0 1 auto; }
  .orow .c-client small { flex: none; }
}
@media (max-width: 560px) {
  /* карточки клиента и авто: значок сверху, телефоны — ровно под именем, слева */
  .ot-card { align-items: flex-start; }
  .ot-card > .icon-btn { margin-top: -4px; }
  .ot-card[data-s="client"] > .ot-phones, .ot-card[data-s="client"] > .ot-nophone { margin-left: 54px; }
  .ot-phones .ot-phone { justify-content: flex-start; padding: 0 8px; margin-left: -8px; }
}

/* --- телефон, вторая пачка --- */
.btn-mark { display: none; }
@media (max-width: 480px) {
  /* два принтера в шапке заказа: метка «П» — акт приёма, «В» — акт выдачи */
  .page-head .actions .btn { position: relative; }
  .btn-mark { display: grid; place-items: center; position: absolute; right: 3px; bottom: 3px; min-width: 14px; height: 14px; padding: 0 2px; border-radius: 4px;
    font: 700 9.5px/1 inherit; font-style: normal; color: var(--text); background: var(--surface-2); box-shadow: 0 0 0 1px var(--border-strong); }
}
@media (max-width: 900px) {
  .topbar .brand { display: flex; flex: 0 1 auto; margin-right: auto; } /* название мастерской слева в верхней полосе */
  .topbar .brand small { display: none; }
  .modal-f .btn { flex: 1 1 0; justify-content: center; } /* кнопки окна — во всю ширину, под палец */
  .ads-row { padding-right: 24px; }
  .newsvc [data-add] { grid-column: auto; grid-row: auto; }
  /* закрытый заказ / нет прав: количество и цена — просто текст «1 шт», «8000 ₽», без рамок полей, с левого края */
  .items .input-group:has(> .input:disabled) { display: inline-flex; align-items: baseline; gap: 4px; }
  .items .input-group:has(> .input:disabled) .suffix { position: static; transform: none; }
  .items textarea.item-name:disabled { border-color: transparent; background: transparent; padding-left: 0; padding-right: 0; color: var(--text); opacity: 1; }
  .items tr:not(:has(.c-del button)) td.c-name { grid-column: 2 / -1; }
  .items tr:has(td.c-qty .input:disabled) { grid-template-columns: 30px auto minmax(0, 1fr) auto; grid-template-areas: "k n n n" ". q p s"; row-gap: 2px; }
  .items tr:has(td.c-qty .input:disabled) td.c-price { display: flex; align-items: baseline; gap: 6px; }
  .items tr:has(td.c-qty .input:disabled) td.c-price::before { content: '×'; color: var(--faint); }
  .items tr:has(td.c-qty .input:disabled) .input-group .suffix { color: var(--muted); }
  .items .input-group > .input.inline:disabled { field-sizing: content; width: auto; min-width: 1ch; height: auto; padding: 0; border-color: transparent; background: transparent; text-align: left; color: var(--text); opacity: 1; }
}
@media (max-width: 900px) and (hover: none) {
  /* удалить комментарий / фото — крупнее под палец */
  .tl-text .tl-del { width: 32px; height: 32px; right: 4px; }
  .tl.comment .tl-text.has-del { padding-right: 44px; }
  .photo-x { width: 24px; height: 24px; top: -8px; right: -8px; }
  .photo-x svg { width: 13px; height: 13px; }
}
@media (max-width: 640px) {
  /* вкладки настроек и фильтры журнала — одна строка с прокруткой вбок */
  .chips[data-tabs], .chips[data-kinds] { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px 2px; }
  .chips[data-tabs]::-webkit-scrollbar, .chips[data-kinds]::-webkit-scrollbar { display: none; }
  .chips[data-tabs] .chip, .chips[data-kinds] .chip { flex: none; }
  /* «Клиенты / Автомобили» и «+ Клиент» — в одну строку */
  .toolbar { gap: 8px; }
  .toolbar .tb-add { padding: 0 12px; }
  /* касса: строка операции — по высоте содержимого, дата и время одной строкой */
  .pay-row { height: auto; padding: 12px 16px; align-items: start; }
  .pay-row .p-ic { align-self: start; }
  .pay-row .p-info > div.ellipsis:first-child { display: none; } /* машина — видна в заказе */
  .pay-row .p-date { display: flex; gap: 4px; color: var(--muted); }
  .pay-row .p-date > div:first-child::after { content: ','; }
  /* карточка клиента: длинное имя переносится, кнопки с подписями, плашки во всю ширину */
  .cl-name { font-size: 20px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
  .page-head .actions.cl-actions { width: 100%; }
  .page-head .actions.cl-actions .btn { flex: 1 1 0; justify-content: center; }
  .page-head .actions.cl-actions .btn-label { display: inline; }
  .kpis.kpis-sm { flex-direction: column; align-items: stretch; }
  .ct-phones { flex-direction: column; align-items: stretch; }
  /* этапы: поле и кнопка «Добавить этап» друг под другом */
  .stage-add { flex-wrap: wrap; }
  .stage-add > * { flex: 1 1 100% !important; }
  .stage-add .btn { justify-content: center; }
  /* новый заказ: выбранный клиент — кнопка «Другой клиент» под именем */
  .picked { flex-wrap: wrap; }
  .picked > .grow { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .picked > .btn { margin-left: 52px; }
  /* журнал действий: значок слева, текст во всю ширину, время и сотрудник — строкой ниже */
  .alog-row { grid-template-columns: 26px auto minmax(0, 1fr); grid-template-areas: "i x x" "i t w"; column-gap: 10px; row-gap: 3px; align-items: start; }
  .alog-time { font-size: 12px; line-height: 18px; }
  .alog-who { line-height: 18px; margin-left: -6px; }
  .alog-who::before { content: '· '; }
  .alog-ic { margin-top: 1px; }
  /* реклама «по источникам»: вместо широкой таблицы — карточка на источник */
  .ads-table .ads-row:not(.m) { min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 12px 16px; }
  .ads-table .ads-row.head:not(.m) { display: none; }
  .ads-table .ads-row.head:not(.m) + .ads-row { border-top: 0; }
  .ads-row:not(.m) .ads-name, .ads-row:not(.m) .ads-n { grid-column: 1 / -1; }
  .ads-row:not(.m) > span[data-l] { font-size: 13.5px; }
  .ads-row:not(.m) > span[data-l]::before { content: attr(data-l) ' '; color: var(--muted); font-size: 12px; }
  .ads-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ads-kpi { padding: 10px 12px; }
  .ads-kpi span { font-size: 11.5px; line-height: 1.25; }
  .ads-kpi b { font-size: 17px; }
  .ads-kpi small { font-size: 11.5px; }
  /* заголовок карточки с переключателем: заголовок одной строкой, переключатель — ниже, если не влез */
  .card-h:has(> .seg) { flex-wrap: wrap; row-gap: 8px; }
  .card-h:has(> .seg) > h2 { white-space: nowrap; flex: 1 0 auto; }
  .srv-head { align-items: stretch; }
  /* пустой список: кнопка «Новый заказ» уже в середине экрана — плавающую не дублируем */
  .view:has(.empty .btn) .chip.chip-new { display: none; }
}

/* ===== Телефон, 06.11: шапка + нижнее меню, комментарии, единые кнопки, переносы вместо «…» ===== */
.brand-logo { display: none; }
.tl .tl-who { font-weight: 600; }

/* единые размеры кнопок на телефоне и планшете: обычные — 40 px, маленькие (в заголовках карточек, значки-действия) — 36 px */
@media (max-width: 900px) {
  .btn:not(.btn-sm):not(.btn-lg):not(.ct-phone):not(.ct-phone2):not(.ot-phone), .icon-btn:not(.sm), .toolbar .tb-add { height: 40px; }
  .icon-btn:not(.sm) { width: 40px; }
  .btn-sm, .card-h .btn-sm, .mc-h .cost-add-btn, .cost-add-btn, .comment-box .btn, .os-dt .dt-btn { height: 36px; }
  .btn-sm { padding: 0 12px; font-size: 13.5px; }
  .icon-btn.sm, .card-h .icon-btn.sm { width: 36px; height: 36px; }
  .input:not(.inline):not(textarea), .select, .search .input { height: 40px; }
  .input.sm:not(textarea), .select.sm, .card-h .input.sm { height: 36px; }
  .search-btn { width: 40px; height: 40px; }
  .search:not(.open) { flex-basis: 40px; }
  .card-h { min-height: 48px; }
  /* адрес выезда — многострочное поле по высоте текста */
  .os-addr { align-items: flex-start; }
  .os-addr textarea.input { height: auto; min-height: 36px; padding: 8px 10px; resize: none; overflow: hidden; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
}
.svc-row textarea.s-name { height: 34px; min-height: 34px; padding: 7px 10px; resize: none; overflow: hidden; line-height: 1.35; font: inherit; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 900px) and (hover: none) { .svc-row textarea.s-name { font-size: 16px; min-height: 36px; } }
.os-addr textarea.input { height: 34px; min-height: 34px; padding: 7px 10px; resize: none; overflow: hidden; line-height: 1.35; font: inherit; font-size: 13.5px; }

@media (max-width: 640px) {
  /* --- шапка: эмблема + название, поиск и профиль справа; разделы — внизу экрана --- */
  .topbar-in { flex-wrap: nowrap; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 10px 8px 14px; }
  .topbar .brand { gap: 9px; min-width: 0; }
  .brand-logo { display: block; flex: none; width: 30px; height: 30px; }
  .topbar .brand b { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; }
  .user-pill { height: 40px; padding: 0 3px; border: 0; background: transparent; }
  .user-pill .avatar { width: 34px; height: 34px; font-size: 13px; }
  .search.open { flex: 1 1 auto; }
  .topbar:has(.search.open) .brand-text { display: none; }

  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; order: 0; flex-basis: auto;
    display: flex; gap: 2px; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); overflow: visible;
  }
  .nav a { flex: 1 1 0; min-width: 0; height: 52px; flex-direction: column; justify-content: center; gap: 3px; padding: 0; border-radius: 12px;
    font-size: 11.5px; font-weight: 500; color: var(--muted); background: transparent; }
  .nav a svg.i { width: 22px; height: 22px; padding: 3px 16px; box-sizing: content-box; border-radius: 999px; transition: background .15s, color .15s; }
  .nav a.active, .nav a.active:hover { color: var(--accent-text); font-weight: 650; background: transparent; }
  .nav a.active svg.i { background: none; }                    /* активный раздел — только цветом, без подложки-«таблетки» */
  .nav a { -webkit-tap-highlight-color: transparent; }         /* без серой вспышки-обводки при нажатии */
  .nav-badge { top: 1px; left: calc(50% + 10px); }
  .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .chip.chip-new { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(82px + env(safe-area-inset-bottom)); }

  /* --- комментарии: во всю ширину, текст 15 px с воздухом, автор жирным, корзина в строке автора --- */
  .tl.comment { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 6px 0 10px; }
  .tl.comment::before, .tl.comment .tl-ic { display: none; }
  .tl.comment .tl-meta { min-height: 30px; gap: 6px; font-size: 12.5px; padding-right: 40px; }
  .tl.comment .tl-who { color: var(--text); font-size: 14px; }
  .tl.comment .tl-text { font-size: 15px; line-height: 1.5; padding: 10px 14px; border-radius: 4px 14px 14px 14px; margin-top: 2px; }
  .tl.comment .tl-text.has-del { padding-right: 14px; }
  .tl.comment .tl-text .tl-del { top: -34px; right: -4px; transform: none; width: 34px; height: 34px; }
  .comment-box { align-items: flex-end; }

  /* --- переносы вместо обрезки «…» --- */
  /* список заказов — строки всегда одной высоты (82 px): длинное имя/машина обрезаются «…», номер заказа №… всегда виден справа от имени */
  .orow .c-client b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .orow { grid-template-columns: minmax(0, 1fr) 120px; }        /* колонка суммы/этапа одной ширины во всех строках */
  .orow .c-sum { justify-content: flex-end; }                   /* сумма — по правому краю, ровно над временем */
  .orow .c-client small { margin-left: auto; padding-left: 6px; } /* №… прижат к правому краю — номера стоят ровной колонкой */
  .crow .c-name b.ellipsis, .crow .c-name b { white-space: normal; overflow: visible; overflow-wrap: anywhere; line-height: 1.3; }
  .crow .c-cars { flex-wrap: wrap; row-gap: 2px; overflow: visible; }
  .crow .c-cars > span { overflow: visible; }
  .crow .c-name .avatar { display: none; } /* список клиентов: кружки с инициалами на телефоне не нужны — имя с левого края */
  .om-row b.ellipsis { white-space: normal; overflow-wrap: anywhere; line-height: 1.3; }
  .pay-row .p-text .ellipsis { white-space: normal; overflow-wrap: anywhere; }
  .kpi-sm { height: auto; min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
  .kpi-sm .foot { white-space: normal; }
  .file-t a { white-space: normal; overflow-wrap: anywhere; }
  .fl-order { flex-wrap: wrap; }
  .fl-order span { white-space: normal; }
  .srv-fact b { white-space: normal; }
  .crow .c-cars > span { white-space: normal; }
  .ot-title, .ot-title a { overflow-wrap: anywhere; min-width: 0; }
  .ot-card > .ot-main { min-width: 0; }
  /* оплата: сумма не сжимается в узкую щель — сумма и комментарий делят строку 2:3 */
  .pay-form { grid-template-columns: minmax(112px, 2fr) minmax(0, 3fr); }
  .pay-form .input-group .input { padding-right: 28px; }
}
/* панели над списками (касса, клиенты): всё одной высоты 40 px, края ровно по ширине экрана */
@media (max-width: 900px) {
  .toolbar .seg { padding: 3px; }
  .toolbar .seg button { height: 34px; }
  .toolbar .drp-btn.input { height: 40px; }
}
@media (max-width: 640px) {
  .toolbar > .seg { flex: 1 1 auto; min-width: 0; }
  .toolbar > .seg button { flex: 1 1 auto; justify-content: center; padding: 0 8px; }
  .toolbar > .seg[data-period], .toolbar > .drp-btn { flex: 1 1 100%; }
  .toolbar .tb-add { margin-left: 0; flex: none; }
}
/* кнопки шапки заказа — отдельной строкой под заголовком, если рядом с «Заказ №…» не помещаются
   (закрытый заказ: 5 кнопок — до 480 px; открытый: 4 кнопки — до 360 px); заголовок всегда в одну строку */
@media (max-width: 480px) {
  .page-head[data-s="head"]:has(> .actions > :nth-child(5)) > .actions { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
}
@media (max-width: 360px) {
  .page-head[data-s="head"]:has(> .actions > :nth-child(4)) > .actions { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
}
/* экранная клавиатура открыта — нижнее меню и плавающая кнопка не закрывают поле ввода */
@media (max-width: 640px) and (hover: none) {
  body:has(:is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select):focus) .nav,
  body:has(:is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select):focus) .chip.chip-new { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* живое обновление: строка заказа / карточка, которую только что изменил другой сотрудник, мягко мигает */
@keyframes live-flash { 0%, 35% { background-color: var(--accent-soft); } }
.orow.live-flash { animation: live-flash 2.4s ease-out; }
.view.live-flash .card { animation: live-flash 1.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .orow.live-flash, .view.live-flash .card { animation: none; } }

/* ===== Промт «идеал», 06.11: единообразие, читаемость, зоны нажатия ===== */
/* красный для текста: на тёмном фоне #dc2626 почти не читается (1.7:1) — светлее в тёмной теме */
:root { --danger-text: #b91c1c; }
:root[data-theme="dark"] { --danger-text: #f87171; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --danger-text: #f87171; } }
.oday.late { color: var(--danger-text); }
/* карточка клиента: второй номер того же размера, что и первый; подпись «второй» — справа */
.ct-phone2 { padding: 0 20px; gap: 10px; font-size: 20px; font-weight: 650; letter-spacing: .01em; color: var(--text); }
.ct-phone2 .i, .ct-phone2 .i.sm { width: 20px; height: 20px; color: var(--accent); }
.ct-phone2 small { font-size: 12px; margin-left: 4px; }
@media (max-width: 900px) {
  .card-h .seg button { height: 32px; }                       /* «Открытые/Решённые», «Час/Сутки/Неделя» — были 24 px */
  .cm-chip { height: 36px; }                                   /* марки и модели: крестик был 22 px */
  .cm-chip button { width: 30px; height: 30px; }
  .stage-dot { position: relative; }                           /* цвет этапа: точка 12 px, а нажимать — 32 px */
  .stage-dot::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
  .items .kind { width: 30px; height: 30px; }                  /* «работа/запчасть» */
}
@media (max-width: 640px) {
  .ct-phone2 small { margin-left: auto; }
  .veh-owner .avatar { display: none; }                        /* вкладка «Автомобили» — как в списке клиентов, без кружков */
  .pay-kind, .ads-kpi span, .ads-kpi small, .co-cap { font-size: 12px; }       /* ничего мельче 12 px */
}
@media (max-width: 400px) {                                    /* узкий телефон: оба номера по 18 px и влезают в карточку */
  .ct-phone, .ct-phone2 { font-size: 18px; padding: 0 14px; gap: 8px; min-width: 0; }
  .ct-phone2 small { display: none; }
}
/* весь красный текст — тем же читаемым оттенком (просрочено, время, убыток, отказ) */
.text-danger, .orow .st-time.text-danger, .chip .n.text-danger, .step.cancel, .profit-box.neg, .profit-box.neg > b, .dtp-clash { color: var(--danger-text); }
@media (max-width: 900px) { .orow .cl-phone { display: none; } }   /* планшет: номер в узкой колонке обрезался «512-2…» — как на телефоне, без него */
/* карточка автомобиля в заказе: VIN и пробег — одной строкой на всю ширину карточки (на компьютере обёртка не видна) */
.ot-vk { display: contents; }
@media (max-width: 640px) {
  .ot-card[data-s="vehicle"] { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 14px; row-gap: 8px; align-items: start; }
  .ot-card[data-s="vehicle"] > .ot-ic { grid-column: 1; grid-row: 1 / span 2; }
  .ot-card[data-s="vehicle"] > .icon-btn { grid-column: 3; grid-row: 1; }
  .ot-card[data-s="vehicle"] .ot-main, .ot-card[data-s="vehicle"] .ot-facts { display: contents; }
  .ot-card[data-s="vehicle"] .ot-title { grid-column: 2; grid-row: 1; align-self: center; }
  .ot-card[data-s="vehicle"] .ot-facts > :not(.ot-vk) { grid-column: 2; grid-row: 2; justify-self: start; }
  .ot-card[data-s="vehicle"] .ot-vk { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13.5px; }
  .ot-card[data-s="vehicle"] .ot-note { grid-column: 1 / -1; }
  .ot-vk .ot-vin .icon-btn.sm { width: 32px; height: 32px; }
}
/* телефон: карточки «клиент» и «автомобиль» в заказе — без иконки машины и кружка с инициалами; VIN и пробег всегда одной строкой */
@media (max-width: 640px) {
  .ot-card[data-s="vehicle"] > .ot-ic, .ot-card[data-s="client"] > .avatar { display: none; }
  .ot-card[data-s="client"] > .ot-phones, .ot-card[data-s="client"] > .ot-nophone { margin-left: 0; }
  .ot-card[data-s="vehicle"] { grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .ot-card[data-s="vehicle"] .ot-title { grid-column: 1; }
  .ot-card[data-s="vehicle"] .ot-facts > :not(.ot-vk) { grid-column: 1; }
  .ot-card[data-s="vehicle"] > .icon-btn { grid-column: 2; }
  .ot-card[data-s="vehicle"] .ot-vk { flex-wrap: nowrap; }
  .ot-vk .ot-vin { min-width: 0; }
  .ot-vk .ot-vin .mono { font-size: clamp(11px, 3.4vw, 13px); letter-spacing: 0; }
  .ot-vk .ot-km { flex: none; }
}
@media (max-width: 360px) { .ot-vk .ot-km > svg { display: none; } .ot-vk .ot-km { padding: 0 8px 0 10px; } }
/* телефон: кружки с инициалами (клиенты, сотрудники, выбор клиента, шапка карточки клиента) не показываем нигде — кроме своего аватара в шапке */
@media (max-width: 640px) { .avatar:not(.user-pill > .avatar) { display: none !important; } }
/* шапка заказа на телефоне: «П»/«В» у принтеров — просто буквой рядом с иконкой внутри кнопки, без плашки поверх иконки */
@media (max-width: 480px) {
  .page-head .actions .btn:has(> .btn-mark) { width: auto; padding: 0 10px 0 9px; gap: 3px; }
  .btn-mark { position: static; display: inline; min-width: 0; height: auto; padding: 0; border-radius: 0; background: none; box-shadow: none;
    font: 650 14px/1 inherit; font-style: normal; color: inherit; }
}
/* просрочка в списке заказов — оранжевым (заголовок дня, время, «просрочено · …»), а не красным */
.text-late, .oday.late, .orow .st-time.text-late { color: var(--cost-text); }
/* печать в шапке заказа: на компьютере — две подписанные кнопки, на телефоне/планшете — один принтер с меню выбора документа */
.print-btn, .print-pop .ad-pop-h { display: none; }
.print-menu, .print-pop, .print-pop.hidden { display: contents !important; }
@media (max-width: 900px) {
  .print-menu { display: block !important; }
  .print-btn { display: inline-flex; }
  .print-pop { display: flex !important; left: auto; right: 0; min-width: 200px; }
  .print-pop.hidden { display: none !important; }
  .print-pop .ad-pop-h { display: block; }
  .page-head .actions .print-pop .print-opt { width: 100%; height: 44px; justify-content: flex-start; gap: 10px; padding: 0 10px; border: 0; background: transparent; box-shadow: none; font-weight: 500; }
  .page-head .actions .print-pop .print-opt:hover, .page-head .actions .print-pop .print-opt:focus-visible { background: var(--surface-3); }
  .page-head .actions .print-pop .btn-label { display: inline; }
  .print-pop .print-opt .i { color: var(--muted); }
}
/* заголовок дня в списке заказов — всегда одной строкой (день недели сокращённо: «вт») */
@media (max-width: 640px) { .oday { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 16px; padding-right: 16px; } }
@media (max-width: 360px) { .oday { font-size: 13px; } }
/* «Работы и запчасти» на телефоне — компактно: 1-я строка «значок · название · корзина», 2-я «кол-во · цена · сумма справа»;
   название без рамки (рамка появляется при редактировании) */
@media (max-width: 640px) {
  .items tr:not(:has(td.c-qty .input:disabled)) {
    grid-template-columns: 30px 64px 100px minmax(0, 1fr) 36px;
    grid-template-areas: "k n n n d" ". q p s s";
    gap: 6px 6px; padding: 10px 0;
  }
  .items tr:not(:has(td.c-qty .input:disabled)) td.c-sum { padding-right: 4px; white-space: nowrap; font-size: 15px; }
  .items td.c-del { align-self: center; }
  .items textarea.item-name:not(:disabled) { border-color: transparent; background: transparent; padding-left: 4px; padding-right: 4px; font-weight: 500; }
  .items textarea.item-name:not(:disabled):focus { border-color: var(--accent); background: var(--surface); }
}
@media (max-width: 360px) {
  .items tr:not(:has(td.c-qty .input:disabled)) { grid-template-columns: 30px 56px 88px minmax(0, 1fr) 36px; gap: 6px 4px; }
  .items tr:not(:has(td.c-qty .input:disabled)) td.c-sum { font-size: 14px; }
}
/* iPhone увеличивает страницу при нажатии на поле со шрифтом меньше 16 px и не возвращает масштаб.
   На сенсорных экранах все поля ввода — 16 px, без исключений (раньше .input.sm, поля этапов, позиций и т.п. были 12.5–15 px). */
@media (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
/* сотрудники на телефоне: кружок скрыт — карандаш «Изменить» всегда у правого края */
@media (max-width: 640px) { .user-row { grid-template-columns: minmax(0, 1fr) auto; } }
/* файлы заказа на телефоне: фото — плашками «🖼 Фото 1 | ×» (крестик внутри, не висит поверх); архив — имя до 2 строк,
   переносы только по «_», «-», «.» (без разрыва слова посередине) */
.photo-lbl { display: none; }
@media (max-width: 640px) {
  .photo-icons { gap: 8px; padding: 0 16px 12px; }
  .photo-cell { display: inline-flex; align-items: stretch; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; }
  .photo-ic { width: auto; height: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px 0 10px; border: 0; border-radius: 0; background: transparent; }
  .photo-lbl { display: inline; font-size: 14px; font-weight: 500; color: var(--text); }
  .photo-x { position: static; width: 34px; height: 100%; opacity: 1; border: 0; border-left: 1px solid var(--border); border-radius: 0; background: transparent; color: var(--muted); }
  .photo-x svg { width: 14px; height: 14px; }
  .file-list { padding: 0 16px 8px; }
  .file-item { gap: 10px; padding: 10px 0; }
  .file-ic { width: 36px; height: 36px; border-radius: 9px; }
  .file-t a { white-space: normal; overflow-wrap: break-word; word-break: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.35; }
}
@media (max-width: 640px) { .file-t small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } }
@media (max-width: 360px) {                                    /* 320 px: две плашки фото — в один ряд */
  .photo-ic { gap: 6px; padding: 0 10px 0 8px; }
  .photo-x { width: 30px; }
}
/* список заказов на телефоне: третья строка — телефон клиента (один, первый); строки по-прежнему одной высоты */
.orow .m-phone { display: none; }
@media (max-width: 640px) {
  .orow { height: 104px; grid-template-areas: "car sum" "client stage" "phone phone"; }
  .orow .m-phone { display: flex; justify-content: space-between; gap: 8px; grid-area: phone; min-height: 18px; font-size: 14px; line-height: 18px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .orow .m-phone > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .orow .c-client small { display: none; }   /* №заказа переехал в третью строку справа — имени клиента больше места */
  .orow.closed .m-phone { color: var(--faint); }
}
/* телефон: без значков «работа/запчасть» (ключ/коробка) в позициях и без значка архива в файлах;
   имя файла — в одну строку, что не влезло — «…» */
@media (max-width: 640px) {
  .items td.c-kind { display: none; }
  .items tr:not(:has(td.c-qty .input:disabled)) { grid-template-columns: 64px 100px minmax(0, 1fr) 36px; grid-template-areas: "n n n d" "q p s s"; }
  .items tr:has(td.c-qty .input:disabled) { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "n n n" "q p s"; }
  .items tr:not(:has(.c-del button)) td.c-name { grid-column: 1 / -1; }
  .file-ic { display: none; }
  .file-t a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: unset; }
}
@media (max-width: 360px) {
  .items tr:not(:has(td.c-qty .input:disabled)) { grid-template-columns: 56px 88px minmax(0, 1fr) 36px; }
}
/* телефон: без значков-машинок — в заказах карточки клиента и в списке «Клиенты → Автомобили» */
@media (max-width: 640px) {
  .om-ic, .veh-ic { display: none; }
  .om-row { gap: 10px; }
  .veh-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "c c" "p n" "o o"; }
}
/* карточка клиента на телефоне (вариант B): «Изменить» — карандаш справа от имени, «Новый заказ» — одна кнопка во всю ширину;
   плашки «Заказов / Автомобилей / Оплачено» без цветных значков, подписи одной ширины */
@media (max-width: 640px) {
  .page-head.cl-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 10px; align-items: start; }
  .page-head.cl-head > .row { grid-column: 1; grid-row: 1; }
  .page-head.cl-head .actions.cl-actions { display: contents; }
  .page-head.cl-head .cl-actions [data-act="edit"] { grid-column: 2; grid-row: 1; flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .page-head.cl-head .cl-actions [data-act="edit"] .btn-label { display: none; }
  .page-head.cl-head .cl-actions .btn-primary { grid-column: 1 / -1; grid-row: 2; width: 100%; justify-content: center; }
  .kpi-sm .ico { display: none; }
  .kpi-sm { padding-left: 12px; }
  .kpi-sm .label { width: 108px; }
  .kpi-sm { height: 40px; }
  .kpi-sm .foot { white-space: nowrap; }      /* длинный список машин — «…», плашки одной высоты */
}
