/* Just Clean CRM — компоненты. Подключать после tokens.css (переменные). Без сборщика: один файл. */

/* ---------- Движение: длительности и кривые (в tokens.json семейства motion нет — живут здесь) ---------- */
:root {
  --dur-1: 120ms;  /* нажатие, наведение, смена цвета */
  --dur-2: 200ms;  /* появление фрагмента, тоста, окна */
  --dur-3: 320ms;  /* схлопывание строки, исчезновение задачи */
  --dur-flash: 1600ms; /* подсветка изменённого значения */
  --dur-toast: 6000ms; /* сколько живёт тост с «Отменить» */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/20px var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 22px; line-height: 28px; font-weight: 700; }
h2 { font-size: 17px; line-height: 24px; font-weight: 700; }
h3 { font-size: 15px; line-height: 20px; font-weight: 700; }
h4 { font-size: 14px; line-height: 20px; font-weight: 700; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
a.plain { text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button { font: inherit; color: inherit; }
input[type=checkbox], input[type=radio] { accent-color: var(--ink); width: 16px; height: 16px; }
hr { border: 0; border-top: 1px solid var(--line-field); margin: 12px 0; }

.muted { color: var(--ink-muted); }
.small { font-size: 13px; line-height: 18px; }
.caption { font-size: 12px; line-height: 16px; }
.strong { font-weight: 700; }
.eyebrow { font-size: 12px; line-height: 16px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num, th.num, .right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mobile-only { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stack.tight { gap: 4px; }
.stack.loose { gap: 16px; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

/* ---------- Иконки (спрайт из bundle.js / base.html) ---------- */
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.lg { width: 20px; height: 20px; }
.icon.xl { width: 24px; height: 24px; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); background: var(--bg); }
.app.full { min-height: 100vh; }
.app > div { min-width: 0; }
.sidebar { background: var(--surface-alt); border-right: 1px solid var(--line-field); display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; }
.app.full .sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; }
.sidebar-brand img { height: 56px; width: auto; display: block; }
.sidebar-brand span { font-size: 12px; line-height: 16px; letter-spacing: .1em; color: var(--ink-muted); }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius-btn); color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav-item:hover { background: var(--surface); }
.nav-item[aria-current="page"] { background: var(--accent-soft); font-weight: 700; }
.nav-item .count { margin-left: auto; }
.nav-sep { height: 1px; background: var(--line-field); margin: 8px 10px; }
.sidebar-foot { margin-top: auto; padding-top: 8px; }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.app.collapsed .sidebar { padding: 12px 10px; align-items: center; }
.app.collapsed .nav-item { width: 44px; justify-content: center; padding: 0; position: relative; }
.app.collapsed .nav-label, .app.collapsed .sidebar-brand span { display: none; }
.app.collapsed .sidebar-brand { padding: 4px 0 16px; }
.app.collapsed .sidebar-brand img { height: 32px; }
.app.collapsed .nav-item .count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
@media (max-width: 1199px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .app .sidebar { padding: 12px 10px; align-items: center; }
  .app .nav-item { width: 44px; justify-content: center; padding: 0; position: relative; }
  .app .nav-label, .app .sidebar-brand span { display: none; }
  .app .sidebar-brand img { height: 32px; }
  .app .nav-item .count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
}
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--line-field); position: sticky; top: 0; z-index: 20; }
.search { position: relative; flex: 1; max-width: 520px; }
.search .icon { position: absolute; left: 10px; top: 10px; color: var(--ink-muted); }
.search kbd { position: absolute; right: 8px; top: 8px; font: 12px/18px var(--font-sans); color: var(--ink-muted); border: 1px solid var(--line-field); border-radius: var(--radius-sm); padding: 0 5px; background: var(--surface); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius-btn); text-decoration: none; }
.user-chip:hover { background: var(--surface-alt); }
.user-chip .who { display: flex; flex-direction: column; line-height: 16px; }
.user-chip .who small { font-size: 12px; color: var(--ink-muted); }
.main { padding: 20px 24px 32px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-muted); }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-muted); }
.crumbs a { color: var(--ink-muted); }

/* Меню на телефоне: открывается кнопкой в шапке (Alpine, .is-open), поверх содержимого. */
@media (max-width: 640px) {
  .app .sidebar.is-open { display: flex; position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 30; width: var(--sidebar-w); align-items: stretch; padding: 12px 8px; box-shadow: var(--shadow-pop); overflow-y: auto; }
  .app .sidebar.is-open .nav-item { width: auto; justify-content: flex-start; padding: 0 10px; height: var(--control-h-touch); }
  .app .sidebar.is-open .nav-label { display: inline; }
  .app .sidebar.is-open .nav-item .count { position: static; margin-left: auto; }
  .app .sidebar.is-open .sidebar-brand { display: none; }
}

