/* ═══════════════════════════════════════════════════════════════════════
 * components-v2.css — Production-ready компонентная система (v200.0)
 *
 * Все классы используют design-tokens.css.
 * Префикс v2- чтобы не конфликтовать с legacy .btn/.modal.
 *
 * Компоненты:
 *  - .v2-btn (primary/secondary/ghost/danger/link, sm/md/lg)
 *  - .v2-input (default/error/disabled, sm/md/lg)
 *  - .v2-textarea, .v2-select
 *  - .v2-checkbox, .v2-radio, .v2-switch
 *  - .v2-card, .v2-stat-card
 *  - .v2-badge (default/success/warn/danger/info, soft/solid)
 *  - .v2-avatar (sm/md/lg + stack)
 *  - .v2-tabs
 *  - .v2-tooltip (через data-tooltip)
 *  - .v2-modal, .v2-drawer, .v2-sheet
 *  - .v2-divider
 *  - .v2-kbd
 * ═══════════════════════════════════════════════════════════════════════ */

/* ───── BUTTON ───── */

.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--button-height);
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.v2-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.v2-btn:active { transform: translateY(0.5px); }
.v2-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* sizes */
.v2-btn-sm { height: var(--button-height-sm); padding: 0 var(--sp-2); font-size: var(--fs-sm); }
.v2-btn-lg { height: var(--button-height-lg); padding: 0 var(--sp-5); font-size: var(--fs-lg); }
.v2-btn-block { display: flex; width: 100%; }
.v2-btn-icon { padding: 0; width: var(--button-height); flex-shrink: 0; }
.v2-btn-icon.v2-btn-sm { width: var(--button-height-sm); }
.v2-btn-icon.v2-btn-lg { width: var(--button-height-lg); }

/* variants */
.v2-btn-primary {
  background: var(--accent);
  color: var(--text-on-brand);
}
.v2-btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-sm); }

.v2-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.v2-btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-2); }

.v2-btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.v2-btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.v2-btn-danger {
  background: var(--danger);
  color: var(--text-on-brand);
}
.v2-btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.v2-btn-link {
  background: transparent;
  color: var(--accent);
  height: auto;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.v2-btn-link:hover { color: var(--accent-hover); }

/* ───── INPUT / TEXTAREA / SELECT ───── */

.v2-input,
.v2-textarea,
.v2-select {
  display: block;
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--sp-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.v2-input::placeholder, .v2-textarea::placeholder { color: var(--text-3); }
.v2-input:hover, .v2-textarea:hover, .v2-select:hover { border-color: var(--border-2); }
.v2-input:focus, .v2-textarea:focus, .v2-select:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring); }
.v2-input:disabled, .v2-textarea:disabled, .v2-select:disabled { opacity: 0.5; cursor: not-allowed; background: var(--surface-2); }
.v2-input.is-error, .v2-textarea.is-error, .v2-select.is-error { border-color: var(--danger); box-shadow: var(--focus-ring-danger); }

.v2-textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-2) var(--sp-3);
  resize: vertical;
}

.v2-input-sm { height: 24px; padding: 0 var(--sp-2); font-size: var(--fs-sm); }
.v2-input-lg { height: var(--input-height-lg); padding: 0 var(--sp-4); font-size: var(--fs-lg); }

.v2-input-group { display: flex; align-items: stretch; gap: 0; }
.v2-input-group > .v2-input { border-radius: var(--r-md) 0 0 var(--r-md); }
.v2-input-group > .v2-btn { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* Label */
.v2-label {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
}
.v2-help-text {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.v2-error-text {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--danger);
}

/* ───── CHECKBOX / RADIO / SWITCH ───── */

.v2-checkbox, .v2-radio {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-out);
}
.v2-checkbox { border-radius: var(--r-xs); }
.v2-radio { border-radius: var(--r-full); }
.v2-checkbox:hover, .v2-radio:hover { border-color: var(--accent); }
.v2-checkbox:focus-visible, .v2-radio:focus-visible { box-shadow: var(--focus-ring); }
.v2-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6l3 3 5-6' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px; background-repeat: no-repeat; background-position: center;
}
.v2-radio:checked {
  background: radial-gradient(circle at center, var(--accent) 0 4px, transparent 5px);
  border-color: var(--accent);
}

