/* ==========================================================================
   Aerobox CRM — Design System v2 (SaaS minimalism)
   Слои: 1) токены  2) базис  3) компоненты  4) шелл  5) разделы  6) адаптив
   ========================================================================== */

/* ---------- 1. Токены ---------- */
:root {
  /* браузерная схема: нативные контролы, скроллбары, попапы select/date */
  color-scheme: light;
  accent-color: var(--accent);

  /* поверхность */
  --bg: #F6F7FA;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --border: #E7EAF0;
  --border-strong: #D9DEE8;
  --border-soft: #EFF1F6;

  /* текст */
  --text: #151B28;
  --text-2: #5A6478;
  --text-3: #67707F;
  --text-disabled: #B6BDCC;

  /* бренд */
  --accent: #3155EA;
  --accent-fg: #3155EA;          /* акцент ТОЛЬКО как цвет текста/иконки (AA в обеих темах) */
  --accent-hover: #2846C8;
  --accent-active: #1F3AA8;
  --accent-soft: #EEF2FF;
  --accent-soft-2: #E2E9FF;
  --btn-top: #4163EC;            /* верх градиента первичной кнопки */
  --ring: rgba(49, 85, 234, .28);

  /* сайдбар */
  --sidebar: #131A2C;
  --sidebar-item: #A7B0C4;
  --sidebar-label: #5E6A85;
  --sidebar-hover: #1D2740;
  --sidebar-active: #26314F;

  /* семантика */
  --green: #178A47;  --green-soft: #E7F6EE;  --green-strong: #16A34A;
  --red: #D23030;    --red-soft: #FCEDED;
  --amber: #B45D09;  --amber-soft: #FDF2E3;
  --violet: #6D33D6; --violet-soft: #F2ECFD;
  --cyan: #0879A1;   --cyan-soft: #E3F4FA;
  --pink: #C92573;   --pink-soft: #FBE9F2;
  --gray-soft: #EEF1F6;
  --hover: #F7F9FC;
  --seg-bg: #E9ECF3;

  /* фирменный «рельс» + движение */
  --rail: var(--accent); --rail-w: 3px;
  --ease-out: cubic-bezier(.22,.61,.36,1);

  /* геометрия */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;

  /* тени с внутренним светом по верхней кромке (--lift) */
  --lift: rgba(255, 255, 255, .16);
  --shadow-1:
    0 1px 1px rgba(15, 23, 42, .04),
    0 1px 3px rgba(15, 23, 42, .05),
    inset 0 1px 0 var(--lift);
  --shadow-2:
    0 1px 2px rgba(15, 23, 42, .05),
    0 4px 10px -3px rgba(15, 23, 42, .07),
    0 14px 32px -10px rgba(15, 23, 42, .10),
    inset 0 1px 0 var(--lift);
  --shadow-3:
    0 2px 8px rgba(15, 23, 42, .07),
    0 20px 56px -14px rgba(15, 23, 42, .26),
    inset 0 1px 0 var(--lift);

  /* стекло (полупрозрачные поверхности под backdrop-filter) */
  --glass: rgba(255, 255, 255, .86);
  --glass-head: rgba(250, 251, 253, .84);

  --sidebar-w: 224px;
  --topbar-h: 56px;

  /* типографика */
  --font-display: 'Geologica', 'Manrope', -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-body: 'Manrope', -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --fz-xs: 11px; --fz-sm: 12.5px; --fz-md: 13.5px; --fz-lg: 15px; --fz-xl: 17px; --fz-2xl: 21px;
}

/* ---------- 2. Базис ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fz-md); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; caret-color: var(--accent); }
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); border-radius: var(--r-xs); }
::placeholder { color: var(--text-3); }
::selection { background: var(--accent-soft-2); color: var(--text); }
.num, .amount, .tbl td.num, .stat .val,
.tbl tfoot td, .kb-head .sum, .kb-card .amount,
.kpi-pct { font-variant-numeric: tabular-nums lining-nums; }
.cur { color: var(--text-3); font-weight: 600; font-size: .86em; }
/* денежные значения не переносят символ валюты на новую строку */
.tbl td.num, .tbl tfoot td, .kb-card .amount, .stat .val { white-space: nowrap; }
/* длинные имена без пробелов не рвут сетку */
.kb-card .name, .tbl .cell-main .t { overflow-wrap: anywhere; hyphens: auto; }
/* в реестрах слогоделение мешает сканированию — рвём только по мягким переносам */
.tbl .cell-main .t { hyphens: manual; }
/* полоса прокрутки не сдвигает контент при смене раздела */
.content, .drawer-body { scrollbar-gutter: stable; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   3. КОМПОНЕНТЫ
   ========================================================================== */

/* ---------- Кнопки: 4 размера × 7 вариантов ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--r-sm); font-weight: 700; white-space: nowrap; user-select: none;
  height: 36px; padding: 0 14px; font-size: var(--fz-md);
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-xs { height: 26px; padding: 0 9px;  font-size: var(--fz-xs); gap: 5px; border-radius: var(--r-xs); }
.btn-xs svg { width: 13px; height: 13px; }
.btn-sm { height: 31px; padding: 0 11px; font-size: var(--fz-sm); gap: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: var(--fz-lg); }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(180deg, var(--btn-top) 0%, var(--accent) 58%); color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .16), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 62%); }
.btn-primary:active { background: var(--accent-active); box-shadow: inset 0 2px 4px rgba(10, 20, 60, .32); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--surface-2); border-color: #C7CEDC; }
.btn-soft { background: var(--accent-soft); color: var(--accent-fg); }
.btn-soft:hover { background: var(--accent-soft-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-soft); color: var(--text); }
.btn-danger { background: linear-gradient(180deg, #E04040 0%, var(--red) 58%); color: #fff; }
.btn-danger:hover { background: #B82626; }
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-danger-soft:hover { background: #F8DCDC; }
.btn-success { background: linear-gradient(180deg, #23B85C 0%, var(--green-strong) 58%); color: #fff; }
.btn-success:hover { background: #128A3E; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* иконка-кнопка: 3 размера */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--text-2); flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--gray-soft); color: var(--text); }
.btn-icon svg { width: 17px; height: 17px; }
.btn-icon.xs { width: 24px; height: 24px; border-radius: var(--r-xs); } .btn-icon.xs svg { width: 13px; height: 13px; }
.btn-icon.lg { width: 38px; height: 38px; } .btn-icon.lg svg { width: 19px; height: 19px; }

/* ---------- Поля ввода: 3 размера + состояния ---------- */
.input, .field input, .field select, .field textarea {
  width: 100%; height: 36px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 0 11px; font-size: var(--fz-md); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; min-height: 74px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: #C7CEDC; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
.input.sm { height: 31px; font-size: var(--fz-sm); padding: 0 9px; }
.input.lg { height: 42px; font-size: var(--fz-lg); }
.input.is-error, .field.is-error input { border-color: var(--red); box-shadow: 0 0 0 3px rgba(210,48,48,.15); }
.input[disabled] { background: var(--surface-2); color: var(--text-disabled); cursor: not-allowed; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.field .hint { font-size: var(--fz-xs); color: var(--text-3); margin-top: 4px; }
.field .error-text { font-size: var(--fz-xs); color: var(--red); margin-top: 4px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* поле с иконкой */
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.input-wrap .input { padding-left: 32px; }

/* select */
.field select, .select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6478' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
  transition: border-color .12s, box-shadow .12s, background-position .12s var(--ease-out);
}
.field select:hover, .select:hover { background-position: right 9px center; }
.field select:focus, .select:focus { background-position: right 10px center; }
/* попап нативного списка наследует тему (Windows/Linux игнорируют color-scheme для option) */
select option { background: var(--surface); color: var(--text); }

/* date / time: единая высота, аккуратная иконка календаря */
.field input[type="date"], .field input[type="time"],
.input[type="date"], .input[type="time"] { appearance: none; -webkit-appearance: none; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: .5; cursor: pointer; transition: opacity .12s;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator,
input[type="time"]:focus::-webkit-calendar-picker-indicator { opacity: 1; }

/* number: без спиннеров — суммы правятся с клавиатуры */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select {
  height: 33px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding-left: 11px; font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); background-color: var(--surface);
}
.select:hover { border-color: #C7CEDC; }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* чекбокс / радио / свитч */
.checkbox, .radio { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; }
.checkbox input, .radio input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: all .12s; flex-shrink: 0; }
.checkbox input { border-radius: 5px; }
.radio input { border-radius: 50%; }
.checkbox input:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l5 5L19.5 7'/%3E%3C/svg%3E") center/11px no-repeat;
  border-color: var(--accent);
}
.radio input:checked { border: 5px solid var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 36px; height: 21px; border-radius: 20px; background: #CBD2DF; transition: background .15s; cursor: pointer; flex-shrink: 0; }
.switch input::after {
  content: ''; position: absolute; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; box-shadow: 0 1px 3px rgba(15,23,42,.25);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}
.switch input:checked { background: var(--green-strong); }
.switch input:checked::after { transform: translateX(15px); }
.switch.accent input:checked { background: var(--accent); }

/* ---------- Пилюли-статусы: 2 размера, с точкой ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 2.5px 9px; font-size: var(--fz-xs); font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.pill.sm { padding: 1px 7px; font-size: 10.5px; }
.pill.lg { padding: 4px 12px; font-size: var(--fz-sm); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--accent-soft); color: var(--accent-fg); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.cyan { background: var(--cyan-soft); color: var(--cyan); }
.pill.pink { background: var(--pink-soft); color: var(--pink); }
.pill.gray { background: var(--gray-soft); color: var(--text-2); }
.pill.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.pill.tag { background: var(--gray-soft); color: var(--text-2); font-weight: 700; }
.pill.tag .dot { display: none; }
html[data-theme="dark"] .pill.tag { background: var(--surface-2); color: var(--text-2); }
/* светлая тема: на мягких подложках семантические цвета не добирают AA — берём затемнённые
   варианты только для текста пилюль (в тёмной теме токены уже светлые, их не трогаем) */
:root {
  --pill-green-fg: #0F6634; --pill-amber-fg: #8F4805; --pill-red-fg: #B41F1F;
  --pill-cyan-fg: #0A6486;  --pill-pink-fg: #B01E63;
}
.pill.green { color: var(--pill-green-fg); }
.pill.amber { color: var(--pill-amber-fg); }
.pill.red   { color: var(--pill-red-fg); }
.pill.cyan  { color: var(--pill-cyan-fg); }
.pill.pink  { color: var(--pill-pink-fg); }
html[data-theme="dark"] {
  --pill-green-fg: var(--green); --pill-amber-fg: var(--amber); --pill-red-fg: var(--red);
  --pill-cyan-fg: var(--cyan);   --pill-pink-fg: var(--pink);
}

/* чип-фильтр */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-fg); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-fg); }
.chip .cnt { font-weight: 800; opacity: .65; }