/* ---------- Аватар, счётчик ---------- */
.avatar { width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--accent-icon); color: var(--on-accent); font-size: 11px; line-height: 24px; font-weight: 700; text-align: center; flex: none; display: inline-block; }
.avatar.lg { width: 32px; height: 32px; line-height: 32px; font-size: 13px; }
.avatar.dark { background: var(--ink); color: var(--on-ink); }
.avatar.none { background: var(--surface); border: 1px dashed var(--line); color: var(--ink-muted); line-height: 22px; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line-field); font-size: 12px; line-height: 1; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.count.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.count.dark { background: var(--ink); border-color: transparent; color: var(--on-ink); }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-btn); background: var(--accent); color: var(--on-accent); font: 500 14px/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.secondary:hover { background: var(--surface-alt); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--surface-alt); }
.btn.danger { background: var(--surface); border-color: var(--line); color: var(--danger-ink); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.dark { background: var(--ink); color: var(--on-ink); }
.btn.dark:hover { background: var(--ink-muted); }
.btn.sm { height: var(--control-h-sm); padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { height: var(--control-h-touch); padding: 0 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: var(--control-h); padding: 0; }
.btn.sm.icon-only { width: var(--control-h-sm); }
.btn[disabled], .btn.is-disabled { background: var(--off-soft); border-color: transparent; color: var(--ink-muted); cursor: not-allowed; }
.btn .spinner { display: none; }
.btn.htmx-request .spinner { display: inline-block; }
.btn.htmx-request { pointer-events: none; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.field.required > label::after { content: " *"; color: var(--danger-ink); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea, .search input {
  width: 100%; height: var(--control-h); padding: 0 10px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-btn); font: 400 14px/20px var(--font-sans); }
.field textarea, textarea.input { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
.field select, select.input { appearance: none; padding-right: 30px; 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='%235f656d' 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 8px center; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-muted); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field ::placeholder, .input::placeholder { color: var(--ink-muted); opacity: 1; }
.field input[readonly], .field input:disabled, .field select:disabled { background: var(--surface-alt); color: var(--ink-muted); }
.field .hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.field .error { display: none; gap: 4px; align-items: flex-start; font-size: 12px; line-height: 16px; color: var(--danger-ink); }
.field.has-error .error { display: flex; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger-solid); background: var(--surface); }
.field.has-error > label:not(.check) { color: var(--danger-ink); }
.affix { position: relative; }
.affix > span { position: absolute; right: 10px; top: 8px; color: var(--ink-muted); pointer-events: none; }
.affix input { padding-right: 44px !important; text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.input.sm { height: var(--control-h-sm); font-size: 13px; }

/* ---------- Карточка ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 16px; border-bottom: 1px solid var(--line-field); }
.card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; overflow-x: auto; border-radius: 0 0 var(--radius-card) var(--radius-card); }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line-field); display: flex; gap: 8px; align-items: center; }
.card.soft { background: var(--surface-section); border-color: var(--line-field); }
.card.flat { border-color: var(--line-field); }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 12px; }
.kv dt { color: var(--ink-muted); font-size: 13px; line-height: 20px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
dl { margin: 0; }

/* ---------- Бейджи ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--off-soft); color: var(--off-ink); font-size: 12px; line-height: 16px; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.plain::before, .badge.accent::before, .badge.outline::before, .badge.has-icon::before { display: none; }
.badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.badge.ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge.info { background: var(--info-soft); color: var(--info-ink); }
.badge.off { background: var(--off-soft); color: var(--off-ink); }
.badge.accent { background: var(--accent); color: var(--on-accent); }
.badge.outline { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--off-solid); }
.dot.ok { background: var(--ok-solid); } .dot.warn { background: var(--warn-solid); } .dot.danger { background: var(--danger-solid); } .dot.info { background: var(--info-solid); }

/* ---------- Вкладки и переключатель ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-field); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; margin-bottom: -1px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink-muted); text-decoration: none; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab:focus-visible { outline-offset: -3px; border-radius: var(--radius-btn) var(--radius-btn) 0 0; }
.tab[aria-selected="true"], .tab.active { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent-hover); }
.tab .count { height: 18px; min-width: 18px; font-size: 11px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--accent-soft); border-radius: var(--radius-btn); }
.seg button, .seg a { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; font-size: 13px; white-space: nowrap; }
.seg [aria-pressed="true"], .seg .active { background: var(--surface); font-weight: 700; box-shadow: 0 0 0 1px var(--line-field); }

/* ---------- Таблица ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface-alt); color: var(--ink-muted); font-size: 12px; line-height: 16px; font-weight: 700; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-field); white-space: nowrap; }
.table th.sortable { cursor: pointer; }
.table th[aria-sort] { color: var(--ink); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line-field); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg); }
.table tbody tr.is-selected td { background: var(--accent-soft); }
.table tfoot td { background: var(--surface-alt); font-weight: 700; border-top: 1px solid var(--line-field); border-bottom: 0; }
.table.compact td { padding: 6px 12px; }
.table .client { max-width: 340px; }
.table .client a { font-weight: 700; text-decoration: none; }
.table .client a:hover { text-decoration: underline; }
.table .sub { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table input.input { height: 30px; }
.table-foot { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line-field); font-size: 13px; color: var(--ink-muted); }

/* ---------- Фильтры ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.filters .field { width: 180px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* ---------- Алерт ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: var(--radius-btn); background: var(--info-soft); color: var(--info-ink); font-size: 13px; line-height: 18px; }
.alert .icon { margin-top: 1px; }
.alert.danger { background: var(--danger-soft); color: var(--danger-ink); }
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); }
.alert.ok { background: var(--ok-soft); color: var(--ok-ink); }
.alert b { color: inherit; }

/* ---------- Пустое состояние, загрузка ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 16px; color: var(--ink-muted); }
.empty.page { padding: 48px 16px; }
.empty-icon { width: 44px; height: 44px; border-radius: var(--radius-pill); background: var(--accent-icon); color: var(--on-accent); display: grid; place-items: center; margin-bottom: 4px; }
.empty h4 { color: var(--ink); font-size: 15px; }
.empty p { max-width: 340px; font-size: 13px; line-height: 18px; }
.empty .btn-group { margin-top: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-field); border-top-color: var(--ink); border-radius: 50%; animation: jc-spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes jc-spin { to { transform: rotate(360deg); } }
.skeleton { display: block; height: 12px; border-radius: var(--radius-sm); background: var(--surface-alt); }
.skeleton.w-40 { width: 40%; } .skeleton.w-60 { width: 60%; } .skeleton.w-80 { width: 80%; } .skeleton.h-20 { height: 20px; }
.loading-row { display: flex; align-items: center; gap: 8px; padding: 12px 16px; color: var(--ink-muted); font-size: 13px; }
/* HTMX: индикатор и «приглушение» заменяемого куска */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.swap-target { transition: opacity .15s; }
.swap-target.htmx-request, .is-loading { opacity: .5; pointer-events: none; }
.fade-in { animation: jc-fade .2s ease-out; }
.htmx-added { opacity: 0; }
.htmx-settling { transition: opacity .2s; }
@keyframes jc-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Воронка (доска) ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 4px; }
.col { background: var(--surface-alt); border-radius: var(--radius-card); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.col-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 4px 4px 2px; min-height: 44px; align-content: flex-start; }
.col-head h3 { font-size: 14px; }
.col-head h3 { min-width: 0; overflow-wrap: break-word; }
.col-head .sum { flex-basis: 100%; font-size: 12px; line-height: 16px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.deal { display: flex; flex-direction: column; gap: 6px; padding: 10px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); text-decoration: none; color: var(--ink); }
.deal:hover { border-color: var(--ink-muted); }
.deal.is-overdue { border-color: var(--danger-solid); box-shadow: inset 0 0 0 1px var(--danger-solid); }
.deal-top { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.deal-top .num { margin-right: auto; }
.deal-client { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.deal-obj { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.deal-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; }
.deal-foot .partner { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.due .icon { width: 13px; height: 13px; }
.due.today { color: var(--warn-ink); font-weight: 700; }
.due.overdue { color: var(--danger-ink); font-weight: 700; }

/* ---------- Карточка заказа ---------- */
.order-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.order-title { display: flex; align-items: flex-start; gap: 12px; }
.order-title h1 { overflow-wrap: anywhere; }
.order-title .meta { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.facts { display: grid; grid-template-columns: repeat(6, minmax(0, auto)); gap: 4px 28px; justify-content: start; }
.fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact .k { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.fact .v { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.steps { display: flex; gap: 4px; }
.step { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.step::before { content: ""; height: 6px; border-radius: var(--radius-pill); background: var(--line-field); }
.step.done::before { background: var(--ok-solid); }
.step.current::before { background: var(--accent-hover); }
.step.current { color: var(--ink); font-weight: 700; }
.step.done { color: var(--ink); }
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.order-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 72px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 14px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 0; width: 2px; background: var(--line-field); }
.tl:last-child { padding-bottom: 0; } .tl:last-child::before { display: none; }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); margin-top: 2px; }
.tl.done .tl-dot { background: var(--ok-solid); border-color: var(--ok-solid); }
.tl.current .tl-dot { background: var(--accent); border-color: var(--ink); }
.tl .t { font-weight: 700; }
.tl .m { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; border-bottom: 1px solid var(--line-field); }
.task:last-child { border-bottom: 0; }
.task input { margin-top: 2px; }
.task .body { flex: 1; min-width: 0; }
.task.is-done .title { text-decoration: line-through; color: var(--ink-muted); }
.file { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line-field); }
.file:last-child { border-bottom: 0; }
.file-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-alt); display: grid; place-items: center; flex: none; font-size: 10px; font-weight: 700; color: var(--ink-muted); }
.comment { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; padding: 10px 16px; }
.comment .m { font-size: 12px; color: var(--ink-muted); }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-field); align-items: flex-end; }
.composer textarea { min-height: 36px; height: 36px; }

/* ---------- Плеер звонка ---------- */
.call { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.call + .call { margin-top: 8px; }
.card-body > .call { border-color: var(--line-field); }
.call-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.call-dir { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-icon); color: var(--on-accent); }
.call-dir.in { background: var(--info-soft); color: var(--info-ink); }
.call-dir.missed { background: var(--danger-soft); color: var(--danger-ink); }
.call-who { flex: 1; min-width: 0; }
.call-who .t { font-weight: 700; }
.call-who .m { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.player { display: flex; align-items: center; gap: 10px; padding: 0 14px 10px; }
.play { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.play .icon { width: 14px; height: 14px; }
.track { position: relative; flex: 1; height: 4px; border-radius: var(--radius-pill); background: var(--line-field); cursor: pointer; }
.track > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--ink); }
.track > b { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.player time { font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.speed { height: 24px; padding: 0 6px; border: 1px solid var(--line-field); border-radius: var(--radius-sm); background: var(--surface); font-size: 12px; cursor: pointer; }
.call-summary { padding: 0 14px 12px; font-size: 13px; line-height: 18px; }
.call-summary b { font-weight: 700; }
details.transcript { border-top: 1px solid var(--line-field); }
details.transcript > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; color: var(--ink); }
details.transcript > summary::-webkit-details-marker { display: none; }
details.transcript > summary .icon { transition: transform .15s; }
details.transcript[open] > summary .icon { transform: rotate(180deg); }
.lines { display: flex; flex-direction: column; gap: 8px; padding: 4px 14px 14px; max-height: 280px; overflow: auto; }
.line { display: grid; grid-template-columns: 40px 76px minmax(0, 1fr); gap: 8px; font-size: 13px; line-height: 18px; }
.line time { color: var(--ink-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.line .who { font-weight: 700; }
.line.client .who { color: var(--info-ink); }
.line mark { background: var(--warn-soft); color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---------- ИИ предлагает ---------- */
.ai { background: var(--accent-soft); border: 1px solid var(--accent-hover); border-radius: var(--radius-card); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-head { display: flex; align-items: center; gap: 8px; }
.ai-head h4 { font-size: 14px; }
.ai-head .m { margin-left: auto; font-size: 12px; color: var(--ink-muted); }
.ai-fields { display: grid; grid-template-columns: 20px 120px minmax(0, 1fr); gap: 6px 8px; align-items: start; font-size: 13px; line-height: 18px; }
.ai-fields input[type=checkbox] { margin: 1px 0 0; width: 15px; height: 15px; accent-color: var(--ink); }
.ai-fields .k { color: var(--ink-muted); }
.ai-fields .v b { font-weight: 700; }
.ai-fields .was { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.ai-fields .q { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); font-style: italic; }
.ai-task { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; background: var(--surface); border-radius: var(--radius-btn); font-size: 13px; line-height: 18px; }
.ai-actions { display: flex; gap: 8px; align-items: center; }
.ai-actions .m { margin-left: auto; font-size: 12px; color: var(--ink-muted); }
.ai.is-resolved { background: var(--surface); border-color: var(--line-field); padding: 8px 14px; flex-direction: row; align-items: center; font-size: 13px; }

/* ---------- Расчёт и КП ---------- */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.totals { position: sticky; top: 72px; background: var(--surface-section); border: 1px solid var(--line-field); border-radius: var(--radius-card); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.totals dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 14px; }
.totals dt { color: var(--ink-muted); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.totals .grand { border-top: 1px solid var(--line-field); padding-top: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.totals .grand b { font-size: 28px; line-height: 34px; font-variant-numeric: tabular-nums; }
.margin { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius-btn); background: var(--surface); }

/* ---------- Полоски: загрузка, баллы ---------- */
.meter { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--line-field); overflow: hidden; min-width: 60px; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--ok-solid); }
.meter.warn > i { background: var(--warn-solid); }
.meter.danger > i { background: var(--danger-solid); }
.meter.ink > i { background: var(--ink); }
.meter-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 13px; }
.meter-row .num { text-align: right; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.kpi .k { font-size: 13px; color: var(--ink-muted); }
.kpi .v { font-size: 28px; line-height: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ---------- Распределение ---------- */
.dist-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
.cand { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px 24px; }
.cand.is-top { border-color: var(--accent-hover); box-shadow: inset 0 0 0 1px var(--accent-hover); }
.cand-score { font-size: 28px; line-height: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cand-why { font-size: 13px; line-height: 18px; color: var(--ink); }
.cand-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line-field); padding-top: 12px; }

/* ---------- Загрузка файлов / фото ---------- */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 16px; border: 1px dashed var(--line); border-radius: var(--radius-card); background: var(--surface); text-align: center; color: var(--ink-muted); font-size: 13px; cursor: pointer; }
.drop:hover, .drop.is-over { border-color: var(--ink); background: var(--accent-soft); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius-img); background: var(--surface-alt); border: 1px solid var(--line-field); display: grid; place-items: center; color: var(--ink-muted); overflow: hidden; font-size: 12px; }
.thumb .x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-field); display: grid; place-items: center; }

/* ---------- Модальное окно ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(58, 63, 71, .35); display: grid; place-items: center; z-index: 50; }
.dialog { width: min(480px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); }
.dialog .card-head { border-bottom: 1px solid var(--line-field); }

/* ---------- Кабинет партнёра (Telegram, 375 px) ---------- */
.tg { width: 100%; max-width: 480px; margin: 0 auto; background: var(--bg); font-size: 15px; line-height: 21px; min-height: 100%; display: flex; flex-direction: column; }
.tg-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line-field); min-height: 52px; }
.tg-head h1 { font-size: 17px; line-height: 22px; }
.tg-body { padding: 12px 16px 96px; display: flex; flex-direction: column; gap: 12px; }
.tg-bar { position: sticky; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line-field); display: flex; gap: 8px; }
.tg .btn { height: var(--control-h-touch); font-size: 15px; }
.tg .btn.sm { height: 36px; font-size: 14px; }
.tg .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .tg .field select, .tg .field textarea { height: var(--control-h-touch); font-size: 16px; }
.tg .tabs .tab { height: 44px; }
.m-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); text-decoration: none; color: var(--ink); }
.m-card.is-overdue { border-color: var(--danger-solid); box-shadow: inset 0 0 0 1px var(--danger-solid); }
.m-row { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.m-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.m-section > h3 { padding: 12px 14px 0; }
.m-section > .card-body { padding: 10px 14px 14px; }
.stepper-m { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.stepper-m .chip { height: 32px; }

/* ---------- Отчёты: графики на SVG ---------- */
.chart { width: 100%; height: auto; display: block; font-family: var(--font-sans); }
.chart text { fill: var(--ink-muted); font-size: 11px; }
.chart .grid { stroke: var(--line-field); stroke-width: 1; }
.chart .s1 { fill: var(--chart-1); } .chart .s2 { fill: var(--chart-2); } .chart .s3 { fill: var(--chart-3); }
.chart .l1 { fill: none; stroke: var(--chart-1); stroke-width: 2; } .chart .l3 { fill: none; stroke: var(--chart-3); stroke-width: 2; stroke-dasharray: 4 3; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- Узкие экраны ---------- */
@media (max-width: 1100px) {
  .order-layout, .calc-layout, .dist-layout { grid-template-columns: minmax(0, 1fr); }
  .order-side, .totals { position: static; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .app .sidebar { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search kbd { display: none; }
  .topbar > .spacer { display: none; }
  .main { padding: 12px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .btn { height: var(--control-h-touch); }
  .btn.sm { height: 36px; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .page-head h1, .order-title h1 { font-size: 19px; line-height: 24px; }
  .order-head { padding: 14px; gap: 12px; }
  .order-title { flex-direction: column; align-items: stretch; }
  .order-title .btn-group { flex-wrap: wrap; }
  .order-title .btn-group .btn.secondary:not(.icon-only) { flex: 1; }
  .fact .v { white-space: normal; flex-wrap: wrap; }
  .step:not(.current) { font-size: 0; }
  .fact .due { white-space: normal; }
  .ai-fields { grid-template-columns: 20px 92px minmax(0, 1fr); }
}

/* поиск: отступ под иконку (после общих правил полей) */
.search input[type=search] { padding-left: 34px; padding-right: 32px; }

/* ---------- Дополнения после аудита ---------- */
/* Числовое поле в ячейке таблицы: справа, фиксированная ширина */
.input.num-in { width: 72px; text-align: right; margin-left: auto; display: block; font-variant-numeric: tabular-nums; }
.input.num-in.w-lg { width: 92px; }
.table td.num .field { align-items: flex-end; }
/* Правка значения в блоке «ИИ предлагает» */
.ai-fields .v .input { height: 30px; font-size: 13px; font-weight: 700; background: var(--surface); }
.ai-fields .v .input:not(:focus) { border-color: var(--line-field); }
/* Строка-предупреждение в карточке на доске */
.deal-alert { display: flex; }
.deal-foot .badge { padding: 0 6px; gap: 4px; min-width: 0; }
.deal-foot .avatar { width: 22px; height: 22px; line-height: 22px; font-size: 10px; }
.deal-foot .avatar.none { line-height: 20px; }
/* Всплывающее окно входящего звонка */
.call-pop { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); }
.call-pop.static { position: static; width: auto; }
.call-pop .call-head { padding: 12px 14px; }
.call-pop .body { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 18px; }
.call-pop .actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-field); }
/* Чек-лист условий (смена шага, договор) */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: start; font-size: 13px; line-height: 18px; }
.checklist .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok-ink); }
.checklist .mark .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.checklist li.miss .mark { background: var(--danger-soft); color: var(--danger-ink); }
.checklist li.miss { color: var(--ink); }
.checklist li.wait .mark { background: var(--off-soft); color: var(--off-ink); }
/* Модальное окно внутри макета (не fixed) */
.backdrop.static { position: absolute; }
.mock-stage { position: relative; }
/* Таймер первого звонка в заявках */
.timer { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.timer.warn { color: var(--warn-ink); }
.timer.danger { color: var(--danger-ink); }
.timer .icon { width: 13px; height: 13px; }
/* Боковая панель на странице списка (форма новой заявки, фильтры) */
.list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.list-layout > aside { position: sticky; top: 72px; }
@media (max-width: 1100px) { .list-layout { grid-template-columns: minmax(0, 1fr); } .list-layout > aside { position: static; } }
/* Группы в списке задач */
.group-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-alt); border-bottom: 1px solid var(--line-field); font-size: 12px; line-height: 16px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .06em; }
.group-head.danger { color: var(--danger-ink); }
/* Переключатель (настройки) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { appearance: none; width: 32px; height: 18px; margin: 0; border-radius: var(--radius-pill); background: var(--off-solid); position: relative; cursor: pointer; transition: background-color .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked { background: var(--ok-solid); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:disabled { opacity: .45; cursor: not-allowed; }
/* Обратный отсчёт у партнёра */
.countdown { display: flex; align-items: baseline; gap: 8px; }
.countdown b { font-size: 28px; line-height: 34px; font-variant-numeric: tabular-nums; }