.v2-switch {
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--border-2);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out);
}
.v2-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  transition: left var(--duration-base) var(--ease-spring);
}
.v2-switch:checked { background: var(--accent); }
.v2-switch:checked::after { left: 16px; }
.v2-switch:focus-visible { box-shadow: var(--focus-ring); }

/* ───── CARD ───── */

.v2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--sp-4);
}
.v2-card-elevated { border: none; box-shadow: var(--shadow-md); }
.v2-card-interactive { cursor: pointer; transition: all var(--duration-fast) var(--ease-out); }
.v2-card-interactive:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.v2-card-hd {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.v2-card-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.v2-card-meta { font-size: var(--fs-xs); color: var(--text-3); margin-left: auto; }

/* Stat card (dashboard KPI) */
.v2-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.v2-stat-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-3);
}
.v2-stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.v2-stat-delta { font-size: var(--fs-sm); color: var(--text-3); }
.v2-stat-delta.is-up { color: var(--success); }
.v2-stat-delta.is-down { color: var(--danger); }

/* ───── BADGE ───── */

.v2-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  background: var(--surface-2);
  color: var(--text-2);
}
.v2-badge-success { background: var(--success-soft); color: var(--success-700); }
.v2-badge-warn    { background: var(--warn-soft);    color: var(--warn-700); }
.v2-badge-danger  { background: var(--danger-soft);  color: var(--danger-700); }
.v2-badge-info    { background: var(--info-soft);    color: var(--info-700); }
.v2-badge-accent  { background: var(--accent-soft);  color: var(--accent-text); }

.v2-badge-solid.v2-badge-success { background: var(--success); color: white; }
.v2-badge-solid.v2-badge-warn    { background: var(--warn);    color: white; }
.v2-badge-solid.v2-badge-danger  { background: var(--danger);  color: white; }
.v2-badge-solid.v2-badge-info    { background: var(--info);    color: white; }
.v2-badge-solid.v2-badge-accent  { background: var(--accent);  color: white; }

.v2-badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
}

/* ───── AVATAR ───── */

.v2-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: var(--r-full);
  background: var(--accent);
  color: white;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  overflow: hidden;
  flex-shrink: 0;
}
.v2-avatar img { width: 100%; height: 100%; object-fit: cover; }
.v2-avatar-sm { width: 24px; height: 24px; font-size: var(--fs-xs); }
.v2-avatar-lg { width: 40px; height: 40px; font-size: var(--fs-md); }
.v2-avatar-xl { width: 56px; height: 56px; font-size: var(--fs-lg); }