/* бейдж-счётчик */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 10px; font-size: 10.5px; font-weight: 800; background: var(--accent); color: #fff; }
.badge.gray { background: var(--gray-soft); color: var(--text-2); }
.badge.red { background: var(--red); }

/* тип файла */
.filetag { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-sm); font-size: 10px; font-weight: 800; letter-spacing: .03em; flex-shrink: 0; }
.filetag.pdf { background: var(--red-soft); color: var(--red); }
.filetag.docx { background: var(--accent-soft); color: var(--accent-fg); }
.filetag.xlsx { background: var(--green-soft); color: var(--green); }
.filetag.sm { width: 28px; height: 28px; font-size: 8.5px; border-radius: var(--r-xs); }

/* ---------- Аватары: 5 размеров + группа ---------- */
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; letter-spacing: .02em;
}
.avatar.xs { width: 20px; height: 20px; font-size: 8.5px; }
.avatar.sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 60px; height: 60px; font-size: 20px; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--surface); margin-left: -7px; }
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .more { background: var(--gray-soft); color: var(--text-2); }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card.hoverable { transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.card.hoverable:hover { border-color: #C9D4F5; box-shadow: var(--shadow-2); }
.clickable-stat { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .12s; }
.clickable-stat:hover { border-color: #C9D4F5; box-shadow: var(--shadow-2); transform: translateY(-1px); }
.clickable-stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.clickable-stat.stat-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-2); }

/* stat-карточка */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 15px 17px; position: relative; }
.stat .lbl { font-size: var(--fz-xs); font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.stat .val { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.022em; margin-top: 6px; line-height: 1.1; color: var(--text); }
.stat .val.pos { color: var(--green); }
.stat .val.neg { color: var(--red); }
.stat .val.warn { color: var(--amber); }
.stat .sub { font-size: var(--fz-sm); margin-top: 4px; font-weight: 600; color: var(--text-3); }

/* примыкающий «рельс» у ключевого KPI */
.stat.primary::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: var(--rail-w);
  border-radius: 0 3px 3px 0; background: var(--rail); }

/* заголовок stat с иконкой (готовит волну 2) */
.stat .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat .spark { margin-top: 8px; line-height: 0; }
.stat .spark svg { width: 100%; height: 30px; }
.emp-risk { display: flex; flex-direction: column; }
.emp-risk-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 6px; border: none; background: none; text-align: left; cursor: pointer; border-bottom: 1px solid var(--border-soft); font-size: 13px; transition: background .1s; border-radius: var(--r-sm); }
.emp-risk-row:last-child { border-bottom: none; }
.emp-risk-row:hover { background: var(--hover); }
.emp-risk-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.stat-ic { width: 22px; height: 22px; border-radius: var(--r-xs); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-ic svg { width: 13px; height: 13px; }
.stat-ic.blue { background: var(--accent-soft); color: var(--accent-fg); }
.stat-ic.green { background: var(--green-soft); color: var(--green); }
.stat-ic.amber { background: var(--amber-soft); color: var(--amber); }
.stat-ic.gray { background: var(--gray-soft); color: var(--text-2); }
.stat-ic.violet { background: var(--violet-soft); color: var(--violet); }
.stat .trend { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fz-xs); font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.stat .trend.up { background: var(--green-soft); color: var(--green); }
.stat .trend.down { background: var(--red-soft); color: var(--red); }

/* ---------- Таблицы: обычная + компактная ---------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: auto; max-height: calc(100vh - 210px); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fz-md); }
.tbl th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl.compact td { padding: 7px 14px; font-size: var(--fz-sm); }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num, .tbl th.num { text-align: right; }
.tbl .bold { font-weight: 700; }
.tbl .cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl .cell-main .t { font-weight: 700; color: var(--text); }

/* фирменный «рельс» слева у строк-действий */
.tbl tbody tr.clickable td:first-child { position: relative; }
.tbl tbody tr.clickable td:first-child::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: var(--rail-w);
  border-radius: 0 3px 3px 0; background: var(--rail); opacity: 0; transform: scaleY(.4);
  transform-origin: center; transition: opacity .15s var(--ease-out), transform .15s var(--ease-out);
}
.tbl tbody tr.clickable:hover td:first-child::before { opacity: 1; transform: scaleY(1); }

/* кнопка удаления в строке — проявляется на hover */
.tbl tbody tr .btn-icon[data-del-prod],
.tbl tbody tr .btn-icon[data-del-task],
.task-row [data-del-task] { opacity: 0; transition: opacity .12s; }
.tbl tbody tr:hover .btn-icon[data-del-prod],
.tbl tbody tr:hover .btn-icon[data-del-task],
.task-row:hover [data-del-task],
.tbl tbody tr .btn-icon[data-del-prod]:focus-visible,
.tbl tbody tr .btn-icon[data-del-task]:focus-visible,
.task-row [data-del-task]:focus-visible { opacity: 1; }
.tbl .cell-main .s { font-size: var(--fz-xs); color: var(--text-3); margin-top: 1px; }
.tbl tfoot td { position: sticky; bottom: 0; background: var(--surface-2); border-top: 1px solid var(--border); font-weight: 800; }
/* числовой акцент — дисплейным шрифтом, на ступень легче */
.tbl td.num.bold, .tbl tfoot td { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

/* ---------- Табы ---------- */
.subnav { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.subnav button {
  padding: 9px 13px; font-size: var(--fz-md); font-weight: 700; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s;
  display: inline-flex; align-items: center; gap: 7px;
}
.subnav button:hover { color: var(--text); }
.subnav button.active { color: var(--accent-fg); border-bottom-color: var(--accent); }
.subnav .cnt { font-size: var(--fz-xs); font-weight: 800; background: var(--gray-soft); color: var(--text-2); border-radius: 999px; padding: 1px 7px; }
.subnav button.active .cnt { background: var(--accent-soft); color: var(--accent-fg); }

/* сегмент-контрол: 2 размера */
.seg { display: inline-flex; background: var(--seg-bg); border-radius: var(--r-sm); padding: 3px; }
.seg button { padding: 5px 13px; border-radius: var(--r-xs); font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; transition: all .12s; }
.seg button svg { width: 14px; height: 14px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.14); }
.seg.sm button { padding: 3px 9px; font-size: var(--fz-xs); }

/* ---------- Тулбар ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Меню (dropdown) ---------- */
.menu {
  position: fixed; z-index: 90; min-width: 190px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3);
  padding: 5px; animation: pop .13s ease;
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-xs); font-size: var(--fz-md); font-weight: 600; color: var(--text);
}
.menu-item svg { width: 15px; height: 15px; color: var(--text-3); }
.menu-item:hover { background: var(--gray-soft); }
.menu-item.danger { color: var(--red); }
.menu-item.danger svg { color: var(--red); }
.menu-item.danger:hover { background: var(--red-soft); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* ---------- Тултип ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: #1B2233; color: #fff; font-size: var(--fz-xs); font-weight: 600; white-space: nowrap;
  padding: 5px 9px; border-radius: var(--r-xs); z-index: 95; pointer-events: none;
  animation: fade-in .12s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Прогресс и шаги ---------- */
.progress { height: 7px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress.sm { height: 5px; }
.progress.lg { height: 10px; }
.stages-track { display: flex; gap: 3px; }
.stages-track span { flex: 1; height: 5px; border-radius: 3px; background: var(--gray-soft); }
.stages-track span.on { background: var(--accent); }

/* ---------- Модалка / Drawer ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13, 18, 32, .5); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-xl); width: 540px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 24px;
  box-shadow: var(--shadow-3), 0 0 0 1px rgba(15, 23, 42, .06);
  animation: pop .16s ease;
}
.modal.sm { width: 420px; } .modal.lg { width: 720px; }
@keyframes pop { from { transform: scale(.97) translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { font-family: var(--font-display); font-size: var(--fz-xl); font-weight: 600; letter-spacing: -.012em; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.drawer-overlay {
  position: fixed; inset: 0; background: rgba(13, 18, 32, .45); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease-out); backdrop-filter: blur(1px);
}
.drawer-overlay:not(.open) { transition-duration: .15s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 96vw;
  background: var(--surface); z-index: 51; box-shadow: var(--shadow-3);
  border-left: 1px solid var(--border);
  transform: translateX(105%); transition: transform .26s var(--ease-out); display: flex; flex-direction: column;
}
.drawer:not(.open) { transition-duration: .18s; }
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head .top { display: flex; align-items: flex-start; gap: 10px; }
.drawer-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -.012em; flex: 1; line-height: 1.35; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 22px 22px; }
.drawer-tabs { display: flex; gap: 2px; margin-top: 14px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tabs button { flex-shrink: 0; white-space: nowrap; }
.drawer-tabs button { padding: 9px 12px; font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.drawer-tabs button.active { color: var(--accent-fg); border-bottom-color: var(--accent); }
.drawer-foot { padding: 13px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--surface); }

/* список свойств */
.prop-list { display: grid; grid-template-columns: 132px 1fr; row-gap: 11px; column-gap: 12px; font-size: var(--fz-md); align-items: center; }
.prop-list dt { color: var(--text-3); font-weight: 600; }
.prop-list dd { font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.prop-list .pl-sep { grid-column: 1 / -1; height: 1px; background: var(--border-soft); margin: 5px 0 3px; padding: 0; }
.prop-list dd .dash, .prop-list dd.is-empty { color: var(--text-3); font-weight: 600; }
.prop-list dd.pl-hero { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums lining-nums; }
.prop-list dd.pl-hero .cur { font-size: .62em; }

/* строка-элемент внутри карточек/drawer */
.row-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; background: var(--surface);
  transition: border-color .12s, background .12s;
}
.row-item.clickable { cursor: pointer; }
.row-item.clickable:hover { border-color: #C9D4F5; background: var(--surface-2); }
.stage-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; background: var(--surface); }
.stage-dot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }

/* ---------- Пустые состояния ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; padding: 11px; margin: 0 auto 12px; display: block; box-sizing: content-box;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-fg); }
.empty .t { font-weight: 800; color: var(--text-2); margin-bottom: 4px; font-size: var(--fz-lg); }
.empty p { font-size: var(--fz-md); max-width: 340px; margin: 0 auto; line-height: 1.5; }

/* прочерк-заглушка */
.dash { color: var(--text-3); }

/* ---------- Тосты ---------- */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: var(--r-md); font-weight: 700; font-size: var(--fz-md);
  box-shadow: var(--shadow-3); animation: toast-in .2s ease;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green-strong); flex-shrink: 0; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- kbd ---------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 21px; height: 21px;
  padding: 0 5px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); font-size: 11px; font-weight: 800; color: var(--text-2);
}