/* ================= Обратная связь и микро-анимации ================= */
/* Правило: двигаются только прозрачность, цвет фона и сдвиг до 8 px. Без пружин, отскоков и масштабирования больше 2%. */

/* 1. Нажатие */
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn:active:not([disabled]):not(.secondary):not(.ghost):not(.danger):not(.dark) { background: var(--accent-hover); }
.btn.secondary:active:not([disabled]), .btn.ghost:active:not([disabled]) { background: var(--line-field); }
.nav-item:active, .chip:active, .tab:active, .deal:active, .m-card:active { background-color: var(--surface-alt); }
.deal, .m-card, .nav-item, .chip, .table tbody tr td { transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out); }

/* 2. Тосты: подтверждение действия, «Отменить», ошибка */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column-reverse; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toasts.static { position: static; transform: none; width: 440px; flex-direction: column; }
.toast { position: relative; overflow: hidden; pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 10px 10px 14px; background: var(--ink); color: var(--on-ink); border-radius: var(--radius-btn); box-shadow: var(--shadow-pop); font-size: 14px; line-height: 20px; animation: jc-toast-in var(--dur-2) var(--ease-out); }
.toast .icon { flex: none; color: var(--accent); }
.toast.danger .icon { color: var(--danger-soft); }
.toast .msg { flex: 1; min-width: 0; }
.toast .msg b { font-weight: 700; }
.toast .act { flex: none; height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--accent); font: 700 13px/1 var(--font-sans); cursor: pointer; }
.toast .act:hover { background: rgba(255, 255, 255, .08); }
.toast .act:focus-visible, .toast .x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toast .x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--on-ink); display: grid; place-items: center; cursor: pointer; opacity: .8; }
.toast .x .icon { color: inherit; width: 14px; height: 14px; }
.toast .timer-line { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); transform-origin: left; animation: jc-toast-timer var(--dur-toast) linear forwards; }
.toast.is-leaving { animation: jc-toast-out var(--dur-2) var(--ease-in) forwards; }
@keyframes jc-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes jc-toast-out { to { opacity: 0; transform: translateY(4px); } }
@keyframes jc-toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* 3. Подсветка изменённого: поле, строка, итог после сохранения или ответа сервера */
.flash { animation: jc-flash var(--dur-flash) var(--ease-out); }
@keyframes jc-flash { 0%, 25% { background-color: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-hover); } 100% { background-color: transparent; box-shadow: 0 0 0 2px transparent; } }
.count.is-bumped { animation: jc-bump var(--dur-flash) var(--ease-out); }
@keyframes jc-bump { 0%, 25% { background: var(--accent); border-color: var(--accent); } 100% { } }