.v2-avatar-stack { display: inline-flex; }
.v2-avatar-stack .v2-avatar:not(:first-child) {
  margin-left: -8px;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ───── TABS ───── */

.v2-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.v2-tabs::-webkit-scrollbar { display: none; }
.v2-tab {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.v2-tab:hover { color: var(--text); }
.v2-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.v2-tab[data-count]::after {
  content: attr(data-count);
  display: inline-block;
  margin-left: var(--sp-1);
  background: var(--surface-3);
  color: var(--text-2);
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.v2-tab.is-active[data-count]::after { background: var(--accent-soft); color: var(--accent-text); }

/* v199.339 H3: УНИФИКАЦИЯ — общие правила для всех существующих tab-классов.
 * Не ломает JS — просто выравнивает визуал. transition / cursor / font одинаковые. */
.ref-tab, .sc-tab, .deal-tab, .gd-tab, .st-tab, .an-tab, .mode-tabs > *, .dbb-tab, .trash-tab, .cb-tab {
  transition: color var(--duration-fast), background var(--duration-fast), border-color var(--duration-fast) !important;
  cursor: pointer;
  font-family: inherit;
}
/* underline-tabs семейство: ref/sc/deal/gd — одинаковый focus-ring */
.ref-tab:focus-visible, .sc-tab:focus-visible, .deal-tab:focus-visible, .gd-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-radius: 4px;
}

/* v199.339 H3: 3 варианта tabs (underline default + pill + button)
 *  - .v2-tabs            — underline (Linear/Notion style, default)
 *  - .v2-tabs--pill      — pill-tabs внутри surface2 (settings analytics)
 *  - .v2-tabs--button    — кнопко-подобные tabs (border + bg, settings hub)
 * Migration: ref-tab / sc-tab / deal-tab / gd-tab → default; an-tab → --pill; st-tab → --button. */

/* PILL variant */
.v2-tabs--pill {
  background: var(--surface-2);
  border: none;
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
  margin-bottom: var(--sp-3);
}
.v2-tabs--pill .v2-tab {
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  margin: 0;
  height: 30px;
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.v2-tabs--pill .v2-tab.is-active {
  background: var(--surface);
  color: var(--text);
  border: none;
  box-shadow: var(--shadow-xs);
}

/* BUTTON variant */
.v2-tabs--button {
  border: none;
  background: transparent;
  gap: 8px;
  flex-wrap: wrap;
}
.v2-tabs--button .v2-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 8px 16px;
  margin: 0;
  font-size: var(--fs-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}
.v2-tabs--button .v2-tab:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}
.v2-tabs--button .v2-tab.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ───── TOOLTIP — pure CSS через data-tooltip ───── */

[data-tooltip] { position: relative; }
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: white;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-tooltip);
  animation: v2TooltipFade var(--duration-fast) var(--ease-out);
}
@keyframes v2TooltipFade { from { opacity: 0; transform: translate(-50%, 2px); } to { opacity: 1; transform: translateX(-50%); } }

/* ───── MODAL — base layout ───── */

.v2-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: v2FadeIn var(--duration-fast) var(--ease-out);
}
.v2-modal {
  background: var(--surface);
  border-radius: var(--modal-radius);
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
  animation: v2ModalIn var(--duration-base) var(--ease-out);
}
.v2-modal-hd {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.v2-modal-title { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text); flex: 1; }
.v2-modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.v2-modal-ft {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}
.v2-modal-sm { width: 380px; }
.v2-modal-lg { width: 680px; }
.v2-modal-xl { width: 880px; }

@keyframes v2FadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes v2ModalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ───── DRAWER (slide from right) ───── */

.v2-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: var(--z-modal);
  animation: v2FadeIn var(--duration-fast) var(--ease-out);
}
.v2-drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 480px;
  max-width: 92vw;
  background: var(--surface);
  box-shadow: var(--shadow-2xl);
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  flex-direction: column;
  animation: v2DrawerIn var(--duration-base) var(--ease-out);
}
@keyframes v2DrawerIn { from { transform: translateX(100%); } to { transform: none; } }

/* ───── SHEET (mobile bottom-sheet) ───── */

@media (max-width: 640px) {
  .v2-modal {
    align-self: flex-end;
    width: 100%;
    max-width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh;
    animation: v2SheetIn var(--duration-slow) var(--ease-out);
  }
  .v2-modal-overlay { align-items: flex-end; padding: 0; }
  @keyframes v2SheetIn { from { transform: translateY(100%); } to { transform: none; } }
}

/* ───── DIVIDER ───── */

.v2-divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--sp-4) 0;
}
.v2-divider-vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
  margin: 0 var(--sp-2);
}

/* ───── KEYBOARD KEY ───── */

.v2-kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  color: var(--text-2);
  box-shadow: var(--shadow-inset-xs);
}

