/* =============================================================================
 * Pllato Suite — UI Components
 * =============================================================================
 *
 * Семантические primitive-компоненты на новых токенах (design-tokens.css).
 * Применяются в новых/редизайн-секциях. Existing legacy-классы (.card-old,
 * .deals-toolbar, и т.п.) пока не трогаем — мигрируем модуль за модулем.
 *
 * Принципы:
 *   - Все размеры через токены (height, padding, radius, font).
 *   - Один паттерн = везде (Card/Badge/Tabs/Field/Modal).
 *   - States: hover, focus-visible, active, disabled, empty.
 *   - Keyboard: tab order + focus indicator (жёлтое glow) везде.
 *   - Long values: ellipsis + tooltip pattern.
 * ========================================================================== */

/* =============================================================================
 * CARD — основной контейнер контента
 * ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  position: relative;
}
.card-elevated {
  box-shadow: var(--shadow-card);
}
.card-interactive {
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card-interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}
.card-interactive:active { transform: translateY(0); }
.card-interactive:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--brand-primary);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
}
.card-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.card-body { padding: 16px 20px; }
.card-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-base);
  justify-content: flex-end;
}

/* Compact card — для kanban (плотные) */
.card-compact { padding: 12px 14px; }
.card-compact .card-header { padding: 10px 14px; }
.card-compact .card-body { padding: 10px 14px; }

/* =============================================================================
 * BADGE — статусные/информационные чипы
 * ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  background: var(--status-neutral-bg);
  color: var(--status-neutral);
  border: 1px solid transparent;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge.badge-lg {
  height: 24px;
  padding: 0 10px;
  font-size: var(--font-size-sm);
}
.badge.badge-sm {
  height: 16px;
  padding: 0 6px;
  font-size: 10px;
}

/* Status variants */
.badge.success { background: var(--status-success-bg); color: var(--status-success); }
.badge.warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge.danger  { background: var(--status-danger-bg);  color: var(--status-danger);  }
.badge.info    { background: var(--status-info-bg);    color: var(--status-info);    }
.badge.neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }

/* Solid (более насыщенные — для важных меток) */
.badge.solid.success { background: var(--status-success); color: #fff; }
.badge.solid.warning { background: var(--status-warning); color: #fff; }
.badge.solid.danger  { background: var(--status-danger);  color: #fff; }
.badge.solid.info    { background: var(--status-info);    color: #fff; }
.badge.solid.brand   { background: var(--brand-primary);  color: var(--brand-on-primary); }

/* Outline (тонкие — для меток-категорий) */
.badge.outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* Counter badge — мини-кружок с числом (для notification bell etc) */
.badge-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--status-danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

/* =============================================================================
 * TABS — горизонтальные табы (в карточке сделки и т.п.)
 * ========================================================================== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  align-items: stretch;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  position: relative;
  margin-bottom: -1px;     /* перекрыть border-bottom родителя для активного */
}
.tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand-primary);
}
.tab:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}
.tab .badge-counter,
.tab .badge {
  margin-left: 4px;
}

/* =============================================================================
 * FIELD — labelled form input (label + control + help/error)
 * ========================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  line-height: var(--line-height-sm);
}
.field-label .required {
  color: var(--status-danger);
  margin-left: 2px;
}
.field-control { display: flex; align-items: stretch; gap: 6px; }
.field-help {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  line-height: var(--line-height-xs);
}
.field-error {
  font-size: var(--font-size-xs);
  color: var(--status-danger);
  line-height: var(--line-height-xs);
}
.field.has-error .input,
.field.has-error .input:focus { border-color: var(--status-danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px var(--status-danger-bg); }

/* Horizontal field group (label left, control right) */
.field-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.field-row .field-label { padding-top: 8px; }

/* =============================================================================
 * EMPTY STATE — единый паттерн пустых страниц/таблиц
 * ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: .6;
}
.empty-state-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.empty-state-desc {
  font-size: var(--font-size-sm);
  max-width: 360px;
  margin-bottom: 16px;
  line-height: var(--line-height-sm);
}

/* =============================================================================
 * STACK utilities — гэп-helpers для разводки контента
 * ========================================================================== */
.stack-v   { display: flex; flex-direction: column; }
.stack-v-4 { display: flex; flex-direction: column; gap: 4px;  }
.stack-v-8 { display: flex; flex-direction: column; gap: 8px;  }
.stack-v-12{ display: flex; flex-direction: column; gap: 12px; }
.stack-v-16{ display: flex; flex-direction: column; gap: 16px; }
.stack-v-20{ display: flex; flex-direction: column; gap: 20px; }
.stack-v-24{ display: flex; flex-direction: column; gap: 24px; }

.stack-h   { display: flex; align-items: center; }
.stack-h-4 { display: flex; align-items: center; gap: 4px;  }
.stack-h-6 { display: flex; align-items: center; gap: 6px;  }
.stack-h-8 { display: flex; align-items: center; gap: 8px;  }
.stack-h-12{ display: flex; align-items: center; gap: 12px; }
.stack-h-16{ display: flex; align-items: center; gap: 16px; }