/* 4. Индикатор сохранения (автосохранение черновика, поля в таблице) */
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ink-muted); white-space: nowrap; }
.save-state .icon { width: 13px; height: 13px; }
.save-state.is-saving .spinner { width: 12px; height: 12px; border-width: 1.5px; }
.save-state.is-saved { color: var(--ok-ink); animation: jc-fade var(--dur-2) var(--ease-out); }
.save-state.is-error { color: var(--danger-ink); font-weight: 700; }

/* 5. Задача выполнена: зачёркивание, затем строка схлопывается */
.task .title { transition: color var(--dur-2) var(--ease-out); }
.task.is-done .title { text-decoration: line-through; text-decoration-color: var(--ink-muted); }
.task.is-leaving, tr.is-leaving { animation: jc-leave var(--dur-3) var(--ease-in) 600ms forwards; }
@keyframes jc-leave { to { opacity: 0; } }
.collapse-out { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-3) var(--ease-in), opacity var(--dur-3) var(--ease-in); }
.collapse-out > * { overflow: hidden; min-height: 0; }
.collapse-out.is-collapsed { grid-template-rows: 0fr; opacity: 0; }

/* 6. Перетаскивание на доске */
.deal[draggable="true"] { cursor: grab; }
.deal.is-dragging { opacity: .45; }
.deal.is-drag-ghost { transform: rotate(-1deg); box-shadow: var(--shadow-pop); border-color: var(--ink-muted); }
.drop-slot { height: 64px; border: 2px dashed var(--ok-solid); border-radius: var(--radius-card); background: var(--accent-soft); }
.col.is-drop-ok { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--ok-solid); transition: background-color var(--dur-1), box-shadow var(--dur-1); }
.col.is-drop-no { background: var(--danger-soft); box-shadow: inset 0 0 0 2px var(--danger-solid); cursor: not-allowed; }
.col .drop-hint { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; line-height: 16px; padding: 6px 4px; }
.col.is-drop-no .drop-hint { color: var(--danger-ink); }
.col.is-drop-ok .drop-hint { color: var(--ok-ink); }