/* ───── TABLE ───── */

.v2-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-md);
}
.v2-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}
.v2-table tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.v2-table tbody tr { transition: background var(--duration-fast); }
.v2-table tbody tr:hover { background: var(--surface-hover); }
.v2-table tbody tr.is-selected { background: var(--accent-soft); }

/* ───── LOADING SPINNER ───── */

.v2-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: v2Spin 0.6s linear infinite;
}
.v2-spinner-lg { width: 24px; height: 24px; border-width: 3px; }
@keyframes v2Spin { to { transform: rotate(360deg); } }

/* ───── TOAST ───── */

.v2-toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--gray-900);
  color: white;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-md);
  z-index: var(--z-toast);
  animation: v2ToastIn var(--duration-base) var(--ease-spring);
}
.v2-toast.is-success { background: var(--success); }
.v2-toast.is-warn    { background: var(--warn); }
.v2-toast.is-danger  { background: var(--danger); }
@keyframes v2ToastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───── SKELETON shimmer (cross-link с feature-ux-states) ───── */
.v2-skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: v2Shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes v2Shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* v199.339 L13: empty-state — единый компонент */
.v2-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
  color: var(--text-3);
}
.v2-empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
  color: var(--text-3);
}
.v2-empty-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin: 0;
}
.v2-empty-desc {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin: 0;
  max-width: 360px;
  line-height: 1.5;
}
.v2-empty-cta {
  margin-top: 8px;
}

/* v199.339 L14: skeleton — shimmer animation */
.v2-skeleton {
  display: block;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: v2-shimmer 1.4s ease-in-out infinite;
}
@keyframes v2-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.v2-skeleton-text   { height: 12px; margin: 4px 0; }
.v2-skeleton-title  { height: 18px; margin: 6px 0; }
.v2-skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; }
.v2-skeleton-card   { height: 60px; margin-bottom: 8px; border-radius: var(--r-md); }
@media (prefers-reduced-motion: reduce) {
  .v2-skeleton { animation: none; background: var(--surface-2); }
}

/* v199.339 L9: badge cap — длинные теги обрезаются ellipsis */
.badge {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

/* v199.339 P2: native window-virtualization для kanban — content-visibility пропускает
 * rendering карточек вне viewport, экономит 50-90% paint-time на длинных колонках.
 * Браузер сам решает что рендерить; contain-intrinsic-size держит scroll-height стабильным. */
.cb-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 88px;
  /* fallback для Safari < 18 (без content-visibility поведение обычное) */
}

/* То же для строк длинных списков (контакты/компании/товары) */
.list-table tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}

/* v199.340 H1 SAFE: utility-классы для entity-page (заменяют inline-style) */
.ep-topbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ep-back-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ep-page-title {
  flex: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ep-search-input {
  height: 32px;
  width: 180px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}
.ep-action-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}
.ep-action-btn--danger { color: var(--red); }
.ep-layout {
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  gap: 16px;
  padding: 16px 20px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.ep-zone {
  overflow-y: auto;
  align-self: stretch;
}
.ep-zone--center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: auto;
}