/* ==========================================================================
   4. ШЕЛЛ (auth, sidebar, topbar)
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; }
.auth-logo { position: fixed; top: 28px; left: 32px; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: 40px 44px; }
.auth-card h1 { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -.012em; margin-bottom: 26px; }
.auth-field { margin-bottom: 20px; }
.auth-field .row { display: flex; justify-content: space-between; align-items: baseline; }
.auth-field label { display: block; font-size: var(--fz-sm); color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.auth-field a { font-size: var(--fz-sm); color: var(--text-3); }
.auth-field input { width: 100%; border: none; border-bottom: 1px solid var(--border-strong); padding: 8px 2px; font-size: var(--fz-lg); background: transparent; border-radius: 0; }
.auth-field input:focus { outline: none; border-bottom-color: var(--accent); box-shadow: none; }
.auth-foot { display: flex; gap: 20px; margin-top: 8px; font-size: var(--fz-sm); color: var(--text-3); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: var(--fz-sm); margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-oauth { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.app { display: none; height: 100vh; }
.app.visible { display: flex; }

/* сайдбар */
.sidebar { width: var(--sidebar-w); background: var(--sidebar); display: flex; flex-direction: column; flex-shrink: 0; }
.sb-logo { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 16.5px; letter-spacing: .005em; }
.sb-nav { flex: 1; padding: 4px 10px 10px; overflow-y: auto; scrollbar-width: thin; }
.sb-group { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-label); padding: 14px 12px 5px; }
.sb-item {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 11px; border-radius: var(--r-sm); color: var(--sidebar-item); font-size: 13px; font-weight: 700;
  margin-bottom: 1px; transition: background .12s, color .12s; text-align: left;
}
.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.sb-item:hover { background: var(--sidebar-hover); color: #fff; }
.sb-item.active { background: var(--sidebar-active); color: #fff; }
.sb-item.active::before {
  content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.sb-item .cnt { margin-left: auto; background: rgba(255,255,255,.13); border-radius: 10px; padding: 1px 7px; font-size: 10.5px; font-weight: 800; }
.sb-item .cnt.hot { background: var(--accent); color: #fff; }
.sb-item:empty { display: none; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-top: 1px solid rgba(255,255,255,.07); cursor: pointer; }
.sb-user:hover { background: var(--sidebar-hover); }
.sb-user .name { color: #fff; font-weight: 700; font-size: 12.5px; }
.sb-user .mail { font-size: 11px; color: #7C87A0; }

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

/* топбар */
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; flex-shrink: 0;
}
.topbar h1 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -.012em; }
.topbar .subtitle { font-size: var(--fz-sm); color: var(--text-3); font-weight: 600; margin-top: 1px; }
.top-search { position: relative; margin-left: auto; }
.top-search input {
  width: 280px; height: 34px; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 0 12px 0 34px; font-size: var(--fz-sm); background: var(--surface-2); transition: all .15s;
}
.top-search input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--ring); width: 320px; }
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.top-search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.top-search input::placeholder { color: var(--text-2); }

.content { flex: 1; overflow: auto; padding: 18px 20px; }
.content.no-pad { padding: 0; }

/* ==========================================================================
   5. РАЗДЕЛЫ
   ========================================================================== */

/* ---------- Канбан ---------- */
.kanban { display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px; overflow-x: auto; min-height: 100%; }
/* правый край: padding-right флекс-контейнера при overflow съедается — держим его на колонке */
.kanban { padding-right: 0; }
.kb-col { width: 286px; flex-shrink: 0; }
.kb-col:last-child { margin-right: 20px; }
.kb-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.kb-head .kb-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kb-head .t { font-weight: 800; font-size: var(--fz-md); }
.kb-head .cnt { font-size: var(--fz-xs); font-weight: 800; color: var(--text-3); background: var(--gray-soft); border-radius: 999px; padding: 1px 7px; }
.kb-head .sum { margin-left: auto; font-family: var(--font-display); font-size: 13px; color: var(--text-2); font-weight: 600; letter-spacing: -.01em; }
.kb-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: var(--r-md); transition: background .15s, outline .15s; padding-bottom: 36px; }
.kb-cards.dragover { background: var(--accent-soft); outline: 2px dashed var(--accent-soft-2); }
.kb-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 11px 12px 11px 15px; box-shadow: var(--shadow-1); cursor: pointer; overflow: hidden;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.kb-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stripe, var(--accent)); }
.kb-card:hover { border-color: #C9D4F5; box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kb-card.dragging { opacity: .45; transform: rotate(1.5deg); }
.kb-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.kb-card .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.kb-card .tags:empty { display: none; }
.kb-card .name { font-weight: 700; font-size: var(--fz-md); line-height: 1.4; }
.kb-card .amount { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -.015em; margin-top: 5px; }
.kb-card .who { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--text-3); font-size: var(--fz-sm); font-weight: 600; }
.kb-card .who svg { width: 13px; height: 13px; }
.kb-card .foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.kb-card .task-flag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fz-xs); font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.kb-card .task-flag svg { width: 12px; height: 12px; }
.kb-card .task-flag.future, .kb-card .task-flag.gray { background: var(--gray-soft); color: var(--text-2); }
.kb-card .task-flag.today, .kb-card .task-flag.amber { background: var(--amber-soft); color: var(--amber); }
.kb-card .task-flag.overdue, .kb-card .task-flag.red { background: var(--red-soft); color: var(--red); }
.kb-card .deal-age { font-size: var(--fz-xs); font-weight: 700; color: var(--text-3); }
.kb-card .deal-age.amber { color: var(--amber); }
.kb-card .deal-age.red { color: var(--red); font-weight: 800; }
.kb-card .foot .avatar { margin-left: auto; }
.kb-add { width: 100%; padding: 9px; border-radius: var(--r-md); color: var(--text-3); font-weight: 700; font-size: var(--fz-sm); border: 1.5px dashed var(--border-strong); transition: all .12s; }
.kb-add:hover { color: var(--accent-fg); border-color: var(--accent); background: var(--accent-soft); }
/* компактный плейсхолдер пустой колонки канбана (заявки/тикеты) */
.kb-empty { padding: 14px 0; text-align: center; font-size: var(--fz-xs); font-weight: 700; color: var(--text-3); border: 1.5px dashed var(--border-soft); border-radius: var(--r-md); }
/* карточка заявки: текст обращения в 2 строки */
.kb-card .lead-msg { margin-top: 6px; font-size: var(--fz-sm); color: var(--text-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* SLA-чип возраста на карточках канбана (заявки/тикеты) */
.kb-card .sla-chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fz-xs); font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--accent-soft); color: var(--accent-fg); }
.kb-card .sla-chip svg { width: 11px; height: 11px; }
.kb-card .sla-chip.muted { background: var(--gray-soft); color: var(--text-2); }
.kb-card .sla-chip.over { background: var(--red-soft); color: var(--red); }
.kb-card .tk-rating { margin-left: auto; font-size: var(--fz-sm); font-weight: 800; color: var(--amber); white-space: nowrap; }

/* ---------- Задачи ---------- */
.task-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background .1s; }
.task-row:hover { background: var(--hover); }
.task-row:last-child { border-bottom: none; }
.task-check {
  width: 20px; height: 20px; border-radius: 50%; border: 1.7px solid #C4CBDA; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: all .13s;
}
.task-check:hover { border-color: var(--green-strong); background: var(--green-soft); }
.task-check.done { background: var(--green-strong); border-color: var(--green-strong); color: #fff; }
.task-check svg { width: 11px; height: 11px; }
.task-type { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r-sm); flex-shrink: 0; }
.task-type svg { width: 15px; height: 15px; }
.task-type.call { background: var(--green-soft); color: var(--green); }
.task-type.email { background: var(--amber-soft); color: var(--amber); }
.task-type.meeting { background: var(--violet-soft); color: var(--violet); }
.task-type.task { background: var(--accent-soft); color: var(--accent-fg); }
.task-row .t-name { font-weight: 700; }
.task-row .t-sub { font-size: var(--fz-xs); color: var(--text-3); margin-top: 1px; }
.task-row.completed .t-name { text-decoration: line-through; color: var(--text-3); }
.task-row .t-deal { display: flex; align-items: center; gap: 5px; flex: 0 1 210px; min-width: 0; justify-content: flex-end;
  font-size: 12px; font-weight: 600; color: var(--text-2); }