/* 7. Прогресс загрузки файла */
.progress { position: relative; height: 4px; border-radius: var(--radius-pill); background: var(--line-field); overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--ink); transition: width var(--dur-2) linear; }
.progress.ok > i { background: var(--ok-solid); }
.progress.danger > i { background: var(--danger-solid); }
.upload-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; }
.upload-row .meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.thumb.is-uploading::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 8px; height: 4px; border-radius: 999px; background: var(--line-field); }
.thumb .bar { position: absolute; left: 8px; bottom: 8px; height: 4px; border-radius: 999px; background: var(--ink); z-index: 1; transition: width var(--dur-2) linear; }

/* 8. Окна: появление */
.backdrop { animation: jc-fade var(--dur-2) var(--ease-out); }
.dialog { animation: jc-toast-in var(--dur-2) var(--ease-out); }
.dialog.danger-confirm .card-head h2 { color: var(--danger-ink); }

/* Раскрытие деталей (расшифровка, «ещё») */
details > summary .icon { transition: transform var(--dur-1) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  .toast .timer-line { display: none; }
  .flash { animation: none !important; background-color: var(--accent-soft); }
}

/* ---------- База компонентов (/ui) ---------- */
.ui-code { margin: 8px 0 0; padding: 10px 12px; background: var(--surface-alt); border-radius: var(--radius-btn); font-size: 12px; line-height: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ui-swatch { display: inline-block; width: 48px; height: 20px; border-radius: var(--radius-sm); border: 1px solid var(--line-field); vertical-align: middle; }

/* ---------- Добавлено при внедрении (docs/design/components.md, «Вспомогательные») ---------- */
[x-cloak] { display: none !important; }
.grow { flex: 1; min-width: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.call-foot { padding: 0 14px 12px; }
.call-foot .ai { margin: 0; }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card:not([open]) > summary.card-head { border-bottom: 0; }
.input.sm { height: var(--control-h-sm); width: auto; max-width: 180px; padding: 0 8px; font-size: 13px; }
.task form { margin: 0; }
.task .body form { margin-top: 6px; }
.kpi .v.danger, .danger-text { color: var(--danger-ink); }
a.kpi { text-decoration: none; color: inherit; transition: background-color var(--dur-1) var(--ease-out); }
a.kpi:hover { background: var(--accent-soft); }
@media (min-width: 1101px) { .dist-order { position: sticky; top: 72px; } } /* в одну колонку не липнет — иначе закрывает кандидатов */
.order-side .cand { grid-template-columns: minmax(0, 1fr); padding: 12px; }
.kv { grid-template-columns: 110px minmax(0, 1fr); }
details.obj-row > summary { list-style: none; cursor: pointer; }
details.obj-row > summary::-webkit-details-marker { display: none; }
details.obj-row[open] { background: var(--surface-section); }
.tg-logo { height: 32px; width: auto; }
.main > .tg { margin: 0; }
.main > .tg .tg-head { position: static; padding: 0; border: 0; min-height: 0; }
.main > .tg .m-card .row .input { height: var(--control-h-touch); font-size: 16px; }
.card-body.flush > .table-wrap { border: 0; border-radius: 0; }
.kpi .empty-icon { width: 32px; height: 32px; }

/* ---------- Расчёт: поля в ячейках ---------- */
/* .input.sm ниже по файлу сбрасывал ширину числовых полей, а .field input:not(...) перебивал рамку ошибки. */
.input.sm.num-in { width: 72px; max-width: none; }
.input.sm.num-in.w-lg, .table td.num .field .input.num-in.w-lg { width: 92px; }
.input.sm.wide { width: 100%; min-width: 180px; max-width: none; }
.input.sm.unit { width: 64px; }
.field.has-error input:not([type=checkbox]):not([type=radio]):not([type=file]) { border-color: var(--danger-solid); }

/* ---------- Карта компании (п. 11.6): отдельного эталона нет, блоки на токенах кита ---------- */
.map-title { margin: 24px 0 8px; font-weight: 400; }
.map-row { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.map-block { color: var(--ink); display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-card); text-decoration: none; }
.map-block:hover { border-color: var(--accent-hover); background: var(--accent-soft); }
.map-block.top { border-color: var(--accent-hover); }
.map-block.partner { background: var(--surface-alt); }
.map-block.kb { border-style: dashed; }
.map-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.map-step { color: var(--ink); display: flex; flex-direction: column; padding: 8px 12px; border-radius: var(--radius-btn);
  background: var(--accent-soft); text-decoration: none; }
.map-step:hover { background: var(--accent); }
.map-arrow { color: var(--ink-muted); display: inline-flex; }
@media (max-width: 600px) { .map-flow { flex-direction: column; align-items: stretch; } .map-arrow { text-align: center; transform: rotate(90deg); } }


/* ---------- Агент площадок ---------- */
.agent-changes td { vertical-align: top; }
.agent-step { margin: 6px 0; padding: 6px 8px; background: var(--warn-soft); color: var(--warn-ink); border-radius: var(--radius-btn); white-space: pre-wrap; }
.agent-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-btn); margin: 2px; }