/* v199.340 H1 MASS: utility-классы для топ inline-style паттернов в HTML */
.u-icon-13 { width: 13px; height: 13px; }
.u-icon-14 { width: 14px; height: 14px; }
.u-icon-16 { width: 16px; height: 16px; }
.u-icon-13-green { width: 13px; height: 13px; color: #117c43; }
.u-icon-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.u-h-icon-row { display: flex; align-items: center; gap: 5px; }
.u-h-icon-row-sm { display: flex; align-items: center; gap: 5px; font-size: 11px; }
.u-mt-18 { margin-top: 18px; }
.u-mb-14 { margin-bottom: 14px; }
.u-mr-auto { margin-right: auto; }
.u-min-w-240 { min-width: 240px; }
.u-border-b-only { border-bottom: 1px solid var(--border); }
.u-border-t-mt { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.u-input-flex-32 { flex: 1; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; }
.u-input-full-pad { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12px; }
.u-scroll-content { flex: 1; overflow-y: auto; padding: 18px 22px; }
.u-scroll { flex: 1; overflow-y: auto; }
.u-section-header { padding: 6px 12px 4px; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.u-section-header-bordered { padding: 6px 12px 4px; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; border-top: 1px solid var(--border); margin-top: 4px; }
.u-form-label-bold { font-size: 11px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 6px; }
.u-form-label-help { font-size: 11px; color: var(--text-3); display: block; margin-bottom: 4px; }
.u-text-hint { font-size: 11px; color: var(--text3); }
.u-text-section-title { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.u-text-label-80 { font-size: 11px; color: var(--text2); width: 80px; }
.u-tag-mini { padding: 2px 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; font-size: 11px; }

/* v199.340: print stylesheet для entity-page */
@media print {
  body * { visibility: hidden; }
  #page-entity, #page-entity * { visibility: visible; }
  #page-entity { position: absolute; left: 0; top: 0; width: 100%; }
  #page-entity .ep-topbar, #page-entity .ep-right { display: none !important; }
  #page-entity .ep-layout { grid-template-columns: 280px 1fr !important; gap: 20px; }
  /* v199.340: tabs скрыты, активный tab контент печатается */
  #page-entity .v2-tabs { display: none !important; }
  #page-entity #ep-tab-content { display: block !important; page-break-inside: auto; }
  #page-entity .v2-empty { display: none !important; }
  #page-entity #ep-tab-content button,
  #page-entity .v2-skeleton { display: none !important; }
  .toast-container, #sidebar, .sb-rail, #toast-container,
  #mobile-menu-toggle, .ux-sp-overlay, .ux-sp-panel { display: none !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  @page { margin: 1.5cm; size: A4; }
}

/* v199.340: mobile sticky tabs на entity-page */
@media (max-width: 900px) {
  #page-entity .v2-tabs {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 5;
    margin: 0 -12px 8px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
  }
}

/* v199.340 Tabs unification phase 2: alias legacy → unified behavior.
 * Делаем 13 классов псевдо-наследниками .v2-tab по common stylesheet.
 * НЕ переименовываем в HTML/JS (риск). Только синхронизируем визуал/анимацию/focus. */
.ref-tab, .sc-tab, .deal-tab, .gd-tab, .dbb-tab, .trash-tab, .cb-tab, .an-tab, .st-tab {
  /* Унифицированный font-family + transition уже добавлены раньше; добавим focus-trap */
  font-family: inherit;
}
.ref-tab.active, .sc-tab.active, .deal-tab.active, .gd-tab.active,
.dbb-tab.active, .trash-tab.active, .cb-tab.active, .an-tab.active, .st-tab.active {
  /* Унифицированный accent-цвет для active */
  --tab-accent: var(--accent);
}
/* Все active-tabs получают consistent underline behavior */
.ref-tab.active, .sc-tab.active, .deal-tab.active, .gd-tab.active,
.dbb-tab.active, .trash-tab.active, .cb-tab.active {
  border-bottom-color: var(--accent) !important;
  color: var(--accent) !important;
}
.an-tab.active {
  background: var(--surface) !important;
  color: var(--text) !important;
}
.st-tab.active {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}
/* Keyboard nav для всех tab-классов */
.ref-tabs, .sc-tabs, .deal-tabs, .gd-subtabs, .dbb-tabs, .trash-tabs, .cb-tabs, .an-tabs, .st-tabs {
  outline: none;
}
.ref-tab:focus-visible, .sc-tab:focus-visible, .deal-tab:focus-visible,
.gd-tab:focus-visible, .dbb-tab:focus-visible, .trash-tab:focus-visible,
.cb-tab:focus-visible, .an-tab:focus-visible, .st-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-radius: 4px;
}