.task-row .t-deal svg { flex-shrink: 0; color: var(--text-3); }
.task-row .t-deal span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .task-row .t-deal { display: none; } }
.t-group-head { padding: 13px 16px 7px; font-size: var(--fz-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.t-group-head.overdue { color: var(--red); }

/* ---------- Чаты ---------- */
.chat-layout { display: flex; height: 100%; background: var(--surface); }
.chat-list { width: 300px; border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
.chat-item { display: flex; gap: 11px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--border-soft); transition: background .1s; }
.chat-item:hover { background: var(--hover); }
.chat-item, .row-item { position: relative; }
.chat-item.active { background: var(--accent-soft); }
.chat-item.active::before, .row-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: var(--rail-w);
  border-radius: 0 3px 3px 0; background: var(--rail);
}
.row-item.active { border-color: var(--accent); background: var(--accent-soft); }
.chat-item .cn { font-weight: 700; font-size: var(--fz-md); display: flex; justify-content: space-between; gap: 8px; }
.chat-item .cn time { font-weight: 600; color: var(--text-3); font-size: var(--fz-xs); }
.chat-item .cp { font-size: var(--fz-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; margin-top: 1px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 11px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.chat-msgs > .msg:first-child { margin-top: auto; }
.msg { max-width: 62%; padding: 9px 13px; border-radius: 14px; font-size: var(--fz-md); line-height: 1.5; box-shadow: var(--shadow-1); }
.msg.in { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.out { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg time { display: block; font-size: 10px; opacity: .6; margin-top: 3px; text-align: right; }
.chat-input { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 0 14px; }
.chat-input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ---------- Дашборды ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* нечётная последняя карточка не оставляет пустую половину ряда */
.chart-grid > .chart-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.chart-card { padding: 17px; }
.chart-card h3 { font-family: var(--font-display); font-size: var(--fz-md); font-weight: 600; letter-spacing: -.012em; margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; }
@media (max-width: 1000px) { .chart-grid { grid-template-columns: 1fr; } }

/* ---------- Настройки / интеграции ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.int-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.int-card .ic { width: 40px; height: 40px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; }
.int-card .ic svg { width: 20px; height: 20px; }
.int-card h3 { font-size: var(--fz-md); font-weight: 800; display: flex; align-items: center; gap: 8px; }
.int-card p { font-size: var(--fz-sm); color: var(--text-2); line-height: 1.5; flex: 1; }

.tag-funnel { font-size: var(--fz-xs); color: var(--text-2); font-weight: 700; background: var(--gray-soft); padding: 3px 10px; border-radius: var(--r-xs); }

/* ---------- Таймлайн (документы, история) ---------- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent-fg); }
.tl-item.muted::before { border-color: var(--border-strong); }
.tl-item .tt { font-weight: 700; font-size: var(--fz-md); }
.tl-item .ts { font-size: var(--fz-xs); color: var(--text-3); margin-top: 2px; }
.activity-grid { display: grid; gap: 2px 28px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.activity-grid .tl-item { padding: 8px 0 8px 16px; }
.activity-grid .tl-item::before { top: 12px; left: 0; }

/* ==========================================================================
   6. Адаптив
   ========================================================================== */
@media (max-width: 900px) {
  .sidebar { width: 62px; }
  .sb-item span, .sb-logo span, .sb-user > div, .sb-item .cnt, .sb-group { display: none; }
  .sb-item { justify-content: center; padding: 10px; }
  .sb-item.active::before { left: -10px; }
  .sb-logo { justify-content: center; padding: 16px 0; }
  .top-search input { width: 150px; }
  .top-search input:focus { width: 170px; }
  .top-search .kbd { display: none; }
  .drawer { width: 100vw; max-width: 100vw; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .chat-list { width: 220px; }
}
@media (max-width: 620px) {
  .content { padding: 12px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .subtitle { display: none; }
  .chat-list { display: none; }
}
@media (max-width: 560px) {
  /* заголовок раздела важнее поиска — не ужимаем его первым */
  .topbar h1 { flex-shrink: 0; max-width: 45vw; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-search { min-width: 0; flex-shrink: 2; }
  .top-search input { width: 100%; min-width: 0; }
  .top-search input:focus { width: 100%; }
  .top-search .kbd { display: none; }
  .topbar #create-btn .cbtn-label { display: none; }
  .topbar #create-btn { padding-left: 10px; padding-right: 10px; }
  .topbar #create-btn .cbtn-plus { font-size: 17px; line-height: 1; }

  /* тач-таргеты: пункты меню — полные 44px, кнопки топбара и «×» — комфортный минимум */
  .sb-item { min-height: 44px; }
  .topbar .btn, .topbar .btn-icon { min-height: 40px; }
  .topbar .btn-icon { min-width: 40px; }
  .notif-head .btn-icon.xs, .daily-head .btn-icon.xs { width: 32px; height: 32px; }
  .notif-head .btn-icon.xs svg, .daily-head .btn-icon.xs svg { width: 15px; height: 15px; }
}

/* ==========================================================================
   7. Компоненты v2.1 — задачи, портал, расширенный кит
   ========================================================================== */

/* ---------- Ползунок (range) ---------- */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--gray-soft) var(--fill, 50%)); outline: none; cursor: pointer; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--accent); box-shadow: var(--shadow-1); cursor: grab; }
.range::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); box-shadow: var(--shadow-1); cursor: grab; }
.range:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.08); }
.range.green { background: linear-gradient(to right, var(--green-strong) var(--fill, 50%), var(--gray-soft) var(--fill, 50%)); }
.range.green::-webkit-slider-thumb { border-color: var(--green-strong); }