.stack-grow > :first-child { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* =============================================================================
 * TYPOGRAPHY utilities
 * ========================================================================== */
.text-xs  { font-size: var(--font-size-xs);   line-height: var(--line-height-xs); }
.text-sm  { font-size: var(--font-size-sm);   line-height: var(--line-height-sm); }
.text-base{ font-size: var(--font-size-base); line-height: var(--line-height-base); }
.text-md  { font-size: var(--font-size-md);   line-height: var(--line-height-md); }
.text-lg  { font-size: var(--font-size-lg);   line-height: var(--line-height-lg); }
.text-xl  { font-size: var(--font-size-xl);   line-height: var(--line-height-xl); }

.font-medium  { font-weight: var(--font-weight-medium); }
.font-semibold{ font-weight: var(--font-weight-semibold); }
.font-bold    { font-weight: var(--font-weight-bold); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--status-success); }
.text-warning   { color: var(--status-warning); }
.text-danger    { color: var(--status-danger); }
.text-info      { color: var(--status-info); }
.text-brand     { color: var(--brand-primary); }

/* Truncate single-line text with ellipsis */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* =============================================================================
 * PAGE LAYOUT — единая шапка страницы (page-header pattern)
 * ========================================================================== */
.page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.page-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.page-header-bar .page-title-block {
  flex: 1;
  min-width: 0;
}
.page-header-bar h1 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0;
}
.page-header-bar .page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
}
.page-header-bar .page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-height: 0;
}

/* Toolbar pattern — фильтры + действия под page-header */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .toolbar-search { flex: 1 1 240px; min-width: 200px; }
.toolbar .toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-default);
}

/* =============================================================================
 * SELECT — оформление select под единый стиль с .input
 * ========================================================================== */
.select {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  height: var(--size-control-md);
  padding: 0 28px 0 var(--padding-control-md);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235e6470' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.select:hover { border-color: var(--text-disabled); }
.select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.select.select-sm { height: var(--size-control-sm); font-size: var(--font-size-sm); }
.select.select-lg { height: var(--size-control-lg); font-size: var(--font-size-md); }

/* =============================================================================
 * KBD — клавиатурная подсказка (Tab, Enter, Esc, Cmd+K, и т.д.)
 * ========================================================================== */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  font-family: var(--font-family-mono);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1;
}

/* =============================================================================
 * DIVIDER
 * ========================================================================== */
.divider-h {
  height: 1px;
  background: var(--border-default);
  border: none;
  margin: 16px 0;
}
.divider-v {
  width: 1px;
  background: var(--border-default);
  align-self: stretch;
}

/* =============================================================================
 * GLOBAL SEARCH BAR — видимая поисковая строка сверху страницы
 * Триггер для Cmd+K модалки (см. cmdk.js)
 * ========================================================================== */
.global-search-wrap {
  padding: 12px 24px 0;
  display: flex;
  justify-content: flex-end;
}
.global-search {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-family-body);
  font-size: var(--font-size-sm);
  min-width: 280px;
  max-width: 420px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.global-search:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.global-search:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.global-search-icon { display: inline-flex; }
.global-search-placeholder { flex: 1; text-align: left; }
.global-search-kbd { display: inline-flex; gap: 2px; }
.global-search-kbd kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-family: var(--font-family-mono);
  font-size: 10px;
  color: var(--text-secondary);
}
@media (max-width: 768px) {
  /* На мобиле поисковая строка → компактная плавающая кнопка справа сверху,
     не отбирает вертикальное место у контента. */
  .global-search-wrap {
    padding: 0;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 50;
    pointer-events: none;
  }
  .global-search {
    pointer-events: auto;
    min-width: 0;
    max-width: none;
    width: 40px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-card);
  }
  .global-search-placeholder { display: none; }
  .global-search-kbd { display: none; }
  .global-search-icon { margin: 0; }
}

/* =============================================================================
 * CMD+K — глобальный поиск (Spotlight-style)
 * ========================================================================== */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  /* Плоское затемнение вместо backdrop-filter: blur() — blur пересчитывается
     на каждом кадре и тормозит модалки (см. #133). */
  background: rgba(15, 17, 24, 0.62);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 20px;
  animation: cmdk-fade-in 120ms ease;
}
@keyframes cmdk-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cmdk-panel {
  width: 100%;
  max-width: 600px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdk-slide-in 180ms ease;
}
@keyframes cmdk-slide-in {
  from { transform: translateY(-8px); opacity: 0.5; }
  to   { transform: translateY(0); opacity: 1; }
}
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
}
.cmdk-input-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-family-body);
  font-size: var(--font-size-md);
  line-height: 1.4;
  color: var(--text-primary);
  padding: 4px 0;
  min-width: 0;
}
.cmdk-input::placeholder { color: var(--text-muted); }
.cmdk-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  font-family: var(--font-family-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmdk-results {
  flex: 1;
  overflow-y: auto;
  max-height: min(60vh, 480px);
  padding: 4px;
}
.cmdk-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px 6px;
}
.cmdk-section-title:first-child { padding-top: 6px; }

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-family-body);
  transition: background var(--transition-fast);
  min-width: 0;
}
.cmdk-item.active,
.cmdk-item:hover {
  background: var(--bg-surface-hover);
}
.cmdk-item.active {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
}
.cmdk-item-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.cmdk-item-body {
  flex: 1;
  min-width: 0;
}
.cmdk-item-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-item-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: .6;
  display: inline-block;
  flex-shrink: 0;
}
.cmdk-item-extra {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  padding-left: 12px;
}