/* ---------- Чаты Авито (п. 6.1): пузыри сообщений, ответ — тем же .composer, что комментарии ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line-field); }
.chat:first-of-type { border-top: 0; padding-top: 0; }
.chat .composer { padding: 8px 0 0; border-top: 0; }
.messages { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.msg { max-width: 80%; padding: 6px 10px; border-radius: var(--radius-btn); background: var(--surface-alt); white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: var(--accent-soft); }

/* ---------- Вход: второй фактор ---------- */
.login-card .qr { display: grid; place-items: center; padding: 8px; background: #fff; border: 1px solid var(--line-field); border-radius: var(--radius-card); }
.login-card .qr svg { width: 200px; height: 200px; }
.recovery-codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.recovery-codes code { font-size: 15px; letter-spacing: .04em; }
.login-card .btn { width: 100%; }
.login-card .btn-group { display: grid; grid-template-columns: 1fr 1fr; }

/* ---------- Логотип: горизонтальный в развёрнутом меню и на входе, вертикальный знак — в свёрнутом меню ---------- */
.sidebar-brand { flex-direction: column; align-items: flex-start; gap: 4px; }
.sidebar-brand img.brand-h { height: 34px; }
.sidebar-brand img.brand-v { display: none; }
.app.collapsed .sidebar-brand img.brand-h { display: none; }
.app.collapsed .sidebar-brand img.brand-v { display: block; }
@media (max-width: 1199px) {
  .app .sidebar-brand img.brand-h { display: none; }
  .app .sidebar-brand img.brand-v { display: block; }
}
.login-card .logo { height: 44px; margin-bottom: 4px; }

/* Узкий экран: переключатель периода листается вбок, а не растягивает страницу; формы с колонками из разметки
   (style="grid-template-columns:…") и карточки кандидатов распределения — в одну колонку. */
@media (max-width: 640px) {
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .form-grid[style] { grid-template-columns: minmax(0, 1fr) !important; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .cand { grid-template-columns: minmax(0, 1fr); padding: 12px; }
}