/* ---------- Алерты ---------- */
.alert { display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fz-md); font-weight: 600; border: 1px solid; align-items: flex-start; }
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert b { display: block; margin-bottom: 2px; }
.alert.info { background: var(--accent-soft); border-color: #D6E0FF; color: #23409f; }
.alert.info svg { color: var(--accent-fg); }
.alert.success { background: var(--green-soft); border-color: #C9EBD7; color: #135F35; }
.alert.success svg { color: var(--green); }
.alert.warn { background: var(--amber-soft); border-color: #F4E0BC; color: #7C4207; }
.alert.warn svg { color: var(--amber); }
.alert.error { background: var(--red-soft); border-color: #F5CDCD; color: #8F2222; }
.alert.error svg { color: var(--red); }
.alert .hint-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 22px; flex: 1; }
.alert .hint-grid b { display: block; margin-bottom: 1px; }
@media (max-width: 720px) { .alert .hint-grid { grid-template-columns: 1fr; } }

/* ---------- Скелетоны и спиннер ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--gray-soft); border-radius: var(--r-xs); }
.skeleton::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--gray-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
/* компактная загрузка внутри уже отрисованного блока — не пустое состояние на пол-экрана */
.loading-inline {
  display: flex; align-items: center; gap: 9px; padding: 14px 2px;
  font-size: var(--fz-sm); font-weight: 600; color: var(--text-2);
}
.loading-inline .spinner { width: 15px; height: 15px; border-width: 2px; }
/* подсказка под коротким списком */
.list-hint {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; padding: 11px 14px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
  font-size: var(--fz-sm); font-weight: 600; color: var(--text-2);
}
.spinner.lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Хлебные крошки / пагинация / шаги ---------- */
.breadcrumbs { display: flex; align-items: center; gap: 7px; font-size: var(--fz-sm); font-weight: 600; color: var(--text-3); flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs .sep { color: var(--border-strong); }
.breadcrumbs .cur { color: var(--text); font-weight: 700; }
.pagination { display: inline-flex; gap: 4px; }
.pagination button { min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--r-sm); font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); }
.pagination button:hover { background: var(--gray-soft); }
.pagination button.active { background: var(--accent); color: #fff; }
.pagination button:disabled { opacity: .4; }
.stepper { display: flex; align-items: center; gap: 0; }
.stepper .step { display: flex; align-items: center; gap: 9px; font-size: var(--fz-sm); font-weight: 700; color: var(--text-3); }
.stepper .step .num { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1.7px solid var(--border-strong); font-size: 12px; font-weight: 800; background: var(--surface); flex-shrink: 0; }
.stepper .step.done .num { background: var(--green-strong); border-color: var(--green-strong); color: #fff; }
.stepper .step.active { color: var(--text); }
.stepper .step.active .num { border-color: var(--accent); color: var(--accent-fg); }
.stepper .bar { width: 42px; height: 2px; background: var(--border); margin: 0 10px; }
.stepper .bar.done { background: var(--green-strong); }

/* ---------- Аккордеон / рейтинг ---------- */
details.accordion { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); margin-bottom: 8px; overflow: hidden; }
details.accordion summary { list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: var(--fz-md); display: flex; align-items: center; gap: 9px; }
details.accordion summary::-webkit-details-marker { display: none; }
details.accordion summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; }
details.accordion[open] summary::after { transform: rotate(225deg); }
details.accordion .acc-body { padding: 0 14px 13px; color: var(--text-2); font-size: var(--fz-md); line-height: 1.55; }
.stars { display: inline-flex; gap: 3px; }
.stars svg { width: 17px; height: 17px; color: #E3E7EF; }
.stars svg.on { color: #F5B90F; fill: #F5B90F; }

/* ---------- Чек-лист задачи ---------- */
.cl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cl-head .t { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.cl-head .progress { flex: 1; max-width: 140px; }
.cl-head .pct { font-size: var(--fz-xs); font-weight: 800; color: var(--text-2); }
.cl-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--r-sm); transition: background .1s; }
.cl-item:hover { background: var(--surface-2); }
.cl-item:hover .btn-icon { opacity: 1; }
.cl-item .btn-icon { opacity: 0; }
.cl-item .txt { flex: 1; font-weight: 600; font-size: var(--fz-md); }
.cl-item.done .txt { text-decoration: line-through; color: var(--text-3); }
.cl-add { display: flex; gap: 8px; margin-top: 8px; }
.cl-add input { flex: 1; }

/* ---------- Комментарии ---------- */
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment .bubble { flex: 1; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 4px 12px 12px 12px; padding: 9px 12px; }
.comment.mine .bubble { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.comment .meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.comment .meta b { font-size: var(--fz-sm); }
.comment .meta time { font-size: var(--fz-xs); color: var(--text-3); }
.comment .txt { font-size: var(--fz-md); line-height: 1.5; font-weight: 500; }
.comment-input { display: flex; gap: 10px; align-items: flex-start; margin-top: 4px; }
.comment-input textarea { flex: 1; min-height: 40px; height: 40px; }

/* ---------- Файлы ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); padding: 22px; text-align: center;
  color: var(--text-3); font-size: var(--fz-md); font-weight: 600; cursor: pointer; transition: all .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); }
.dropzone svg { width: 22px; height: 22px; margin-bottom: 6px; }
.file-row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; }
.file-row .fn { flex: 1; min-width: 0; }
.file-row .fn .t { font-weight: 700; font-size: var(--fz-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .fn .s { font-size: var(--fz-xs); color: var(--text-3); }

/* ---------- Бронирование слотов ---------- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.slot { height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--fz-sm); font-weight: 700; color: var(--text-2); transition: all .12s; }
.slot:hover { border-color: var(--accent); color: var(--accent-fg); }
.slot.busy { background: var(--gray-soft); border-color: var(--border); color: var(--text-disabled); cursor: not-allowed; text-decoration: line-through; }
.slot.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.slot-day { font-size: var(--fz-sm); font-weight: 800; margin: 14px 0 8px; color: var(--text-2); text-transform: capitalize; }

/* ---------- Портал клиента ---------- */
.portal-body { max-width: 1060px; margin: 0 auto; padding: 22px clamp(16px, 4vw, 40px) 60px; }
.portal-nav { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px; padding: 0 clamp(16px, 4vw, 40px); height: 58px; }
.portal-nav .brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15.5px; }
.portal-nav .brand .badge-p { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--accent-soft); color: var(--accent-fg); border-radius: 6px; padding: 2px 7px; }
.portal-tabs { display: flex; gap: 2px; margin-left: 10px; height: 100%; }
.portal-tabs button { padding: 0 13px; font-size: var(--fz-md); font-weight: 700; color: var(--text-2); border-bottom: 2px solid transparent; }
.portal-tabs button.active { color: var(--accent-fg); border-bottom-color: var(--accent); }
.portal-hero { background: linear-gradient(135deg, #1B2440 0%, #131A2C 100%); color: #fff; border-radius: var(--r-xl);
  padding: 24px 28px; margin-bottom: 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.portal-hero h1 { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.012em; }
.portal-hero p { color: #A7B0C4; font-size: var(--fz-md); margin-top: 3px; }
.ticket-status-open { background: var(--accent-soft); color: var(--accent-fg); }
@media (max-width: 700px) { .portal-tabs { overflow-x: auto; } }

/* ==========================================================================
   8. v2.2 — глобальный поиск, массовые операции, календарь, автоматизации
   ========================================================================== */

/* ---------- Глобальный поиск ---------- */
.gsearch-panel {
  position: fixed; z-index: 80; width: 460px; max-width: calc(100vw - 24px); max-height: 66vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); padding: 6px; animation: pop .14s ease;
}
.gs-group { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); padding: 10px 10px 4px; }
.gs-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); }
.gs-item:hover, .gs-item.hover { background: var(--gray-soft); }
.gs-item .ic { width: 28px; height: 28px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent-fg); }
.gs-item .ic svg { width: 14px; height: 14px; }
.gs-item .tx { flex: 1; min-width: 0; }
.gs-item .tx .t { font-weight: 700; font-size: var(--fz-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item .tx .s { font-size: var(--fz-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item .m { font-size: var(--fz-xs); color: var(--text-3); font-weight: 700; white-space: nowrap; }
.gs-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: var(--fz-md); }

/* ---------- Онбординг «Первые шаги» над канбаном ---------- */
.onb-wrap { padding: 14px 20px 0; }
.onb { padding: 14px 16px 15px; border-radius: var(--r-lg); }
.onb-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.onb-title { font-family: var(--font-display); font-size: var(--fz-lg); font-weight: 600; letter-spacing: -.012em; }
.onb-sub { font-size: var(--fz-sm); color: var(--text-3); font-weight: 600; margin-top: 1px; }
.onb-pct {
  margin-left: auto; font-family: var(--font-display); font-weight: 600; font-size: var(--fz-lg);
  color: var(--accent-fg); font-variant-numeric: tabular-nums lining-nums;
}
.onb-bar { margin-bottom: 12px; }
/* 5 шагов: либо один ровный ряд, либо список — без «дырок» в неполном ряду */
.onb-steps { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px)  { .onb-steps { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .onb-steps { grid-template-columns: repeat(3, 1fr); } }
/* 5 шагов в 2 или 3 колонки: последний добирает остаток ряда — без пустой половины */
@media (min-width: 640px) and (max-width: 1179px) { .onb-steps > .onb-step:last-child { grid-column: span 2; } }
@media (min-width: 1180px) { .onb-steps { grid-template-columns: repeat(5, 1fr); } }
.onb-step {
  display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  transition: border-color .12s, background .12s, transform .12s;
}
.onb-step:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.onb-step[disabled] { cursor: default; background: var(--surface-2); border-color: var(--border-soft); }
.onb-step .mark {
  width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 1.7px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center;
}
.onb-step.done .mark { background: var(--green-strong); border-color: var(--green-strong); color: #fff; }
.onb-step .mark svg { width: 11px; height: 11px; }
.onb-step .tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.onb-step .tx .t { font-weight: 700; font-size: var(--fz-md); }
.onb-step.done .tx .t { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-disabled); }
.onb-step .tx .s { font-size: var(--fz-xs); color: var(--text-3); font-weight: 600; line-height: 1.4; }
/* на узких экранах карточка не должна отжимать канбан вниз — оставляем только шаги */
@media (max-width: 620px) {
  .onb-wrap { padding: 12px 12px 0; }
  .onb-step { padding: 8px 11px; }
  .onb-step .tx .s { display: none; }
}

/* ---------- Сводка дня (панель сверху справа, не блокер) ---------- */
.daily-pop {
  position: fixed; z-index: 79; top: calc(var(--topbar-h) + 12px); right: 16px;
  width: 372px; max-width: calc(100vw - 24px);
  background: var(--glass); backdrop-filter: blur(16px) saturate(1.6); -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); overflow: hidden;
  animation: daily-in .34s var(--ease-out) both;
}
.daily-pop.no-anim, .daily-pop.no-anim .daily-row { animation: none; }
.daily-pop.leaving { animation: daily-out .16s ease both; }
@keyframes daily-in { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes daily-out { to { opacity: 0; transform: translateY(-6px); } }

.daily-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 10px 16px; }
.daily-hi { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -.014em; }
.daily-sub { font-size: var(--fz-sm); color: var(--text-3); font-weight: 600; margin-top: 2px; }
.daily-head .btn-icon { margin-left: auto; flex-shrink: 0; }

.daily-rows { padding: 0 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.daily-row {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--r-md); transition: background .12s;
  animation: daily-row-in .3s var(--ease-out) both; animation-delay: var(--d, 0ms);
}
@keyframes daily-row-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.daily-row:hover { background: var(--hover); }
.daily-row .ic {
  width: 30px; height: 30px; border-radius: var(--r-sm); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-fg);
}
.daily-row .ic svg { width: 15px; height: 15px; }
.daily-row.red .ic { background: var(--red-soft); color: var(--red); }
.daily-row .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.daily-row .tx .t { font-weight: 700; font-size: var(--fz-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.daily-row .tx .s { font-size: var(--fz-xs); color: var(--text-3); font-weight: 600; }
.daily-row.red .tx .s { color: var(--red); }
.daily-row .go { color: var(--text-disabled); display: inline-flex; flex-shrink: 0; transition: transform .14s, color .12s; }
.daily-row .go svg { width: 15px; height: 15px; }
.daily-row:hover .go { color: var(--accent-fg); transform: translateX(2px); }

.daily-clear { padding: 2px 16px 18px; }
.daily-clear .t { font-weight: 800; font-size: var(--fz-lg); margin-bottom: 5px; }
.daily-clear p { font-size: var(--fz-sm); color: var(--text-2); line-height: 1.5; margin-bottom: 13px; }

@media (max-width: 620px) {
  .daily-pop { right: 8px; left: 8px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .daily-pop, .daily-row { animation: none; }
}

/* ---------- Центр уведомлений (поповер под колокольчиком) ---------- */
.notif-pop {
  position: fixed; z-index: 82; width: 420px; max-width: calc(100vw - 16px);
  display: flex; flex-direction: column; max-height: min(70vh, 620px);
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); animation: pop .14s var(--ease-out);
}
.notif-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 12px;
  border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.notif-tabs { display: flex; gap: 4px; flex: 1; min-width: 0; }
.notif-tabs button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; font-size: var(--fz-sm); font-weight: 700;
  color: var(--text-2); transition: background .12s, color .12s;
}
.notif-tabs button:hover { background: var(--hover); color: var(--text); }
.notif-tabs button.active { background: var(--accent-soft); color: var(--accent-fg); }
.notif-tabs .cnt {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.notif-body { padding: 10px 12px 4px; overflow-y: auto; overscroll-behavior: contain; }
.notif-body .empty { padding: 26px 12px; }
.notif-body .empty svg { width: 38px; height: 38px; padding: 9px; }
.notif-body .row-item:last-child { margin-bottom: 8px; }
@media (max-width: 620px) {
  .notif-pop { width: calc(100vw - 16px); right: 8px !important; }
}

/* ---------- Массовые операции ---------- */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--sidebar); color: #fff; border-radius: var(--r-md);
  padding: 9px 14px; margin-bottom: 12px; animation: pop .15s ease;
}
.bulk-bar .cnt { font-weight: 800; font-size: var(--fz-md); }
.bulk-bar .select { background-color: #26314F; border-color: #3A4664; color: #fff; height: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A7B0C4' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
.bulk-bar .select option { color: var(--text); background: #fff; }
.bulk-bar .btn-ghost { color: #C6CDDD; }
.bulk-bar .btn-ghost:hover { background: #26314F; color: #fff; }

/* ---------- Календарь задач ---------- */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -.012em; text-transform: capitalize; min-width: 150px; text-align: center; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-dow span { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, background .12s; cursor: pointer;
}
.cal-day:hover { border-color: #C7CEDC; }
.cal-day.other { background: transparent; border-color: var(--border-soft); }
.cal-day.other .dnum { color: var(--text-disabled); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-day.dragover { background: var(--accent-soft); border-color: var(--accent); }
.cal-day .dnum { font-size: var(--fz-xs); font-weight: 800; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.cal-day.today .dnum { color: var(--accent-fg); }
.cal-day .more { font-size: 10.5px; font-weight: 700; color: var(--text-3); padding: 1px 5px; }
.cal-grid.week .cal-day { min-height: 340px; }
.cal-task {
  display: flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px;
  background: var(--accent-soft); font-size: 11px; font-weight: 700; cursor: grab;
  border-left: 3px solid var(--accent); overflow: hidden;
}
.cal-task span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-task:hover { filter: brightness(.97); }
.cal-task.dragging { opacity: .4; }
.cal-task.overdue { background: var(--red-soft); border-left-color: var(--red); }
.cal-task.done { background: var(--gray-soft); border-left-color: var(--border-strong); color: var(--text-3); text-decoration: line-through; }
.cal-task.t-call { border-left-color: var(--green-strong); background: var(--green-soft); }
.cal-task.t-email { border-left-color: var(--amber); background: var(--amber-soft); }
.cal-task.t-meeting { border-left-color: var(--violet); background: var(--violet-soft); }
.cal-task.done, .cal-task.overdue { /* важнее типа */ }
.cal-task.overdue { border-left-color: var(--red); background: var(--red-soft); }
.cal-task.done { border-left-color: var(--border-strong); background: var(--gray-soft); }

/* ---------- Автоматизации ---------- */
.auto-stage { margin-bottom: 14px; }
.auto-stage > .head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.auto-stage > .head .t { font-weight: 800; font-size: var(--fz-md); }
.auto-rule {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; background: var(--surface);
}
.auto-rule .ic { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--amber-soft); color: var(--amber);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auto-rule .ic svg { width: 15px; height: 15px; }
.auto-rule.off { opacity: .55; }
.auto-rule .desc { flex: 1; min-width: 0; font-size: var(--fz-md); font-weight: 600; line-height: 1.5; }
.auto-rule .desc .cond { font-size: var(--fz-xs); color: var(--text-3); font-weight: 700; }
.auto-act { display: inline-flex; align-items: center; gap: 5px; background: var(--gray-soft); border-radius: 6px;
  padding: 2px 8px; font-size: var(--fz-xs); font-weight: 700; color: var(--text-2); margin: 2px 4px 2px 0; }

/* дубликаты */
.dup-warn { margin-bottom: 14px; }
.dup-warn .gs-item { border: 1px solid var(--border); margin-top: 8px; background: var(--surface); }

/* ==========================================================================
   9. v2.3 — почта, звонки, рассылки, бизнес-процессы, канбан задач
   ========================================================================== */

/* ---------- Почта ---------- */
.mail-folders { padding: 10px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; }
.mail-folders .chip { flex: 1; justify-content: center; }
.mail-item { position: relative; }
.mail-item .unread-dot { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.mail-item.unread .cn span:first-child { font-weight: 800; }
.mail-read-head { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.mail-read-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -.012em; margin-bottom: 8px; }
.mail-scroll { flex: 1; overflow-y: auto; }
.mail-body { padding: 20px; font-size: 13.5px; line-height: 1.65; color: var(--text); white-space: pre-line; }
.mail-attachments { padding: 0 20px 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.mail-attach { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.mail-attach:hover { border-color: var(--accent); color: var(--accent-fg); }

/* ---------- Звонки ---------- */
.call-dir { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.call-dir svg { width: 15px; height: 15px; }
.call-dir.in { background: var(--green-soft); color: var(--green); }
.call-dir.out { background: var(--accent-soft); color: var(--accent-fg); }
.call-dir.missed { background: var(--red-soft); color: var(--red); }
.wave { display: inline-flex; align-items: center; gap: 2px; height: 18px; }
.wave i { width: 3px; border-radius: 2px; background: #C3CBDC; }
.wave.playing i { background: var(--accent); animation: wavep 1s infinite ease-in-out; }
.wave i:nth-child(odd) { animation-delay: .15s; }
@keyframes wavep { 0%,100% { transform: scaleY(.6);} 50% { transform: scaleY(1.15);} }

/* ---------- Рассылки ---------- */
.ver-res { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.ver-res .em { flex: 1; font-family: var(--font-mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Бизнес-процессы ---------- */
.bp-card-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.bp-canvas { overflow: auto; background:
  linear-gradient(var(--border-soft) 1px, transparent 1px),
  linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 24px 24px; border-radius: var(--r-md); border: 1px solid var(--border); }
.bp-canvas svg { display: block; }
.bp-node rect, .bp-node polygon { fill: #fff; stroke: var(--border-strong); stroke-width: 1.5; transition: all .2s; }
.bp-node.n-start rect, .bp-node.n-end rect { fill: var(--sidebar); stroke: var(--sidebar); }
.bp-node.n-start text, .bp-node.n-end text { fill: #fff; }
.bp-node.n-condition polygon { fill: var(--amber-soft); stroke: #E7C892; }
.bp-node text { font-size: 11.5px; font-weight: 700; fill: var(--text); font-family: var(--font-body); }
.bp-node .sub { font-size: 9.5px; font-weight: 600; fill: var(--text-3); }
.bp-node.visited rect, .bp-node.visited polygon { stroke: var(--green-strong); stroke-width: 2; }
.bp-node.active rect, .bp-node.active polygon { stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 0 6px rgba(49,85,234,.45)); animation: bp-pulse 1s infinite; }
.bp-node.n-end.reached rect { fill: var(--green-strong); stroke: var(--green-strong); }
@keyframes bp-pulse { 0%,100% { opacity: 1; } 50% { opacity: .75; } }
.bp-edge { stroke: #B9C2D4; stroke-width: 1.7; fill: none; transition: stroke .2s; }
.bp-edge.active { stroke: var(--accent); stroke-width: 2.5; }
.bp-edge.passed { stroke: var(--green-strong); stroke-width: 2; }
.bp-edge-label { font-size: 10px; font-weight: 800; fill: var(--text-2); font-family: var(--font-body); }
.bp-edge-label.yes { fill: var(--green); }
.bp-edge-label.no { fill: var(--red); }

.bp-log { max-height: 420px; overflow-y: auto; }
.bp-log-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border-soft); font-size: 12.5px; animation: pop .2s ease; }
.bp-log-item .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-fg); font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bp-log-item.decision .n { background: var(--amber-soft); color: var(--amber); }
.bp-log-item.finish .n { background: var(--green-soft); color: var(--green); }
.bp-log-item .t { font-weight: 700; }
.bp-log-item .s { color: var(--text-2); margin-top: 1px; line-height: 1.45; }

/* ==========================================================================
   10. ВОЛНА 1 — сквозная полировка (рельс, движение, скроллбары, ритм)
   ========================================================================== */

/* ---------- Появление при перерисовке ---------- */
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.reveal { animation: reveal .24s var(--ease-out) both; }
.content > .stat-grid > .stat,
.content > .stat-grid .stat { animation: reveal .24s var(--ease-out) both; }
.content > .stat-grid > .stat:nth-child(2) { animation-delay: .05s; }
.content > .stat-grid > .stat:nth-child(3) { animation-delay: .1s; }
.content > .stat-grid > .stat:nth-child(4) { animation-delay: .15s; }
.content > .stat-grid > .stat:nth-child(5) { animation-delay: .2s; }
.content > .stat-grid > .stat:nth-child(6) { animation-delay: .25s; }
/* на мобиле карточки в столбик — stagger читается как мигание пустотой, гасим задержки */
@media (max-width: 700px) {
  .content > .stat-grid > .stat { animation-delay: 0s !important; animation-duration: .18s; }
}

/* плотная по горизонтали таблица — для широких реестров (Документы) */
.tbl.tight th, .tbl.tight td { padding-left: 10px; padding-right: 10px; }

/* ---------- История изменений: строки диффов ---------- */
.hist-ch { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; margin-top: 3px; flex-wrap: wrap; }
.hist-ch b { color: var(--text-2); font-weight: 700; }
.hist-ch .hf { color: var(--text-3); text-decoration: line-through; text-decoration-color: rgba(220, 38, 38, .45); }
.hist-ch .ha { color: var(--text-3); }
.hist-ch .ht { color: var(--text); font-weight: 700; }

/* ---------- Конструктор бизнес-процессов ---------- */
.bp-ed-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; padding: 4px 2px; }
.bp-ed-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 9px;
}
.bp-ed-row .ic { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none; background: var(--surface); border: 1px solid var(--border); }
.bp-ed-row.t-start .ic, .bp-ed-row.t-end .ic { background: var(--gray-soft, #EEF1F7); }
.bp-ed-row.t-action .ic { background: var(--accent-soft); color: var(--accent-fg); border-color: transparent; }
.bp-ed-row.t-condition .ic { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.bp-ed-row .tx { flex: 1; min-width: 0; }
.bp-ed-row .tx .t { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-ed-row .tx .s { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-ed-row .btn-icon { opacity: 0; transition: opacity .12s; }
.bp-ed-row:hover .btn-icon, .bp-ed-row .btn-icon:focus-visible { opacity: 1; }
.bp-ed-plus {
  align-self: flex-start; width: 22px; height: 18px; margin: 0 0 0 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-strong); border-radius: 6px; background: none;
  color: var(--text-3); font-weight: 800; font-size: 13px; line-height: 1; cursor: pointer;
}
.bp-ed-plus:hover { color: var(--accent-fg); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- KPI и планы: прогресс-бары план/факт ---------- */
.kpi-cell { display: flex; align-items: center; gap: 8px; }
.kpi-bar {
  flex: 1; height: 7px; border-radius: 4px; background: var(--surface-2, #EEF1F7);
  border: 1px solid var(--border-soft, var(--border)); overflow: hidden; min-width: 60px;
}
.kpi-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s var(--ease-out); }
.kpi-bar.ok i { background: var(--green); }
.kpi-bar.mid i { background: var(--amber); }
.kpi-bar.low i { background: var(--red); }
.kpi-bar.big { height: 10px; margin-top: 4px; }
.kpi-pct { font-family: var(--font-display); font-weight: 600; font-size: 12.5px; letter-spacing: -.012em; font-variant-numeric: tabular-nums lining-nums; min-width: 38px; text-align: right; }
.kpi-pct.pos { color: var(--green); }

/* ---------- Скроллбары ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #B7C0D0; }
.sb-nav { scrollbar-color: #2A3552 transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: #2A3552; border-color: var(--sidebar); }
.sb-nav::-webkit-scrollbar-thumb:hover { background: #37456B; }

/* ---------- Сайдбар: разделитель + online-точка ---------- */
.sidebar { box-shadow: inset -1px 0 0 rgba(255,255,255,.05); }
/* ---------- Индикатор «сейчас в системе» (переиспользуемый) ---------- */
.avatar-online { position: relative; }
.avatar-online::after {
  content: ''; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--green-strong);
  border: 2px solid var(--avatar-ring, var(--surface));
}
.avatar-online.sm::after, .avatar-online.xs::after { width: 8px; height: 8px; border-width: 1.6px; right: -1px; bottom: -1px; }
.avatar-online.lg::after, .avatar-online.xl::after { width: 12px; height: 12px; border-width: 2.5px; }
.sb-user .avatar-online { --avatar-ring: var(--sidebar); }
/* внутри таблиц строка подсвечивается на hover — кольцо берём под фон строки */
.tbl tr:hover .avatar-online { --avatar-ring: var(--hover); }

/* ---------- Канбан-шапка ---------- */
.kb-head { border-bottom: 1px solid var(--border-soft); margin-bottom: 8px; }
.kb-head .sum { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -.014em; font-variant-numeric: tabular-nums lining-nums; }
.kb-head .sum.muted { color: var(--text-3); font-weight: 600; }
.kb-head .cnt { font-weight: 800; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }

/* ---------- Канбан-карточка: нейтральная полоса + приглушённый ноль ---------- */
.kb-card::before { background: var(--stripe, var(--border)); box-shadow: 1px 0 0 rgba(15, 23, 42, .04); }
.kb-card .amount.muted { color: var(--text-3); font-weight: 600; }

/* ---------- Сетка stat 3×2 ---------- */
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .stat-grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stat-grid.cols-3 { grid-template-columns: 1fr; } }

/* ---------- Карточки бизнес-процессов: футер к низу, равная высота ---------- */
.bp-card-row > .card { display: flex; flex-direction: column; }
.bp-card-row > .card > div:last-child { margin-top: auto; }

/* ---------- Документы: дата без переноса ---------- */
.tbl td.nowrap { white-space: nowrap; }

/* ==========================================================================
   11. ВОЛНА «МАТЕРИАЛ» — стекло на плавающих поверхностях
   (топбар НЕ стеклянный: под ним ничего не проезжает)
   ========================================================================== */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tbl th, .tbl tfoot td {
    background: var(--glass-head);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
  }
  .menu, .gsearch-panel, .toast {
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
  }
  .portal-nav {
    background: var(--glass);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
  }
  .modal-overlay {
    -webkit-backdrop-filter: blur(6px) saturate(115%);
    backdrop-filter: blur(6px) saturate(115%);
  }
}

/* ==========================================================================
   12. ВОЛНА 2 — ДВИЖЕНИЕ
   ========================================================================== */

/* ---------- М1. Оркестр загрузки ---------- */
@keyframes boot-side { from { opacity: 0; transform: translateX(-16px); } }
@keyframes boot-drop { from { opacity: 0; transform: translateY(-10px); } }
@keyframes boot-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes view-in  { from { opacity: 0; } }

.app.booting .sidebar { animation: boot-side .34s var(--ease-out) both; }
.app.booting .topbar  { animation: boot-drop .30s var(--ease-out) both .10s; }
.app.booting .content { animation: boot-rise .34s var(--ease-out) both .20s; }
/* KPI-карточки вступают после того, как поднялся контент */
.app.booting .content > .stat-grid > .stat { animation-delay: .34s; }
.app.booting .content > .stat-grid > .stat:nth-child(2) { animation-delay: .39s; }
.app.booting .content > .stat-grid > .stat:nth-child(3) { animation-delay: .44s; }
.app.booting .content > .stat-grid > .stat:nth-child(4) { animation-delay: .49s; }
.app.booting .content > .stat-grid > .stat:nth-child(5) { animation-delay: .54s; }
.app.booting .content > .stat-grid > .stat:nth-child(6) { animation-delay: .59s; }

/* смена раздела — только прозрачность (контент сам является скролл-контейнером) */
.content.view-in { animation: view-in .18s var(--ease-out) both; }

/* ---------- М4. Рисующиеся графики ---------- */
@keyframes ln-draw { from { stroke-dashoffset: 1; } }
@keyframes chart-fade { from { opacity: 0; } }
@keyframes bar-grow { from { transform: scaleY(0); } }
@keyframes dn-in { from { stroke-dasharray: 0 var(--c); } }

.ln-draw { stroke-dasharray: 1; animation: ln-draw .75s var(--ease-out) both; }
.ln-dots { animation: chart-fade .3s ease both .55s; }
.ln-area { animation: chart-fade .4s ease both .35s; }
.spk-draw { stroke-dasharray: 1; animation: ln-draw .6s var(--ease-out) both .15s; }
.bar-grow { transform-box: fill-box; transform-origin: 50% 100%; animation: bar-grow .45s var(--ease-out) both; }
.dn-seg { animation: dn-in .5s var(--ease-out) both; }

/* ---------- М6. Конфетти ---------- */
.confetti-canvas { position: fixed; inset: 0; z-index: 200; pointer-events: none; }

/* ---------- М7. Микро-физика ---------- */
.btn { transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .08s; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-icon { transition: background .15s, color .15s, transform .08s; }
.btn-icon:active { transform: scale(.92); }
.chip:active, .seg button:active, .pagination button:active, .slot:active { transform: scale(.96); }
.kb-card:active { transform: translateY(0) scale(.995); }

@keyframes check-pop { 0% { transform: scale(.82); } 55% { transform: scale(1.1); } 100% { transform: none; } }
.checkbox input:checked, .radio input:checked { animation: check-pop .22s var(--ease-out); }
.task-check.done { animation: check-pop .24s var(--ease-out); }

@keyframes toast-out { to { transform: translateY(8px) scale(.98); opacity: 0; } }
.toast.leaving { animation: toast-out .16s var(--ease-out) both; }

/* ==================================================================
   ТЁМНАЯ ТЕМА — переопределение токенов (html[data-theme="dark"])
   Палитра согласована со страницей звонка (call.css)
================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --accent-fg: #7C9BFF;   /* акцент-текст: AA на тёмных поверхностях */

  --bg: #0F1420;
  --surface: #171E30;
  --surface-2: #1C2438;
  --border: #252E47;
  --border-strong: #364159;
  --border-soft: #202940;
  --hover: #1D2740;
  --seg-bg: #0F1626;

  --text: #EDF1F9;
  --text-2: #A6B0C7;
  --text-3: #828DA5;
  --text-disabled: #4A5570;

  --accent-soft: #202C58;
  --accent-soft-2: #27356E;
  --ring: rgba(90, 122, 255, .35);

  --sidebar: #0B101B;
  --sidebar-item: #8F9AB4;
  --sidebar-label: #566180;
  --sidebar-hover: #16203A;
  --sidebar-active: #1D2A4D;

  --green: #45C481;  --green-soft: #14301F;  --green-strong: #35B56C;
  --red: #F17070;    --red-soft: #3A1B1E;
  --amber: #E9A23B;  --amber-soft: #34270F;
  --violet: #A784EE; --violet-soft: #2A1E46;
  --cyan: #4FBBDE;   --cyan-soft: #102B37;
  --pink: #EF77B0;   --pink-soft: #3A182A;
  --gray-soft: #232C42;

  --lift: rgba(255, 255, 255, .06);
  --shadow-1:
    0 1px 2px rgba(0, 0, 0, .35),
    inset 0 1px 0 var(--lift);
  --shadow-2:
    0 1px 2px rgba(0, 0, 0, .40),
    0 6px 16px -4px rgba(0, 0, 0, .45),
    0 18px 40px -12px rgba(0, 0, 0, .50),
    inset 0 1px 0 var(--lift);
  --shadow-3:
    0 4px 12px rgba(0, 0, 0, .50),
    0 24px 64px -16px rgba(0, 0, 0, .70),
    inset 0 1px 0 var(--lift);

  --glass: rgba(23, 30, 48, .86);
  --glass-head: rgba(28, 36, 56, .82);
}
/* точечные поправки тёмного режима */
html[data-theme="dark"] [data-tip]:hover::after { background: #2E3A5C; }
html[data-theme="dark"] .kbd { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-2); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { border-color: var(--bg); }
html[data-theme="dark"] .auth-wrap { background: var(--bg); }
html[data-theme="dark"] .auth-card { background: var(--surface); border-color: var(--border); }

/* алерты: в светлой теме текст/рамки заданы литералами — в тёмной переопределяем целиком */
html[data-theme="dark"] .alert.info    { border-color: var(--accent-soft-2); color: var(--accent-fg); }
html[data-theme="dark"] .alert.success { border-color: #245F3C; color: #7FD6A3; }
html[data-theme="dark"] .alert.warn    { border-color: #5C4520; color: #F0BE72; }
html[data-theme="dark"] .alert.error   { border-color: #5F2A2E; color: #F5A0A0; }

/* материал: контурная подсветка плавающих поверхностей */
html[data-theme="dark"] .modal { box-shadow: var(--shadow-3), 0 0 0 1px rgba(255, 255, 255, .07); }
html[data-theme="dark"] .drawer { border-left-color: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .kb-card::before { box-shadow: 1px 0 0 rgba(0, 0, 0, .35); }
html[data-theme="dark"] .sb-item.active { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07); }

/* контролы: шеврон селекта и выделение текста */
html[data-theme="dark"] .field select,
html[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A6B0C7' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
/* панель массовых операций всегда тёмная — её шеврон не трогаем */
html[data-theme="dark"] .bulk-bar .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A7B0C4' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
html[data-theme="dark"] ::selection { background: #2C3C7E; color: #fff; }

/* ==========================================================================
   12. ВОЛНА «ВЛАСТЬ» — командная палитра, сортировка, peek, плотность
   ========================================================================== */

/* ---------- Командная палитра (⌘K) ---------- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 110; display: flex; justify-content: center;
  align-items: flex-start; padding: 12vh 16px 16px;
  background: rgba(13, 18, 32, .46); animation: fade-in .12s ease;
}
.cmdk-panel {
  width: 620px; max-width: 100%; max-height: 68vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); overflow: hidden; animation: pop .14s var(--ease-out);
}
.cmdk-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cmdk-head > svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.cmdk-head input {
  flex: 1; min-width: 0; height: 28px; border: none; background: none; padding: 0;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.cmdk-head input:focus { outline: none; box-shadow: none; }
.cmdk-head input::placeholder { color: var(--text-3); font-weight: 500; }
.cmdk-list { flex: 1; overflow-y: auto; padding: 6px; }
.cmdk-list .gs-item .m { text-transform: none; }
.gs-item .m.hk-chip { display: inline-flex; align-items: center; gap: 3px; }
.gs-item .m.hk-chip .kbd { min-width: 19px; height: 19px; font-size: 10.5px; }
.cmdk-foot {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px; flex-shrink: 0;
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--fz-xs); font-weight: 600; color: var(--text-3);
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }
.cmdk-foot .kbd { min-width: 19px; height: 19px; font-size: 10.5px; }
@media (max-width: 640px) { .cmdk-overlay { padding-top: 6vh; } .cmdk-foot { display: none; } }

/* ---------- Сортируемые заголовки таблиц ---------- */
.tbl th[data-sort] { cursor: pointer; user-select: none; transition: color .12s, background .12s; }
.tbl th[data-sort]:hover { color: var(--text-2); }
.tbl th[data-sort]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; }
.th-arr { color: var(--accent-fg); font-size: 11px; line-height: 1; }
.tbl th[data-sort][aria-sort="none"]:hover .th-arr::after { content: '↕'; color: var(--text-3); }

/* ---------- Peek-карточка ---------- */
.peek-pop {
  position: fixed; z-index: 105; width: 322px; padding: 12px 14px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); animation: pop .12s var(--ease-out);
}
.peek-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.peek-head .ic {
  width: 30px; height: 30px; border-radius: var(--r-sm); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-fg);
}
.peek-head .ic svg { width: 15px; height: 15px; }
.peek-head .tx { min-width: 0; }
.peek-head .tx .t { font-weight: 800; font-size: var(--fz-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-head .tx .s { font-size: var(--fz-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: var(--fz-sm); }
.peek-row .l { width: 108px; flex-shrink: 0; color: var(--text-3); font-weight: 600; }
.peek-row .v { min-width: 0; flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.peek-open { width: 100%; margin-top: 10px; justify-content: center; }
[data-peek] { cursor: default; }

/* ---------- Плотность таблиц ---------- */
html[data-density="compact"] .tbl th { padding-top: 6px; padding-bottom: 6px; }
html[data-density="compact"] .tbl td { padding-top: 6px; padding-bottom: 6px; }
html[data-density="compact"] .tbl.compact td,
html[data-density="compact"] .tbl.tight td { padding-top: 4px; padding-bottom: 4px; }
html[data-density="compact"] .task-row { padding-top: 7px; padding-bottom: 7px; }

/* ---------- Тёмная тема: поправки волны ---------- */
html[data-theme="dark"] .cmdk-overlay { background: rgba(5, 8, 16, .58); }
html[data-theme="dark"] .cmdk-panel { box-shadow: var(--shadow-3), 0 0 0 1px rgba(255, 255, 255, .07); }
html[data-theme="dark"] .peek-pop { box-shadow: var(--shadow-2), 0 0 0 1px rgba(255, 255, 255, .07); }

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .cmdk-panel, .peek-pop {
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
  }
  .cmdk-overlay { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .cmdk-overlay, .cmdk-panel, .peek-pop { animation: none; }
}

/* ---------- Шпаргалка горячих клавиш ---------- */
.hk-grid { display: block; column-count: 2; column-gap: 34px; }
.hk-grid > div { break-inside: avoid; margin-bottom: 14px; }
.hk-title {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); margin-bottom: 8px;
}
.hk-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.hk-keys { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; min-width: 86px; }
.hk-tx { font-size: var(--fz-sm); font-weight: 600; color: var(--text-2); }
@media (max-width: 640px) { .hk-grid { column-count: 1; } }

/* ---------- Инлайн-правка ячейки ---------- */
.tbl td[data-edit-amount] { cursor: cell; }
.tbl td[data-edit-amount]:hover { box-shadow: inset 0 0 0 1px var(--border-strong); border-radius: var(--r-xs); }
input.cell-edit {
  width: 100%; height: 26px; padding: 0 6px; text-align: right;
  font-size: var(--fz-md); font-weight: 700; font-family: inherit;
  border: 1px solid var(--accent); border-radius: var(--r-xs);
  background: var(--surface); color: var(--text); box-shadow: 0 0 0 3px var(--ring);
}
input.cell-edit:focus { outline: none; }

/* в палитре подсветку ведёт клавиатура: мышь синхронизируется через mousemove */
.cmdk-list .gs-item:hover { background: none; }
.cmdk-list .gs-item.hover { background: var(--gray-soft); box-shadow: inset 2px 0 0 var(--accent); }

/* ==========================================================================
   14. ВОЛНА 5 — карточные реестры на узком экране (≤560px)
   Таблицы сделок и контактов на телефоне превращаются в карточки: горизонтальный
   скролл реестра заменён вертикальным списком. Токены общие — тёмная тема работает.
   ========================================================================== */
.mcards { display: flex; flex-direction: column; gap: 10px; }
.mcard {
  position: relative; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  cursor: pointer; transition: border-color .14s ease, box-shadow .14s ease;
}
.mcard::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: var(--rail-w);
  border-radius: 0 3px 3px 0; background: var(--rail); opacity: 0; transition: opacity .14s ease;
}
.mcard:hover, .mcard:focus-visible { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.mcard:hover::before, .mcard:focus-visible::before { opacity: 1; }
.mcard:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.mc-row { display: flex; align-items: baseline; gap: 10px; }
.mc-t { flex: 1; min-width: 0; font-size: var(--fz-md); font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.mc-sum { flex: none; font-weight: 800; white-space: nowrap; }
.mc-sub { margin-top: 2px; font-size: var(--fz-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.mc-foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border-soft); font-size: 11.5px; color: var(--text-2); }
.mc-foot .mc-next { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.mc-foot a { color: var(--accent-fg); font-weight: 700; }
.mc-total {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 11px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: var(--fz-sm); font-weight: 800;
}
.mc-total .lbl { color: var(--text-2); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .mcard, .mcard::before { transition: none; } }

/* ==================================================================
   ВИТОК 6 «Плотность без пустот» — подвал разделов, a11y, фокус
================================================================== */
/* подвал разреженных разделов: тихий дайджест из реальных данных Store */
.sec-digest { margin-top: 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; }
.sec-digest > .sd-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 15px 17px; }
.sec-digest .sd-lbl { font-size: var(--fz-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.sec-digest .sd-val { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.018em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums lining-nums; }
.sec-digest .sd-sub { font-size: var(--fz-sm); color: var(--text-3); font-weight: 600; margin-top: 3px; }
.sec-digest .sd-mini { display: flex; flex-direction: column; gap: 2px; }
.sec-digest .sd-mini .r { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: var(--fz-sm); font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border-soft); }
.sec-digest .sd-mini .r:last-child { border-bottom: none; }
.sec-digest .sd-mini .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-digest .sd-mini .m { color: var(--text-3); font-weight: 700; flex-shrink: 0; font-variant-numeric: tabular-nums lining-nums; }

/* центрирование коротких пустых разделов */
.view-fill { min-height: calc(100vh - var(--topbar-h) - 120px); display: flex; flex-direction: column; justify-content: center; }
.view-fill > .empty { padding-top: 8px; padding-bottom: 8px; }
/* короткий раздел с подвалом-сводкой: топим подвал к низу вьюпорта, воздух уходит
   в середину (между списком и сводкой) — читается как «футер», а не пустой низ */
.content.digest-foot { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.content.digest-foot > .sec-digest { margin-top: auto; }

/* skip-link (a11y) */
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 210; transform: translateY(-160%); background: var(--surface); color: var(--accent-fg); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 9px 14px; font-weight: 800; font-size: var(--fz-sm); box-shadow: var(--shadow-2); transition: transform .16s var(--ease-out); }
.skip-link:focus-visible { transform: none; outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* фокус-KPI: главный показатель крупнее */
.stat.primary .val { font-size: 28px; letter-spacing: -.026em; }
@media (max-width: 560px) { .stat.primary .val { font-size: 25px; } }

/* реестры: зебра только широким таблицам */
.tbl .cell-main .t { letter-spacing: -.005em; }
.tbl.zebra tbody tr:nth-child(even) td { background: var(--surface-2); }
.tbl.zebra tbody tr:hover td { background: var(--hover); }
html[data-theme="dark"] .tbl.zebra tbody tr:nth-child(even) td { background: #1A2236; }
.tbl tbody tr.clickable:focus-within td:first-child::before { opacity: 1; transform: scaleY(1); }

/* пустые состояния */
.empty .empty-cta { margin-top: 14px; display: inline-flex; }
.drawer-body .empty { padding: 30px 16px; }
.drawer-body .empty svg { width: 40px; height: 40px; }