.cmdk-empty,
.cmdk-loading {
  padding: 32px 16px;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.cmdk-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-base);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.cmdk-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cmdk-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-family: var(--font-family-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

/* =============================================================================
 * SKELETON LOADING — placeholder с shimmer-анимацией пока грузим данные
 * ========================================================================== */
@keyframes skeleton-shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-active) 0%,
    var(--bg-hover) 50%,
    var(--bg-active) 100%
  );
  background-size: 200px 100%;
  background-repeat: no-repeat;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
  display: block;
}
.skeleton-line  { height: 14px; margin: 6px 0; width: 100%; }
.skeleton-line.sm { height: 10px; }
.skeleton-line.lg { height: 18px; }
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-block { height: 64px; border-radius: var(--radius-md); margin: 8px 0; }
.skeleton-block.lg { height: 120px; }
.skeleton-circle { width: 36px; height: 36px; border-radius: var(--radius-pill); }
.skeleton-circle.sm { width: 24px; height: 24px; }
.skeleton-circle.lg { width: 48px; height: 48px; }

/* Готовые комплекты для типичных мест загрузки */
.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
}
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.skeleton-row > .skeleton-circle { flex-shrink: 0; }
.skeleton-row > .skeleton-line { flex: 1; }

/* =============================================================================
 * MENU POPOVER — "⋯"-меню с пунктами (action menu)
 * Используется в page-header'ах для группировки admin-actions.
 * ========================================================================== */
.menu-popup {
  position: fixed;        /* JS позиционирует относительно trigger */
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  z-index: var(--z-popover);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  font: inherit;
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}
.menu-item:hover {
  background: var(--bg-hover);
}
.menu-item:focus-visible {
  outline: none;
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}
.menu-item-icon {
  flex-shrink: 0;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .7;
}
.menu-item.destructive { color: var(--status-danger); }
.menu-item.destructive:hover { background: var(--status-danger-bg); }
.menu-item:disabled {
  color: var(--text-disabled);
  cursor: not-allowed;
}
.menu-item:disabled:hover { background: transparent; }
.menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* =============================================================================
 * COMBOBOX — input с server-side search dropdown
 * Используется для customer-picker, user-picker и др. где список большой
 * (тысячи записей не помещаются в <select>).
 * ========================================================================== */
.combobox {
  position: relative;
  width: 100%;
}
.combobox-input {
  /* наследует .input */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%235e6470' stroke-width='1.5'><circle cx='6' cy='6' r='4.5'/><path d='M9.5 9.5l3 3' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
  padding-right: 32px !important;
}
.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-popover);
}
.combobox-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}
.combobox-option:last-of-type { border-bottom: none; }
.combobox-option:hover,
.combobox-option.active {
  background: var(--bg-surface-hover);
}
.combobox-option .name {
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combobox-option .meta {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}
.combobox-option .badge {
  margin-left: 6px;
}
.combobox-option-empty,
.combobox-option-loading {
  padding: 12px;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.combobox-option-create {
  padding: 10px 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  cursor: pointer;
  background: var(--bg-base);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast);
}
.combobox-option-create:hover {
  background: rgba(33, 120, 203, .14);
}
.combobox-option-create::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border-radius: var(--radius-pill);
  font-weight: var(--font-weight-bold);
  font-size: 13px;
  flex-shrink: 0;
}
.combobox-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-top: 6px;
  max-width: 100%;
}
.combobox-selected-chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  flex-shrink: 0;
}
.combobox-selected-chip .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.combobox-selected-chip .clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--radius-xs);
}
.combobox-selected-chip .clear:hover {
  background: var(--bg-hover);
  color: var(--status-danger);
}

/* =============================================================================
 * AVATAR — единый паттерн (rail-avatar остался legacy)
 * ========================================================================== */
.ui-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.ui-avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.ui-avatar.lg { width: 36px; height: 36px; font-size: var(--font-size-sm); }
.ui-avatar.xl { width: 48px; height: 48px; font-size: var(--font-size-base); }
.ui-avatar img { width: 100%; height: 100%; object-fit: cover; }
