/**
 * main.css
 * Главный файл стилей Reference Books Module
 * Импортирует все CSS модули в правильном порядке
 * 
 * Version: 2.0 (Enhanced with tokens, dark mode, utilities, animations)
 */

/* ============================================
   TOKENS & VARIABLES (базовые значения)
   ============================================ */
/* === core/tokens.css === */
/**
 * tokens.css
 * Design Tokens - сырые значения дизайн-системы
 * Не используйте напрямую! Используйте variables.css
 */

:root {
  /* ============================================
     COLOR PALETTE - Raw colors
     ============================================ */
  
  /* Blue (Primary) */
  --color-blue-50: #e3f2fd;
  --color-blue-100: #bbdefb;
  --color-blue-200: #90caf9;
  --color-blue-300: #64b5f6;
  --color-blue-400: #42a5f5;
  --color-blue-500: #2196f3;
  --color-blue-600: #1e88e5;
  --color-blue-700: #1976d2;
  --color-blue-800: #1565c0;
  --color-blue-900: #0d47a1;
  
  /* Green (Success) */
  --color-green-50: #e8f5e9;
  --color-green-100: #c8e6c9;
  --color-green-200: #a5d6a7;
  --color-green-300: #81c784;
  --color-green-400: #66bb6a;
  --color-green-500: #4caf50;
  --color-green-600: #43a047;
  --color-green-700: #388e3c;
  --color-green-800: #2e7d32;
  --color-green-900: #1b5e20;
  
  /* Red (Error/Danger) */
  --color-red-50: #ffebee;
  --color-red-100: #ffcdd2;
  --color-red-200: #ef9a9a;
  --color-red-300: #e57373;
  --color-red-400: #ef5350;
  --color-red-500: #f44336;
  --color-red-600: #e53935;
  --color-red-700: #d32f2f;
  --color-red-800: #c62828;
  --color-red-900: #b71c1c;
  
  /* Orange (Warning) */
  --color-orange-50: #fff3e0;
  --color-orange-100: #ffe0b2;
  --color-orange-200: #ffcc80;
  --color-orange-300: #ffb74d;
  --color-orange-400: #ffa726;
  --color-orange-500: #ff9800;
  --color-orange-600: #fb8c00;
  --color-orange-700: #f57c00;
  --color-orange-800: #ef6c00;
  --color-orange-900: #e65100;
  
  /* Yellow */
  --color-yellow-50: #fffde7;
  --color-yellow-100: #fff9c4;
  --color-yellow-200: #fff59d;
  --color-yellow-300: #fff176;
  --color-yellow-400: #ffee58;
  --color-yellow-500: #ffeb3b;
  --color-yellow-600: #fdd835;
  --color-yellow-700: #fbc02d;
  --color-yellow-800: #f9a825;
  --color-yellow-900: #f57f17;
  
  /* Purple */
  --color-purple-50: #f3e5f5;
  --color-purple-100: #e1bee7;
  --color-purple-200: #ce93d8;
  --color-purple-300: #ba68c8;
  --color-purple-400: #ab47bc;
  --color-purple-500: #9c27b0;
  --color-purple-600: #8e24aa;
  --color-purple-700: #7b1fa2;
  --color-purple-800: #6a1b9a;
  --color-purple-900: #4a148c;
  
  /* Gray Scale (ОЧЕНЬ ВАЖНО!) */
  --color-gray-50: #fafafa;
  --color-gray-100: #f5f5f5;
  --color-gray-200: #eeeeee;
  --color-gray-300: #e0e0e0;
  --color-gray-400: #bdbdbd;
  --color-gray-500: #9e9e9e;
  --color-gray-600: #757575;
  --color-gray-700: #616161;
  --color-gray-800: #424242;
  --color-gray-900: #212121;
  
  /* Black & White */
  --color-white: #ffffff;
  --color-black: #000000;
  
  /* ============================================
     SPACING SCALE
     ============================================ */
  --spacing-unit: 4px;
  --spacing-0: 0;
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-7: 28px;
  --spacing-8: 32px;
  --spacing-9: 36px;
  --spacing-10: 40px;
  --spacing-11: 44px;
  --spacing-12: 48px;
  --spacing-14: 56px;
  --spacing-16: 64px;
  --spacing-20: 80px;
  --spacing-24: 96px;
  --spacing-32: 128px;
  
  /* ============================================
     TYPOGRAPHY
     ============================================ */
  
  /* Font Families */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 
               'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 
               'Helvetica Neue', sans-serif;
  --font-serif: Georgia, Cambria, 'Times New Roman', Times, serif;
  --font-mono: 'Courier New', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  
  /* Font Sizes */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;
  --font-size-4xl: 36px;
  --font-size-5xl: 48px;
  
  /* Font Weights */
  --font-weight-thin: 100;
  --font-weight-extralight: 200;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  --font-weight-black: 900;
  
  /* Line Heights */
  --line-height-none: 1;
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;
  
  /* Letter Spacing */
  --letter-spacing-tighter: -0.05em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;
  
  /* ============================================
     BORDER RADIUS
     ============================================ */
  --radius-none: 0;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-3xl: 24px;
  --radius-full: 9999px;
  
  /* ============================================
     SHADOWS
     ============================================ */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-2xl: 0 16px 48px rgba(0, 0, 0, 0.3);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-none: none;
  
  /* ============================================
     Z-INDEX SCALE
     ============================================ */
  --z-0: 0;
  --z-10: 10;
  --z-20: 20;
  --z-30: 30;
  --z-40: 40;
  --z-50: 50;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-notification: 1080;
  --z-max: 9999;
  
  /* ============================================
     TRANSITIONS & ANIMATIONS
     ============================================ */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;
  
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* ============================================
     BREAKPOINTS (для reference в JS)
     ============================================ */
  --breakpoint-xs: 480px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  
  /* ============================================
     SIZING
     ============================================ */
  --size-0: 0;
  --size-px: 1px;
  --size-full: 100%;
  --size-screen: 100vh;
  --size-min: min-content;
  --size-max: max-content;
  --size-fit: fit-content;
}
/* === core/variables.css === */
/**
 * variables.css
 * Семантические CSS переменные - используют tokens.css
 * Поддержка Light/Dark режимов
 */

:root {
  /* ============================================
     SEMANTIC COLORS - Light Mode (default)
     ============================================ */
  
  /* Primary */
  --primary: var(--color-blue-500);
  --primary-hover: var(--color-blue-700);
  --primary-active: var(--color-blue-800);
  --primary-light: var(--color-blue-50);
  --primary-lighter: var(--color-blue-100);
  
  /* Success */
  --success: var(--color-green-500);
  --success-hover: var(--color-green-700);
  --success-light: var(--color-green-50);
  
  /* Error/Danger */
  --error: var(--color-red-500);
  --error-hover: var(--color-red-700);
  --error-light: var(--color-red-50);
  --danger: var(--color-red-500);
  --danger-hover: var(--color-red-700);
  --danger-light: var(--color-red-50);
  
  /* Warning */
  --warning: var(--color-orange-500);
  --warning-hover: var(--color-orange-700);
  --warning-light: var(--color-orange-50);
  
  /* Info */
  --info: var(--color-blue-500);
  --info-light: var(--color-blue-50);
  
  /* ============================================
     TEXT COLORS
     ============================================ */
  --text-primary: var(--color-gray-900);
  --text-secondary: var(--color-gray-700);
  --text-muted: var(--color-gray-500);
  --text-disabled: var(--color-gray-400);
  --text-inverse: var(--color-white);
  
  /* Legacy aliases */
  --text-color: var(--text-primary);
  
  /* ============================================
     BACKGROUND COLORS
     ============================================ */
  --bg-primary: var(--color-white);
  --bg-secondary: var(--color-gray-50);
  --bg-tertiary: var(--color-gray-100);
  --bg-hover: var(--color-gray-100);
  --bg-active: var(--color-gray-200);
  --bg-disabled: var(--color-gray-200);
  --bg-inverse: var(--color-gray-900);
  
  /* Legacy aliases */
  --bg-color: var(--bg-primary);
  --background-secondary: var(--bg-secondary);
  
  /* ============================================
     BORDER COLORS
     ============================================ */
  --border: var(--color-gray-300);
  --border-light: var(--color-gray-200);
  --border-dark: var(--color-gray-400);
  --border-focus: var(--primary);
  
  /* Legacy alias */
  --border-color: var(--border);
  
  /* ============================================
     SPACING (semantic)
     ============================================ */
  --space-xs: var(--spacing-1);   /* 4px */
  --space-sm: var(--spacing-2);   /* 8px */
  --space-md: var(--spacing-4);   /* 16px */
  --space-lg: var(--spacing-6);   /* 24px */
  --space-xl: var(--spacing-8);   /* 32px */
  --space-2xl: var(--spacing-12); /* 48px */
  
  /* ============================================
     TYPOGRAPHY
     ============================================ */
  --font-family: var(--font-sans);
  --font-family-mono: var(--font-mono);
  
  /* ============================================
     BORDER RADIUS (semantic)
     ============================================ */
  --radius: var(--radius-md);
  --border-radius: var(--radius-sm); /* legacy */
  
  /* ============================================
     SHADOWS (semantic)
     ============================================ */
  --shadow: var(--shadow-md);
  
          /* Overlay */
          --overlay-bg: rgba(0, 0, 0, 0.5);
          --overlay-blur: blur(4px);
          
          /* Text on colored backgrounds */
          --color-on-primary: var(--color-white);
          --color-on-error: var(--color-white);
          --color-on-success: var(--color-white);
          
          /* Touch targets */
          --touch-target-min: 44px;
  
  /* ============================================
     TRANSITIONS (semantic)
     ============================================ */
  --transition: var(--transition-base);
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  /* Primary остается */
  --primary: var(--color-blue-400);
  --primary-hover: var(--color-blue-300);
  --primary-light: var(--color-blue-900);
  
  /* Success */
  --success: var(--color-green-400);
  --success-hover: var(--color-green-300);
  --success-light: var(--color-green-900);
  
  /* Error */
  --error: var(--color-red-400);
  --error-hover: var(--color-red-300);
  --error-light: var(--color-red-900);
  --danger: var(--color-red-400);
  --danger-hover: var(--color-red-300);
  --danger-light: var(--color-red-900);
  
  /* Warning */
  --warning: var(--color-orange-400);
  --warning-hover: var(--color-orange-300);
  --warning-light: var(--color-orange-900);
  
  /* Info */
  --info: var(--color-blue-400);
  --info-light: var(--color-blue-900);
  
  /* Text */
  --text-primary: var(--color-gray-50);
  --text-secondary: var(--color-gray-300);
  --text-muted: var(--color-gray-500);
  --text-disabled: var(--color-gray-600);
  --text-inverse: var(--color-gray-900);
  
  /* Background */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #3a3a3a;
  --bg-hover: #333333;
  --bg-active: #404040;
  --bg-disabled: #404040;
  --bg-inverse: var(--color-gray-50);
  
  /* Borders */
  --border: var(--color-gray-700);
  --border-light: var(--color-gray-800);
  --border-dark: var(--color-gray-600);
  --border-focus: var(--primary);
  
  /* Shadows - более заметные в темной теме */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.8);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.9);
  
   /* Overlay */
   --overlay-bg: rgba(0, 0, 0, 0.7);
}


/* ============================================
   CORE STYLES (базовые стили)
   ============================================ */
/* === core/base.css === */
/**
 * base.css
 * Базовые стили модуля Reference Books
 */

/* ============================================
   ROOT ELEMENT
   ============================================ */
#reference-books-root {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

#reference-books-root * {
  box-sizing: border-box;
}

/* ============================================
   LAYOUT
   ============================================ */
.reference-books-module {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.module-container {
  width: 100%;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ============================================
   MODULE HEADER
   ============================================ */
.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 10;
  height: 56px;
  flex: 0 0 56px;
}

.module-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
}

.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================
   MOBILE: MODULE HEADER
   ============================================ */
@media (max-width: 768px) {
  .module-header {
    padding: 0 8px;
    height: 28px;
    flex: 0 0 28px;
    margin-bottom: 0;
  }

  .module-title {
    font-size: 13px;
  }

  .module-title {
    font-size: 14px;
  }

  .module-container {
    padding: 0;
  }

  .header-right .btn span {
    display: none;
  }

  .header-right .btn {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
  }

  .header-right .btn svg {
    margin: 0;
  }
}

@media (max-width: 480px) {
  .module-header {
    padding: 6px 8px;
    height: 44px;
    flex: 0 0 44px;
  }

  .module-title {
    font-size: 14px;
  }

  .module-container {
    padding: 8px;
  }
}

/* ============================================
   LOADING
   ============================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-container,
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin: 10px 0;
  font-size: 14px;
}

.grid-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.grid-placeholder-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.grid-placeholder-text {
  font-size: 18px;
  font-weight: 500;
}

/* ============================================
   PANEL HEADERS (h1, h2)
   ============================================ */
.panel-header h1,
.panel-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   LABELS & CHECKBOXES
   ============================================ */
label {
  color: var(--text-primary);
}

/* ============================================
   FOCUS STATES (Accessibility)
   ============================================ */

/* Убираем стандартный outline */
*:focus:not(:focus-visible) {
   outline: none;
  }

/* Красивый focus для клавиатурной навигации */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Focus для интерактивных элементов */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Специальный focus для кнопок */
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Skip to content link (accessibility) */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  z-index: var(--z-max);
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
  font-weight: 600;
  transition: top 0.2s;
}

.skip-to-content:focus {
  top: 0;
}

/* ============================================
   SCROLLBAR (унифицированные стили)
   ============================================ */

/* Для Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-400) var(--color-gray-100);
}

[data-theme="dark"] * {
  scrollbar-color: var(--color-gray-600) var(--color-gray-800);
}

/* Для Webkit (Chrome, Safari, Edge) */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--radius-sm);
}

*::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-gray-100);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Dark mode scrollbar */
[data-theme="dark"] *::-webkit-scrollbar-track {
  background: var(--color-gray-800);
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: var(--color-gray-600);
  border-color: var(--color-gray-800);
}

[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Тонкий scrollbar */
.scrollbar-thin::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  border-width: 1px;
}

/* Скрытый scrollbar */
.scrollbar-none {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  /* Скрываем ненужное при печати */
  .no-print,
  .btn,
  .toolbar,
  .sidebar,
  nav,
  .modal-overlay,
  .toast-container,
  .context-menu,
  button,
  .pagination,
  .widget-actions {
    display: none !important;
  }
  
  /* Убираем тени и эффекты */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  /* Оптимизируем для печати */
  body,
  #reference-books-root {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }
  
  /* Ссылки */
  a {
    text-decoration: underline;
    color: #000;
  }
  
  /* Показываем URL после ссылок */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #666;
  }
  
  /* Не показываем URL для якорных ссылок */
  a[href^="#"]:after,
  a[href^="javascript:"]:after {
    content: "";
  }
  
  /* Разрывы страниц */
  .page-break {
    page-break-after: always;
  }
  
  .page-break-before {
    page-break-before: always;
  }
  
  .page-break-inside-avoid {
    page-break-inside: avoid;
  }
  
  /* Заголовки не разрывать */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  
  /* Таблицы */
  table {
    page-break-inside: avoid;
    border-collapse: collapse;
  }
  
  thead {
    display: table-header-group;
  }
  
  tr {
    page-break-inside: avoid;
  }
  
  /* Изображения */
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }
  
  /* Списки */
  ul, ol {
    page-break-inside: avoid;
  }
  
  /* Блоки кода */
  pre, blockquote {
    page-break-inside: avoid;
    border: 1px solid #ccc;
    padding: 10px;
  }
  
  /* Карточки */
  .card {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
}
/* === core/animations.css === */
/**
 * animations.css
 * Готовые анимации и utility классы для transitions
 */

/* ============================================
   KEYFRAMES - FADE
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   KEYFRAMES - SLIDE
   ============================================ */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-100%);
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

/* ============================================
   KEYFRAMES - SCALE
   ============================================ */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0);
  }
}

/* ============================================
   KEYFRAMES - BOUNCE
   ============================================ */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* ============================================
   KEYFRAMES - SHAKE
   ============================================ */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

@keyframes shakeY {
  0%, 100% {
    transform: translateY(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateY(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateY(5px);
  }
}

/* ============================================
   KEYFRAMES - PULSE
   ============================================ */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes pulseScale {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* ============================================
   KEYFRAMES - SPIN
   ============================================ */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

/* ============================================
   KEYFRAMES - FLIP
   ============================================ */
@keyframes flipIn {
  from {
    transform: perspective(400px) rotateY(90deg);
    opacity: 0;
  }
  to {
    transform: perspective(400px) rotateY(0);
    opacity: 1;
  }
}

@keyframes flipOut {
  from {
    transform: perspective(400px) rotateY(0);
    opacity: 1;
  }
  to {
    transform: perspective(400px) rotateY(90deg);
    opacity: 0;
  }
}

/* ============================================
   KEYFRAMES - SKELETON LOADING
   ============================================ */
@keyframes skeletonLoading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ============================================
   ANIMATION CLASSES - FADE
   ============================================ */
.animate-fade-in {
  animation: fadeIn 0.3s var(--ease-out);
}

.animate-fade-out {
  animation: fadeOut 0.3s var(--ease-in);
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s var(--ease-out);
}

.animate-fade-in-down {
  animation: fadeInDown 0.4s var(--ease-out);
}

/* ============================================
   ANIMATION CLASSES - SLIDE
   ============================================ */
.animate-slide-in-up {
  animation: slideInUp 0.3s var(--ease-out);
}

.animate-slide-in-down {
  animation: slideInDown 0.3s var(--ease-out);
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s var(--ease-out);
}

.animate-slide-in-right {
  animation: slideInRight 0.3s var(--ease-out);
}

.animate-slide-out-up {
  animation: slideOutUp 0.3s var(--ease-in);
}

.animate-slide-out-down {
  animation: slideOutDown 0.3s var(--ease-in);
}

.animate-slide-out-left {
  animation: slideOutLeft 0.3s var(--ease-in);
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s var(--ease-in);
}

/* ============================================
   ANIMATION CLASSES - SCALE
   ============================================ */
.animate-scale-in {
  animation: scaleIn 0.2s var(--ease-out);
}

.animate-scale-out {
  animation: scaleOut 0.2s var(--ease-in);
}

.animate-zoom-in {
  animation: zoomIn 0.3s var(--ease-out);
}

.animate-zoom-out {
  animation: zoomOut 0.3s var(--ease-in);
}

/* ============================================
   ANIMATION CLASSES - BOUNCE
   ============================================ */
.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-bounce-in {
  animation: bounceIn 0.6s var(--ease-out);
}

/* ============================================
   ANIMATION CLASSES - SHAKE
   ============================================ */
.animate-shake {
  animation: shake 0.5s var(--ease-in-out);
}

.animate-shake-y {
  animation: shakeY 0.5s var(--ease-in-out);
}

/* ============================================
   ANIMATION CLASSES - PULSE
   ============================================ */
.animate-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}

.animate-pulse-scale {
  animation: pulseScale 2s var(--ease-in-out) infinite;
}

/* ============================================
   ANIMATION CLASSES - SPIN
   ============================================ */
.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-spin-slow {
  animation: spin 3s linear infinite;
}

.animate-spin-fast {
  animation: spin 0.5s linear infinite;
}

.animate-spin-reverse {
  animation: spinReverse 1s linear infinite;
}

/* ============================================
   ANIMATION CLASSES - FLIP
   ============================================ */
.animate-flip-in {
  animation: flipIn 0.5s var(--ease-out);
}

.animate-flip-out {
  animation: flipOut 0.5s var(--ease-in);
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-200) 0%,
    var(--color-gray-100) 50%,
    var(--color-gray-200) 100%
  );
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-800) 0%,
    var(--color-gray-700) 50%,
    var(--color-gray-800) 100%
  );
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--space-md);
}

.skeleton-subtitle {
  height: 20px;
  width: 40%;
  margin-bottom: var(--space-md);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

.skeleton-button {
  height: 40px;
  width: 120px;
  border-radius: var(--radius-md);
}

.skeleton-input {
  height: 42px;
  border-radius: var(--radius-md);
}

/* ============================================
   TRANSITION CLASSES
   ============================================ */
.transition-none {
  transition: none;
}

.transition-all {
  transition: all var(--transition-base);
}

.transition-fast {
  transition: all var(--transition-fast);
}

.transition-slow {
  transition: all var(--transition-slow);
}

.transition-colors {
  transition: color var(--transition-base),
              background-color var(--transition-base),
              border-color var(--transition-base);
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-shadow {
  transition: box-shadow var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

/* ============================================
   ANIMATION DELAYS
   ============================================ */
.delay-75 {
  animation-delay: 75ms;
}

.delay-100 {
  animation-delay: 100ms;
}

.delay-150 {
  animation-delay: 150ms;
}

.delay-200 {
  animation-delay: 200ms;
}

.delay-300 {
  animation-delay: 300ms;
}

.delay-500 {
  animation-delay: 500ms;
}

.delay-700 {
  animation-delay: 700ms;
}

.delay-1000 {
  animation-delay: 1000ms;
}

/* ============================================
   ANIMATION DURATIONS
   ============================================ */
.duration-75 {
  animation-duration: 75ms;
}

.duration-100 {
  animation-duration: 100ms;
}

.duration-150 {
  animation-duration: 150ms;
}

.duration-200 {
  animation-duration: 200ms;
}

.duration-300 {
  animation-duration: 300ms;
}

.duration-500 {
  animation-duration: 500ms;
}

.duration-700 {
  animation-duration: 700ms;
}

.duration-1000 {
  animation-duration: 1000ms;
}

/* ============================================
   SHIMMER EFFECT (для особого loading)
   ============================================ */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

[data-theme="dark"] .shimmer::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
}

/* ============================================
   PREFERS REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .skeleton {
    animation: none;
    background: var(--color-gray-200);
  }
}
/* === core/layouts.css === */
/**
 * layouts.css
 * Готовые layout шаблоны для быстрой разработки
 */

/* ============================================
   CONTAINER
   ============================================ */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

@media (min-width: 640px) {
  .container { max-width: 640px; }
}

@media (min-width: 768px) {
  .container { max-width: 768px; }
}

@media (min-width: 1024px) {
  .container { max-width: 1024px; }
}

@media (min-width: 1280px) {
  .container { max-width: 1280px; }
}

/* ============================================
   SIDEBAR LAYOUT
   ============================================ */
.layout-sidebar {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: var(--space-lg);
  min-height: 100vh;
}

.layout-sidebar-left {
  grid-column: 1;
  background: var(--bg-secondary);
  padding: var(--space-lg);
}

.layout-sidebar-main {
  grid-column: 2;
  padding: var(--space-lg);
}

@media (max-width: 768px) {
  .layout-sidebar {
    grid-template-columns: 1fr;
  }
  
  .layout-sidebar-left {
    grid-column: 1;
  }
  
  .layout-sidebar-main {
    grid-column: 1;
  }
}

/* ============================================
   TWO COLUMN LAYOUT
   ============================================ */
.layout-two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

@media (max-width: 768px) {
  .layout-two-col {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   THREE COLUMN LAYOUT
   ============================================ */
.layout-three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

@media (max-width: 1024px) {
  .layout-three-col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .layout-three-col {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   HOLY GRAIL LAYOUT
   ============================================ */
.layout-holy-grail {
  display: grid;
  grid-template-areas:
    "header header header"
    "nav main aside"
    "footer footer footer";
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  gap: var(--space-md);
}

.layout-holy-grail-header {
  grid-area: header;
  background: var(--bg-secondary);
  padding: var(--space-md);
}

.layout-holy-grail-nav {
  grid-area: nav;
  background: var(--bg-secondary);
  padding: var(--space-md);
}

.layout-holy-grail-main {
  grid-area: main;
  padding: var(--space-lg);
}

.layout-holy-grail-aside {
  grid-area: aside;
  background: var(--bg-secondary);
  padding: var(--space-md);
}

.layout-holy-grail-footer {
  grid-area: footer;
  background: var(--bg-secondary);
  padding: var(--space-md);
}

@media (max-width: 768px) {
  .layout-holy-grail {
    grid-template-areas:
      "header"
      "nav"
      "main"
      "aside"
      "footer";
    grid-template-columns: 1fr;
  }
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.layout-dashboard {
  display: grid;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  grid-template-columns: 250px 1fr;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

.layout-dashboard-sidebar {
  grid-area: sidebar;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  padding: var(--space-lg);
  overflow-y: auto;
}

.layout-dashboard-header {
  grid-area: header;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layout-dashboard-main {
  grid-area: main;
  padding: var(--space-lg);
  overflow-y: auto;
  background: var(--bg-secondary);
}

@media (max-width: 768px) {
  .layout-dashboard {
    grid-template-areas:
      "header"
      "main";
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }
  
  .layout-dashboard-sidebar {
    display: none;
  }
}

/* ============================================
   CARD GRID LAYOUT
   ============================================ */
.layout-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.layout-card-grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.layout-card-grid-lg {
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

/* ============================================
   SPLIT LAYOUT (50/50)
   ============================================ */
.layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 100vh;
}

.layout-split-left,
.layout-split-right {
  padding: var(--space-2xl);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.layout-split-left {
  background: var(--bg-secondary);
}

@media (max-width: 768px) {
  .layout-split {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   CENTERED LAYOUT
   ============================================ */
.layout-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-lg);
}

.layout-centered-content {
  width: 100%;
  max-width: 500px;
}

/* ============================================
   STICKY HEADER LAYOUT
   ============================================ */
.layout-sticky-header {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout-sticky-header-top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
}

.layout-sticky-header-main {
  flex: 1;
  padding: var(--space-lg);
}

/* ============================================
   FLEX CENTER (универсальный)
   ============================================ */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ============================================
   MASONRY LAYOUT
   ============================================ */
.layout-masonry {
  column-count: 3;
  column-gap: var(--space-lg);
}

.layout-masonry-item {
  break-inside: avoid;
  margin-bottom: var(--space-lg);
}

@media (max-width: 1024px) {
  .layout-masonry {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  .layout-masonry {
    column-count: 1;
  }
}

/* ============================================
   ASPECT RATIO BOXES
   ============================================ */
.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-4-3 {
  aspect-ratio: 4 / 3;
}

/* ============================================
   SECTION
   ============================================ */
.section {
  padding: var(--space-2xl) 0;
}

.section-sm {
  padding: var(--space-xl) 0;
}

.section-lg {
  padding: calc(var(--space-2xl) * 2) 0;
}
/* === core/buttons.css === */
/**
 * buttons.css
 * Все стили кнопок проекта
 */

/* ============================================
   BASE BUTTON
   ============================================ */
.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  outline: none;
  line-height: 1.5;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   BUTTON VARIANTS
   ============================================ */
.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--color-gray-600);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-gray-700);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-info {
  background: var(--info);
  color: white;
}

.btn-info:hover:not(:disabled) {
  background: var(--color-blue-700);
}

/* ============================================
   BUTTON STYLES
   ============================================ */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--color-gray-600);
  color: var(--color-gray-600);
}

.btn-outline-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

/* ============================================
   BUTTON SIZES
   ============================================ */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg-hover);
  transform: scale(1.1);
  color: var(--text-primary);
}

.btn-icon i {
  font-size: 14px;
}

/* ============================================
   GHOST BUTTONS
   ============================================ */
.btn-primary-ghost {
  color: var(--primary);
  background: transparent;
  border: none;
}

.btn-primary-ghost:hover {
  background: var(--primary-light);
}

.btn-success-ghost {
  color: var(--success);
  background: transparent;
  border: none;
}

.btn-success-ghost:hover {
  background: var(--success-light);
}

.btn-warning-ghost {
  color: var(--warning);
  background: transparent;
  border: none;
}

.btn-warning-ghost:hover {
  background: var(--warning-light);
}

.btn-danger-ghost {
  color: var(--danger);
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.btn-danger-ghost:hover {
  background: var(--danger-light);
}

/* ============================================
   SPECIAL BUTTONS
   ============================================ */
.btn-back {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.btn-back:hover {
  background: var(--bg-hover);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-logout:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-logout svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   LINK BUTTON
   ============================================ */
.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.btn-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ============================================
   TEXT BUTTON
   ============================================ */
.btn-text {
  padding: 4px 8px;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  transition: var(--transition-base);
}

.btn-text:hover {
  color: var(--primary-hover);
}

/* ============================================
   CLOSE BUTTONS
   ============================================ */
.btn-close,
.modal-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.btn-close:hover,
.modal-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   NAVIGATION BUTTONS
   ============================================ */
.btn-nav {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.btn-nav:hover {
  background: var(--bg-hover);
}

.btn-nav:active {
  background: var(--bg-active);
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.btn-action {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.btn-action:hover {
  background: var(--bg-hover);
}

.btn-add-role,
.btn-permissions {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-base);
}

.btn-add-role:hover,
.btn-permissions:hover {
  background: var(--primary-hover);
}

.btn-add-role:disabled,
.btn-permissions:disabled {
  background: var(--bg-disabled);
  cursor: not-allowed;
}

/* ============================================
   BUTTON LABEL (hidden on mobile)
   ============================================ */
.btn-label {
  display: inline;
}

/* ============================================
   MOBILE BUTTON ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 12px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .btn {
    font-size: 13px;
    padding: 8px 12px;
  }

  .btn-lg {
    padding: 10px 18px;
    font-size: 14px;
  }
}
/* === core/forms.css === */
/**
 * forms.css
 * Стили форм, инпутов, селектов, чекбоксов
 */

/* ============================================
   FORM GROUPS
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.form-label.required::after {
  content: ' *';
  color: var(--error);
}

.required {
  color: var(--error);
}

/* Catch-all: инпуты без класса .form-input внутри .form-group */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="search"],
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* ============================================
   INPUTS
   ============================================ */
.form-input,
.form-control,
.form-textarea,
.form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  outline: none;
}

.form-control {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus,
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error);
}

.form-input.error:focus,
.form-textarea.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 3px var(--error-light);
}

.form-control:disabled {
  background: var(--bg-disabled);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* ============================================
   TEXTAREA
   ============================================ */
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* ============================================
   SELECT
   ============================================ */
.form-select,
.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 180px;
  min-height: 40px;
}

@media (max-width: 768px) {
  .form-select,
  .filter-select {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
}

.form-select:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-select:focus:not(:focus-visible),
.filter-select:focus:not(:focus-visible) {
  border-color: var(--border);
  box-shadow: none;
}

.limit-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.limit-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   HINTS & ERRORS
   ============================================ */
.form-hint,
.form-text,
small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.error-message {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--error);
}

/* ============================================
   CHECKBOX
   ============================================ */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
}

/* ============================================
   RADIO
   ============================================ */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-base);
}

.radio-option:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.radio-option input[type="radio"] {
  margin-top: 4px;
  cursor: pointer;
}

.radio-option input[type="radio"]:checked + .radio-content {
  color: var(--primary);
}

.radio-option:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.radio-content {
  flex: 1;
}

.radio-content strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.radio-content small {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
  color: var(--text-primary);
}

.radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.radio-label:hover {
  color: var(--primary);
}

/* ============================================
   RADIO GROUP VERTICAL
   ============================================ */
.radio-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   SEARCH INPUT
   ============================================ */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 8px 40px 8px 40px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   INLINE EDIT
   ============================================ */
.inline-edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.inline-edit-input:focus {
  outline: none;
  border-color: var(--primary-hover);
}

.inline-edit-input.loading {
  background: var(--bg-disabled);
  cursor: wait;
}

.inline-edit-input.error {
  border-color: var(--error);
  background: var(--error-light);
}

/* ============================================
   FORM ROWS
   ============================================ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   FORM ACTIONS
   ============================================ */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

/* ============================================
   HANDBOOK SELECT (Custom Dropdown)
   ============================================ */
.handbook-select {
  position: relative;
  width: 100%;
}

.select-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  min-height: 38px;
}

.select-input:hover {
  border-color: var(--primary);
}

.handbook-select[data-open="true"] .select-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.select-value {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-arrow {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
}

.handbook-select[data-open="true"] .select-arrow {
  transform: rotate(180deg);
}

.select-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.select-clear:hover {
  background: var(--bg-hover);
  color: var(--error);
}

/* ============================================
   DROPDOWN
   ============================================ */
.select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
}

/* ============================================
   SEARCH INPUT IN DROPDOWN
   ============================================ */
.select-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  outline: none;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.select-search:focus {
  border-bottom-color: var(--primary);
}

/* ============================================
   OPTIONS CONTAINER - 🔥 КРИТИЧНО ДЛЯ ПРОКРУТКИ
   ============================================ */
.select-options {
  max-height: 300px;  /* 🔥 ГЛАВНОЕ! */
  overflow-y: auto;   /* 🔥 ГЛАВНОЕ! */
  overflow-x: hidden;
}

.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  transition: var(--transition-base);
}

.select-option:hover {
  background: var(--bg-hover);
}

.option-value {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
}

.option-code {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 8px;
}

.select-no-results {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   FOOTER (Add New Button)
   ============================================ */
.select-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
}

.btn-add-new {
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-add-new:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ============================================
   ADD FORM
   ============================================ */
.select-add-form {
  display: flex;
  gap: 8px;
}

.select-add-form .add-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.select-add-form .btn-save,
.select-add-form .btn-cancel {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-base);
}

.select-add-form .btn-save {
  background: var(--primary);
  color: white;
}

.select-add-form .btn-save:hover {
  background: var(--primary-hover);
}

.select-add-form .btn-cancel {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.select-add-form .btn-cancel:hover {
  background: var(--bg-hover);
}

/* ============================================
   HANDBOOK SELECT SIMPLE
   ============================================ */
.handbook-select-simple {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.handbook-select-simple:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.select-options::-webkit-scrollbar {
  width: 8px;
}

.select-options::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.select-options::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}

.select-options::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
/* === core/tables.css === */
/**
 * tables.css
 * Стили таблиц и связанных элементов
 */

/* ============================================
   BASE TABLE
   ============================================ */
.table-container {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overflow-y: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.table tbody td {
  overflow: hidden;
  vertical-align: top;
  line-height: 1.4;
}

/* === Cell content wrapper === */
.table tbody td .cell-content {
  max-height: 4.2em;
  overflow-y: auto;
  line-height: 1.4;
  word-break: break-word;
  scrollbar-width: thin;
}

.table tbody td .cell-content::-webkit-scrollbar {
  width: 4px;
}

.table tbody td .cell-content::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: 2px;
}

.table tbody td .cell-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-400);
}

/* === Mobile: скролл внутри ячейки === */
@media (max-width: 768px) {
  .table tbody td .cell-content {
    max-height: 2.8em;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .table tbody td .cell-content.text-only {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    -webkit-box-orient: unset;
  }

  .table tbody td .cell-content.expanded {
    max-height: 120px;
  }
}

.table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table thead th {
  background: var(--bg-secondary);
}

.table tbody tr {
  transition: var(--transition-base);
  color: var(--text-primary);
  background: var(--bg-primary);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table tr.selected {
  background: var(--primary-light);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   TABLE ACTIONS
   ============================================ */
.table-actions {
  display: flex;
  gap: 8px;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell .btn-icon {
  margin-right: 4px;
}

/* ============================================
   TABLE STATES
   ============================================ */
.table-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.table tr.selected {
  background: var(--primary-light) !important;
}

.editable-cell {
  cursor: text;
  position: relative;
}

.editable-cell:hover {
  background: var(--bg-hover);
}

/* ============================================
   TABLE WITH CHECKBOXES
   ============================================ */
.table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ============================================
   SORTABLE COLUMNS
   ============================================ */
.table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.table th.sortable:hover {
  background: var(--bg-hover);
}

.sort-indicator {
  font-size: 12px;
  color: var(--primary);
  margin-left: 4px;
}

/* ============================================
   ROW STATES (для импорта)
   ============================================ */
.row-ok {
  background: var(--success-light);
}

.row-warning {
  background: var(--warning-light);
}

.row-error {
  background: var(--error-light);
}

.row-ok:hover,
.row-warning:hover,
.row-error:hover {
  filter: brightness(0.98);
}

.cell-row-number {
  background: var(--bg-secondary);
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
}

/* ============================================
   SPECIFIC TABLES
   ============================================ */

/* Preview Table (Import) */
.preview-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.preview-table thead {
  background: var(--bg-secondary);
}

.preview-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.preview-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.preview-table tbody tr:last-child td {
  border-bottom: none;
}

.preview-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Mapping Table */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.mapping-table thead {
  background: var(--bg-secondary);
}

.mapping-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
}

.mapping-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.mapping-table tbody tr:last-child td {
  border-bottom: none;
}

/* Errors Table */
.errors-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 14px;
}

.errors-table thead {
  background: var(--bg-secondary);
}

.errors-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
}

.errors-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--error);
}

.errors-table tbody tr:last-child td {
  border-bottom: none;
}

/* Values Table (Batch Select Dialog) */
.values-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.values-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.values-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
}

.values-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-primary);
}

.values-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Permissions Table */
.permissions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.permissions-table thead {
  background: var(--bg-secondary);
}

.permissions-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

.permissions-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-primary);
}

.permissions-table tbody tr:hover {
  background: var(--bg-hover);
}

.permissions-table .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.permissions-table .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.permissions-table .check-icon {
  color: var(--success);
  font-size: 18px;
  font-weight: bold;
}

.permissions-table .cross-icon {
  color: var(--text-disabled);
  font-size: 18px;
}

/* Table Field Editor */
.table-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

.table-field-table th {
  background: var(--bg-secondary);
  padding: 10px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  color: var(--text-primary);
}

.table-field-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-primary);
}

.table-field-row:hover {
  background: var(--bg-hover);
}

/* ===== Pinned (Frozen) Columns ===== */
.table-container {
  overflow-x: auto;
  position: relative;
}

.table-container.has-pinned-columns {
  overflow-x: auto;
}

.table-container.has-pinned-columns table {
  border-collapse: separate;
  border-spacing: 0;
}

.pinned-column {
  position: sticky !important;
  background: var(--bg-primary, #fff);
  z-index: 1;
  min-width: 60px;
}

thead .pinned-column {
  z-index: 3 !important;
  background: var(--bg-secondary, #f8f9fa);
}

.pinned-column-last {
  border-right: 2px solid var(--border) !important;
  box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
  clip-path: inset(0 -8px 0 0);
}

tr:hover .pinned-column {
  background: var(--bg-hover, #f5f5f5);
}

tr.selected .pinned-column {
  background: var(--primary-light, #e8f0fe);
}

/* Тень только при скролле */
.table-container.has-pinned-columns {
  scroll-behavior: smooth;
}

/* ============================================
   MOBILE TABLE ADAPTATION
   ============================================ */
/* ============================================
   MOBILE TABLE ADAPTATION
   ============================================ */
@media (max-width: 768px) {
  .table-container {
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .table th,
  .table td {
    padding: 8px 10px;
    font-size: 13px;
    max-height: 2.8em;
    line-height: 1.4;
  }

  .table th {
    font-size: 11px;
    padding: 6px 8px;
    letter-spacing: 0.3px;
  }

  .table tbody td {
    max-height: 2.8em;
  }

  .table input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
  }

  .table-actions .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .table th,
  .table td {
    padding: 6px 8px;
    font-size: 12px;
  }
}
/* === core/utilities-extended.css === */
/**
 * utilities.css  
 * Utility классы (расширенная версия с полным набором)
 * Стиль Tailwind CSS для быстрой разработки
 */

/* ============================================
   DISPLAY
   ============================================ */
.d-none { display: none !important; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }
.d-inline-grid { display: inline-grid; }

/* ============================================
   FLEX DIRECTION
   ============================================ */
.flex-row { flex-direction: row; }
.flex-row-reverse { flex-direction: row-reverse; }
.flex-column { flex-direction: column; }
.flex-col { flex-direction: column; }
.flex-column-reverse { flex-direction: column-reverse; }

/* ============================================
   FLEX WRAP
   ============================================ */
.flex-wrap { flex-wrap: wrap; }
.flex-wrap-reverse { flex-wrap: wrap-reverse; }
.flex-nowrap { flex-wrap: nowrap; }

/* ============================================
   FLEX
   ============================================ */
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

/* ============================================
   FLEX GROW & SHRINK
   ============================================ */
.flex-grow { flex-grow: 1; }
.flex-grow-0 { flex-grow: 0; }
.flex-shrink { flex-shrink: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ============================================
   JUSTIFY CONTENT
   ============================================ */
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* ============================================
   ALIGN ITEMS
   ============================================ */
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

/* Aliases */
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }
.align-center { align-items: center; }
.align-baseline { align-items: baseline; }
.align-stretch { align-items: stretch; }

/* ============================================
   ALIGN CONTENT
   ============================================ */
.content-start { align-content: flex-start; }
.content-end { align-content: flex-end; }
.content-center { align-content: center; }
.content-between { align-content: space-between; }
.content-around { align-content: space-around; }
.content-evenly { align-content: space-evenly; }

/* ============================================
   ALIGN SELF
   ============================================ */
.self-auto { align-self: auto; }
.self-start { align-self: flex-start; }
.self-end { align-self: flex-end; }
.self-center { align-self: center; }
.self-stretch { align-self: stretch; }

/* ============================================
   GAP
   ============================================ */
.gap-0 { gap: 0; }
.gap-1 { gap: var(--spacing-1); }
.gap-2 { gap: var(--spacing-2); }
.gap-3 { gap: var(--spacing-3); }
.gap-4 { gap: var(--spacing-4); }
.gap-5 { gap: var(--spacing-5); }
.gap-6 { gap: var(--spacing-6); }
.gap-8 { gap: var(--spacing-8); }
.gap-10 { gap: var(--spacing-10); }
.gap-12 { gap: var(--spacing-12); }

/* ============================================
   MARGIN
   ============================================ */
.m-0 { margin: 0; }
.m-1 { margin: var(--spacing-1); }
.m-2 { margin: var(--spacing-2); }
.m-3 { margin: var(--spacing-3); }
.m-4 { margin: var(--spacing-4); }
.m-5 { margin: var(--spacing-5); }
.m-6 { margin: var(--spacing-6); }
.m-8 { margin: var(--spacing-8); }
.m-10 { margin: var(--spacing-10); }
.m-12 { margin: var(--spacing-12); }
.m-auto { margin: auto; }

/* Margin Top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-1); }
.mt-2 { margin-top: var(--spacing-2); }
.mt-3 { margin-top: var(--spacing-3); }
.mt-4 { margin-top: var(--spacing-4); }
.mt-5 { margin-top: var(--spacing-5); }
.mt-6 { margin-top: var(--spacing-6); }
.mt-8 { margin-top: var(--spacing-8); }
.mt-10 { margin-top: var(--spacing-10); }
.mt-12 { margin-top: var(--spacing-12); }
.mt-auto { margin-top: auto; }

/* Margin Right */
.mr-0 { margin-right: 0; }
.mr-1 { margin-right: var(--spacing-1); }
.mr-2 { margin-right: var(--spacing-2); }
.mr-3 { margin-right: var(--spacing-3); }
.mr-4 { margin-right: var(--spacing-4); }
.mr-5 { margin-right: var(--spacing-5); }
.mr-6 { margin-right: var(--spacing-6); }
.mr-8 { margin-right: var(--spacing-8); }
.mr-auto { margin-right: auto; }

/* Margin Bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-1); }
.mb-2 { margin-bottom: var(--spacing-2); }
.mb-3 { margin-bottom: var(--spacing-3); }
.mb-4 { margin-bottom: var(--spacing-4); }
.mb-5 { margin-bottom: var(--spacing-5); }
.mb-6 { margin-bottom: var(--spacing-6); }
.mb-8 { margin-bottom: var(--spacing-8); }
.mb-10 { margin-bottom: var(--spacing-10); }
.mb-12 { margin-bottom: var(--spacing-12); }
.mb-auto { margin-bottom: auto; }

/* Margin Left */
.ml-0 { margin-left: 0; }
.ml-1 { margin-left: var(--spacing-1); }
.ml-2 { margin-left: var(--spacing-2); }
.ml-3 { margin-left: var(--spacing-3); }
.ml-4 { margin-left: var(--spacing-4); }
.ml-5 { margin-left: var(--spacing-5); }
.ml-6 { margin-left: var(--spacing-6); }
.ml-8 { margin-left: var(--spacing-8); }
.ml-auto { margin-left: auto; }

/* Margin X (horizontal) */
.mx-0 { margin-left: 0; margin-right: 0; }
.mx-1 { margin-left: var(--spacing-1); margin-right: var(--spacing-1); }
.mx-2 { margin-left: var(--spacing-2); margin-right: var(--spacing-2); }
.mx-3 { margin-left: var(--spacing-3); margin-right: var(--spacing-3); }
.mx-4 { margin-left: var(--spacing-4); margin-right: var(--spacing-4); }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Margin Y (vertical) */
.my-0 { margin-top: 0; margin-bottom: 0; }
.my-1 { margin-top: var(--spacing-1); margin-bottom: var(--spacing-1); }
.my-2 { margin-top: var(--spacing-2); margin-bottom: var(--spacing-2); }
.my-3 { margin-top: var(--spacing-3); margin-bottom: var(--spacing-3); }
.my-4 { margin-top: var(--spacing-4); margin-bottom: var(--spacing-4); }
.my-auto { margin-top: auto; margin-bottom: auto; }

/* ============================================
   PADDING
   ============================================ */
.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-1); }
.p-2 { padding: var(--spacing-2); }
.p-3 { padding: var(--spacing-3); }
.p-4 { padding: var(--spacing-4); }
.p-5 { padding: var(--spacing-5); }
.p-6 { padding: var(--spacing-6); }
.p-8 { padding: var(--spacing-8); }
.p-10 { padding: var(--spacing-10); }
.p-12 { padding: var(--spacing-12); }

/* Padding Top */
.pt-0 { padding-top: 0; }
.pt-1 { padding-top: var(--spacing-1); }
.pt-2 { padding-top: var(--spacing-2); }
.pt-3 { padding-top: var(--spacing-3); }
.pt-4 { padding-top: var(--spacing-4); }
.pt-5 { padding-top: var(--spacing-5); }
.pt-6 { padding-top: var(--spacing-6); }
.pt-8 { padding-top: var(--spacing-8); }
.pt-10 { padding-top: var(--spacing-10); }

/* Padding Right */
.pr-0 { padding-right: 0; }
.pr-1 { padding-right: var(--spacing-1); }
.pr-2 { padding-right: var(--spacing-2); }
.pr-3 { padding-right: var(--spacing-3); }
.pr-4 { padding-right: var(--spacing-4); }
.pr-5 { padding-right: var(--spacing-5); }
.pr-6 { padding-right: var(--spacing-6); }
.pr-8 { padding-right: var(--spacing-8); }

/* Padding Bottom */
.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: var(--spacing-1); }
.pb-2 { padding-bottom: var(--spacing-2); }
.pb-3 { padding-bottom: var(--spacing-3); }
.pb-4 { padding-bottom: var(--spacing-4); }
.pb-5 { padding-bottom: var(--spacing-5); }
.pb-6 { padding-bottom: var(--spacing-6); }
.pb-8 { padding-bottom: var(--spacing-8); }
.pb-10 { padding-bottom: var(--spacing-10); }

/* Padding Left */
.pl-0 { padding-left: 0; }
.pl-1 { padding-left: var(--spacing-1); }
.pl-2 { padding-left: var(--spacing-2); }
.pl-3 { padding-left: var(--spacing-3); }
.pl-4 { padding-left: var(--spacing-4); }
.pl-5 { padding-left: var(--spacing-5); }
.pl-6 { padding-left: var(--spacing-6); }
.pl-8 { padding-left: var(--spacing-8); }

/* Padding X */
.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: var(--spacing-1); padding-right: var(--spacing-1); }
.px-2 { padding-left: var(--spacing-2); padding-right: var(--spacing-2); }
.px-3 { padding-left: var(--spacing-3); padding-right: var(--spacing-3); }
.px-4 { padding-left: var(--spacing-4); padding-right: var(--spacing-4); }
.px-5 { padding-left: var(--spacing-5); padding-right: var(--spacing-5); }
.px-6 { padding-left: var(--spacing-6); padding-right: var(--spacing-6); }

/* Padding Y */
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: var(--spacing-1); padding-bottom: var(--spacing-1); }
.py-2 { padding-top: var(--spacing-2); padding-bottom: var(--spacing-2); }
.py-3 { padding-top: var(--spacing-3); padding-bottom: var(--spacing-3); }
.py-4 { padding-top: var(--spacing-4); padding-bottom: var(--spacing-4); }
.py-5 { padding-top: var(--spacing-5); padding-bottom: var(--spacing-5); }
.py-6 { padding-top: var(--spacing-6); padding-bottom: var(--spacing-6); }

/* ============================================
   WIDTH
   ============================================ */
.w-auto { width: auto; }
.w-full { width: 100%; }
.w-screen { width: 100vw; }
.w-min { width: min-content; }
.w-max { width: max-content; }
.w-fit { width: fit-content; }

.w-1\/2 { width: 50%; }
.w-1\/3 { width: 33.333333%; }
.w-2\/3 { width: 66.666667%; }
.w-1\/4 { width: 25%; }
.w-2\/4 { width: 50%; }
.w-3\/4 { width: 75%; }

/* ============================================
   HEIGHT
   ============================================ */
.h-auto { height: auto; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-min { height: min-content; }
.h-max { height: max-content; }
.h-fit { height: fit-content; }

/* ============================================
   TEXT ALIGNMENT
   ============================================ */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* ============================================
   FONT SIZE
   ============================================ */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

/* ============================================
   FONT WEIGHT
   ============================================ */
.font-thin { font-weight: var(--font-weight-thin); }
.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-extrabold { font-weight: var(--font-weight-extrabold); }

/* ============================================
   LINE HEIGHT
   ============================================ */
.leading-none { line-height: var(--line-height-none); }
.leading-tight { line-height: var(--line-height-tight); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-relaxed { line-height: var(--line-height-relaxed); }
.leading-loose { line-height: var(--line-height-loose); }

/* ============================================
   TEXT COLOR
   ============================================ */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-disabled { color: var(--text-disabled); }
.text-inverse { color: var(--text-inverse); }
.text-white { color: var(--color-white); }

.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }

/* ============================================
   TEXT TRANSFORM
   ============================================ */
.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }
.normal-case { text-transform: none; }

/* ============================================
   TEXT DECORATION
   ============================================ */
.underline { text-decoration: underline; }
.line-through { text-decoration: line-through; }
.no-underline { text-decoration: none; }

/* ============================================
   WHITE SPACE
   ============================================ */
.whitespace-normal { white-space: normal; }
.whitespace-nowrap { white-space: nowrap; }
.whitespace-pre { white-space: pre; }
.whitespace-pre-line { white-space: pre-line; }
.whitespace-pre-wrap { white-space: pre-wrap; }

/* ============================================
   TEXT OVERFLOW
   ============================================ */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-ellipsis { text-overflow: ellipsis; }
.text-clip { text-overflow: clip; }

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   BORDER RADIUS
   ============================================ */
.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius-md); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* ============================================
   OVERFLOW
   ============================================ */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-visible { overflow: visible; }
.overflow-scroll { overflow: scroll; }

.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }
.overflow-x-visible { overflow-x: visible; }
.overflow-y-visible { overflow-y: visible; }
.overflow-x-scroll { overflow-x: scroll; }
.overflow-y-scroll { overflow-y: scroll; }

/* ============================================
   POSITION
   ============================================ */
.static { position: static; }
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.sticky { position: sticky; }

/* ============================================
   TOP / RIGHT / BOTTOM / LEFT
   ============================================ */
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.inset-auto { top: auto; right: auto; bottom: auto; left: auto; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.top-auto { top: auto; }
.right-auto { right: auto; }
.bottom-auto { bottom: auto; }
.left-auto { left: auto; }

/* ============================================
   OPACITY
   ============================================ */
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ============================================
   CURSOR
   ============================================ */
.cursor-auto { cursor: auto; }
.cursor-default { cursor: default; }
.cursor-pointer { cursor: pointer; }
.cursor-wait { cursor: wait; }
.cursor-text { cursor: text; }
.cursor-move { cursor: move; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }

/* ============================================
   USER SELECT
   ============================================ */
.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }
.select-auto { user-select: auto; }

/* ============================================
   POINTER EVENTS
   ============================================ */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* ============================================
   VISIBILITY
   ============================================ */
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* ============================================
   SHADOW
   ============================================ */
.shadow-none { box-shadow: none; }
.shadow-xs { box-shadow: var(--shadow-xs); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }

/* ============================================
   BADGES (из старого utilities.css)
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-error,
.badge-danger {
  background: var(--error-light);
  color: var(--error);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border);
  margin: 0 var(--space-md);
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media (max-width: 768px) {
  .mobile-hidden { display: none !important; }
  .mobile-only { display: block; }
}

@media (min-width: 769px) {
  .desktop-hidden { display: none !important; }
  .desktop-only { display: block; }
  .mobile-only { display: none; }
}

/* ============================================
   PRINT UTILITIES
   ============================================ */
@media print {
  .print-hidden { display: none !important; }
  .no-print { display: none !important; }
}

/* ============================================
   COMPONENTS (переиспользуемые компоненты)
   ============================================ */
/* === components/modal.css === */
/**
 * modal.css
 * Стили модальных окон и диалогов
 */

/* ============================================
   MODAL OVERLAY (ЕДИНСТВЕННЫЙ ИСТОЧНИК)
   ============================================ */
.modal-overlay,
.user-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none !important;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal-overlay.modal-show,
.modal-overlay.active,
.user-modal-overlay.modal-show,
.user-modal-overlay.active,
.user-modal-overlay.open,
.user-modal-overlay.show {
  display: flex !important;
  opacity: 1;
  pointer-events: all;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.modal-fullscreen {
  max-height: 95vh;
  overflow: hidden;
}

.modal-show .modal {
  transform: scale(1);
}

/* Modal sizes */
.modal-small {
  width: 400px;
  max-width: 90%;
}

.modal-medium {
  width: 600px;
  max-width: 90%;
}

.modal-large {
  width: 900px;
  max-width: 95%;
}

/* Fullscreen modal */
.modal-fullscreen {
  width: 98vw;
  max-width: 98vw;
  height: 95vh;
  max-height: 95vh;
  margin: 1vh auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
}

.modal-fullscreen .modal-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal-fullscreen .modal-footer {
  flex-shrink: 0;
}

/* ============================================
   MODAL DIALOG (альтернативная структура)
   ============================================ */
.modal-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   MODAL HEADER
   ============================================ */
.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn,
.modal-close,
.btn-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.modal-close-btn:hover,
.modal-close:hover,
.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   MODAL BODY
   ============================================ */
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body.modal-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================
   MODAL FOOTER
   ============================================ */
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.modal-buttons .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-base);
}

.modal-buttons .btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.modal-buttons .btn-primary {
  background: var(--success);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: var(--shadow-md);
}

.modal-buttons .btn-primary:hover {
  background: var(--success-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.modal-buttons .btn-primary:disabled {
  background: var(--bg-disabled);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ============================================
   СПЕЦИАЛЬНЫЕ ДИАЛОГИ
   ============================================ */

/* Unknown Select Value Dialog */
.unknown-select-dialog {
  border: none;
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 550px;
  width: 90%;
  box-shadow: var(--shadow-2xl);
}

.unknown-select-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* Batch Select Dialog */
.batch-select-dialog {
  border: none;
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  box-shadow: var(--shadow-2xl);
}

.batch-select-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.batch-select-dialog .dialog-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.batch-select-dialog .dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.batch-select-dialog .dialog-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-select-dialog .close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.batch-select-dialog .close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Tabs в диалогах */
.batch-select-dialog .dialog-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.batch-select-dialog .tab-btn {
  background: none;
  border: none;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition-base);
  position: relative;
  top: 2px;
}

.batch-select-dialog .tab-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.batch-select-dialog .tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.batch-select-dialog .dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}

.batch-select-dialog .tab-content {
  display: none;
}

.batch-select-dialog .tab-content.active {
  display: block;
}

.batch-select-dialog .dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

/* ============================================
   MODAL CONTAINER (кастомная версия)
   ============================================ */
.modal-overlay .modal-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
            .modal-large {
              width: 100vw;
              max-width: 100vw;
              max-height: 90vh;
              max-height: 90dvh;
              border-radius: var(--radius-xl) var(--radius-xl) 0 0;
              margin-top: auto;
            }
            
            .modal-medium,
            .modal-small {
              width: 100vw;
              max-width: 100vw;
              max-height: 85vh;
              max-height: 85dvh;
              border-radius: var(--radius-xl) var(--radius-xl) 0 0;
              margin-top: auto;
            }
            
            .modal-overlay.modal-show,
            .modal-overlay.active {
              align-items: flex-end;
            }
            
            .modal-header {
              flex-direction: column;
              gap: 12px;
            }
            
            .modal-body {
              overscroll-behavior: contain;
              -webkit-overflow-scrolling: touch;
  }
}
/* === components/toast.css === */
/**
 * toast.css
 * Стили уведомлений (toast notifications)
 */

/* ============================================
   TOAST CONTAINER
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================
   TOAST ICON
   ============================================ */
.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  border-radius: var(--radius-full);
}

/* ============================================
   TOAST VARIANTS
   ============================================ */
.toast-success {
  border-left: 4px solid var(--success);
}

.toast-success .toast-icon {
  background: var(--success);
  color: white;
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-error .toast-icon {
  background: var(--error);
  color: white;
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
  background: var(--warning);
  color: white;
}

.toast-info {
  border-left: 4px solid var(--info);
}

.toast-info .toast-icon {
  background: var(--info);
  color: white;
}

/* ============================================
   TOAST CONTENT
   ============================================ */
.toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* ============================================
   TOAST CLOSE
   ============================================ */
.toast-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   CALENDAR NOTIFICATION (специальный тип)
   ============================================ */
.calendar-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  max-width: 320px;
  z-index: 10001;
  animation: slideInUp 0.3s;
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.calendar-notification-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 8px;
}

.calendar-notification-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.calendar-notification-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.calendar-notification-close:hover {
  color: var(--text-primary);
}

.calendar-notification-body {
  font-size: 13px;
  color: var(--text-primary);
}

.calendar-notification-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .calendar-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}
/* === components/pagination.css === */
/**
 * pagination.css
 * Стили пагинации v2
 */

/* Стили пагинации теперь в handbook-items.css (секция PAGINATION v2) */
/* Этот файл оставлен пустым для обратной совместимости подключения */
/* === components/search.css === */
/**
 * search.css
 * Стили поиска и поисковых элементов
 */

/* ============================================
   SEARCH INPUT WRAPPER
   ============================================ */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
}

/* ============================================
   SEARCH ICON
   ============================================ */
.search-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

/* ============================================
   SEARCH INPUT
   ============================================ */
.search-input {
  width: 100%;
  padding: 8px 40px 8px 40px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  outline: none;
  height: 40px;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   SEARCH CLEAR
   ============================================ */
.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   USER SEARCH (для прав доступа)
   ============================================ */
.user-search {
  position: relative;
  width: 300px;
}

.user-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.user-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

.user-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.user-result:hover {
  background: var(--bg-hover);
}

.user-result .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.user-result .user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.user-result .user-info strong {
  font-size: 14px;
  color: var(--text-primary);
}

.user-result .user-info small {
  font-size: 12px;
  color: var(--text-secondary);
}

.user-result .btn-add-user {
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.user-result .btn-add-user:hover {
  background: var(--primary-hover);
}

.no-results {
  padding: 15px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   COMMENTS SEARCH
   ============================================ */
.comments-search {
  margin-bottom: 15px;
}

.comments-search-input {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.comments-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   FIELDS SEARCH (для панели полей)
   ============================================ */
.fields-search {
  margin-bottom: 12px;
}

.fields-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ============================================
   SEARCH SECTION (для диалогов)
   ============================================ */
.search-section input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.search-section input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .search-input-wrapper {
    max-width: 100%;
  }
  
  .search-input {
    font-size: 16px; /* prevents iOS zoom */
    min-height: 34px;
    height: 34px;
    padding: 4px 32px 4px 32px;
  }

  .search-icon {
    left: 8px;
    font-size: 14px;
  }

  .search-clear {
    width: 34px;
    height: 34px;
    right: 0;
  }
  
  .user-search {
    width: 100%;
  }
}
/* === components/tree-view.css === */
/**
 * tree-view.css
 * Стили древовидного представления (TreeView Component)
 */

/* ============================================
   TREE VIEW CONTAINER
   ============================================ */
.tree-view {
  padding: 1rem;
}

/* ============================================
   TREE NODE
   ============================================ */
.tree-node {
  margin: 0;
  position: relative;
}

.tree-node-content {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
  cursor: pointer;
}

.tree-node-content:hover {
  background-color: var(--bg-hover);
}

/* ============================================
   DRAG & DROP STATES
   ============================================ */
.tree-node.dragging {
  opacity: 0.5;
}

.tree-node.drop-target > .tree-node-content {
  background-color: var(--primary-light);
  border: 2px dashed var(--primary);
}

/* ============================================
   TREE TOGGLE
   ============================================ */
.tree-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tree-toggle.expanded {
  transform: rotate(0deg);
}

.tree-toggle:hover {
  background: var(--bg-hover);
}

/* ============================================
   TREE SPACER
   ============================================ */
.tree-spacer {
  display: inline-block;
  width: 20px;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

/* ============================================
   TREE CHECKBOX
   ============================================ */
.tree-checkbox {
  margin: 0;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================================
   TREE ICON
   ============================================ */
.tree-icon {
  font-size: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

/* ============================================
   TREE LABEL
   ============================================ */
.tree-label {
  flex: 1;
  font-weight: 500;
  flex-grow: 1;
  color: var(--text-primary);
}

/* ============================================
   TREE CODE
   ============================================ */
.tree-code {
  margin-left: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-family: monospace;
  font-size: 12px;
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

/* ============================================
   TREE CHILDREN
   ============================================ */
.tree-children {
  padding-left: 0;
  position: relative;
}

/* ============================================
   TREE LINES (иерархия)
   ============================================ */
.tree-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.tree-line::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 15px;
  height: 1px;
  background: var(--border);
}

/* Вертикальная линия для родительских элементов */
.tree-node:has(.tree-children) > .tree-node-content::after {
  content: '';
  position: absolute;
  left: calc(var(--level, 0) * 30px + 9px);
  top: 50%;
  bottom: -100%;
  width: 1px;
  background: var(--border);
}

/* ============================================
   TREE EMPTY STATE
   ============================================ */
.tree-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .tree-view {
    padding: 0.5rem;
  }
  
  .tree-node-content {
    padding: 6px 8px;
  }
  
  .tree-code {
    font-size: 11px;
  }
}
/* === components/context-menu.css === */
/**
 * context-menu.css
 * Стили контекстного меню
 */

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  min-width: 180px;
  padding: 0.25rem 0;
}

/* ============================================
   MENU ITEM
   ============================================ */
.menu-item {
  padding: 0.5rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-base);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.menu-item:hover {
  background-color: var(--bg-hover);
}

.menu-item:first-child {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.menu-item:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.menu-item-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.menu-item.danger,
.menu-item[style*="--error"] {
  color: var(--error);
}

.menu-item.danger:hover {
  background: var(--error-light);
}

.context-menu .menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* ============================================
   MOVE MENU (специальное меню перемещения виджетов)
   ============================================ */
.move-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  max-height: 500px;
  overflow-y: auto;
  z-index: 10000;
  padding: 8px 0;
  animation: moveMenuFadeIn 0.2s ease-out;
}

@keyframes moveMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.move-menu-title {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.move-menu-separator {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  margin: 8px 0 4px 0;
}

.move-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition-base);
}

.move-menu-item:hover:not(.current) {
  background: var(--primary-light);
}

.move-menu-item.current {
  background: var(--primary-light);
  cursor: default;
  opacity: 0.7;
}

.move-menu-item-nested {
  padding-left: 48px;
  font-size: 14px;
}

.move-menu-icon {
  font-size: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.move-menu-text {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
}

.move-menu-position {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

.move-menu-badge {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--primary);
}

.move-menu-group {
  margin: 4px 0;
}

.move-menu-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-hover);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.move-menu::-webkit-scrollbar {
  width: 8px;
}

.move-menu::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--radius-sm);
}

.move-menu::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
}

.move-menu::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   AUTOCOMPLETE DROPDOWN (как контекстное меню)
   ============================================ */
.autocomplete-dropdown {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 250px;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  cursor: pointer;
  transition: var(--transition-base);
  gap: 10px;
}

.autocomplete-option:hover {
  background: var(--bg-hover);
}

.autocomplete-option-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-600) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.autocomplete-option-icon {
  font-size: 24px;
  margin-right: 10px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.autocomplete-option-info {
  flex: 1;
  min-width: 0;
}

.autocomplete-option-name {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option-email,
.autocomplete-option-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-action {
  background-color: var(--bg-secondary);
  font-weight: 600;
  color: var(--primary);
}

.autocomplete-action:hover {
  background-color: var(--primary-light);
}

.autocomplete-divider {
  height: 1px;
  background-color: var(--border);
  margin: 4px 0;
}

.autocomplete-search-box {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.autocomplete-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.autocomplete-search-input:focus {
  border-color: var(--primary);
}

.autocomplete-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Scrollbar */
.autocomplete-dropdown::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--radius-xs);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   EMOJI PICKER (как контекстное меню)
   ============================================ */
.emoji-picker {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.emoji-picker-btn {
  padding: 8px;
  border: none;
  background: var(--bg-primary);
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
}

.emoji-picker-btn:hover {
  background: var(--bg-hover);
}
/* === components/drawer.css === */
/* Drawer styles */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 500px;
  max-width: 90vw;
  background: var(--bg-primary);
  box-shadow: var(--shadow-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.drawer-right {
  right: 0;
  transform: translateX(100%);
}

.drawer-right.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.drawer-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.drawer-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.drawer-close-btn:hover {
  background: var(--bg-hover);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.drawer-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.drawer-stats {
  padding: 1rem;
  background: var(--info-light);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* Equipment cards */
.equipment-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.equipment-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  transition: box-shadow 0.2s;
}

.equipment-card:hover {
  box-shadow: var(--shadow-md);
}

.equipment-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.equipment-card-header h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.equipment-card-field {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.equipment-card-field strong {
  color: var(--text-primary);
  margin-right: 0.5rem;
}

.equipment-card-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-success {
  background: var(--success-light);
  color: var(--success-hover);
}

.badge-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Tree expanded panel */
.expanded-panel {
  padding: 12px;
  margin: 8px 0;
  background: var(--bg-secondary);
          border: 1px solid var(--border);
          border-radius: var(--radius-md);
}

.panel-section {
  margin-bottom: 12px;
}

.panel-section h5 {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.field-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.field-label {
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 100px;
}

.field-value {
  color: var(--text-primary);
  word-break: break-word;
}

.panel-actions {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Tree links */
.tree-link {
  color: var(--primary);
  text-decoration: none;
}

.tree-link:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* Cascade hover popup */
.cascade-trigger {
  cursor: pointer;
  color: var(--primary);
          border-bottom: 1px dashed var(--primary);
  padding: 2px 0;
}

.cascade-trigger:hover {
  color: var(--primary-hover);
}

.cascade-inline {
  display: none;
  margin-top: 8px;
  background: var(--bg-primary);
          border: 1px solid var(--border);
          border-radius: var(--radius-md);
  padding: 6px;
  max-height: 250px;
  overflow: auto;
}

.cascade-inline.visible {
  display: block;
}

.cascade-popup.visible {
  display: block;
}

.cascade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cascade-table td {
  padding: 4px 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.cascade-table tr:nth-child(even) {
  background: var(--bg-secondary);
}

/* ============================================
   TREE VIEW
   ============================================ */
.tree-container {
  padding: 1rem 0;
}

.tree-node {
  margin: 4px 0;
}

.tree-node-header {
  padding: 8px 12px;
  background: var(--bg-secondary);
          border: 1px solid var(--border);
          border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.tree-node-header:hover {
  background: var(--bg-hover);
          border-color: var(--border-dark);
}

.tree-node-code {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-left: 8px;
}

.tree-node-children {
  margin-top: 4px;
}

.tree-node-badge {
  background: var(--bg-tertiary);
          color: var(--text-primary);
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.btn-expand {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============================================
   TREE EXPANDED PANEL
   ============================================ */
.expanded-panel {
  padding: 12px;
  margin: 8px 0;
  background: var(--bg-secondary);
          border: 1px solid var(--border);
          border-radius: var(--radius-md);
}

.panel-section {
  margin-bottom: 12px;
}

.panel-section h5 {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.field-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.field-label {
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 100px;
}

.field-value {
  color: var(--text-primary);
  word-break: break-word;
}

.panel-actions {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ============================================
   TREE LINKS
   ============================================ */
.tree-link {
  color: var(--primary);
  text-decoration: none;
}

.tree-link:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* ============================================
   CASCADE HOVER POPUP
   ============================================ */
.cascade-trigger {
  cursor: pointer;
  color: var(--primary);
          border-bottom: 1px dashed var(--primary);
  padding: 2px 0;
}

.cascade-trigger:hover {
  color: var(--primary-hover);
}

.cascade-popup {
  display: none;
  position: fixed;
  z-index: 10000;
  background: var(--bg-primary);
          border: 1px solid var(--border);
          border-radius: var(--radius-lg);
          box-shadow: var(--shadow-lg);
  padding: 8px;
  max-width: 400px;
  max-height: 300px;
  overflow: auto;
}

.cascade-popup.visible {
  display: block;
}

.cascade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cascade-table td {
  padding: 4px 8px;
  border: 1px solid var(--border);;
  white-space: nowrap;
}

.cascade-table tr:nth-child(even) {
  background: var(--bg-secondary);
}

/* ============================================
   DRAWER HEADER ACTIONS
   ============================================ */
.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-btn {
  padding: 8px 12px;
  background: var(--bg-secondary);
          border: 1px solid var(--border);
          border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.settings-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.05);
}

/* ============================================
   HIDDEN ITEMS NOTICE
   ============================================ */
.hidden-items-notice {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--warning-light);
          border-left: 3px solid var(--warning);
          border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--warning-hover);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tooltip-icon {
  cursor: help;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.tooltip-icon:hover {
  opacity: 1;
}

.no-access-message {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .drawer {
    width: 100vw;
    max-width: 100vw;
  }

  .drawer-header {
    padding: 12px 16px;
  }

  .drawer-header h3 {
    font-size: 1rem;
  }

  .drawer-content {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .drawer-close-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cascade-popup {
    max-width: calc(100vw - 24px);
    left: 12px !important;
    right: 12px !important;
  }

  .field-row {
    flex-direction: column;
    gap: 2px;
  }

  .field-label {
    min-width: 0;
  }
}
/* === components/notifications.css === */
/* Кнопка уведомлений */
.notifications-button {
  position: relative;
  font-size: 20px;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
}

.notifications-button:hover {
  background: var(--bg-hover);
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* Dropdown */
.notifications-dropdown {
  width: 400px;
  max-height: 600px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notifications-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.notifications-dropdown-header strong {
  font-size: 16px;
  font-weight: 600;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-text:hover {
  background: var(--primary-light);
}

.notifications-dropdown-body {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
}

.notifications-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.notification-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
}

.notification-item:hover {
  background: var(--bg-hover);
}

.notification-item.unread {
  background: var(--primary-light);
}

.notification-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.notification-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.notification-time {
  font-size: 12px;
  color: var(--text-muted);
}

.notification-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  top: 20px;
  right: 16px;
}

.notifications-dropdown-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-md);
}

.btn-link:hover {
  background: var(--primary-light);
}

/* Responsive */
@media (max-width: 768px) {
  .notifications-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 70vh;
    max-height: 70dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 10000;
  }

  .notifications-dropdown-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .notification-item {
    padding: 14px 16px;
  }

  .notifications-button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ============================================
   PANELS (основные панели приложения)
   ============================================ */
/* === panels/handbooks.css === */
/**
 * handbooks.css
 * Стили панели справочников (grid карточек)
 */

/* ============================================
   HANDBOOKS PANEL
   ============================================ */
.handbooks-panel {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 16px 24px;
}

.handbooks-panel .panel-header {
  flex-shrink: 0;
}

.handbooks-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 2px;
  min-height: 0;
}

.handbooks-panel .panel-content::-webkit-scrollbar {
  width: 8px;
}

.handbooks-panel .panel-content::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: 4px;
}

.handbooks-panel .panel-content::-webkit-scrollbar-thumb {
  background: var(--color-gray-500);
  border-radius: 4px;
}

.handbooks-panel .panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-600);
}

/* ============================================
   PANEL HEADER
   ============================================ */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border);
}

.panel-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

/* ============================================
   PANEL TOOLBAR
   ============================================ */
.panel-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

/* ============================================
   PANEL CONTENT
   ============================================ */
.panel-content {
  min-height: 200px;
}

/* ============================================
   HANDBOOKS GRID
   ============================================ */
.handbooks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
  padding: 4px 4px 16px 4px;
}

/* ============================================
   HANDBOOK CARD
   ============================================ */
.handbook-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.handbook-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.handbook-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}

.handbook-card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.handbook-type {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.handbook-card-body {
  margin-bottom: 15px;
}

.handbook-code {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-family: monospace;
}

.handbook-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.handbook-date {
  font-size: 12px;
  color: var(--text-muted);
}

.handbook-card-footer {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.handbook-card-footer .btn-open {
  flex: 1;
}

/* ============================================
   HANDBOOK CUSTOM FIELDS
   ============================================ */
.handbook-custom-fields {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.handbook-custom-field {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.handbook-custom-field strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================
   DELETED HANDBOOKS
   ============================================ */
.handbook-card-deleted {
  opacity: 0.6;
  background: var(--bg-secondary);
  border: 2px dashed var(--color-gray-500) !important;
}

.handbook-card-deleted .handbook-card-header h3 {
  text-decoration: line-through;
  color: var(--text-disabled);
}

/* ============================================
   ORGANIZATION USERS PANEL
   ============================================ */
.organization-users-panel {
  padding: 20px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .handbooks-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  .panel-header .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-header .header-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .handbooks-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 12px;
  }

  .handbook-card {
    padding: 14px;
  }

  .handbook-card-header h3 {
    font-size: 16px;
  }

  .handbook-card-footer {
    flex-wrap: wrap;
  }

  .handbook-card-footer .btn-open {
    flex: 1 1 100%;
  }

  .panel-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .handbooks-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .handbook-card {
    padding: 12px;
  }

  .handbook-card-header h3 {
    font-size: 15px;
  }

  .handbook-code,
  .handbook-desc {
    font-size: 12px;
  }

  .handbook-card-footer .btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  .panel-header .header-actions .btn span {
    display: none;
  }

  .panel-header h2 {
    font-size: 18px;
  }
}

.show-deleted-label {
  color: var(--text-secondary);
}

/* Метка приватного справочника */
.handbook-private {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-left: 0.5rem;
  box-shadow: var(--shadow-sm);
}

/* Анимация при наведении */
.handbook-card:hover .handbook-private {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.handbook-card-header h3 {
  flex: 1;
  min-width: 0;
}

.handbook-card-header h3 {
  margin: 0;
  word-break: break-word;
}

.handbook-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ============================================
   IMAGE UPLOAD
   ============================================ */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.image-upload-area:hover,
.image-upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.image-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.image-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.image-preview img {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.btn-remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-image:hover {
  background: var(--error-hover);
}

/* ============================================
   HANDBOOK CARD THUMBNAIL
   ============================================ */
.handbook-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.handbook-card-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.handbook-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 480px) {
  .handbook-card-thumb {
    width: 40px;
    height: 40px;
  }
}
/* === panels/handbook-items.css === */
/**
 * handbook-items.css
 * Стили панели элементов справочника
 */

 /* ============================================
   UNIFIED TOOLBAR — один ряд
   ============================================ */
.unified-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  min-height: 44px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* Назад */
.ut-back {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.ut-back:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

/* Название */
.ut-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  flex-shrink: 1;
  min-width: 0;
}

/* Поиск */
.ut-search {
  flex: 1;
  min-width: 120px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.ut-search .search-input-wrapper {
  flex: 1;
  min-width: 0;
}

/* Кнопка поиска (мобилка) — скрыта на десктопе */
.ut-search-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Шаблоны */
.ut-presets {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* View mode toggle (для TREE) */
.ut-view-toggle {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Общая icon кнопка */
.ut-icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition-base);
}

.ut-icon-btn:hover {
  background: var(--bg-hover);
}

.ut-icon-btn.active {
  background: #e3f2fd;
  border-color: #1976d2;
}

.ut-icon-btn.warning {
  background: #fff3e0;
  border-color: #ff9800;
}

/* Badge на кнопке */
.ut-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #1976d2;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.ut-badge.warning {
  background: #ff9800;
}

/* +Создать */
.ut-add {
  flex-shrink: 0;
}

.ut-add-btn {
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-base);
  white-space: nowrap;
}

.ut-add-btn:hover {
  background: var(--primary-hover);
}

/* ⋮ Меню */
.ut-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.ut-menu-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.ut-menu-btn:hover {
  background: var(--bg-hover);
}

/* Dropdown меню */
.ut-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 4px 0;
}

.ut-dropdown.open {
  display: block;
}

.ut-dropdown-section {
  padding: 8px 12px;
}

.ut-dropdown-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 16px 4px;
  letter-spacing: 0.5px;
}

.ut-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.ut-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.ut-dropdown-item:hover {
  background: var(--bg-hover);
}

.ut-dropdown-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--error);
  color: white;
  margin-left: auto;
}

.ut-filter-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-primary);
}

/* ============================================
   MOBILE OVERRIDES
   ============================================ */
@media (max-width: 768px) {
  .unified-toolbar {
    gap: 2px;
    padding: 2px 0;
    min-height: 34px;
  }

  /* Название — короче */
  .ut-title {
    font-size: 14px;
    max-width: 120px;
  }

  /* Поиск — скрыт по умолчанию, раскрывается по кнопке */
  .ut-search {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-primary);
    padding: 4px;
    border-bottom: 1px solid var(--border);
    max-width: none;
  }

  .ut-search.expanded {
    display: block;
  }

  .ut-search-toggle {
    display: flex;
  }

  /* Кнопки меньше */
  .ut-back,
  .ut-icon-btn,
  .ut-menu-btn,
  .ut-search-toggle {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .ut-add-btn {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  /* Dropdown — bottom sheet */
  .ut-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
    padding-bottom: env(safe-area-inset-bottom, 0);
    max-height: 70vh;
  }

  .ut-dropdown-item {
    padding: 14px 20px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .ut-title {
    max-width: 80px;
    font-size: 13px;
  }
}

/* ============================================
   HANDBOOK ITEMS PANEL
   ============================================ */
.handbook-items-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  max-width: 100%;
  padding: 16px 24px;
  padding-bottom: 0;
}

@media (max-width: 768px) {
  .handbook-items-panel {
    padding: 0 4px 0;
    height: 100%;
  }
}

.handbook-items-panel .panel-header {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .handbook-items-panel .panel-header {
    margin: 0;
    padding: 2px 0;
  }
}

.handbook-items-panel .panel-toolbar {
  flex-shrink: 0;
}

.handbook-items-panel .panel-content {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.handbook-items-panel .panel-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.handbook-items-panel .panel-content::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--radius-sm);
}

.handbook-items-panel .panel-content::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
}

.handbook-items-panel .panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Контейнер таблицы */
.handbook-items-panel .table-container {
  width: 100%;
  overflow: visible;
}

.handbook-items-panel .table {
  width: 100%;
  table-layout: auto;
}

/* Pagination внизу */
.handbook-items-panel #pagination-container {
  flex-shrink: 0;
  background: var(--bg-primary);
  z-index: 5;
  border-top: 1px solid var(--border);
  padding: 0 8px;
}

@media (max-width: 768px) {
  .handbook-items-panel #pagination-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 2px 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  }

  .handbook-items-panel .panel-content {
    padding-bottom: 120px !important;
  }
}

/* ============================================
   PAGINATION v2 — compact single row
   ============================================ */
.pagination {
  display: flex;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 13px;
  white-space: nowrap;
}

.pg-info {
  color: var(--text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

.pg-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background 0.15s;
  flex-shrink: 0;
}

.pg-btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.pg-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pg-numbers {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pg-num {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background 0.15s;
}

.pg-num:hover {
  background: var(--bg-hover);
}

.pg-num.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  border-color: var(--primary);
}

.pg-ellipsis {
  color: var(--text-muted);
  padding: 0 2px;
  font-size: 12px;
}

.pg-input-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.pg-input {
  width: 36px;
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-align: center;
  background: var(--bg-primary);
  color: var(--text-primary);
  -moz-appearance: textfield;
}

.pg-input::-webkit-inner-spin-button,
.pg-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pg-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

.pg-total {
  color: var(--text-muted);
  font-size: 12px;
}

.pg-limit {
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 768px) {
  .pagination {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 3px 0;
    font-size: 12px;
  }

  .pg-numbers {
    display: none;
  }

  .pg-btn {
    min-width: 26px;
    height: 26px;
    font-size: 13px;
    padding: 0 4px;
  }

  .pg-input {
    height: 24px;
    font-size: 11px;
  }

  .pg-limit {
    height: 24px;
    font-size: 11px;
  }

  .pg-info {
    font-size: 11px;
  }

  .pg-total {
    font-size: 11px;
  }
}

/* ============================================
   BULK TOOLBAR
   ============================================ */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.bulk-count {
  font-weight: 500;
  color: var(--primary);
  margin-right: auto;
}

.bulk-toolbar .btn {
  margin: 0;
}

/* ============================================
   HANDBOOK ITEM DETAIL
   ============================================ */
.handbook-item-detail-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  gap: 20px;
}

.detail-header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.detail-header-right {
  display: flex;
  gap: 10px;
}

.detail-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

/* ============================================
   DETAIL BODY (flex wrapper: content + sidebar)
   ============================================ */
.detail-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.detail-body .detail-content {
  flex: 1;
  min-width: 0;
  transition: all 0.3s ease;
}

/* ============================================
   SETTINGS SIDEBAR
   ============================================ */
.settings-sidebar {
  width: 0;
  overflow: hidden;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  transition: width 0.3s ease;
  flex-shrink: 0;
}

.settings-sidebar.open {
  width: 300px;
}

.settings-sidebar-inner {
  width: 300px;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
}

.settings-sidebar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.settings-sidebar .widget-palette-item {
  padding: 14px;
  margin: 8px 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  border: 2px solid transparent;
}

.settings-sidebar .widget-palette-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateX(-4px);
}

.settings-sidebar .widget-palette-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-sidebar .widget-palette-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

@media (max-width: 768px) {
  .settings-sidebar.open {
    width: 260px;
  }
  .settings-sidebar-inner {
    width: 260px;
    padding: 12px;
  }
}

.detail-placeholder {
  background: var(--bg-primary);
  padding: 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.detail-placeholder h3 {
  margin-top: 0;
  color: var(--text-primary);
}

.detail-placeholder pre {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  color: var(--text-primary);
}

/* ============================================
   MULTIPLE VALUES DISPLAY
   ============================================ */
.multiple-values-display {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-height: 60px;
  overflow-y: auto;
  overflow-x: hidden;
}

.multiple-values-display::-webkit-scrollbar {
  width: 6px;
}

.multiple-values-display::-webkit-scrollbar-track {
  background: transparent;
}

.multiple-values-display::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}

.multiple-values-display:hover::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
}

.multiple-values-display:hover::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Firefox */
.multiple-values-display {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.multiple-values-display:hover {
  scrollbar-color: var(--color-gray-400) transparent;
}

.multiple-values-display.inline {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}

.multiple-value-item {
  padding: 2px 0;
  line-height: 1.4;
  color: var(--text-primary);
}

.multiple-value-item:not(:last-child) {
  margin-bottom: 4px;
}

.multiple-values-display .handbook-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.multiple-values-display .handbook-link:hover {
  text-decoration: underline;
}

/* ============================================
   ITEM LINK (в Markdown)
   ============================================ */
.item-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed var(--primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.item-link:hover {
  color: var(--primary-hover);
  border-bottom-style: solid;
  background-color: var(--primary-light);
}

/* ============================================
   SECTIONS (группировка элементов)
   ============================================ */
.handbook-items-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.handbook-items-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-primary);
}

.handbook-items-section-header {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.handbook-items-section-title {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.handbook-items-section-empty {
  padding: 20px;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.handbook-items-section-empty strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--text-primary);
}

.handbook-items-section-empty p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.handbook-items-stats {
  padding: 16px;
  background: var(--info-light);
  border: 1px solid var(--info);
  border-radius: var(--radius-lg);
  text-align: center;
  font-size: 15px;
  color: var(--info);
}

.handbook-items-stats strong {
  font-weight: 700;
}

.handbook-items-section .handbook-items-table {
  margin: 0;
  border: none;
}

.handbook-items-section .handbook-items-table thead th {
  background: var(--bg-primary);
  border-top: none;
}

/* ============================================
   BIDIRECTIONAL FIELDS
   ============================================ */
.bidirectional-fields-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.bidirectional-field-group {
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.bidirectional-field-group h4 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.bidirectional-field-group .form-group {
  margin-bottom: 12px;
}

.bidirectional-field-group .form-group:last-child {
  margin-bottom: 0;
}

.linked-handbook-name {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   HANDBOOK FIELD WRAPPER
   ============================================ */
.handbook-field-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.handbook-field-wrapper > .handbook-field-container {
  flex: 1;
  min-width: 0;
}

.handbook-field-wrapper > button {
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .handbook-items-panel {
    padding: 4px 6px;
  }

  /* Breadcrumb compact */
  .breadcrumb {
    font-size: 13px;
    gap: 4px;
  }

  .panel-header {
    margin: 0;
    padding: 0 0 2px 0;
    border-bottom: none;
  }

  .breadcrumb #back-btn {
    padding: 3px 6px;
    font-size: 12px;
  }

  /* Toolbar: stack vertically */
  .panel-toolbar {
    flex-direction: row;
    gap: 0;
    margin-bottom: 2px;
    margin-top: 0;
    padding-top: 0;
  } 

  /* Bidirectional fields */
  .bidirectional-fields-container {
    grid-template-columns: 1fr;
  }
  
  .detail-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .detail-header-right {
    justify-content: flex-end;
  }

  /* View mode toggle compact */
  .view-mode-toggle {
    display: flex;
    gap: 4px;
  }

  .view-mode-toggle .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Bulk toolbar */
  .bulk-toolbar {
    flex-wrap: wrap;
    padding: 10px;
    gap: 8px;
  }

  .bulk-count {
    width: 100%;
    text-align: center;
  }

  .bulk-toolbar .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .handbook-items-panel {
    padding: 6px;
  }

  .breadcrumb {
    font-size: 14px;
  }

  .detail-title {
    font-size: 18px;
  }

  /* Toolbar buttons: only icons */
  #toolbar-buttons .btn {
    padding: 8px;
    font-size: 14px;
  }
}

/* ===================================
   TABLE FIELD TOOLTIP (FieldsContainerWidget & HandbookItemsPanel)
   =================================== */

/* Tooltip контейнер */
.table-tooltip {
  display: none;
  position: fixed;
  z-index: 10000;
  max-width: 800px;
  max-height: 500px;
  overflow: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 10px;
}

/* Preview текст в ячейке */
.table-preview {
  max-height: 40px;
  overflow-y: auto;
  line-height: 1.5;
}

.table-preview-text {
  cursor: pointer;
  color: var(--primary-hover);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.table-preview-text:hover {
  text-decoration: underline;
}

.table-preview-text .info-icon {
  font-size: 0.85em;
  opacity: 0.7;
}

/* Старая таблица (HandbookItemsPanel) */
.tooltip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tooltip-table thead {
  background-color: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.tooltip-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.tooltip-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.tooltip-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.tooltip-table tfoot {
  background-color: var(--info-light);
  position: sticky;
  bottom: 0;
}

.tooltip-table tfoot td {
  font-weight: bold;
  border-top: 2px solid var(--border);
}

/* Новая таблица (FieldsContainerWidget) */
.table-field-tooltip {
  font-size: 0.9em;
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
}

.table-field-tooltip thead {
  background-color: var(--bg-secondary);
}

.table-field-tooltip th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary) !important;
  z-index: 1;
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.table-field-tooltip td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.table-field-tooltip tbody tr:hover {
  background-color: var(--bg-hover);
}

.table-field-tooltip tfoot {
  background-color: var(--info-light);
}

.table-field-tooltip tfoot td {
  font-weight: bold;
  border-top: 2px solid var(--border);
}

/* ========================================
   LABELED MULTIPLE PREVIEW (в таблице)
   ======================================== */

.labeled-multiple-preview {
  display: inline-block;
}

.labeled-preview-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--primary-hover);
  transition: all 0.2s;
  cursor: pointer;
}

.labeled-preview-text:hover {
  background: var(--primary-lighter);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.labeled-preview-text .info-icon {
  font-size: 14px;
  opacity: 0.7;
}

/* Labeled tooltip */
.labeled-tooltip {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  overflow: auto;
  padding: 0;
}

.labeled-tooltip table {
  width: 100%;
  border-collapse: collapse;
}

.labeled-tooltip th {
  background: var(--bg-secondary);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.labeled-tooltip td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  vertical-align: top;
}

.labeled-tooltip td:first-child {
  font-weight: 500;
  color: var(--primary);
  white-space: nowrap;
  width: 30%;
}

.labeled-tooltip td:last-child {
  color: var(--text-primary);
  word-wrap: break-word;
}

.labeled-tooltip tr:last-child td {
  border-bottom: none;
}

.labeled-tooltip tr:hover {
  background: var(--bg-hover);
}

/* Scrollbar для tooltip */
.labeled-tooltip::-webkit-scrollbar {
  width: 8px;
}

.labeled-tooltip::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.labeled-tooltip::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: 4px;
}

.labeled-tooltip::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

.data-migration-form .alert {
  padding: 1rem;
  background: var(--info-light);
  border-left: 4px solid var(--info);
  margin-bottom: 1.5rem;
}

.preview-section {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.preview-stats {
  display: flex;
  gap: 1rem;
}

.stat-item {
  padding: 0.75rem;
  background: var(--bg-primary);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  flex: 1;
}

.stat-item.success {
  border-left-color: var(--success);
}

.stat-item.warning {
  border-left-color: var(--warning);
}

.reverse-links-widget {
  margin-top: 20px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.reverse-link-group {
  margin-bottom: 15px;
}

.reverse-link-group h4 {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.reverse-link-group small {
  color: var(--text-secondary);
  font-weight: normal;
}

.reverse-link-group ul {
  list-style: none;
  padding-left: 0;
}

.reverse-link-group li {
  padding: 4px 0;
}

.reverse-link-group a {
  color: var(--primary);
  text-decoration: none;
}

.reverse-link-group a:hover {
  text-decoration: underline;
}

/* ============================================
   TRANSITIVE LINKS SIDEBAR (push-панель)
   ============================================ */
.transitive-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  transition: width 0.3s ease, min-width 0.3s ease;
  flex-shrink: 0;
  z-index: 20;
}

.transitive-sidebar.open {
  width: 420px;
  min-width: 420px;
  display: flex;
  flex-direction: column;
}

.transitive-sidebar-inner {
  width: 420px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.transitive-sidebar .drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-primary);
}

.transitive-sidebar .drawer-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transitive-sidebar .drawer-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.transitive-sidebar .drawer-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
}

.transitive-sidebar .drawer-close-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.transitive-sidebar .drawer-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .transitive-sidebar.open {
    width: 100%;
    min-width: 100%;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
  }
  .transitive-sidebar-inner {
    width: 100%;
  }
}
/* === panels/permissions.css === */
/**
 * permissions.css
 * Стили панели прав доступа
 */

/* ============================================
   HANDBOOK PERMISSIONS PANEL
   ============================================ */
.handbook-permissions-panel {
  padding: 32px 20px 20px;
}

.handbook-permissions-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.handbook-permissions-panel .btn-back {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.handbook-permissions-panel .btn-back:hover {
  background: var(--bg-hover);
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 12px 24px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  transition: var(--transition-base);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============================================
   TAB PANES
   ============================================ */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.pane-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.empty-state h3 {
  margin: 0 0 10px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.empty-state .btn-add-role {
  margin-top: 20px;
}

/* ============================================
   PANEL INFO
   ============================================ */
.panel-info {
  display: flex;
  gap: 15px;
  padding: 15px;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-top: 30px;
}

.panel-info .icon-info {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--primary);
}

.panel-info .info-content {
  flex: 1;
}

.panel-info .info-content p {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: var(--text-primary);
}

.panel-info .info-content ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.panel-info .info-content li {
  margin: 5px 0;
}

/* ============================================
   PERMISSION DIALOG
   ============================================ */
.permission-dialog .form-group {
  margin-bottom: 20px;
}

.permission-dialog .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.permission-dialog select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.permission-dialog .selected-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.permission-dialog .selected-user .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.permission-dialog .selected-user .user-info {
  display: flex;
  flex-direction: column;
}

.permission-dialog .selected-user .user-info strong {
  font-size: 14px;
  color: var(--text-primary);
}

.permission-dialog .selected-user .user-info small {
  font-size: 12px;
  color: var(--text-secondary);
}

.permission-dialog .subject-info {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.permission-dialog .subject-info strong {
  font-size: 14px;
  color: var(--text-primary);
}

/* ============================================
   PERMISSIONS FORM
   ============================================ */
.permissions-form h4 {
  margin: 0 0 20px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.permission-group {
  margin-bottom: 25px;
}

.permission-group h5 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.permission-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.permission-checkbox:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.permission-checkbox input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}

.permission-checkbox input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.permission-checkbox .permission-info {
  flex: 1;
}

.permission-checkbox .permission-info strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.permission-checkbox .permission-info small {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .handbook-permissions-panel .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-btn {
    white-space: nowrap;
  }
  
  .panel-info {
    flex-direction: column;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-secondary {
  padding: 8px 16px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-secondary:hover {
  background: #5a6268;
}
/* === panels/import.css === */
/**
 * import.css
 * Стили импорта данных и обработки ошибок
 * ОБНОВЛЕНО: исправлен скролл и групповые операции
 */

/* ============================================
   IMPORT WIZARD
   ============================================ */
.import-wizard {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 500px;
}

/* ============================================
   WIZARD PROGRESS
   ============================================ */
.wizard-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  position: relative;
}

.wizard-progress::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 40px;
  right: 40px;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.progress-step.active .step-number {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: scale(1.1);
}

.progress-step.completed .step-number {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.progress-step.completed .step-number::before {
  content: '✓';
}

.step-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-step.active .step-label {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   WIZARD CONTENT
   ============================================ */
.wizard-content {
  flex: 1;
  padding: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-y: auto;
  max-height: 500px;
}

.import-step h3 {
  margin: 0 0 16px 0;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
}

.import-step > p {
  margin: 0 0 20px 0;
  color: var(--text-secondary);
}

/* ============================================
   STEP 1: FILE UPLOAD
   ============================================ */
.template-download {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--info-light);
  border: 1px solid var(--info);
  border-radius: var(--radius-lg);
}

.template-download p {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 14px;
}

.template-buttons {
  display: flex;
  gap: 12px;
}

.file-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 60px 40px;
  text-align: center;
  background: var(--bg-secondary);
  transition: var(--transition-base);
  cursor: pointer;
}

.file-dropzone:hover,
.file-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.icon-upload {
  font-size: 48px;
  color: var(--text-secondary);
}

.dropzone-content p {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
}

.dropzone-content .link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.dropzone-content small {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--info-light);
  border: 1px solid var(--info);
  border-radius: var(--radius-lg);
  margin-top: 16px;
}

.icon-file {
  font-size: 24px;
  color: var(--info);
}

.file-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.file-size {
  color: var(--text-secondary);
  font-size: 14px;
}

.btn-remove-file {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: var(--transition-base);
}

.btn-remove-file:hover {
  background: var(--danger-hover);
}

/* ============================================
   STEP 3: MAPPING
   ============================================ */
.mapping-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.mapping-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.mapping-select optgroup {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 8px;
  font-style: normal;
}

.mapping-select option {
  padding: 6px 12px;
  color: var(--text-primary);
}

.mapping-select optgroup[label="Дополнительные поля"] option::before {
  content: '→ ';
  color: var(--primary);
  margin-right: 4px;
}

.preview-cell {
  color: var(--text-secondary);
  font-style: italic;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--info-light);
  border: 1px solid var(--info);
  border-radius: var(--radius-lg);
  color: var(--info);
  font-size: 14px;
}

/* ============================================
   STEP 4: VALIDATION & EDITING
   ============================================ */
.step4-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.processed-table-wrapper {
  position: relative;
}

.processed-table-wrapper:fullscreen {
  background: var(--bg-primary);
  padding: 20px;
  overflow: auto;
}

.processed-table-wrapper:fullscreen .processed-table-container {
  max-height: none;
  height: calc(100vh - 100px);
}

.cell-editable {
  cursor: text;
  position: relative;
  min-height: 40px;
  padding: 8px !important;
}

.cell-editable:hover {
  background: var(--warning-light) !important;
  outline: 2px solid var(--warning);
  outline-offset: -2px;
}

.cell-editable:focus {
  background: var(--warning-light) !important;
  outline: 2px solid var(--warning);
  outline-offset: -2px;
  box-shadow: 0 0 0 3px var(--warning-light);
}

.cell-editable .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  pointer-events: none;
  font-size: 14px;
}

.cell-error {
  background: var(--error-light) !important;
}

.cell-warning {
  background: var(--warning-light) !important;
}

.step4-hint {
  margin-top: 15px;
  padding: 12px;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
}

.badge-error {
  background: var(--error);
  color: white;
}

.badge-warning {
  background: var(--warning);
  color: white;
}

/* ============================================
   STEP 5: SETTINGS
   ============================================ */
.import-summary {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.import-summary h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}

.import-summary ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.import-summary li {
  padding: 6px 0;
  color: var(--text-primary);
  font-size: 14px;
}

.import-summary strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================
   STEP 6: EXECUTION
   ============================================ */
.execution-progress {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 20px;
}

.progress-bar-container {
  width: 100%;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-xl);
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#progress-percent {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

#progress-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.execution-result {
  text-align: center;
  padding: 40px 20px;
}

.result-success {
  margin-bottom: 32px;
}

.icon-check {
  font-size: 64px;
  color: var(--success);
  display: block;
  margin-bottom: 16px;
}

.result-success h4 {
  margin: 0;
  color: var(--success);
  font-size: 24px;
  font-weight: 600;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.stat-item strong {
  font-size: 32px;
  font-weight: 700;
  color: var(--success);
}

.stat-item.error strong {
  color: var(--error);
}

.stat-item span {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   WIZARD BUTTONS
   ============================================ */
.wizard-buttons {
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.wizard-buttons button {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
}

.wizard-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   IMPORT ERRORS PANEL - ОСНОВНОЙ КОНТЕЙНЕР
   ============================================ */
.import-errors-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 120px);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Заголовок панели */
.import-errors-panel .panel-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-primary);
}

.import-errors-panel .header-left {
  flex: 1;
  min-width: 0;
}

.import-errors-panel .panel-header h2 {
  margin: 0 0 10px 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.import-errors-panel .header-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.import-errors-panel .stat-badge {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.import-errors-panel .stat-badge.stat-pending {
  background: var(--warning-light);
  color: var(--warning);
}

.import-errors-panel .stat-badge.stat-fixed {
  background: var(--success-light);
  color: var(--success);
}

.import-errors-panel .stat-badge.stat-ignored {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Групповые действия */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  transition: var(--transition-base);
}

.select-all-label:hover {
  background: var(--bg-hover);
}

.select-all-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.selected-count {
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Фильтры */
.filters-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.filters-bar .filter-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

.filters-bar .filter-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.filters-bar .filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Список ошибок - С ПРОКРУТКОЙ */
.errors-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
}

/* ERROR ITEM - КАРТОЧКА ОШИБКИ */
.error-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  transition: var(--transition-base);
}

.error-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.error-item.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  border-left-width: 4px;
}

/* Заголовок ошибки */
.error-item .error-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.error-checkbox {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 2px;
}

.error-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.error-item .error-status {
  font-size: 20px;
}

.error-item .error-source {
  font-weight: 500;
  color: var(--text-primary);
}

.error-item .error-row {
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xs);
  font-weight: 500;
}

.error-item .error-date {
  margin-left: auto;
  font-size: 12px;
}

/* Сообщение об ошибке */
.error-item .error-message {
  margin-bottom: 12px;
  padding: 12px;
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
}

.error-item .error-message strong {
  color: var(--warning);
  font-weight: 600;
}

/* Таблица с данными - УЛУЧШЕНО */
.error-item .error-data-full {
  margin-bottom: 12px;
}

.error-item .error-data-full details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.error-item .error-data-full summary {
  padding: 10px 12px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
  transition: var(--transition-base);
}

.error-item .error-data-full summary:hover {
  background: var(--bg-hover);
}

.error-item .error-data-full details[open] summary {
  border-bottom: 1px solid var(--border);
}

.error-item .error-data-table {
  max-height: 400px;
  overflow: auto;
  margin: 0;
  padding: 0;
}

.error-item .error-data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.error-item .error-data-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  z-index: 1;
}

.error-item .error-data-table th {
  padding: 8px;
  text-align: left;
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-primary);
}

.error-item .error-data-table td {
  padding: 8px;
  border: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
}

.error-item .error-data-table td:first-child {
  background: var(--bg-secondary);
  font-weight: 500;
}

/* Старый превью данных (если используется) */
.error-item .error-data {
  margin-bottom: 12px;
  font-size: 14px;
}

.error-item .error-data strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.error-item .error-data-preview {
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

.error-item .error-data-preview .data-field {
  display: inline-block;
  margin-right: 8px;
}

.error-item .error-data-preview .data-field strong {
  display: inline;
  color: var(--text-secondary);
}

/* Действия с ошибкой */
.error-item .error-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.error-item .error-actions .btn {
  font-size: 13px;
  padding: 6px 12px;
}

/* Пустое состояние */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
}

.empty-filtered {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin: 20px;
}

/* ============================================
   IMPORT PROGRESS BAR
   ============================================ */
.import-progress-bar {
  position: relative;
  width: 100%;
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 20px 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  transition: width 0.3s ease;
  position: relative;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1;
}

.progress-message {
  text-align: center;
  color: var(--text-secondary);
  margin: 10px 0;
}

.import-success {
  padding: 16px;
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius-lg);
  color: var(--success);
  text-align: center;
  font-weight: 500;
  margin-top: 20px;
}

.import-error {
  padding: 16px;
  background: var(--error-light);
  border: 1px solid var(--error);
  border-radius: var(--radius-lg);
  color: var(--error);
  text-align: center;
  font-weight: 500;
  margin-top: 20px;
}

/* ============================================
   FIX: Badge внутри contenteditable
   ============================================ */
.cell-editable,
[contenteditable="true"] {
  position: relative;
}

.cell-editable .badge,
.cell-editable .error-badge,
.cell-editable .warning-badge,
.badge-error,
.badge-warning {
  /* Убрать из flow документа */
  position: absolute !important;
  top: 4px !important;
  right: 4px !important;
  
  /* Запретить взаимодействие */
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  
  /* Не учитывать в contenteditable */
  -webkit-user-modify: read-only !important;
  
  /* Запретить фокус */
  cursor: default !important;
  outline: none !important;
  
  /* Визуально */
  z-index: 10 !important;
  display: inline-block !important;
  padding: 2px 6px;
  border-radius: 3px;
}

/* Запретить выделение текста в badge */
.cell-editable .badge::selection,
.badge-error::selection,
.badge-warning::selection {
  background: transparent !important;
  color: inherit !important;
}

/* При фокусе игнорировать badge */
.cell-editable:focus .badge,
[contenteditable="true"]:focus .badge {
  visibility: visible !important;
}

/* ============================================
   MODAL SIZES - XLARGE
   ============================================ */
.modal.xlarge .modal-content {
  max-width: 90vw;
  width: 90vw;
  max-height: 90vh;
}

.modal.xlarge .modal-body {
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .wizard-progress {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .wizard-progress::before {
    display: none;
  }
  
  .result-stats {
    flex-direction: column;
    gap: 20px;
  }
  
  .wizard-content {
    padding: 16px;
  }
  
  .import-errors-panel {
    max-height: none;
  }
  
  .import-errors-panel .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .import-errors-panel .header-stats {
    width: 100%;
  }
  
  .bulk-actions {
    width: 100%;
    justify-content: flex-start;
  }
  
  .filters-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  
  .errors-list {
    padding: 15px;
  }
  
  .error-item .error-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .error-item .error-date {
    margin-left: 0;
  }
  
  .error-item .error-actions {
    width: 100%;
  }
  
  .error-item .error-actions .btn {
    flex: 1;
    min-width: 100px;
  }
}
/* === panels/export.css === */
/**
 * export.css
 * Стили экспорта данных
 */

/* ============================================
   EXPORT DIALOG
   ============================================ */
.export-dialog {
  padding: 20px;
}

/* ============================================
   FORMAT OPTIONS (карточки форматов)
   ============================================ */
.format-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 10px;
}

.format-option {
  cursor: pointer;
}

.format-option input[type="radio"] {
  display: none;
}

.format-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  transition: var(--transition-base);
  background: var(--bg-primary);
}

.format-option input[type="radio"]:checked + .format-card {
  border-color: var(--success);
  background: var(--success-light);
}

.format-card:hover {
  border-color: var(--success);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.format-icon {
  font-size: 36px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.format-name {
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.format-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================
   EXPORT INFO
   ============================================ */
.export-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-top: 20px;
}

.export-info .icon-info {
  font-size: 20px;
  color: var(--primary);
}

/* ============================================
   EXPORT DIALOG BUTTONS
   ============================================ */
.export-dialog .modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .format-options {
    grid-template-columns: 1fr;
  }
}
/* === panels/history.css === */
/**
 * history.css
 * История изменений
 */

/* ============================================
   HANDBOOK HISTORY PANEL
   ============================================ */
.handbook-history-panel {
  padding: 20px;
}

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  margin-bottom: 30px;
  padding: 15px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.filter-group input,
.filter-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   TIMELINE
   ============================================ */
.timeline-container {
  position: relative;
  padding-left: 40px;
}

.timeline-container::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-event {
  position: relative;
  margin-bottom: 30px;
  padding: 15px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition-base);
}

.timeline-event:hover {
  box-shadow: var(--shadow-md);
}

.event-marker {
  position: absolute;
  left: -32px;
  top: 20px;
  width: 30px;
  height: 30px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.action-create .event-marker {
  border-color: var(--success);
  background: var(--success-light);
}

.action-update .event-marker {
  border-color: var(--primary);
  background: var(--primary-light);
}

.action-delete .event-marker {
  border-color: var(--error);
  background: var(--error-light);
}

.action-restore .event-marker {
  border-color: var(--warning);
  background: var(--warning-light);
}

.event-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.event-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.event-action {
  color: var(--text-secondary);
  font-size: 14px;
}

.event-time {
  font-size: 13px;
  color: var(--text-muted);
}

.event-description {
  color: var(--text-primary);
  font-size: 14px;
}

.event-actions {
  display: flex;
  gap: 10px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .timeline-container {
    padding-left: 30px;
  }
  
  .event-marker {
    left: -27px;
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  
  .event-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
/* === panels/import-structure.css === */
/* Import Structure Wizard */
.import-step {
  padding: 1rem 0;
}

/* File Upload Zone */
.file-upload-zone {
  border: 2px dashed var(--color-border, #ddd);
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--color-bg-secondary, #f9f9f9);
}

.file-upload-zone:hover {
  border-color: var(--color-primary, #2196f3);
  background-color: var(--color-bg-hover, #f0f8ff);
}

.file-upload-zone.drag-over {
  border-color: var(--color-primary, #2196f3);
  background-color: var(--color-primary-light, #e3f2fd);
  border-style: solid;
}

.file-upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.file-upload-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text-primary, #333);
  margin-bottom: 0.5rem;
}

.file-upload-hint {
  font-size: 0.9rem;
  color: var(--color-text-secondary, #666);
}

/* File Info Box */
.file-info-box {
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1rem;
  background-color: var(--color-bg-success, #f0f9ff);
}

.file-info-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.file-info-icon {
  font-size: 1.5rem;
}

.file-info-name {
  font-weight: 600;
  font-size: 1rem;
}

.file-info-details {
  padding-left: 2rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary, #666);
}

.file-info-details p {
  margin: 0.25rem 0;
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border, #ddd);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.radio-label:hover {
  border-color: var(--color-primary, #2196f3);
  background-color: var(--color-bg-hover, #f9f9f9);
}

.radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
  font-weight: 600;
  color: var(--color-primary, #2196f3);
}

.radio-label input[type="radio"]:disabled {
  cursor: not-allowed;
}

/* Info Box */
.info-box {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--color-bg-info, #e3f2fd);
  border-left: 4px solid var(--color-info, #2196f3);
  border-radius: 4px;
}

.info-box-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.info-box-content p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--color-text-primary, #333);
}

/* Fields Selection */
.fields-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-border, #ddd);
}

.fields-count {
  font-size: 1rem;
  color: var(--color-text-secondary, #666);
}

.fields-count strong {
  color: var(--color-primary, #2196f3);
  font-weight: 600;
}

.fields-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
  padding: 0.5rem;
}

/* Field Selection Row */
.field-selection-row {
  padding: 0.75rem;
  border: 1px solid var(--color-border-light, #e0e0e0);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.field-selection-row:hover {
  background-color: var(--color-bg-hover, #f9f9f9);
  border-color: var(--color-border, #ddd);
}

.field-selection-row.field-conflict {
  background-color: var(--color-bg-warning, #fff3e0);
  border-color: var(--color-warning, #ff9800);
}

.field-checkbox-label {
  display: flex;
  gap: 0.75rem;
  cursor: pointer;
  width: 100%;
}

.field-checkbox {
  margin-top: 0.25rem;
  flex-shrink: 0;
  cursor: pointer;
}

.field-checkbox:disabled {
  cursor: not-allowed;
}

.field-info {
  flex: 1;
}

.field-name-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.field-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text-primary, #333);
}

.field-type {
  font-size: 0.85rem;
}

/* Field Messages */
.field-conflict-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: var(--color-bg-warning-light, #fff8e1);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--color-warning-dark, #f57c00);
}

.conflict-resolution {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 4px;
  font-size: 0.85rem;
  background-color: white;
  cursor: pointer;
}

.field-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: var(--color-bg-info-light, #e8f5e9);
  border-left: 3px solid var(--color-info, #2196f3);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--color-text-primary, #333);
}

/* Wizard Footer */
.wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border, #ddd);
}

.wizard-progress {
  font-size: 0.9rem;
  color: var(--color-text-secondary, #666);
  font-weight: 500;
}

.wizard-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .file-upload-zone {
    padding: 2rem 1rem;
  }
  
  .fields-selection-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .wizard-footer {
    flex-direction: column-reverse;
    gap: 1rem;
  }
  
  .wizard-buttons {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Fields Manager Header (для FieldsManagerDialog) */
.fields-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.fields-manager-header-left,
.fields-manager-header-right {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .fields-manager-header {
    flex-direction: column;
  }
  
  .fields-manager-header-left,
  .fields-manager-header-right {
    width: 100%;
  }
}
/* === panels/cascading-handbook-field.css === */
/* ============================================
   CASCADING LINKS PANEL
   ============================================ */

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.cascading-links-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 999;
  display: flex;
  justify-content: flex-end;
}

.cascading-links-panel {
  width: 600px;
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease-out;
}

.cascading-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.cascading-panel-content::-webkit-scrollbar {
  width: 8px;
}

.cascading-panel-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.cascading-panel-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.cascading-panel-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.path-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s;
  position: relative;
}

.path-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.cascading-search {
  width: 100%;
  padding: 8px 12px 8px 35px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9em;
  transition: all 0.2s;
}

.cascading-search:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.view-mode-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.view-mode-btn:hover {
  transform: translateY(-1px);
}

/* Адаптивность */
@media (max-width: 768px) {
  .cascading-links-panel {
    width: 100%;
  }
}

/* Анимация для графа */
.graph-node {
  transition: all 0.3s;
}

.graph-node:hover {
  transform: scale(1.1);
}

/* Tooltip для узлов графа */
.graph-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
}

.handbook-group-header {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 12px;
  color: #111827;
  border-bottom: 2px solid #f3f4f6;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
/* === panels/notifications.css === */
/**
 * notifications.css
 * Стили панели уведомлений и компонентов
 */

/* ============================================
   NOTIFICATIONS PANEL
   ============================================ */
.notifications-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.notifications-panel .panel-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-lg);
}

.notifications-panel .panel-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.notifications-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ============================================
   PANEL FILTERS
   ============================================ */
.panel-filters {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.filter-btn {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   NOTIFICATION CARD
   ============================================ */
.notification-card {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
  background: var(--bg-primary);
}

.notification-card:hover {
  background: var(--bg-hover);
}

.notification-card.unread {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
  gap: var(--space-md);
}

.notification-header strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.notification-date {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.notification-body {
  margin-bottom: var(--space-md);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.notification-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn-mark-read,
.btn-delete {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.btn-mark-read:hover {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.btn-delete:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
}

/* ============================================
   NOTIFICATIONS BUTTON (в header)
   ============================================ */
.notifications-button {
  position: relative;
  font-size: 20px;
  padding: var(--space-sm) 12px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  color: var(--text-secondary);
}

.notifications-button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}

/* ============================================
   NOTIFICATIONS DROPDOWN
   ============================================ */
.notifications-dropdown {
  width: 400px;
  max-height: 600px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notifications-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.notifications-dropdown-header strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.notifications-dropdown-body {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
}

.notifications-dropdown-body::-webkit-scrollbar {
  width: 6px;
}

.notifications-dropdown-body::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.notifications-dropdown-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-xs);
}

.notifications-dropdown-body::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

.notifications-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.notification-item {
  display: flex;
  gap: 12px;
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
}

.notification-item:hover {
  background: var(--bg-hover);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item.unread {
  background: var(--primary-light);
}

.notification-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.notification-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.notification-time {
  font-size: 12px;
  color: var(--text-muted);
}

.notification-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: var(--radius-full);
  position: absolute;
  top: 20px;
  right: var(--space-md);
}

.notifications-dropdown-footer {
  padding: 12px var(--space-md);
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--bg-secondary);
}

/* ============================================
   LOADING & ERROR
   ============================================ */
.loading,
.error {
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
}

.error {
  color: var(--danger);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .notifications-dropdown {
    width: calc(100vw - 32px);
    max-width: 400px;
  }
  
  .notifications-panel .panel-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .panel-filters {
    flex-wrap: wrap;
  }
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */
[data-theme="dark"] .notification-item.unread {
  background: rgba(33, 150, 243, 0.15);
}

[data-theme="dark"] .notification-badge {
  background: var(--danger);
}
/* === panels/calendar-drawer.css === */
/**
 * calendar-drawer.css
 * Выдвижная панель глобального календаря (CalendarDrawerPanel)
 * Все стили перенесены из CalendarDrawerPanel.js injectStyles()
 * 
 * Структура:
 *   1. Overlay
 *   2. Drawer Panel
 *   3. Header (с кнопкой создания события)
 *   4. Filters Panel
 *   5. Body (calendar mount)
 *   6. Loading & Error
 *   7. Handbook Picker Modal
 *   8. Responsive
 *   9. Dark Mode
 */


/* ============================================
   1. OVERLAY
   ============================================ */

.cal-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cal-drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}


/* ============================================
   2. DRAWER PANEL
   ============================================ */

.cal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 42vw;
  min-width: 480px;
  max-width: 800px;
  background: var(--bg-primary, #fff);
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cal-drawer.active {
  transform: translateX(0);
}


/* ============================================
   3. HEADER
   ============================================ */

.cal-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  flex-shrink: 0;
}

.cal-drawer-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-drawer-icon {
  font-size: 22px;
  line-height: 1;
}

.cal-drawer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary, #111);
}

.cal-drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Кнопка создания события (вынесена из widget header) */
.cal-drawer-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary, #4A90E2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cal-drawer-create-btn:hover {
  background: var(--primary-hover, #357ABD);
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.cal-drawer-create-btn:active {
  transform: scale(0.97);
}

.cal-drawer-create-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

/* Generic buttons */
.cal-drawer-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  color: var(--text-secondary, #666);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s ease;
}

.cal-drawer-btn:hover {
  background: var(--bg-hover, #f3f4f6);
  color: var(--text-primary, #111);
}

.cal-drawer-filter-toggle.active {
  background: var(--primary, #4A90E2);
  color: #fff;
  border-color: var(--primary, #4A90E2);
}

.cal-drawer-filter-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #E91E63;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}


/* ============================================
   4. FILTERS PANEL
   ============================================ */

.cal-drawer-filters {
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  flex-shrink: 0;
}

.cal-drawer-filters-inner {
  padding: 14px 20px 8px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.cal-filter-section {
  flex: 1;
  min-width: 200px;
}

.cal-filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-filter-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-filter-section-actions {
  display: flex;
  gap: 8px;
}

.cal-filter-link {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--primary, #4A90E2);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color 0.12s ease;
}

.cal-filter-link:hover {
  color: var(--primary-hover, #357ABD);
}

/* Handbook checkboxes */
.cal-filter-handbooks-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-filter-handbooks-list::-webkit-scrollbar {
  width: 4px;
}

.cal-filter-handbooks-list::-webkit-scrollbar-thumb {
  background: var(--color-gray-300, #d1d5db);
  border-radius: 2px;
}

.cal-filter-hb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #333);
  transition: background 0.1s ease;
}

.cal-filter-hb-item:hover {
  background: var(--bg-hover, #f3f4f6);
}

.cal-filter-hb-item input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: var(--primary, #4A90E2);
}

.cal-filter-hb-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cal-filter-hb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-hb-icons {
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* Category checkboxes */
.cal-filter-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cal-filter-cat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #333);
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg-primary, #fff);
  transition: all 0.15s ease;
}

.cal-filter-cat-item:hover {
  border-color: var(--primary, #4A90E2);
}

.cal-filter-cat-item input[type="checkbox"] {
  accent-color: var(--primary, #4A90E2);
}

.cal-filter-cat-icon {
  font-size: 14px;
}

/* Apply button */
.cal-filter-apply-row {
  padding: 8px 20px 12px;
  display: flex;
  justify-content: flex-end;
}

.cal-filter-apply-btn {
  padding: 7px 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary, #4A90E2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cal-filter-apply-btn:hover {
  background: var(--primary-hover, #357ABD);
}


/* ============================================
   5. BODY — CALENDAR MOUNT
   ============================================ */

.cal-drawer-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cal-drawer-calendar-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Widget overrides inside drawer */
.cal-drawer-calendar-wrap .widget-container {
  box-shadow: none;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.cal-drawer-calendar-wrap .calendar-content {
  flex: 1;
  min-height: 0;
}

/* Hide widget header (merged into drawer header) */
.cal-drawer-calendar-wrap .widget-header {
  display: none !important;
}

.cal-drawer-calendar-wrap .calendar-toolbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border, #eee);
}


/* ============================================
   6. LOADING & ERROR
   ============================================ */

.cal-drawer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-secondary, #888);
  font-size: 14px;
}

@keyframes calDrawerSpin {
  to { transform: rotate(360deg); }
}

.cal-drawer-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border, #e5e7eb);
  border-top-color: var(--primary, #4A90E2);
  border-radius: 50%;
  animation: calDrawerSpin 0.7s linear infinite;
}

.cal-drawer-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-secondary, #888);
  font-size: 14px;
}

.cal-drawer-retry-btn {
  padding: 8px 20px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  cursor: pointer;
  font-size: 13px;
  color: var(--primary, #4A90E2);
  transition: all 0.15s ease;
}

.cal-drawer-retry-btn:hover {
  background: var(--bg-hover, #f5f5f5);
}


/* ============================================
   7. HANDBOOK PICKER MODAL
   ============================================ */

@keyframes calDrawerFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes calDrawerSlide {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.cal-hb-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: calDrawerFade 0.15s ease;
}

.cal-hb-picker-modal {
  background: var(--bg-primary, #fff);
  border-radius: 14px;
  width: 400px;
  max-width: 92vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: calDrawerSlide 0.2s ease;
  overflow: hidden;
}

.cal-hb-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #eee);
}

.cal-hb-picker-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #111);
}

.cal-hb-picker-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary, #999);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.cal-hb-picker-close:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #333);
}

.cal-hb-picker-search {
  padding: 12px 20px 8px;
}

.cal-hb-picker-input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cal-hb-picker-input:focus {
  border-color: var(--primary, #4A90E2);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}

.cal-hb-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px;
}

.cal-hb-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary, #333);
  text-align: left;
  transition: background 0.1s ease;
}

.cal-hb-picker-item:hover {
  background: var(--primary-light, #f0f5ff);
}

.cal-hb-picker-color {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.cal-hb-picker-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-hb-picker-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted, #aaa);
  font-size: 14px;
}


/* ============================================
   8. RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .cal-drawer {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
  }

  .cal-drawer-overlay.active {
    background: rgba(0, 0, 0, 0.4);
  }

  .cal-drawer-header {
    padding: 12px 16px;
  }

  .cal-drawer-title {
    font-size: 15px;
  }

  .cal-drawer-filters-inner {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 6px;
  }

  .cal-filter-section {
    min-width: 0;
  }

  .cal-filter-handbooks-list {
    max-height: 140px;
  }

  .cal-filter-apply-row {
    padding: 6px 16px 10px;
  }

  .cal-drawer-calendar-wrap .calendar-toolbar {
    padding: 6px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .cal-hb-picker-modal {
    width: 95vw;
    max-height: 80vh;
  }
}

@media (max-width: 480px) {
  .cal-drawer-calendar-wrap .calendar-view-switcher .view-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .cal-drawer-calendar-wrap .btn-nav {
    min-width: 32px;
    padding: 4px 6px;
  }

  .cal-drawer-create-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}


/* ============================================
   9. DARK MODE
   ============================================ */

[data-theme="dark"] .cal-drawer {
  box-shadow: -4px 0 40px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cal-hb-picker-modal {
  background: var(--bg-secondary);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .cal-drawer-overlay.active {
  background: rgba(0, 0, 0, 0.5);
}

/* === panels/list-map-panel.css === */
/* ============================================================
   SPLIT-VIEW: Таблица + Карта
   ============================================================ */

.split-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.split-left {
  flex: 1 1 100%;
  min-width: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  transition: flex 0.05s ease-out;
}

.split-right {
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border-left: 1px solid #e0e0e0;
}

/* Resizer handle */
.split-resizer {
  display: none;
  width: 5px;
  cursor: col-resize;
  background: #e8e8e8;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}

.split-resizer:hover,
.split-resizer:active {
  background: #1976d2;
}

.split-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 32px;
  border-left: 1px solid rgba(0,0,0,0.15);
  border-right: 1px solid rgba(0,0,0,0.15);
}

.split-resizer:hover::after,
.split-resizer:active::after {
  border-color: rgba(255,255,255,0.6);
}

/* ============================================================
   Кнопка карты в toolbar
   ============================================================ */

#map-toggle-btn {
  position: relative;
}

#map-toggle-btn.active {
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 6px;
}

/* ============================================================
   LIST MAP PANEL — Панель карты
   ============================================================ */

.list-map-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
}

/* Хедер */
.list-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #fafafa;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  min-height: 36px;
}

.list-map-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-map-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.list-map-count {
  font-size: 11px;
  background: #e3f2fd;
  color: #1565c0;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.list-map-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.list-map-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  color: #666;
  transition: background 0.15s, color 0.15s;
}

.list-map-btn:hover {
  background: #e8e8e8;
  color: #333;
}

.list-map-btn-close:hover {
  background: #ffebee;
  color: #c62828;
}

/* Тело карты */
.list-map-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.list-map-body .leaflet-container {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

/* ============================================================
   POPUP маркера на карте списка
   ============================================================ */

.list-map-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0;
}

.list-map-popup .leaflet-popup-content {
  margin: 0;
  min-width: 180px;
}

.list-map-popup-content {
  padding: 10px 12px;
}

.list-map-popup-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.list-map-popup-header strong {
  font-size: 13px;
  color: #212121;
  line-height: 1.3;
  word-break: break-word;
}

.list-map-popup-label {
  font-size: 10px;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.list-map-popup-code {
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
}

.list-map-popup-address {
  font-size: 12px;
  color: #555;
  line-height: 1.35;
  margin-bottom: 8px;
  word-break: break-word;
}

.list-map-popup-actions {
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.list-map-popup-open {
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.list-map-popup-open:hover {
  background: #1565c0;
}

/* ============================================================
   LOADING STATE
   ============================================================ */

.list-map-panel .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  /* На мобилке split-view отключён — карта полноэкранная поверх */
  .split-container {
    flex-direction: column;
  }

  .split-resizer {
    display: none !important;
  }

  .split-right {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    border-left: none;
    flex: none !important;
    width: 100% !important;
  }

  .list-map-header {
    padding: 10px 12px;
    min-height: 44px;
  }

  .list-map-btn {
    padding: 6px 10px;
    font-size: 18px;
  }

  .list-map-title {
    font-size: 15px;
  }
}

/* ============================================================
   DARK THEME SUPPORT (optional)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  .list-map-header {
    background: #2a2a2a;
    border-color: #444;
  }

  .list-map-title {
    color: #eee;
  }

  .list-map-btn {
    color: #aaa;
  }

  .list-map-btn:hover {
    background: #3a3a3a;
    color: #eee;
  }

  .split-resizer {
    background: #444;
  }

  .split-right {
    background: #1e1e1e;
    border-color: #444;
  }
}

/* Убрать дефолтный фон divIcon */
.list-map-marker {
  background: none !important;
  border: none !important;
}

/* ============================================
   Диалоги 
   ============================================ */

/* === dialog/audit-log-dialog.css === */
.audit-log-modal {
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.audit-log-modal .modal-body {
  overflow-y: auto;
  max-height: calc(90vh - 180px);
}

.audit-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  border: 2px solid #dee2e6;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: #007bff;
  background: #f8f9fa;
}

.filter-btn.active {
  border-color: #007bff;
  background: #007bff;
  color: white;
}

.audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.audit-entry {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  background: white;
  transition: all 0.2s;
}

.audit-entry:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.audit-entry.create {
  border-left: 4px solid #28a745;
}

.audit-entry.update {
  border-left: 4px solid #ffc107;
}

.audit-entry.delete {
  border-left: 4px solid #dc3545;
}

.audit-header {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.audit-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.audit-info {
  flex: 1;
}

.audit-action {
  font-size: 15px;
  margin-bottom: 5px;
}

.audit-meta {
  display: flex;
  gap: 15px;
  font-size: 13px;
  color: #6c757d;
}

.audit-changes {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #dee2e6;
}

.changes-title {
  font-weight: 600;
  margin-bottom: 10px;
  color: #495057;
}

.permissions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.permission-item.enabled {
  background: #d4edda;
  color: #155724;
}

.permission-item.disabled {
  background: #f8d7da;
  color: #721c24;
}

.changes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.permission-change {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 13px;
}

.permission-label {
  font-weight: 500;
  min-width: 200px;
}

.old-value {
  color: #dc3545;
}

.new-value {
  color: #28a745;
  font-weight: 500;
}

.arrow {
  color: #6c757d;
}

.no-changes {
  color: #6c757d;
  font-style: italic;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #6c757d;
}
/* === dialog/field-conditions-dialog.css === */
/**
 * field-conditions-dialog.css
 * Диалог настройки условий отображения для одного поля
 */

/* ============================================
   FIELD CONDITIONS DIALOG LAYOUT
   ============================================ */
.field-conditions-dialog {
  padding: 10px 0;
}

/* ============================================
   INTRO SECTION
   ============================================ */
.conditions-intro {
  margin-bottom: 20px;
  padding: 15px;
  background: var(--primary-light, #f0f9ff);
  border-left: 3px solid var(--primary, #3b82f6);
  border-radius: var(--radius-sm, 4px);
}

.conditions-intro p {
  margin: 0;
  font-size: 14px;
  color: var(--text-primary, #1f2937);
}

.conditions-intro strong {
  font-weight: 600;
  color: var(--primary, #3b82f6);
}

/* ============================================
   LOGIC SELECTOR (AND/OR)
   ============================================ */
.logic-selector {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--border, #e5e7eb);
}

.logic-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  transition: color 0.2s;
}

.logic-selector label:hover {
  color: var(--text-primary, #1f2937);
}

.logic-selector input[type="radio"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.logic-selector input[type="radio"]:checked + span {
  color: var(--primary, #3b82f6);
  font-weight: 600;
}

/* ============================================
   CONDITIONS LIST
   ============================================ */
.conditions-list {
  margin-bottom: 15px;
  min-height: 100px;
}

.condition-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--bg-primary, white);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  margin-bottom: 10px;
  transition: all 0.2s;
}

.condition-row:hover {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.condition-field {
  flex: 1;
  min-width: 150px;
}

.condition-operator {
  flex: 1;
  min-width: 120px;
}

.condition-value {
  flex: 1;
  min-width: 150px;
}

.condition-actions {
  flex-shrink: 0;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.conditions-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted, #9ca3af);
  background: var(--bg-secondary, #f9fafb);
  border: 2px dashed var(--border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  font-size: 14px;
}

.conditions-empty::before {
  content: '📋';
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ============================================
   DELETE BUTTON
   ============================================ */
.btn-delete-condition {
  padding: 8px 12px;
  background: var(--bg-secondary, #fee);
  border: 1px solid #fcc;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--danger, #ef4444);
  transition: all 0.2s;
}

.btn-delete-condition:hover {
  background: var(--danger, #ef4444);
  color: white;
  border-color: var(--danger, #ef4444);
  transform: scale(1.05);
}

/* ============================================
   ADD CONDITION BUTTON
   ============================================ */
#add-condition-btn {
  width: 100%;
  padding: 10px;
  border: 2px dashed var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-md, 6px);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary, #3b82f6);
  transition: all 0.2s;
}

#add-condition-btn:hover {
  border-color: var(--primary, #3b82f6);
  background: var(--primary-light, #f0f9ff);
  transform: translateY(-1px);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .condition-row {
    flex-direction: column;
    gap: 12px;
  }
  
  .condition-field,
  .condition-operator,
  .condition-value {
    width: 100%;
    min-width: auto;
  }
  
  .logic-selector {
    flex-direction: column;
    gap: 12px;
  }
}
/* === dialog/transitive-display-settings-dialog.css === */
/**
 * transitive-display-settings-dialog.css
 * Диалог настройки отображения полей в транзитивных связях
 */

/* ============================================
   MAIN CONTAINER
   ============================================ */
.transitive-settings-dialog {
  max-height: 70vh;
  overflow-y: auto;
}

/* ============================================
   SETTINGS SECTION
   ============================================ */
.settings-section {
  margin-bottom: 20px;
  padding: 15px;
  background: var(--bg-secondary, #f9fafb);
  border-radius: var(--radius-lg, 8px);
  border: 1px solid var(--border, #e5e7eb);
}

.settings-section h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #374151);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   FIELDS LIST
   ============================================ */
.fields-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-primary, white);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  cursor: move;
  transition: all 0.2s;
}

.field-item:hover {
  border-color: var(--primary, #3b82f6);
  background: var(--primary-light, #f0f9ff);
  transform: translateX(4px);
}

.field-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.field-checkbox {
  flex-shrink: 0;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.field-label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary, #374151);
  font-size: 14px;
}

.field-name {
  color: var(--text-muted, #6b7280);
  font-size: 0.875rem;
  font-family: 'Courier New', monospace;
}

/* ============================================
   FIELD CONDITIONS BADGE
   ============================================ */
.field-conditions-badge {
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--primary-light, #dbeafe);
  border-left: 3px solid var(--primary, #3b82f6);
  font-size: 0.75rem;
  color: var(--primary, #1e40af);
  border-radius: var(--radius-xs, 3px);
  display: inline-block;
}

/* ============================================
   FIELD CONTROLS
   ============================================ */
.field-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.btn-move {
  padding: 6px 10px;
  background: var(--bg-secondary, #e5e7eb);
  border: none;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  transition: all 0.2s;
}

.btn-move:hover:not(:disabled) {
  background: var(--primary, #3b82f6);
  color: white;
  transform: scale(1.1);
}

.btn-move:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-configure {
  padding: 6px 10px;
  background: var(--bg-secondary, #f3f4f6);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
  margin-right: 5px;
}

.btn-configure:hover {
  background: var(--primary, #3b82f6);
  color: white;
  border-color: var(--primary, #3b82f6);
  transform: scale(1.1);
}

/* ============================================
   CHECKBOX LABEL
   ============================================ */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm, 4px);
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: var(--bg-hover, #f3f4f6);
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* ============================================
   HISTORY
   ============================================ */
.history-item {
  padding: 12px;
  background: var(--bg-primary, white);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.history-date {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
}

.history-comment {
  color: var(--text-primary, #374151);
  font-size: 0.875rem;
  margin-top: 4px;
}

.btn-restore {
  padding: 6px 14px;
  background: var(--primary, #3b82f6);
  color: white;
  border: none;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-restore:hover {
  background: var(--primary-hover, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--text-muted, #6b7280);
}

.loading-spinner::before {
  content: '⏳';
  font-size: 24px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .field-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .field-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .settings-section {
    padding: 12px;
  }
}

.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
}

.mode-selector label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-selector label:hover {
  border-color: #3b82f6;
  background: #f0f9ff;
}

.mode-selector input[type="radio"]:checked + span {
  font-weight: 600;
  color: #3b82f6;
}

.mode-selector input[type="radio"]:checked ~ * {
  border-color: #3b82f6;
  background: #f0f9ff;
}
/* === dialog/bulk-edit-dialog.css === */
/**
 * bulk-edit-dialog.css
 * Универсальный диалог массового создания/редактирования
 * 
 * Архитектура: наследует стили из core (buttons, forms, tables)
 * Добавляет только специфичные стили для bulk-edit функционала
 */

/* ============================================
   CONTAINER
   ============================================ */
.bulk-edit-dialog {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 120px);
  background: var(--bg-primary);
}

/* ============================================
   TOOLBAR
   ============================================ */
.bulk-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
  display: flex;
  gap: var(--spacing-3);
  align-items: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-base);
}

.stat-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.stat-item strong {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.stat-total { 
  border-left: 3px solid var(--primary); 
}

.stat-ok { 
  border-left: 3px solid var(--success);
}

.stat-warning { 
  border-left: 3px solid var(--warning);
}

.stat-error { 
  border-left: 3px solid var(--error);
}

/* ============================================
   TABLE WRAPPER
   ============================================ */
.bulk-table-wrapper {
  flex: 1;
  overflow: auto;
  background: var(--bg-secondary);
  min-height: 0; /* Важно для flex-контейнера */
}

/* ============================================
   TABLE (наследует от tables.css)
   ============================================ */
.bulk-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-primary);
  font-size: var(--font-size-base);
}

/* Sticky header */
.bulk-table thead {
  position: sticky;
  top: 0;
  z-index: var(--z-10);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
}

.bulk-table thead th {
  padding: var(--spacing-3) var(--spacing-3);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--bg-secondary);
}

.bulk-table thead th:first-child {
  padding-left: var(--spacing-4);
}

.bulk-table thead th:last-child {
  padding-right: var(--spacing-4);
}

/* Rows */
.bulk-table tbody tr {
  transition: var(--transition-base);
  border-bottom: 1px solid var(--border-light);
}

.bulk-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Row states (используем паттерн из tables.css) */
.bulk-row-ok {
  background: var(--bg-primary);
}

.bulk-row-warning {
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
}

.bulk-row-error {
  background: var(--error-light);
  border-left: 4px solid var(--error);
}

.bulk-row-warning:hover,
.bulk-row-error:hover {
  filter: brightness(0.98);
}

/* Cells */
.bulk-table td {
  padding: var(--spacing-3);
  color: var(--text-primary);
  vertical-align: middle;
  position: relative;
}

.bulk-table td:first-child {
  padding-left: var(--spacing-4);
}

.bulk-table td:last-child {
  padding-right: var(--spacing-4);
}

/* ============================================
   ROW NUMBER
   ============================================ */
.row-number {
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-align: center;
  font-size: var(--font-size-sm);
  background: var(--bg-secondary);
}

/* ============================================
   EDITABLE CELLS (contenteditable)
   ============================================ */
.cell-editable {
  cursor: text;
  min-height: 20px;
  padding: var(--spacing-2) var(--spacing-3) !important;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  border: 2px solid transparent;
}

.cell-editable:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.cell-editable:focus {
  outline: none;
  background: var(--bg-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.cell-editable:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
  font-style: italic;
}

/* Cell states */
.cell-error {
  background: var(--error-light) !important;
  border-color: var(--error) !important;
}

.cell-error:focus {
  box-shadow: 0 0 0 3px var(--error-light) !important;
}

.cell-warning {
  background: var(--warning-light) !important;
  border-color: var(--warning) !important;
}

.cell-warning:focus {
  box-shadow: 0 0 0 3px var(--warning-light) !important;
}

/* ============================================
   ERROR/WARNING BADGES
   ============================================ */
.error-badge,
.warning-badge {
    pointer-events: none;
    user-select: none;
  position: absolute;
  top: var(--spacing-1);
  right: var(--spacing-1);
  font-size: var(--font-size-xs);
  cursor: help;
  z-index: var(--z-10);
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ============================================
   FORM CONTROLS (наследуют от forms.css)
   ============================================ */

/* Select fields */
.cell-select select,
.field-select {
  width: 100%;
  padding: var(--spacing-2) var(--spacing-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.field-select:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.field-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Textarea fields */
.cell-textarea textarea,
.field-textarea {
  width: 100%;
  padding: var(--spacing-2) var(--spacing-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-family: var(--font-family);
  resize: vertical;
  min-height: 60px;
  transition: var(--transition-base);
  background: var(--bg-primary);
}

.field-textarea:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Date fields */
.cell-date input,
.field-date {
  width: 100%;
  padding: var(--spacing-2) var(--spacing-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  transition: var(--transition-base);
  background: var(--bg-primary);
}

.field-date:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.field-date:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Checkbox fields */
.cell-checkbox {
  text-align: center;
  padding: var(--spacing-3) !important;
}

.cell-checkbox input[type="checkbox"],
.field-checkbox,
.checkbox-isactive {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  transition: var(--transition-base);
}

.cell-checkbox input[type="checkbox"]:hover {
  transform: scale(1.1);
}

/* Handbook select container */
.cell-handbook {
  padding: var(--spacing-2) var(--spacing-3) !important;
}

.handbook-select-container {
  min-width: 200px;
}

/* ============================================
   STATUS & ACTIONS
   ============================================ */
.status-cell {
  text-align: center;
  font-size: 18px;
}

.action-cell {
  text-align: center;
}

.action-cell .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
}

.action-cell .btn-icon:hover {
  background: var(--error-light);
  color: var(--error);
  transform: scale(1.1);
}

/* ============================================
   FOOTER
   ============================================ */
.bulk-footer {
  padding: var(--spacing-4);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-hints {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.footer-hints strong {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.bulk-table-wrapper::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.bulk-table-wrapper::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.bulk-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.bulk-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
.bulk-table-wrapper {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-secondary);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bulk-row {
  animation: slideInUp 0.3s ease;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
  .bulk-toolbar {
    flex-direction: column;
    gap: var(--spacing-3);
    align-items: stretch;
  }
  
  .toolbar-left,
  .toolbar-right {
    justify-content: space-between;
  }
  
  .stats-bar {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .bulk-table {
    font-size: var(--font-size-sm);
  }
  
  .bulk-table th,
  .bulk-table td {
    padding: var(--spacing-2) var(--spacing-1);
  }
  
  .stat-item {
    font-size: 11px;
    padding: var(--spacing-1) var(--spacing-2);
  }
  
  .stat-item strong {
    font-size: var(--font-size-sm);
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.bulk-table *:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================
   FULLSCREEN MODAL OVERRIDE
   ============================================ */
.modal.modal-fullscreen {
  width: calc(100vw - 40px);
  height: calc(100vh - 80px);
  max-width: none;
  max-height: none;
}

.modal.modal-fullscreen .bulk-edit-dialog {
  max-height: 100%;
}

/* ============================================
   FIX: Badge внутри contenteditable
   ============================================ */
.cell-editable,
[contenteditable="true"] {
  position: relative;
}

.cell-editable .badge,
.cell-editable .error-badge,
.cell-editable .warning-badge,
.badge-error,
.badge-warning {
  /* Убрать из flow документа */
  position: absolute !important;
  top: 4px !important;
  right: 4px !important;
  
  /* Запретить взаимодействие */
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  
  /* Не учитывать в contenteditable */
  -webkit-user-modify: read-only !important;
  
  /* Запретить фокус */
  cursor: default !important;
  outline: none !important;
  
  /* Визуально */
  z-index: 10 !important;
  display: inline-block !important;
}

/* Запретить выделение текста в badge */
.cell-editable .badge::selection,
.badge-error::selection,
.badge-warning::selection {
  background: transparent !important;
  color: inherit !important;
}

/* При фокусе игнорировать badge */
.cell-editable:focus .badge,
[contenteditable="true"]:focus .badge {
  visibility: visible !important;
}
/* === dialog/approval-dialogs.css === */
/**
 * approval-dialogs.css
 * Стили для системы согласований
 */

/* ============================================
   BADGES (бейджи для кнопок)
   ============================================ */
.errors-badge,
.approvals-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ff9800;
  color: #fff;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.errors-badge {
  background-color: #f44336;
}

/* ============================================
   WORKFLOW DIALOG (настройка правил)
   ============================================ */
.approval-workflow-dialog .dialog-content {
  max-height: 85vh;
  overflow-y: auto;
}

.approval-workflow-dialog .form-group {
  margin-bottom: 1rem;
}

.approval-workflow-dialog .form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #333;
}

.approval-workflow-dialog .form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.approval-workflow-dialog .form-control:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Цепочка согласований */
.chain-step {
  border: 1px solid #ddd;
  padding: 10px;
  margin: 5px 0;
  border-radius: 4px;
  background: #f9f9f9;
}

.chain-step:hover {
  background: #f5f5f5;
}

.chain-step .remove-step {
  padding: 2px 8px;
  font-size: 16px;
  line-height: 1;
}

/* Список полей */
#field_names_list {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 4px;
  background: #fff;
}

#field_names_list label {
  display: block;
  margin: 5px 0;
  font-weight: normal;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 3px;
  transition: background 0.2s;
}

#field_names_list label:hover {
  background: #f0f0f0;
}

#field_names_list input[type="checkbox"] {
  margin-right: 8px;
}

/* ============================================
   REQUEST DIALOG (просмотр запроса)
   ============================================ */
.approval-request-dialog .dialog-content {
  max-height: 85vh;
  overflow-y: auto;
}

.approval-request-dialog .info-table {
  width: 100%;
  border-collapse: collapse;
}

.approval-request-dialog .info-table td {
  padding: 5px;
  border-bottom: 1px solid #f0f0f0;
}

.approval-request-dialog .info-table td:first-child {
  font-weight: 500;
  color: #666;
  width: 150px;
}

/* Изменения */
.changes-section {
  margin-bottom: 20px;
}

.changes-section table {
  width: 100%;
  font-size: 0.9em;
}

.changes-section td {
  padding: 5px;
  vertical-align: top;
}

.changes-section td:first-child {
  font-weight: bold;
  color: #333;
  width: 30%;
}

/* История согласований */
.history-section {
  margin-bottom: 20px;
}

.history-section > div > div {
  padding: 10px;
}

.history-section > div > div:not(:first-child) {
  border-top: 1px solid #eee;
}

/* Комментарии */
.comments-section {
  margin-bottom: 20px;
}

#comments-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  padding: 10px;
  border-radius: 4px;
  background: #fff;
}

#comments-list > div {
  padding: 10px;
  border-bottom: 1px solid #eee;
}

#comments-list > div:last-child {
  border-bottom: none;
}

/* Форма перенаправления */
#redirect-form {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 4px;
}

#redirect-form label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

#redirect-form select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* ============================================
   СПИСКИ (правил и запросов)
   ============================================ */

/* Список правил согласований */
#workflows-list > div {
  border: 1px solid #ddd;
  padding: 10px;
  margin: 10px 0;
  border-radius: 4px;
  background: #fff;
  transition: all 0.2s;
}

#workflows-list > div:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

#workflows-list button[data-action] {
  padding: 4px 8px;
  margin-left: 5px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

#workflows-list button[data-action]:hover {
  background: #f5f5f5;
  transform: scale(1.1);
}

/* Список запросов на согласование */
#requests-list > div {
  border: 1px solid #ddd;
  padding: 15px;
  margin: 10px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  background: #fff;
}

#requests-list > div:hover {
  background: #f5f5f5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Статусные бейджи */
.badge {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 500;
  white-space: nowrap;
}

.badge-warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}

.badge-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #28a745;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #dc3545;
}

.badge-secondary {
  background: #e2e3e5;
  color: #383d41;
  border: 1px solid #6c757d;
}

.badge-info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #17a2b8;
}

/* ============================================
   TOOLTIP TABLE (таблица в подсказке)
   ============================================ */
.tooltip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

.tooltip-table thead {
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tooltip-table th,
.tooltip-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
}

.tooltip-table th {
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
}

.tooltip-table tbody tr:hover {
  background: #f8f9fa;
}

.tooltip-table tfoot {
  background: #f0f8ff;
  font-weight: bold;
}

/* ============================================
   ACTIONS (кнопки действий)
   ============================================ */
.actions-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #e9ecef;
}

.actions-section h3 {
  margin-bottom: 15px;
  font-size: 1.1em;
  color: #333;
}

.actions-section textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
}

.actions-section textarea:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Кнопки действий */
.btn-success {
  background: #28a745;
  color: #fff;
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-success:hover {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-danger {
  background: #dc3545;
  color: #fff;
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #c82333;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-info {
  background: #17a2b8;
  color: #fff;
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-info:hover {
  background: #138496;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}

/* ============================================
   INFO ICON (иконка подсказки)
   ============================================ */
.info-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  background: #2196f3;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  margin-left: 4px;
  cursor: help;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .approval-workflow-dialog .dialog-content,
  .approval-request-dialog .dialog-content {
    width: 95vw;
    max-width: 95vw;
  }

  .approval-request-dialog .info-table td:first-child {
    width: 100px;
    font-size: 0.85em;
  }

  #workflows-list > div,
  #requests-list > div {
    font-size: 0.9em;
  }

  .actions-section > div {
    flex-direction: column;
    gap: 5px !important;
  }

  .actions-section button {
    width: 100%;
  }
}

/* ============================================
   DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
  .approval-workflow-dialog .form-control,
  #field_names_list,
  #comments-list,
  #redirect-form {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
  }

  .chain-step {
    background: #2d2d2d;
    border-color: #444;
  }

  .chain-step:hover {
    background: #333;
  }

  #workflows-list > div,
  #requests-list > div {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }

  #workflows-list > div:hover,
  #requests-list > div:hover {
    background: #333;
  }

  .approval-request-dialog .info-table td {
    border-bottom-color: #444;
  }

  .tooltip-table thead {
    background: #2d2d2d;
  }

  .tooltip-table th,
  .tooltip-table td {
    border-bottom-color: #444;
    color: #e0e0e0;
  }

  .tooltip-table tbody tr:hover {
    background: #333;
  }
}
/* === dialog/duplicates-dialog.css === */
/**
 * duplicates-dialog.css
 * Стили для диалога поиска и объединения дублей
 * 
 * ИСПРАВЛЕНО:
 * - Конфликт .form-group label { display: block } из forms.css
 *   перебивал display: flex у .field-checkbox (label внутри .form-group)
 * - Дублирование стилей .duplicate-group / .field-checkbox в конце файла
 * - Конфликт .radio-group между forms.css и этим файлом
 * - Нативные чекбоксы/радио без стилизации
 * - Обрезка контента внизу модалки
 */

/* ============================================
   STEP CONTAINER
   ============================================ */
.duplicates-step {
  padding: 24px;
  max-width: 100%;
}

.duplicates-step h3 {
  margin: 0 0 20px 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ============================================
   FIELD LIST (Список полей для выбора)
   ============================================ */
.duplicates-step .field-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  background: var(--bg-secondary);
}

/* Scrollbar внутри списка полей */
.duplicates-step .field-list::-webkit-scrollbar {
  width: 6px;
}

.duplicates-step .field-list::-webkit-scrollbar-track {
  background: transparent;
}

.duplicates-step .field-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.duplicates-step .field-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   FIELD CHECKBOX
   
   КРИТИЧНО: .form-group label { display: block } из forms.css
   перебивает display: flex. Используем повышенную специфичность
   через .duplicates-step .field-checkbox
   ============================================ */
/* 
 * КРИТИЧНО: forms.css задаёт .form-group label { display: block }
 * Перебиваем максимальной специфичностью + !important 
 */
.duplicates-step .form-group label.field-checkbox,
.duplicates-step .field-list label.field-checkbox,
.duplicates-step label.field-checkbox {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 0 2px 0 !important;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  user-select: none;
  min-height: 36px;
  width: 100%;
  font-weight: 400 !important;
}

.duplicates-step label.field-checkbox:last-child {
  margin-bottom: 0 !important;
}

.duplicates-step label.field-checkbox:hover {
  background: var(--bg-hover);
}

/* Имя поля */
.duplicates-step .field-checkbox .field-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Fallback если span без класса (чекбоксы "Игнорировать...") */
.duplicates-step .field-checkbox > span {
  white-space: nowrap;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Стилизация чекбоксов */
.duplicates-step .field-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-xs);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin: 0;
  flex-shrink: 0;
}

.duplicates-step .field-checkbox input[type="checkbox"]:hover {
  border-color: var(--primary);
}

.duplicates-step .field-checkbox input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.duplicates-step .field-checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.duplicates-step .field-checkbox input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Тип поля — бейдж справа */
.duplicates-step .field-checkbox .field-type-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  font-family: var(--font-family-mono);
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* Fallback для span без класса (чекбоксы вне field-list) */
.duplicates-step .field-checkbox span:not(.field-name):not(.field-type-badge) {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
  white-space: nowrap;
}

/* ============================================
   RADIO GROUP
   
   Изолируем от forms.css .radio-group через
   .duplicates-step .radio-group
   ============================================ */
.duplicates-step .radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.duplicates-step .radio-group > label,
.duplicates-step .form-group .radio-group > label {
  display: flex !important;  /* перебиваем forms.css */
  flex-wrap: nowrap !important;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 0 !important;
  font-weight: 400 !important;
}

.duplicates-step .radio-group > label:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

/* Выбранный вариант */
.duplicates-step .radio-group > label:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Стилизация радио-кнопок */
.duplicates-step .radio-group input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border-dark);
  border-radius: 50%;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin: 0;
  margin-top: 1px;
  flex-shrink: 0;
}

.duplicates-step .radio-group input[type="radio"]:hover {
  border-color: var(--primary);
}

.duplicates-step .radio-group input[type="radio"]:checked {
  border-color: var(--primary);
  background: var(--bg-primary);
}

.duplicates-step .radio-group input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.duplicates-step .radio-group input[type="radio"]:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Текст внутри радио-вариантов */
.duplicates-step .radio-group strong {
  display: inline;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Описание через тире — в той же строке */
.duplicates-step .radio-group .radio-desc {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ============================================
   FORM GROUPS внутри диалога
   ============================================ */
.duplicates-step .form-group {
  margin-bottom: 20px;
}

.duplicates-step .form-group > label:not(.field-checkbox):not(.radio-group > label) {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

/* ============================================
   THRESHOLD SLIDER (Порог схожести)
   ============================================ */
.duplicates-step #threshold-group {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.duplicates-step #threshold-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 12px 0 8px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.duplicates-step #threshold-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--bg-primary);
  transition: box-shadow var(--transition-fast);
}

.duplicates-step #threshold-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--primary-light);
}

.duplicates-step #threshold-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

.duplicates-step #threshold-value {
  display: inline-block;
  margin-left: 6px;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}

/* ============================================
   STEP 2: BULK ACTIONS PANEL
   ============================================ */
.duplicates-step .bulk-actions-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.duplicates-step .selected-count {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================
   GROUPS LIST (Результаты поиска)
   ============================================ */
.duplicates-step .groups-list {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.duplicates-step .groups-list::-webkit-scrollbar {
  width: 6px;
}

.duplicates-step .groups-list::-webkit-scrollbar-track {
  background: transparent;
}

.duplicates-step .groups-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ============================================
   DUPLICATE GROUP (Карточка группы)
   ============================================ */
.duplicates-step .duplicate-group {
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.duplicates-step .duplicate-group:last-child {
  margin-bottom: 0;
}

.duplicates-step .duplicate-group:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.08);
}

/* Group header с чекбоксом */
.duplicates-step .group-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.duplicates-step .group-header .field-checkbox {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.duplicates-step .group-header .field-checkbox h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.duplicates-step .duplicate-group h4 {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.duplicates-step .duplicate-group .text-muted {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: block;
}

/* ============================================
   GROUP ITEMS (Элементы внутри группы)
   ============================================ */
.duplicates-step .group-items {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duplicates-step .group-item {
  border-left: 3px solid var(--primary);
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.duplicates-step .group-item:hover {
  background: var(--bg-hover);
  transform: translateX(3px);
}

/* Информация о записи */
.duplicates-step .item-info {
  margin-bottom: 10px;
}

.duplicates-step .item-info strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: inline;
}

.duplicates-step .item-info .code {
  display: inline-block;
  margin-left: 10px;
  padding: 1px 7px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-family-mono);
  vertical-align: middle;
}

.duplicates-step .item-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.duplicates-step .item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Поля записи */
.duplicates-step .item-fields {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.duplicates-step .item-fields > div {
  margin-top: 4px;
  padding: 5px 0;
  border-top: 1px solid var(--border-light);
}

.duplicates-step .item-fields > div:first-child {
  border-top: none;
  margin-top: 0;
}

.duplicates-step .item-fields strong {
  color: var(--text-primary);
  font-weight: 500;
  margin-right: 6px;
}

/* ============================================
   GROUP ACTIONS (Кнопки группы)
   ============================================ */
.duplicates-step .group-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
}

/* ============================================
   MASTER SELECT (Выбор главной записи)
   ============================================ */
.duplicates-step #master-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.duplicates-step #master-select:hover {
  border-color: var(--primary);
}

.duplicates-step #master-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   STATES: EMPTY / SUCCESS / ERROR / LOADING
   ============================================ */

/* Нет дублей */
.duplicates-step .empty-state,
.modal-body > .empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--success);
  background: var(--success-light);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--success);
}

.duplicates-step .empty-state {
  font-size: 16px;
  font-weight: 500;
}

/* Успех */
.duplicates-step .success-state,
.modal-body > .success-state {
  text-align: center;
  padding: 60px 24px;
  font-size: 16px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  border-radius: var(--radius-lg);
  border: 2px solid var(--success);
}

/* Ошибка */
.duplicates-step .error,
.modal-body > .error {
  text-align: center;
  padding: 48px 24px;
  font-size: 15px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--danger);
}

/* Загрузка */
.duplicates-step .loading,
.modal-body > .loading {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 15px;
}

.loading .spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: duplicates-spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes duplicates-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .duplicates-step {
    padding: 16px;
  }

  .duplicates-step .group-item {
    padding: 12px;
  }

  .duplicates-step .item-meta {
    flex-direction: column;
    gap: 4px;
  }

  .duplicates-step .group-actions {
    flex-direction: column;
  }

  .duplicates-step .group-actions .btn {
    width: 100%;
    text-align: center;
  }

  .duplicates-step .field-list {
    max-height: 180px;
  }

  .duplicates-step .groups-list {
    max-height: 380px;
  }

  .duplicates-step .bulk-actions-panel {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] .duplicates-step .field-list {
  background: var(--bg-primary);
}

[data-theme="dark"] .duplicates-step .duplicate-group {
  background: var(--bg-secondary);
}

[data-theme="dark"] .duplicates-step .duplicate-group:hover {
  box-shadow: 0 2px 8px rgba(66, 165, 245, 0.12);
}

[data-theme="dark"] .duplicates-step .group-item {
  background: var(--bg-primary);
}

[data-theme="dark"] .duplicates-step .item-info .code {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .duplicates-step .field-checkbox input[type="checkbox"] {
  border-color: var(--border);
}

[data-theme="dark"] .duplicates-step .radio-group input[type="radio"] {
  border-color: var(--border);
}

[data-theme="dark"] .duplicates-step #threshold-slider {
  background: var(--bg-tertiary);
}
/* === dialog/data-migration-dialog.css === */
/**
 * data-migration-dialog.css
 * Стили для диалога миграции данных и конвертации полей в TABLE
 */

/* ============================================
   TABS
   ============================================ */
.migration-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--spacing-4);
  background: var(--bg-secondary);
  padding: 0 var(--spacing-4);
  padding-top: var(--spacing-3);
}

.migration-tab {
  padding: var(--spacing-3) var(--spacing-5);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: var(--transition-base);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.migration-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.migration-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-primary);
}

/* ============================================
   TAB CONTENT
   ============================================ */
.migration-tab-content {
  padding: 0 var(--spacing-4) var(--spacing-4);
}

/* ============================================
   FORMS (наследуют от forms.css)
   ============================================ */
.data-migration-form .form-group,
.convert-fields-form .form-group {
  margin-bottom: var(--spacing-4);
}

.data-migration-form label,
.convert-fields-form label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-2);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

/* ============================================
   FIELDS CHECKLIST
   ============================================ */
.fields-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-3);
  background: var(--bg-secondary);
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding: var(--spacing-2) var(--spacing-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: normal;
}

.checklist-item:hover {
  background: var(--bg-hover);
}

.checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.checklist-item .field-name {
  flex: 1;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

/* ============================================
   FIELD TYPE BADGE
   ============================================ */
.field-type-badge {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 2px var(--spacing-2);
  white-space: nowrap;
  letter-spacing: var(--letter-spacing-wide);
}

/* ============================================
   COLUMNS PREVIEW
   ============================================ */
.columns-preview {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.column-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.column-row:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.column-source {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  min-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-arrow {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.column-row .form-control {
  flex: 1;
  min-width: 0;
  padding: var(--spacing-1) var(--spacing-2);
  font-size: var(--font-size-sm);
  height: 30px;
}

/* ============================================
   PREVIEW SECTION (migrate tab)
   ============================================ */
.preview-section {
  margin-top: var(--spacing-4);
  padding: var(--spacing-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.preview-section h4 {
  margin: 0 0 var(--spacing-3);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.preview-stats {
  display: flex;
  gap: var(--spacing-3);
  flex-wrap: wrap;
}

.preview-stats .stat-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.preview-stats .stat-item strong {
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.preview-stats .stat-item.success {
  border-left: 3px solid var(--success);
}

.preview-stats .stat-item.warning {
  border-left: 3px solid var(--warning);
}

/* ============================================
   ALERT INFO
   ============================================ */
.alert-info {
  padding: var(--spacing-3) var(--spacing-4);
  background: var(--primary-light);
  border: 1px solid var(--primary-lighter);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--primary-hover);
  margin-bottom: var(--spacing-4);
  line-height: var(--line-height-relaxed);
}
/* === dialog/fields-widget-settings.css === */
/**
 * fields-widget-settings.css
 * Стили для диалога настроек виджета полей
 */

/* ============================================
   SETTINGS CONTAINER
   ============================================ */
.fields-widget-settings {
  padding: 4px 0;
}

.fields-widget-settings .section-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 16px 0;
}

/* ============================================
   SCOPE TOGGLE
   ============================================ */
.settings-scope-section {
  margin-bottom: 12px;
}

.scope-toggle {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.scope-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
  font-size: 13px;
}

.scope-option:hover {
  background: var(--bg-hover);
}

.scope-option input[type="radio"] {
  margin: 0;
}

.scope-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.scope-label {
  white-space: nowrap;
}

/* ============================================
   LAYOUT OPTIONS
   ============================================ */
.layout-options {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.layout-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-base);
}

.layout-option:hover {
  border-color: var(--primary-light);
  background: var(--bg-hover);
}

.layout-option.active,
.layout-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.layout-option input[type="radio"] {
  display: none;
}

.layout-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 60px;
  height: 36px;
}

.layout-preview .layout-row {
  display: flex;
  gap: 3px;
  flex: 1;
}

.layout-preview .layout-line {
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.4;
  min-height: 6px;
}

.layout-option.active .layout-line,
.layout-option:has(input:checked) .layout-line {
  background: var(--primary);
  opacity: 0.7;
}

.layout-line.full { width: 100%; flex: 1; }
.layout-line.half { flex: 1; }
.layout-line.third { flex: 1; }

.layout-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.layout-option.active .layout-label,
.layout-option:has(input:checked) .layout-label {
  color: var(--primary);
}

/* ============================================
   TOGGLE ROW (Show empty fields)
   ============================================ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  padding: 4px 0;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* ============================================
   FIELDS TOOLBAR
   ============================================ */
.fields-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.fields-toolbar .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ============================================
   FIELDS ORDER LIST
   ============================================ */
.fields-order-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 380px;
  overflow-y: auto;
}

.fields-order-list::-webkit-scrollbar {
  width: 6px;
}

.fields-order-list::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: 3px;
}

.field-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: grab;
  transition: background 0.15s ease;
  user-select: none;
}

.field-order-row:last-child {
  border-bottom: none;
}

.field-order-row:hover {
  background: var(--bg-hover);
}

.field-order-row.dragging {
  opacity: 0.4;
  background: var(--primary-light);
}

.field-order-row.field-hidden {
  opacity: 0.45;
}

.field-order-row.field-hidden .field-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Drag handle */
.field-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.field-drag-handle:active {
  cursor: grabbing;
}

/* Visibility checkbox */
.field-visibility-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.field-visibility-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* Field type icon */
.field-type-icon {
  flex-shrink: 0;
  font-size: 14px;
  width: 22px;
  text-align: center;
  margin-right: 6px;
}

/* Field name */
.field-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Field key hint */
.field-key-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Drag placeholder */
.field-order-placeholder {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-xs);
  margin: 2px 0;
  transition: height 0.15s ease;
}

/* ============================================
LABEL POSITION OPTIONS
============================================ */
.label-position-options {
display: flex;
gap: 12px;
margin-top: 8px;
}
.label-position-option {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding: 12px;
border: 2px solid var(--border);
border-radius: var(--radius);
cursor: pointer;
transition: var(--transition-base);
}
.label-position-option:hover {
border-color: var(--primary-light);
background: var(--bg-hover);
}
.label-position-option.active,
.label-position-option:has(input:checked) {
border-color: var(--primary);
background: var(--primary-light);
}
.label-position-option input[type="radio"] {
display: none;
}
.label-position-preview {
display: flex;
flex-direction: column;
gap: 4px;
width: 70px;
height: 40px;
}
/* Preview: label-left */
.label-position-preview.preview-left {
flex-direction: row;
align-items: center;
gap: 6px;
}
.label-position-preview.preview-left .preview-label {
width: 24px;
height: 8px;
background: var(--text-muted);
border-radius: 2px;
opacity: 0.5;
}
.label-position-preview.preview-left .preview-value {
flex: 1;
height: 8px;
background: var(--text-muted);
border-radius: 2px;
opacity: 0.3;
}
/* Preview: label-top */
.label-position-preview.preview-top .preview-label {
width: 30px;
height: 6px;
background: var(--text-muted);
border-radius: 2px;
opacity: 0.5;
}
.label-position-preview.preview-top .preview-value {
width: 100%;
height: 10px;
background: var(--text-muted);
border-radius: 2px;
opacity: 0.3;
}
.label-position-label {
font-size: 12px;
color: var(--text-secondary);
font-weight: 500;
}
.label-position-option.active .label-position-label,
.label-position-option:has(input:checked) .label-position-label {
color: var(--primary);
}
/* ============================================
DISPLAY MODE OPTIONS (для TABLE полей)
============================================ */
.display-mode-section {
margin-top: 12px;
padding: 12px;
background: var(--bg-secondary);
border-radius: var(--radius-sm);
border: 1px solid var(--border-light);
}
.display-mode-section h5 {
margin: 0 0 8px 0;
font-size: 12px;
font-weight: 600;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.3px;
}
.display-mode-options {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.display-mode-option {
padding: 6px 12px;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
cursor: pointer;
font-size: 12px;
color: var(--text-secondary);
transition: var(--transition-base);
white-space: nowrap;
}
.display-mode-option:hover {
background: var(--bg-hover);
border-color: var(--text-secondary);
}
.display-mode-option.active {
border-color: var(--primary);
background: var(--primary-light);
color: var(--primary);
font-weight: 600;
}
/* ============================================
RESPONSIVE
============================================ */
@media (max-width: 768px) {
.layout-options {
flex-direction: column;
}
.label-position-options {
flex-direction: column;
}
.scope-toggle {
flex-direction: column;
}
.field-key-hint {
display: none;
}
.display-mode-options {
flex-direction: column;
}
}

/* === dialog/tabs-widget-settings.css === */
/**
 * tabs-widget-settings.css
 * Стили диалога настроек виджета вкладок
 * + кнопка настроек виджета (всегда видна)
 */

/* ============================================
   КНОПКА НАСТРОЕК НА ВИДЖЕТЕ (всегда видна)
   ============================================ */
.tabs-widget-container .widget-settings-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-xs);
}

.tabs-widget-container:hover .widget-settings-btn {
  opacity: 1;
}

.tabs-widget-container .widget-settings-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* В режиме редактирования — всегда видна */
.edit-mode .tabs-widget-container .widget-settings-btn {
  opacity: 1;
}

/* ============================================
   OVERLAY — перебиваем display: none !important
   ============================================ */
.tabs-settings-dialog-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: var(--overlay-bg, rgba(0, 0, 0, 0.5)) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 100000 !important;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.tabs-settings-dialog-overlay.open {
  display: flex !important;
  opacity: 1;
  pointer-events: all;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.tabs-settings-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-xl, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-width: 640px;
  width: 95vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
}

.tabs-settings-dialog-overlay.open .tabs-settings-dialog {
  transform: scale(1) translateY(0);
}

/* ============================================
   HEADER
   ============================================ */
.tabs-settings-dialog .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tabs-settings-dialog .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.tabs-settings-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-base);
  line-height: 1;
}

.tabs-settings-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   SCOPE SWITCHER
   ============================================ */
.tabs-settings-scope-switcher {
  display: flex;
  padding: 12px 20px;
  gap: 4px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tabs-settings-scope-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.tabs-settings-scope-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.tabs-settings-scope-btn.active {
  background: var(--primary);
  color: var(--color-on-primary, white);
  border-color: var(--primary);
}

/* ============================================
   BODY
   ============================================ */
.tabs-settings-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.tabs-settings-content {
  padding: 20px;
}

/* ============================================
   SECTIONS
   ============================================ */
.tabs-settings-section {
  margin-bottom: 20px;
}

.tabs-settings-section:last-child {
  margin-bottom: 0;
}

.tabs-section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ============================================
   FORM FIELDS
   ============================================ */
.tabs-settings-field {
  margin-bottom: 14px;
}

.tabs-settings-field:last-child {
  margin-bottom: 0;
}

.tabs-settings-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tabs-settings-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tabs-settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.tabs-settings-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  cursor: pointer;
  transition: border-color 0.15s;
}

.tabs-settings-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.tabs-settings-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  transition: background 0.15s;
}

.tabs-settings-toggle:hover {
  background: var(--bg-tertiary);
}

.toggle-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 1px;
  background: var(--border);
  transition: background 0.2s;
}

.toggle-switch[aria-checked="true"] {
  background: var(--primary);
}

.toggle-switch .toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 0.2s;
}

.toggle-switch[aria-checked="true"] .toggle-knob {
  left: 20px;
}

.toggle-text {
  flex: 1;
}

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.toggle-description {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   TABS MANAGER (список вкладок)
   ============================================ */
.tabs-manager-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-manager-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tab-manager-row:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-xs);
}

.tab-manager-row.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.tab-manager-row.dragging {
  opacity: 0.4;
}

/* Drag handle */
.tab-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  user-select: none;
  padding: 0 2px;
  flex-shrink: 0;
}

.tab-drag-handle:active {
  cursor: grabbing;
}

/* Icon button */
.tab-icon-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.tab-icon-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Tab name input */
.tab-name-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: transparent;
  color: var(--text-primary);
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}

.tab-name-input:hover {
  background: var(--bg-hover);
}

.tab-name-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Widget count badge */
.tab-widget-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.tab-widget-badge.has-widgets {
  background: var(--primary);
  color: white;
}

/* Delete button */
.tab-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: var(--radius-sm);
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}

.tab-delete-btn:hover {
  opacity: 1;
  background: var(--error-light);
}

.tab-delete-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

/* Add tab button */
.tab-add-btn {
  width: 100%;
  padding: 8px;
  border: 2px dashed var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.tab-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   ICON PICKER
   ============================================ */
.tabs-icon-picker {
  position: fixed;
  z-index: 100001;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 280px;
}

.tabs-icon-picker button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.tabs-icon-picker button:hover {
  background: var(--bg-hover);
}

.tabs-icon-picker .icon-none-btn {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   TAB STYLE OPTIONS
   ============================================ */
.tab-style-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-style-option {
  flex: 1;
  min-width: 80px;
  padding: 10px 8px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tab-style-option:hover {
  border-color: var(--primary-light);
  background: var(--bg-hover);
}

.tab-style-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.tab-style-preview {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 20px;
}

/* Standard preview */
.tab-style-preview .preview-tab-standard {
  width: 18px;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  background: var(--bg-secondary);
  border-bottom: none;
}

.tab-style-preview .preview-tab-standard.active-tab {
  background: var(--primary);
  border-color: var(--primary);
}

/* Pills preview */
.tab-style-preview .preview-tab-pills {
  width: 18px;
  height: 12px;
  border-radius: 6px;
  background: var(--bg-secondary);
}

.tab-style-preview .preview-tab-pills.active-tab {
  background: var(--primary);
}

/* Underline preview */
.tab-style-preview .preview-tab-underline {
  width: 18px;
  height: 14px;
  border-bottom: 2px solid transparent;
  background: transparent;
}

.tab-style-preview .preview-tab-underline.active-tab {
  border-bottom-color: var(--primary);
}

.tab-style-label {
  font-weight: 500;
  color: var(--text-primary);
}

.tab-style-option.active .tab-style-label {
  color: var(--primary);
}

/* ============================================
   INFO BANNER
   ============================================ */
.tabs-settings-info {
  padding: 10px 14px;
  background: var(--info-light);
  border: 1px solid var(--primary-lighter, #bfdbfe);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--primary-hover, #1e40af);
}

/* ============================================
   RESET BUTTON
   ============================================ */
.tabs-settings-reset-btn {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid var(--danger, #ef4444);
  color: var(--danger, #ef4444);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.tabs-settings-reset-btn:hover {
  background: var(--danger-light);
}

/* ============================================
   FOOTER
   ============================================ */
.tabs-settings-dialog .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tabs-settings-dialog .btn-cancel {
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.tabs-settings-dialog .btn-cancel:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
}

.tabs-settings-dialog .btn-save {
  padding: 8px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.tabs-settings-dialog .btn-save:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] .tabs-settings-dialog {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .tab-manager-row {
  background: var(--bg-secondary);
}

[data-theme="dark"] .tab-name-input:focus {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .tabs-icon-picker {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .tab-style-option {
  background: var(--bg-secondary);
}

[data-theme="dark"] .tabs-settings-info {
  background: var(--info-light);
  border-color: var(--border);
  color: var(--info, var(--primary));
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 768px) {
  .tabs-settings-dialog-overlay.open {
    align-items: flex-end !important;
  }

  .tabs-settings-dialog {
    max-width: 100vw;
    width: 100vw;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
    transform: translateY(100%);
  }

  .tabs-settings-dialog-overlay.open .tabs-settings-dialog {
    transform: translateY(0);
  }

  .tabs-settings-content {
    padding: 16px;
  }

  .tabs-settings-scope-switcher {
    padding: 10px 16px;
  }

  .tabs-settings-dialog .modal-header {
    padding: 14px 16px;
  }

  .tabs-settings-dialog .modal-footer {
    padding: 12px 16px;
  }

  .tab-style-options {
    flex-direction: column;
  }

  .tab-style-option {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
  }

  .tabs-icon-picker {
    width: calc(100vw - 32px);
    left: 16px !important;
    grid-template-columns: repeat(8, 1fr);
  }

  /* Drag handle скрыт — переключение на кнопки */
  .tab-drag-handle {
    display: none;
  }
}

/* ============================================
   RESPONSIVE — SMALL MOBILE
   ============================================ */
@media (max-width: 380px) {
  .tabs-icon-picker {
    grid-template-columns: repeat(6, 1fr);
  }

  .tabs-settings-scope-switcher {
    flex-direction: column;
    gap: 6px;
  }
}
/* === dialog/handbooks-widget-settings.css === */
/**
 * handbooks-widget-settings.css
 * Стили диалога настроек виджета списка справочников
 * Классы синхронизированы с WidgetHandbooksConfigDialog.js
 */

/* ============================================
   OVERLAY
   ============================================ */
.hb-config-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg, rgba(0, 0, 0, 0.5));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.hb-config-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ============================================
   DIALOG
   ============================================ */
.hb-config-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-xl, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-width: 640px;
  width: 95vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
}

.hb-config-overlay.open .hb-config-dialog {
  transform: scale(1) translateY(0);
}

/* ============================================
   HEADER
   ============================================ */
.hb-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hb-config-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.hb-config-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-base);
  line-height: 1;
}

.hb-config-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   SCOPE SWITCHER
   ============================================ */
.hb-config-scope-switcher {
  display: flex;
  padding: 12px 20px;
  gap: 4px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hb-config-scope-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.hb-config-scope-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.hb-config-scope-btn.active {
  background: var(--primary);
  color: var(--color-on-primary, white);
  border-color: var(--primary);
}

/* ============================================
   BODY
   ============================================ */
.hb-config-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.hb-config-body::-webkit-scrollbar {
  width: 6px;
}

.hb-config-body::-webkit-scrollbar-track {
  background: transparent;
}

.hb-config-body::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: 3px;
}

.hb-config-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-400);
}

.hb-config-content {
  padding: 20px;
}

/* ============================================
   FOOTER
   ============================================ */
.hb-config-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.hb-config-btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-base);
}

.hb-config-btn-cancel {
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.hb-config-btn-cancel:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
}

.hb-config-btn-save {
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm);
}

.hb-config-btn-save:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ============================================
   SECTIONS
   ============================================ */
.hb-config-section {
  margin-bottom: 20px;
}

.hb-config-section:last-child {
  margin-bottom: 0;
}

.hb-config-section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ============================================
   FIELDS
   ============================================ */
.hb-config-field {
  margin-bottom: 14px;
}

.hb-config-field:last-child {
  margin-bottom: 0;
}

.hb-config-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.hb-config-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-sizing: border-box;
}

.hb-config-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.hb-config-input::placeholder {
  color: var(--text-muted);
}

.hb-config-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  cursor: pointer;
  transition: border-color 0.15s;
  outline: none;
  min-width: 0;
}

.hb-config-select.full {
  width: 100%;
}

.hb-config-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   HINT / INFO
   ============================================ */
.hb-config-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

.hb-config-info {
  padding: 10px 14px;
  background: var(--info-light);
  border: 1px solid var(--primary-lighter, #bbdefb);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--primary-hover);
  line-height: 1.4;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.hb-config-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  transition: background 0.15s;
}

.hb-config-toggle:hover {
  background: var(--bg-tertiary);
}

.hb-config-toggle-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 1px;
  background: var(--border);
  transition: background 0.2s;
  padding: 0;
}

.hb-config-toggle-switch.on {
  background: var(--primary);
}

.hb-config-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 0.2s;
  pointer-events: none;
}

.hb-config-toggle-switch.on .hb-config-toggle-knob {
  left: 20px;
}

.hb-config-toggle-text {
  flex: 1;
  min-width: 0;
}

.hb-config-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  line-height: 1.4;
}

.hb-config-toggle-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* ============================================
   RADIO GROUP (handbooks filter mode)
   ============================================ */
.hb-config-radio-group {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.hb-config-radio-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}

.hb-config-radio-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.hb-config-radio-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.hb-config-radio-option input[type="radio"] {
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.hb-config-radio-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--text-primary);
}

/* ============================================
   CHECKLIST (handbooks list, custom fields)
   ============================================ */
.hb-config-checklist {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 4px;
}

.hb-config-checklist-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.hb-config-checklist-search .hb-config-input {
  font-size: 13px;
  padding: 6px 10px;
}

.hb-config-checklist-items {
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hb-config-checklist-items::-webkit-scrollbar {
  width: 5px;
}

.hb-config-checklist-items::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: 3px;
}

.hb-config-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}

.hb-config-checklist-item:last-child {
  border-bottom: none;
}

.hb-config-checklist-item:hover {
  background: var(--bg-hover);
}

.hb-config-checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.hb-config-checklist-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 500;
}

.hb-config-checklist-sub {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-family-mono, monospace);
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

.hb-config-checklist-actions {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

/* Compact вариант (custom fields) */
.hb-config-checklist.compact .hb-config-checklist-items {
  max-height: 200px;
}

.hb-config-checklist.compact .hb-config-checklist-item {
  padding: 6px 12px;
}

/* ============================================
   TEXT BUTTON (select all / deselect all)
   ============================================ */
.hb-config-btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.hb-config-btn-text:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

/* ============================================
   VIEW MODE PICKER (grid / list / compact)
   ============================================ */
.hb-config-view-picker {
  display: flex;
  gap: 8px;
}

.hb-config-view-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.hb-config-view-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.hb-config-view-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.hb-config-view-icon {
  font-size: 22px;
  line-height: 1;
}

.hb-config-view-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.hb-config-view-option.active .hb-config-view-label {
  color: var(--primary);
}

/* ============================================
   SORT ROW (select + direction button)
   ============================================ */
.hb-config-sort-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.hb-config-sort-row .hb-config-select {
  flex: 1;
  min-width: 0;
}

.hb-config-sort-dir-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.hb-config-sort-dir-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================
   ORDER LIST (drag & drop)
   ============================================ */
.hb-config-order-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hb-config-order-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  user-select: none;
}

.hb-config-order-item:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-xs);
}

.hb-config-order-item.dragging {
  opacity: 0.35;
}

.hb-config-order-item.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Touch drag clone */
.hb-config-order-item.dragging-clone {
  opacity: 0.85;
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  background: var(--bg-primary);
}

.hb-config-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
  touch-action: none;
}

.hb-config-drag-handle:active {
  cursor: grabbing;
}

.hb-config-order-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hb-config-order-badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ============================================
   RESET BUTTON
   ============================================ */
.hb-config-reset-btn {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.hb-config-reset-btn:hover {
  background: var(--danger-light);
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] .hb-config-dialog {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .hb-config-scope-btn {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-scope-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}

[data-theme="dark"] .hb-config-toggle {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .hb-config-toggle:hover {
  background: var(--bg-active);
}

[data-theme="dark"] .hb-config-radio-option {
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-radio-option:hover,
[data-theme="dark"] .hb-config-radio-option.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

[data-theme="dark"] .hb-config-checklist {
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-checklist-search {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .hb-config-checklist-actions {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .hb-config-checklist-sub {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .hb-config-view-option {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-view-option:hover,
[data-theme="dark"] .hb-config-view-option.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

[data-theme="dark"] .hb-config-order-item {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-order-item:hover {
  border-color: var(--border-dark);
}

[data-theme="dark"] .hb-config-order-item.dragging-clone {
  background: var(--bg-secondary);
}

[data-theme="dark"] .hb-config-order-badge {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .hb-config-sort-dir-btn {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .hb-config-info {
  background: var(--info-light);
  border-color: var(--border);
  color: var(--info);
}

[data-theme="dark"] .hb-config-body::-webkit-scrollbar-thumb,
[data-theme="dark"] .hb-config-checklist-items::-webkit-scrollbar-thumb {
  background: var(--color-gray-600);
}

/* ============================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
  /* Bottom sheet */
  .hb-config-overlay.open {
    align-items: flex-end;
  }

  .hb-config-dialog {
    max-width: 100vw;
    width: 100vw;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
    transform: translateY(100%);
  }

  .hb-config-overlay.open .hb-config-dialog {
    transform: translateY(0);
  }

  .hb-config-header {
    padding: 14px 16px;
  }

  .hb-config-header h3 {
    font-size: 15px;
  }

  .hb-config-content {
    padding: 16px;
  }

  .hb-config-scope-switcher {
    padding: 10px 16px;
  }

  .hb-config-footer {
    padding: 12px 16px;
  }

  /* Radio group: stack */
  .hb-config-radio-group {
    flex-direction: column;
    gap: 4px;
  }

  .hb-config-radio-option {
    padding: 10px;
  }

  /* View picker: все в ряд, компактнее */
  .hb-config-view-picker {
    gap: 6px;
  }

  .hb-config-view-option {
    padding: 10px 6px;
  }

  .hb-config-view-icon {
    font-size: 20px;
  }

  .hb-config-view-label {
    font-size: 11px;
  }

  /* Sort row: stack */
  .hb-config-sort-row {
    flex-direction: column;
  }

  .hb-config-sort-row .hb-config-select {
    width: 100%;
  }

  .hb-config-sort-dir-btn {
    width: 100%;
    text-align: center;
  }

  /* Select: prevent iOS zoom */
  .hb-config-select,
  .hb-config-input {
    font-size: 16px;
    min-height: 40px;
  }

  /* Touch targets */
  .hb-config-checklist-item {
    padding: 10px 12px;
    min-height: 44px;
  }

  .hb-config-checklist-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .hb-config-order-item {
    padding: 10px;
    min-height: 44px;
  }

  /* Drag handle: bigger touch area */
  .hb-config-drag-handle {
    font-size: 20px;
    padding: 4px 6px;
  }

  /* Footer buttons: full width */
  .hb-config-footer {
    flex-direction: column-reverse;
  }

  .hb-config-btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================
   RESPONSIVE — SMALL MOBILE (≤380px)
   ============================================ */
@media (max-width: 380px) {
  .hb-config-scope-switcher {
    flex-direction: column;
    gap: 4px;
  }

  .hb-config-view-picker {
    flex-wrap: wrap;
  }

  .hb-config-view-option {
    min-width: calc(50% - 4px);
  }
}

/* ============================================
   PRINT — скрыть диалог
   ============================================ */
@media print {
  .hb-config-overlay {
    display: none !important;
  }
}


/* ============================================
   WIDGETS (виджеты GridStack)
   ============================================ */
/* Базовые виджеты */
/* === widgets/gridstack.css === */
/**
 * gridstack.css
 * Базовые стили виджетов GridStack
 */

/* ============================================
   GRIDSTACK BASE
   ============================================ */
.grid-stack {
  background: transparent;
  min-height: 400px;
}

.grid-stack-item {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 200px;
  min-height: 150px;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
  padding: 40px;
}

.grid-stack-item > .grid-stack-item-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ============================================
   WIDGET CONTAINER (внутри grid-stack-item-content)
   ============================================ */
.widget-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ============================================
   WIDGET HEADER
   ============================================ */
.widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  min-height: 48px;
}

.widget-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.widget-actions {
  display: none;
  gap: 4px;
  align-items: center;
}

.widget-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  opacity: 0.7;
  color: var(--text-secondary);
}

.widget-action-btn:hover {
  opacity: 1;
  background: var(--bg-hover);
}

/* ============================================
   WIDGET BODY/CONTENT
   ============================================ */
.widget-body,
.widget-content {
flex: 1;
min-height: 0;
padding: 16px;
overflow-y: auto;
overflow-x: hidden;
}

/* Fields widget управляет своим padding сам */
.widget-content:has(> .fields-widget) {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget-content::-webkit-scrollbar {
  width: 8px;
}

.widget-content::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--radius-sm);
}

.widget-content::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
}

.widget-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   GRID PLACEHOLDER
   ============================================ */
.grid-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.grid-placeholder-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.grid-placeholder-text {
  font-size: 18px;
  font-weight: 500;
}

/* ============================================
   EDIT MODE
   ============================================ */
.edit-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--warning);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  margin-left: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.edit-mode .grid-stack-item {
  border: 2px dashed var(--primary);
}

.edit-mode .grid-stack-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.edit-mode .grid-stack-item > .ui-resizable-handle {
  display: block;
}

.edit-mode .grid-stack-item-content {
  border: 2px dashed transparent;
  transition: border-color 0.2s;
}

.edit-mode .grid-stack-item:hover .grid-stack-item-content {
  border-color: var(--primary);
}

.edit-mode .grid-stack-item.ui-draggable-dragging .grid-stack-item-content,
.edit-mode .grid-stack-item.ui-resizable-resizing .grid-stack-item-content {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.edit-mode .widget-header {
  background: var(--primary-light);
  cursor: move;
}

.edit-mode .widget-actions {
  display: flex;
}

/* Кнопка настроек виджета полей видна всегда */
.fields-widget-settings-btn {
  display: flex !important;
}

/* Кнопка настроек виджета вкладок видна всегда */
.tabs-widget-settings-btn {
  display: flex !important;
}

/* Кнопка настроек виджета списка справочников видна всегда */
.handbooks-list-widget-container .widget-actions {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.handbooks-widget-settings-btn {
  display: flex !important;
}
/* ============================================
   RESIZE HANDLES (скрыты по умолчанию)
   ============================================ */
.grid-stack-item > .ui-resizable-handle {
  display: none;
}

/* ============================================
   WIDGETS PALETTE (панель виджетов)
   ============================================ */
/* Палитра виджетов перенесена в settings-sidebar (handbook-items.css) */

/* ============================================
   WIDGET CONFIG FORM (общие стили)
   ============================================ */
.widget-config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.widget-config-form h4 {
  margin: 16px 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.info-message {
  padding: 12px;
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  color: var(--color-yellow-900);
  font-size: 13px;
}

/* ============================================
   LOCATION SELECTOR (где разместить виджет)
   ============================================ */
.location-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
}

.location-option {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.location-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.location-option input[type="radio"] {
  margin-right: 10px;
}

.location-option input[type="radio"]:checked + .location-label {
  font-weight: 600;
  color: var(--primary);
}

.location-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.location-icon {
  font-size: 18px;
  color: var(--text-secondary);
}

.location-text {
  flex: 1;
  color: var(--text-primary);
}

.location-position {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: normal;
}

.location-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.location-option-nested {
  margin-left: 32px;
  padding: 8px 12px;
}

.location-tabs-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.location-tabs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--primary);
}

.location-tabs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ============================================
   SECTION WIDGETS (специальная подсветка)
   ============================================ */
#widget-in-selected-section,
#widget-in-current-section {
  padding: 20px;
  background: linear-gradient(135deg, var(--color-blue-50) 0%, var(--color-blue-100) 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

#widget-in-selected-section h3,
#widget-in-current-section h3 {
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#widget-in-selected-section .section-description,
#widget-in-current-section .section-description {
  color: var(--primary-hover);
  margin-bottom: 20px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {

  #widget-in-selected-section,
  #widget-in-current-section {
    padding: 16px;
  }
}
/* === widgets/fields-widget.css === */
/**
 * fields-widget.css
 * Виджет панели полей — v2.0
 * 
 * Поддержка:
 * - Настраиваемое положение label (left / top)
 * - Высота ячеек: 3 строки по умолчанию, настраиваемая
 * - TABLE/labeled_multiple: 3 режима (compact / inline / expanded)
 * - Адаптивность: ПК + мобилка
 * - Dark mode через CSS variables
 */

/* ============================================
   FIELDS WIDGET — BASE
   ============================================ */
.fields-widget {
  height: 100%;
  min-height: 0; /* важно для overflow во вложенных flex/grid */
  padding: 0 !important;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  /* чтобы ширина не “плавала” при скролле */
  scrollbar-gutter: stable;
}

.fields-widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fields-widget-search {
  margin-bottom: 12px;
}

.fields-widget-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.fields-widget-actions {
  display: flex;
  gap: 8px;
}

.fields-widget-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.fields-widget-body::-webkit-scrollbar {
  width: 6px;
}

.fields-widget-body::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.fields-widget-body::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.fields-widget-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Fields widget внутри widget-content — убрать лишний padding */
.widget-content:has(> .fields-widget) {
  padding: 0;
  overflow: hidden;
}

/* ============================================
   FIX: правильная цепочка высот для скролла
   (работает даже если fields-widget внутри grid-stack)
   ============================================ */

/* Хост-класс ставим из JS (см. правку ниже) */
.fields-widget-host {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* критично для скролла во flex/grid родителях */
}

/* Контент должен уметь сжиматься, иначе overflow у детей не работает */
.fields-widget-host > .widget-content {
  flex: 1 1 auto;
  min-height: 0;       /* критично */
  padding: 0 !important;
  overflow: hidden;    /* скролл будет у .fields-widget */
}

/* Сам скролл-контейнер */
.fields-widget-host > .widget-content > .fields-widget {
  flex: 1 1 auto;
  min-height: 0;       /* критично */
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;

  /* чтобы ширина не прыгала при появлении/исчезновении скролла */
  scrollbar-gutter: stable;
}


/* ============================================
   FIELDS LIST
   ============================================ */
.fields-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ============================================
   FIELD ITEM — BASE (label-left по умолчанию)
   ============================================ */
.field-item {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
  display: grid;
  grid-template-columns: minmax(60px, 130px) 1fr;
  gap: 8px;
  align-items: start;
  min-height: 32px;
  position: relative;
  box-sizing: border-box;
}

.field-item:hover {
  background: var(--bg-hover);
  z-index: 5;
}

.field-item:last-child {
  border-bottom: none;
}

.field-item-dragging {
  opacity: 0.5;
  background: var(--primary-light);
}

/* ============================================
   LABEL POSITION: TOP (label над value)
   ============================================ */
.fields-widget.label-top .field-item {
  grid-template-columns: 1fr;
  gap: 2px;
}

.fields-widget.label-top .field-label {
  padding-bottom: 2px;
}

/* ============================================
   FIELD INFO
   ============================================ */
.field-info {
  flex: 1;
  min-width: 0;
}

/* ============================================
   FIELD LABEL
   ============================================ */
.field-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
  padding-top: 4px;
  user-select: none;
}

.field-code {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ============================================
   FIELD VALUE — 3 строки по умолчанию
   ============================================ */
/* ============================================
   FIELD VALUE — БАЗОВЫЕ СТИЛИ
   Используем max-height + overflow (НЕ line-clamp),
   потому что line-clamp ломает DOM-элементы (badges, chips, inline-edit).
   По умолчанию: 3 строки.
   ============================================ */
.field-value {
  display: block;
  overflow: hidden;
  min-height: 28px;
  max-height: 78px; /* 3 строки: 13px * 1.5 * 3 ≈ 58.5 + запас на chips/badges */
  cursor: default;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  transition: none;
  position: relative;
}

/* Индикатор обрезки — градиент внизу когда контент обрезан */
.field-value::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(transparent, var(--bg-primary));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

/* Показывать градиент только когда контент overflow */
.field-value:not(.empty):not([style*="max-height: none"]) {
  /* JS добавит .truncated когда scrollHeight > clientHeight */
}

.field-value.truncated::after {
  opacity: 1;
}

.field-value::-webkit-scrollbar {
  width: 3px;
}

.field-value::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: 2px;
}

.field-value::-webkit-scrollbar-track {
  background: transparent;
}

/* Пустое значение */
.field-value.empty {
  color: var(--text-disabled);
  font-style: italic;
  min-height: 20px;
  max-height: none;
  overflow: visible;
}

.field-value.empty::after {
  display: none;
}

/* Inline-editable обёртка из FieldValueRenderer — сделать block
   чтобы max-height на .field-value корректно обрезал контент */
.field-value .inline-editable {
  display: block;
  min-width: 0;
}

/* Контейнер множественных значений — flex-wrap для chips */
.field-value .multiple-values-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
  min-height: 0;
  padding: 2px 0;
}

/* Labeled multiple preview — не обрезать */
.field-value .labeled-multiple-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
}

/* === HOVER EXPANSION через JS (класс .hover-expanded) === */
.field-value.hover-expanded {
  max-height: 240px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  z-index: 10;
  position: relative;
  background: var(--bg-primary, #fff);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: max-height 0.2s ease, box-shadow 0.2s ease;
}

.field-value.hover-expanded::-webkit-scrollbar {
  width: 4px;
}

.field-value.hover-expanded::-webkit-scrollbar-thumb {
  background: var(--color-gray-400, #9ca3af);
  border-radius: 2px;
}

.field-value.hover-expanded::-webkit-scrollbar-track {
  background: transparent;
}

.field-value.hover-expanded::after {
  opacity: 0 !important;
}

/* ============================================
   FIELD VALUE — НАСТРАИВАЕМАЯ ВЫСОТА
   data-lines="1" | "2" | "3" | "4" | "5" | "full" | "auto"
   ============================================ */
.field-item[data-lines="1"] .field-value {
  max-height: 26px !important;
}

.field-item[data-lines="2"] .field-value {
  max-height: 52px !important;
}

.field-item[data-lines="3"] .field-value {
  max-height: 78px !important;
}

.field-item[data-lines="4"] .field-value {
  max-height: 104px !important;
}

.field-item[data-lines="5"] .field-value {
  max-height: 130px !important;
}

.field-item[data-lines="full"] .field-value {
  max-height: 500px !important;
  overflow-y: auto !important;
}

.field-item[data-lines="auto"] .field-value {
  max-height: none !important;
  overflow: visible !important;
}

/* ============================================
   TABLE & IMAGE — ИСКЛЮЧЕНИЯ (не обрезать)
   ============================================ */
/* TABLE & IMAGE — по умолчанию не обрезать,
   но НЕ мешать пользовательской высоте (data-lines) */
.field-item[data-type="TABLE"]:not([data-lines]) .field-value,
.field-item[data-type="IMAGE"]:not([data-lines]) .field-value {
  display: block;
  -webkit-line-clamp: unset;
  max-height: none;
  overflow: visible;
}

/* ============================================
   TABLE / LABELED_MULTIPLE — DISPLAY MODES
   data-display-mode="compact" | "inline" | "expanded"
   ============================================ */

/* --- COMPACT: текст-ссылка + tooltip по hover (TABLE и LABELED_MULTIPLE) --- */
.field-item[data-type="TABLE"][data-display-mode="compact"] .field-value,
.field-item[data-display-mode="compact"] .field-value:has(.labeled-multiple-preview),
.field-item[data-display-mode="compact"] .field-value:has(.table-preview-text) {
  display: flex !important;
  align-items: center;
  max-height: none !important;
  overflow: visible !important;
}

/* --- INLINE: мини-таблица внутри ячейки со скроллом --- */
.field-item[data-display-mode="inline"] .field-value {
  display: block !important;
  -webkit-line-clamp: unset;
  max-height: 180px !important;
  overflow: auto !important;
  overscroll-behavior: contain;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0;
}

.field-item[data-display-mode="inline"] .field-value .inline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.field-item[data-display-mode="inline"] .field-value .inline-table th {
  padding: 4px 8px;
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.field-item[data-display-mode="inline"] .field-value .inline-table td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-item[data-display-mode="inline"] .field-value .inline-table tbody tr:hover td {
  background: var(--bg-hover);
}

.field-item[data-display-mode="inline"] .field-value .inline-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- EXPANDED: таблица на полную ширину строки --- */
.field-item[data-display-mode="expanded"] {
  grid-column: 1 / -1 !important;
}

.field-item[data-display-mode="expanded"] .field-value {
  display: block !important;
  -webkit-line-clamp: unset;
  max-height: 400px !important;
  overflow: auto !important;
  overscroll-behavior: contain;
}

.field-item[data-display-mode="expanded"] .field-value .inline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.field-item[data-display-mode="expanded"] .field-value .inline-table th {
  padding: 8px 12px;
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.field-item[data-display-mode="expanded"] .field-value .inline-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  max-width: 300px;
  word-break: break-word;
}

.field-item[data-display-mode="expanded"] .field-value .inline-table tbody tr:hover td {
  background: var(--bg-hover);
}

.field-item[data-display-mode="expanded"] .field-value .inline-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   FIELD TYPE BADGE
   ============================================ */
.field-type-badge {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.field-actions {
  display: flex;
  gap: 4px;
}

/* ============================================
   FIELD GROUPS
   ============================================ */
.field-group {
  margin-bottom: 0;
}

.field-group-header {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-group-header:hover {
  background: var(--bg-hover);
}

.field-group-toggle {
  font-size: 10px;
  transition: transform 0.2s;
}

.field-group.collapsed .field-group-toggle {
  transform: rotate(-90deg);
}

.field-group.collapsed .field-group-items {
  display: none;
}

.field-group-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.fields-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.fields-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.fields-empty-text {
  font-size: 14px;
}

/* ============================================
   FIELD TYPE INDICATORS
   ============================================ */
.field-type-text { background: var(--primary-light); color: var(--primary); }
.field-type-number { background: var(--warning-light); color: var(--warning); }
.field-type-date { background: var(--color-purple-100); color: var(--color-purple-700); }
.field-type-boolean { background: var(--success-light); color: var(--success); }
.field-type-select { background: var(--color-pink-100); color: var(--color-pink-700); }
.field-type-multiple { background: var(--color-teal-100); color: var(--color-teal-700); }
.field-type-handbook { background: var(--color-yellow-100); color: var(--color-yellow-700); }
.field-type-file { background: var(--color-purple-100); color: var(--color-purple-700); }

/* ============================================
   ADD FIELD BUTTON
   ============================================ */
.add-field-btn {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}

.add-field-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   COLUMN LAYOUTS (12-column grid)
   ============================================ */

/* === 1 Column === */
.fields-widget.layout-1-column {
  display: flex;
  flex-direction: column;
}

/* === 2 Columns === */
.fields-widget.layout-2-column {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  align-items: start;
}

.fields-widget.layout-2-column .field-item {
  grid-column: span 6;
  border-right: 1px solid var(--border-light);
}

.fields-widget.layout-2-column .field-item:nth-child(2n) {
  border-right: none;
}

/* === 3 Columns === */
.fields-widget.layout-3-column {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  align-items: start;
}

.fields-widget.layout-3-column .field-item {
  grid-column: span 4;
  border-right: 1px solid var(--border-light);
}

.fields-widget.layout-3-column .field-item:nth-child(3n) {
  border-right: none;
}

/* === Grid Layout === */
.fields-widget.layout-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  align-items: start;
}

.fields-widget.layout-grid .field-item {
  grid-column: span 6; /* default: half width */
}

/* ============================================
   GRID SPAN OVERRIDES (data-span)
   ============================================ */
.fields-widget.layout-grid .field-item[data-span="1"],
.fields-widget.layout-2-column .field-item[data-span="1"],
.fields-widget.layout-3-column .field-item[data-span="1"]  { grid-column: span 1 !important; }

.fields-widget.layout-grid .field-item[data-span="2"],
.fields-widget.layout-2-column .field-item[data-span="2"],
.fields-widget.layout-3-column .field-item[data-span="2"]  { grid-column: span 2 !important; }

.fields-widget.layout-grid .field-item[data-span="3"],
.fields-widget.layout-2-column .field-item[data-span="3"],
.fields-widget.layout-3-column .field-item[data-span="3"]  { grid-column: span 3 !important; }

.fields-widget.layout-grid .field-item[data-span="4"],
.fields-widget.layout-2-column .field-item[data-span="4"],
.fields-widget.layout-3-column .field-item[data-span="4"]  { grid-column: span 4 !important; }

.fields-widget.layout-grid .field-item[data-span="6"],
.fields-widget.layout-2-column .field-item[data-span="6"],
.fields-widget.layout-3-column .field-item[data-span="6"]  { grid-column: span 6 !important; }

.fields-widget.layout-grid .field-item[data-span="9"],
.fields-widget.layout-2-column .field-item[data-span="9"],
.fields-widget.layout-3-column .field-item[data-span="9"]  { grid-column: span 9 !important; }

.fields-widget.layout-grid .field-item[data-span="12"],
.fields-widget.layout-2-column .field-item[data-span="12"],
.fields-widget.layout-3-column .field-item[data-span="12"] { grid-column: span 12 !important; }

/* ============================================
   FIELD SPAN CONTEXT MENU
   ============================================ */
.field-span-menu {
  position: fixed;
  z-index: var(--z-popover, 10060);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 200px;
  max-width: 260px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  animation: fieldMenuFadeIn 0.15s ease;
}

@keyframes fieldMenuFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.field-span-menu-section-label {
  padding: 6px 16px 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-span-menu-item {
  padding: 7px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-span-menu-item:hover {
  background: var(--bg-hover);
}

.field-span-menu-item.active {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary);
}

.field-span-menu-item .menu-check {
  font-size: 11px;
  color: var(--primary);
}

.field-span-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.field-span-menu-scope {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}

.field-span-menu-scope button {
  flex: 1;
  padding: 7px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.field-span-menu-scope button:first-child {
  border-radius: var(--radius-lg) 0 0 0;
}

.field-span-menu-scope button:last-child {
  border-radius: 0 var(--radius-lg) 0 0;
}

.field-span-menu-scope button.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   IMAGE FIELD PREVIEW
   ============================================ */
.image-field-preview {
  display: inline-block;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  line-height: 0;
}

.image-field-preview img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: block;
}

.image-field-preview:hover img {
  transform: scale(1.03);
  box-shadow: var(--shadow-md);
}

/* ============================================
   IMAGE LIGHTBOX
   ============================================ */
.fields-image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: var(--z-modal, 10050);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  animation: lightboxFadeIn 0.2s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@keyframes lightboxFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fields-image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  cursor: default;
  animation: lightboxZoomIn 0.25s ease;
}

@keyframes lightboxZoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.fields-image-lightbox .lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 24px;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.fields-image-lightbox .lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   TOOLTIPS — labeled_multiple и TABLE (compact mode)
   Элементы добавляются в document.body через JS
   ============================================ */
.labeled-tooltip,
.table-tooltip {
  position: fixed;
  z-index: 10070;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0;
  min-width: 200px;
  max-width: 600px;
  max-height: 400px;
  overflow: auto;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(4px);
  pointer-events: none;
}

.labeled-tooltip.visible,
.table-tooltip[style*="display: block"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Принудительно для table-tooltip (не использует .visible класс) */
.table-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.table-tooltip[style*="display: none"] {
  opacity: 0;
  pointer-events: none;
}

/* Таблица внутри tooltip */
.tooltip-table {
  width: 100%;
  border-collapse: collapse;
}

.tooltip-table th {
  padding: 8px 12px;
  background: var(--bg-secondary, #f9fafb);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted, #6b7280);
  border-bottom: 2px solid var(--border, #e5e7eb);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tooltip-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
  color: var(--text-primary, #1f2937);
}

.tooltip-table tbody tr:hover td {
  background: var(--bg-hover, #f3f4f6);
}

.tooltip-table tbody tr:last-child td {
  border-bottom: none;
}

/* Info icon в превью labeled */
.labeled-preview-text .info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-light, #eff6ff);
  color: var(--primary, #1a73e8);
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

@media (max-width: 768px) {
  .labeled-tooltip,
  .table-tooltip {
    max-width: calc(100vw - 16px);
    max-height: 45vh;
    left: 8px !important;
    right: 8px !important;
    border-radius: 12px;
  }
}

/* ============================================
   TABLE PREVIEW TEXT (compact mode)
   ============================================ */
.field-item[data-type="TABLE"] .table-preview-text,
.field-item[data-type="LABELED_MULTIPLE"] .table-preview-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  white-space: nowrap;
  font-weight: 500;
}

.field-item[data-type="TABLE"] .table-preview-text:hover,
.field-item[data-type="LABELED_MULTIPLE"] .table-preview-text:hover {
  background: var(--primary-light);
}

/* ============================================
   EDIT MODE — LABEL CURSOR
   ============================================ */
.fields-widget.edit-mode-active .field-label {
  cursor: context-menu;
  transition: color var(--transition-fast);
}

.fields-widget.edit-mode-active .field-label:hover {
  color: var(--primary);
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 768px) {
  /* На мобилке — label всегда сверху для экономии места */
  .field-item {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 12px;
    min-height: 44px; /* touch target */
  }

  .field-label {
    font-size: 10px;
    padding-bottom: 2px;
    padding-top: 0;
  }

  .field-value {
    font-size: 14px; /* чуть крупнее для тач */
  }

  .field-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* На мобильных всегда 1 колонка */
  .fields-widget.layout-2-column,
  .fields-widget.layout-3-column,
  .fields-widget.layout-grid {
    display: flex;
    flex-direction: column;
  }

  .fields-widget.layout-2-column .field-item,
  .fields-widget.layout-3-column .field-item,
  .fields-widget.layout-grid .field-item {
    border-right: none !important;
    grid-column: unset !important;
  }

  /* Inline таблица на мобилке — чуть выше */
  .field-item[data-display-mode="inline"] .field-value {
    max-height: 140px;
  }

  .field-item[data-display-mode="inline"] .field-value .inline-table td,
  .field-item[data-display-mode="inline"] .field-value .inline-table th {
    padding: 3px 6px;
    font-size: 11px;
  }

  /* Контекстное меню на мобилке — снизу экрана */
  .field-span-menu {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    top: auto !important;
    max-height: 60vh;
    overflow-y: auto;
    min-width: auto;
    max-width: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
  }

  /* Lightbox — полный экран */
  .fields-image-lightbox img {
    max-width: 95vw;
    max-height: 85vh;
    border-radius: var(--radius-sm);
  }

  .fields-image-lightbox .lightbox-close {
    top: 12px;
    right: 12px;
  }

  .image-field-preview img {
    max-width: 150px;
    max-height: 150px;
  }
}

/* Планшет — 2 колонки ок, 3 нет */
@media (min-width: 769px) and (max-width: 1024px) {
  .fields-widget.layout-3-column {
    grid-template-columns: repeat(12, 1fr);
  }

  .fields-widget.layout-3-column .field-item {
    grid-column: span 6;
  }

  .fields-widget.layout-3-column .field-item:nth-child(3n) {
    border-right: 1px solid var(--border-light);
  }

  .fields-widget.layout-3-column .field-item:nth-child(2n) {
    border-right: none;
  }
}
/* === widgets/handbooks-list-widget.css === */
/**
 * handbooks-list-widget.css
 * Виджет списка справочников — v3
 *
 * ВАЖНО: НЕ трогаем .grid-stack-item и .grid-stack-item-content!
 * Стилизуем только внутренности виджета.
 * Родительские контейнеры уже настроены в gridstack.css:
 *   .widget-container { display:flex; flex-direction:column; height:100% }
 *   .widget-content   { flex:1; overflow-y:auto; padding:16px }
 */

/* ============================================
   WIDGET CONTAINER
   Класс: widget-container handbooks-list-widget-container
   Наследует flex-column + height:100% от .widget-container
   ============================================ */
.handbooks-list-widget-container {
  overflow: hidden;
}

/* Content zone — убрать стандартный padding от .widget-content */
.handbooks-list-widget-container > .handbooks-list-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 !important;
}

/* ============================================
   TOOLBAR
   ============================================ */
.handbooks-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* --- Search --- */
.handbooks-search-input {
  flex: 1 1 160px;
  min-width: 120px;
  max-width: 260px;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.handbooks-search-input::placeholder {
  color: var(--text-muted);
}

.handbooks-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Toolbar row --- */
.handbooks-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.handbooks-toolbar-row .handbooks-search-input {
  flex: 1;
  max-width: none;
}

/* --- Filters panel --- */
.handbooks-filters-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.handbooks-filters-panel.open {
  display: flex;
}

.handbooks-filters-panel:not(.open) {
  display: none;
}

/* --- Sort row --- */
.handbooks-sort-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.handbooks-sort-row select {
  flex: 1;
}

/* --- Bottom row --- */
.handbooks-bottom-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.handbooks-bottom-row select {
  flex: 1;
}

/* --- Drawer-only buttons: hidden in default widget --- */
.handbooks-filters-toggle-btn,
.handbooks-search-toggle-btn {
  display: none;
}

/* --- Selects --- */
.handbooks-filter-select,
.handbooks-custom-filter-select,
.handbooks-sort-select,
.handbooks-group-select {
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  max-width: 170px;
  min-width: 0;
}

.handbooks-filter-select:focus,
.handbooks-custom-filter-select:focus,
.handbooks-sort-select:focus,
.handbooks-group-select:focus {
  border-color: var(--primary);
}

/* --- Sort direction --- */
.handbooks-sort-direction-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.handbooks-sort-direction-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

/* ============================================
   VIEW MODE TOGGLE
   ============================================ */
.view-mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  margin-left: auto;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 15px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.view-mode-btn:last-child {
  border-right: none;
}

.view-mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.view-mode-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   HANDBOOKS CONTAINER (scroll zone)
   ============================================ */
.handbooks-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.handbooks-container::-webkit-scrollbar {
  width: 6px;
}

.handbooks-container::-webkit-scrollbar-track {
  background: transparent;
}

.handbooks-container::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: 3px;
}

.handbooks-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-400);
}

/* ============================================
   VIEW: GRID (карточки)
   ============================================ */
.handbooks-container.handbooks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px;
  align-content: start;
}

.handbooks-grid .handbook-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: box-shadow var(--transition-base),
              border-color var(--transition-base),
              transform var(--transition-base);
  text-align: center;
  position: relative;
  min-height: 100px;
}

.handbooks-grid .handbook-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(33, 150, 243, 0.15);
  transform: translateY(-2px);
}

.handbooks-grid .handbook-item:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Иконка в кружке */
.handbooks-grid .handbook-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  transition: background var(--transition-fast),
              border-color var(--transition-fast);
}

.handbooks-grid .handbook-item:hover .handbook-icon {
  background: var(--primary-light);
  border-color: var(--primary);
}

.handbooks-grid .handbook-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
}

.handbooks-grid .handbook-stats {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
  padding: 2px 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
}

.handbooks-grid .handbook-custom-fields {
  width: 100%;
  border-top: 1px solid var(--border-light);
  padding-top: 6px;
  margin-top: 4px;
}

/* Заголовок группы в grid — полная ширина */
.handbooks-grid .handbooks-group-header {
  grid-column: 1 / -1;
}

/* --- Handbook icon images --- */
.handbook-icon-img {
  object-fit: contain;
  background: none;
}

.handbooks-grid .handbook-icon-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.handbooks-list .handbook-icon-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.handbooks-compact .handbook-icon-img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.handbook-icon-emoji {
  line-height: 1;
}

/* ============================================
   VIEW: LIST (строки)
   ============================================ */
.handbooks-container.handbooks-list {
  display: flex;
  flex-direction: column;
}

.handbooks-list .handbook-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.handbooks-list .handbook-item:last-child {
  border-bottom: none;
}

.handbooks-list .handbook-item:hover {
  background: var(--bg-hover);
}

.handbooks-list .handbook-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.handbooks-list .handbook-item:hover .handbook-icon {
  background: var(--primary-light);
  border-color: var(--primary);
}

.handbooks-list .handbook-info {
  flex: 1;
  min-width: 0;
}

.handbooks-list .handbook-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.handbooks-list .handbook-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.handbooks-list .handbook-type {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.handbooks-list .handbook-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.handbooks-list .handbook-arrow {
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast),
              color var(--transition-fast);
}

.handbooks-list .handbook-item:hover .handbook-arrow {
  transform: translateX(3px);
  color: var(--primary);
}

.handbooks-list .handbook-custom-fields {
  margin-top: 4px;
}

/* ============================================
   VIEW: COMPACT
   ============================================ */
.handbooks-container.handbooks-compact {
  display: flex;
  flex-direction: column;
}

.handbooks-compact .handbook-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 13px;
}

.handbooks-compact .handbook-item:last-child {
  border-bottom: none;
}

.handbooks-compact .handbook-item:hover {
  background: var(--bg-hover);
}

.handbooks-compact .handbook-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.handbooks-compact .handbook-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handbooks-compact .handbook-stats {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================
   GROUP HEADERS
   ============================================ */
.handbooks-group-header {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 5;
}

/* ============================================
   CUSTOM FIELDS
   ============================================ */
.handbook-custom-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
}

.handbook-custom-field {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.handbook-custom-field strong {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 2px;
}

.handbooks-grid .handbook-custom-fields {
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.handbooks-grid .handbook-custom-field {
  text-align: center;
  font-size: 10px;
}

/* ============================================
   EMPTY / ERROR / LOADING
   ============================================ */
.handbooks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.handbooks-grid .handbooks-empty {
  grid-column: 1 / -1;
}

.handbooks-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--error);
  font-size: 14px;
}

.handbooks-list-content > .loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
  flex: 1;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] .handbooks-container::-webkit-scrollbar-thumb {
  background: var(--color-gray-600);
}

[data-theme="dark"] .handbooks-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

[data-theme="dark"] .handbooks-grid .handbook-item {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .handbooks-grid .handbook-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .handbooks-grid .handbook-icon,
[data-theme="dark"] .handbooks-list .handbook-icon {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

[data-theme="dark"] .handbooks-grid .handbook-item:hover .handbook-icon,
[data-theme="dark"] .handbooks-list .handbook-item:hover .handbook-icon {
  background: var(--primary-light);
  border-color: var(--primary);
}

[data-theme="dark"] .handbooks-grid .handbook-stats {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .handbooks-group-header {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .handbooks-toolbar {
  background: var(--bg-secondary);
}

[data-theme="dark"] .handbooks-search-input,
[data-theme="dark"] .handbooks-filter-select,
[data-theme="dark"] .handbooks-custom-filter-select,
[data-theme="dark"] .handbooks-sort-select,
[data-theme="dark"] .handbooks-group-select,
[data-theme="dark"] .handbooks-sort-direction-btn,
[data-theme="dark"] .view-mode-btn {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .view-mode-toggle {
  border-color: var(--border);
}

[data-theme="dark"] .view-mode-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================ */
@media (max-width: 1024px) {
  .handbooks-toolbar {
    gap: 6px;
    padding: 8px 10px;
  }

  .handbooks-search-input {
    max-width: 200px;
  }

  .handbooks-filter-select,
  .handbooks-custom-filter-select,
  .handbooks-sort-select,
  .handbooks-group-select {
    max-width: 140px;
    font-size: 12px;
  }

  .handbooks-container.handbooks-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 10px;
  }
}

/* ============================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
  .handbooks-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
  }

  .handbooks-search-input {
    max-width: none;
    width: 100%;
    min-height: 40px;
    font-size: 16px;
  }

  .handbooks-filter-select,
  .handbooks-custom-filter-select,
  .handbooks-sort-select,
  .handbooks-group-select {
    max-width: none;
    width: 100%;
    min-height: 40px;
    font-size: 16px;
  }

  .handbooks-sort-direction-btn {
    width: 40px;
    height: 40px;
  }

  .view-mode-toggle {
    margin-left: 0;
    align-self: stretch;
  }

  .view-mode-btn {
    flex: 1;
    width: auto;
    height: 40px;
    font-size: 18px;
  }

  .handbooks-container.handbooks-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .handbooks-grid .handbook-item {
    padding: 14px 8px 10px;
    min-height: 90px;
  }

  .handbooks-grid .handbook-icon {
    font-size: 22px;
    width: 40px;
    height: 40px;
  }

  .handbooks-grid .handbook-name {
    font-size: 12px;
  }

  .handbooks-list .handbook-item {
    padding: 12px;
    min-height: 48px;
    gap: 10px;
  }

  .handbooks-list .handbook-name {
    font-size: 15px;
  }

  .handbooks-compact .handbook-item {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 14px;
  }
}

/* ============================================
   RESPONSIVE — SMALL MOBILE (≤480px)
   ============================================ */
@media (max-width: 480px) {
  .handbooks-container.handbooks-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px;
  }

  .handbooks-grid .handbook-item {
    min-height: 80px;
    padding: 12px 6px 10px;
  }

  .handbooks-grid .handbook-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .handbooks-grid .handbook-name {
    font-size: 11px;
  }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  .handbooks-toolbar,
  .view-mode-toggle {
    display: none !important;
  }

  .handbooks-container {
    overflow: visible !important;
  }

  .handbooks-grid .handbook-item {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}


/* === widgets/tabs-widget.css === */
/**
 * tabs-widget.css
 * Виджет с табами (вкладками)
 */

/* ============================================
   TABS WIDGET
   ============================================ */
.tabs-widget {
  padding: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
}

/* ============================================
   TABS HEADER (НЕ ПУТАТЬ с widget-header)
   ============================================ */
.tabs-header {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--bg-hover);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.tabs-header::-webkit-scrollbar {
  height: 4px;
}

.tabs-header::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.tabs-header::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

/* ============================================
   TAB BUTTON
   ============================================ */
.tab-button {
  padding: 12px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  transition: var(--transition-base);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-primary);
}

.tab-button .tab-icon {
  margin-right: 6px;
  font-size: 16px;
}

.tab-button .tab-count {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 11px;
  margin-left: 6px;
  min-width: 20px;
  text-align: center;
}

.tab-button.active .tab-count {
  background: var(--primary);
  color: white;
}

/* ============================================
   TABS CONTENT
   ============================================ */
.tabs-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  display: none;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

.tab-pane.active {
  display: block;
}

.tab-pane::-webkit-scrollbar {
  width: 6px;
}

.tab-pane::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.tab-pane::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.tab-pane::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   TAB ACTIONS (кнопки управления табами)
   ============================================ */
.tabs-actions {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-hover);
}

.tab-action-btn {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-base);
  color: var(--text-secondary);
}

.tab-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

/* ============================================
   EDIT MODE (для настройки табов)
   ============================================ */
.tabs-widget.edit-mode .tab-button {
  position: relative;
  padding-right: 40px;
}

.tab-close-btn {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius-full);
  transition: var(--transition-base);
}

.tabs-widget.edit-mode .tab-close-btn {
  display: block;
}

.tab-close-btn:hover {
  background: var(--bg-hover);
  color: var(--error);
}

/* ============================================
   ADD TAB BUTTON
   ============================================ */
.add-tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--primary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.add-tab-btn:hover {
  background: var(--primary-light);
}

/* ============================================
   TAB CONTENT TYPES
   ============================================ */

/* Таб с виджетами GridStack */
.tab-pane-gridstack {
  padding: 0;
}

.tab-pane-gridstack .grid-stack {
  min-height: 300px;
  padding: 16px;
}

/* Таб с формой */
.tab-pane-form {
  max-width: 800px;
  margin: 0 auto;
}

/* Таб со списком */
.tab-pane-list {
  padding: 0;
}

.tab-pane-list .list-container {
  padding: 16px;
}

/* ============================================
   EMPTY TAB STATE
   ============================================ */
.tab-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  color: var(--text-muted);
  text-align: center;
}

.tab-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.tab-empty-text {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.tab-empty-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   TAB DRAGGING (для сортировки)
   ============================================ */
.tab-button.dragging {
  opacity: 0.5;
}

.tab-button.drag-over {
  border-left: 3px solid var(--primary);
}

/* ============================================
   TAB CONFIG (настройка таба)
   ============================================ */
.tab-config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-config-form .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
}

.tab-icon-selector {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
}

.tab-icon-option {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: var(--transition-base);
  color: var(--text-secondary);
}

.tab-icon-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.tab-icon-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .tab-button {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .tabs-widget.edit-mode .tab-button {
    padding-right: 36px;
  }
  
  .tab-icon-selector {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .tab-pane {
    padding: 12px;
  }
}

/* Сложные виджеты */
/* === widgets/documents.css === */
/**
 * documents.css
 * Виджет документов с загрузкой и превью
 */

/* ============================================
   DOCUMENTS WIDGET
   ============================================ */
.documents-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 !important;
}

.documents-widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.documents-widget-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.documents-widget-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

/* ============================================
   UPLOAD AREA
   ============================================ */
.documents-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  background: var(--bg-hover);
  cursor: pointer;
  transition: var(--transition-base);
  margin-bottom: 20px;
}

.documents-upload-area:hover,
.documents-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.documents-upload-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.documents-upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.documents-upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.documents-upload-link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

/* ============================================
   DOCUMENTS LIST
   ============================================ */
.documents-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
}

.document-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

/* ============================================
   DOCUMENT PREVIEW/ICON
   ============================================ */
.document-preview {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.document-icon {
  font-size: 32px;
  color: var(--text-muted);
}

/* Иконки по типу файла */
.document-icon.pdf { color: var(--error); }
.document-icon.doc,
.document-icon.docx { color: var(--primary); }
.document-icon.xls,
.document-icon.xlsx { color: var(--success); }
.document-icon.ppt,
.document-icon.pptx { color: var(--warning); }
.document-icon.zip,
.document-icon.rar { color: var(--color-purple-600); }
.document-icon.image { color: var(--color-cyan-600); }

/* ============================================
   DOCUMENT INFO
   ============================================ */
.document-info {
  flex: 1;
  min-width: 0;
}

.document-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.document-size,
.document-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================
   DOCUMENT ACTIONS
   ============================================ */
.document-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.document-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-secondary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.document-action-btn.download {
  color: var(--primary);
}

.document-action-btn.delete {
  color: var(--error);
}

.document-action-btn.delete:hover {
  background: var(--error-light);
}

/* ============================================
   UPLOAD PROGRESS
   ============================================ */
.document-upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.upload-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.upload-progress-percent {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
  text-align: right;
}

.upload-cancel-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--error);
  font-size: 16px;
  padding: 4px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.documents-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.documents-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.documents-empty-text {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ============================================
   DOCUMENT GALLERY (grid view)
   ============================================ */
.documents-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.document-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-base);
}

.document-gallery-item:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.document-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.document-gallery-item .document-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  font-size: 48px;
}

.document-gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  padding: 8px;
  color: white;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   VIEW TOGGLE
   ============================================ */
.documents-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.view-toggle-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.view-toggle-btn:hover {
  color: var(--text-primary);
}

.view-toggle-btn.active {
  background: var(--bg-primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   DOCUMENT VIEWER (lightbox)
   ============================================ */
.document-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.document-viewer-content {
  max-width: 90%;
  max-height: 90%;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.document-viewer-content img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  display: block;
}

.document-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
}

.document-viewer-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* ============================================
   SCROLLBAR
   ============================================ */
.documents-widget-body::-webkit-scrollbar {
  width: 6px;
}

.documents-widget-body::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.documents-widget-body::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.documents-widget-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .documents-upload-area {
    padding: 30px 16px;
  }
  
  .document-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .document-preview {
    width: 100%;
    height: 120px;
  }
  
  .document-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .documents-gallery {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
/* === widgets/comments.css === */
/**
 * comments.css
 * Виджет комментариев — под реальную разметку CommentsWidget.js
 */

/* ============================================
   WIDGET CONTAINER
   ============================================ */
.comments-widget-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Header */
.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  gap: 12px;
}

.comments-header .widget-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.comments-count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
}

.comments-header .widget-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.comments-filter-select {
  padding: 5px 28px 5px 10px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: none;
  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='%239e9e9e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.comments-filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Content */
.comments-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comments-content::-webkit-scrollbar { width: 5px; }
.comments-content::-webkit-scrollbar-track { background: transparent; }
.comments-content::-webkit-scrollbar-thumb { background: var(--color-gray-300); border-radius: var(--radius-full); }
.comments-content::-webkit-scrollbar-thumb:hover { background: var(--color-gray-400); }
[data-theme="dark"] .comments-content::-webkit-scrollbar-thumb { background: var(--color-gray-600); }

/* ============================================
   SEARCH
   ============================================ */
.comments-search { flex-shrink: 0; }

.comments-search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  font-size: var(--font-size-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239e9e9e' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.comments-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.comments-search-input::placeholder { color: var(--text-muted); }

/* ============================================
   COMMENT FORM CONTAINER
   ============================================ */
.comment-form-container { flex-shrink: 0; }

.comment-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--primary-light);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.comment-form-header strong { color: var(--primary); }

/* ============================================
   COMMENTS LIST
   ============================================ */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ============================================
   SINGLE COMMENT
   ============================================ */
.comment {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast);
}

.comment:hover { background: var(--bg-secondary); }

.comment > .comment-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--color-white);
  background: linear-gradient(135deg, var(--color-blue-500), var(--color-purple-500));
  user-select: none;
}

.comment-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-meta strong {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.comment-date { font-size: var(--font-size-xs); color: var(--text-muted); }
.comment-edited { font-size: var(--font-size-xs); color: var(--text-muted); font-style: italic; }

.comment-header .comment-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.comment:hover > .comment-header .comment-actions { opacity: 1; }

.comment-header .comment-actions .btn-icon {
  width: 28px;
  height: 28px;
  font-size: 14px;
  border-radius: var(--radius-md);
}

/* ============================================
   COMMENT BODY
   ============================================ */
.comment-body {
  margin-left: 44px;
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.comment-body p { margin: 0 0 6px 0; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body ul, .comment-body ol { margin: 4px 0; padding-left: 20px; }

.comment-body code {
  padding: 1px 5px;
  font-size: 0.9em;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--color-red-600);
}

[data-theme="dark"] .comment-body code { color: var(--color-red-300); }

.mention {
  color: var(--primary);
  font-weight: var(--font-weight-semibold);
  background: var(--primary-light);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.mention-link { cursor: pointer; text-decoration: none; }
.mention-link:hover { background: var(--primary-lighter); text-decoration: underline; }

.item-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  border-bottom: 1px dashed var(--primary);
}

.item-link:hover { border-bottom-style: solid; color: var(--primary-hover); }

/* ============================================
   ATTACHMENTS
   ============================================ */
.comment-attachments-container { margin-top: 10px; margin-left: 44px; }

.attachments-bulk-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--primary-light);
  border: 1px solid var(--color-blue-200);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.attachments-bulk-bar .selected-count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--primary);
  margin-right: auto;
}

.comment-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.comment-attachment {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.comment-attachment:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

.comment-attachment-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  z-index: 2;
  accent-color: var(--primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.comment-attachment:hover .comment-attachment-checkbox,
.comment-attachment-checkbox:checked { opacity: 1; }

.comment-attachment-preview {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  cursor: pointer;
  overflow: hidden;
}

.comment-attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.comment-attachment:hover .comment-attachment-preview img { transform: scale(1.06); }
.comment-attachment-icon { font-size: 36px; opacity: 0.55; }

.comment-attachment-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.comment-attachment-name { font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-attachment-size { font-size: var(--font-size-xs); color: var(--text-muted); }

.comment-attachment-actions {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  border-top: 1px solid var(--border-light);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.comment-attachment:hover .comment-attachment-actions { opacity: 1; }

.comment-attachment-btn {
  flex: 1;
  padding: 5px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment-attachment-btn:hover { background: var(--bg-hover); }
.comment-attachment-btn-delete:hover { background: var(--danger-light); }

/* ============================================
   COMMENT LINKS
   ============================================ */
.comment-links { margin-top: 8px; margin-left: 44px; display: flex; flex-wrap: wrap; gap: 6px; }

.comment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}

.comment-link:hover { background: var(--primary-lighter); }

/* ============================================
   REACTIONS
   ============================================ */
.comment-reactions { margin-top: 8px; margin-left: 44px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.reaction-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.reaction-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: var(--font-weight-semibold); }
.reaction-btn.add-reaction { border-style: dashed; color: var(--text-muted); font-size: 12px; }
.reaction-btn.add-reaction:hover { border-style: solid; }

/* ============================================
   COMMENT FOOTER
   ============================================ */
.comment-footer { margin-top: 6px; margin-left: 44px; display: flex; gap: 12px; align-items: center; }
.comment-footer .btn-link { font-size: var(--font-size-xs); color: var(--text-muted); padding: 2px 6px; }
.comment-footer .btn-link:hover { color: var(--primary); background: var(--primary-light); }

/* ============================================
   REPLIES
   ============================================ */
.comment-replies {
  margin-top: 4px;
  padding-left: 20px;
  border-left: 2px solid var(--border-light);
  margin-left: 16px;
}

.comment-replies .comment { padding: 10px 12px; }
.comment-replies .comment-avatar { width: 28px; height: 28px; font-size: var(--font-size-sm); }

.comment-replies .comment-body,
.comment-replies .comment-reactions,
.comment-replies .comment-footer,
.comment-replies .comment-links,
.comment-replies .comment-attachments-container { margin-left: 38px; }

/* ============================================
   EMOJI PICKER
   ============================================ */
.emoji-picker {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.15s var(--ease-out);
}

.emoji-picker-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-picker-btn:hover { background: var(--bg-hover); transform: scale(1.2); }

/* ============================================
   EMPTY / ERROR / LOADING
   ============================================ */
.comments-empty { padding: 48px 20px; text-align: center; color: var(--text-muted); }
.comments-error { padding: 32px 20px; text-align: center; color: var(--danger); background: var(--danger-light); border-radius: var(--radius-lg); }
.comments-content > .loading { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .comments-header { padding: 12px 14px; flex-wrap: wrap; }
  .comments-content { padding: 14px; gap: 12px; }
  .comment { padding: 10px 8px; }
  .comment-avatar { width: 28px; height: 28px; font-size: var(--font-size-sm); }
  .comment-body, .comment-reactions, .comment-footer, .comment-links, .comment-attachments-container { margin-left: 38px; }
  .comment-replies { padding-left: 12px; margin-left: 8px; }
  .comment-header .comment-actions { opacity: 1; }
  .comment-attachment-actions, .comment-attachment-checkbox { opacity: 1; }
}

/* Dark mode */
[data-theme="dark"] .comment:hover { background: var(--bg-hover); }
[data-theme="dark"] .comment-attachment { background: var(--bg-secondary); }
[data-theme="dark"] .comment-attachment-preview { background: var(--bg-tertiary); }
[data-theme="dark"] .comments-search-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
}

/* Print */
@media print {
  .comment-form-container, .comments-search, .comment-header .comment-actions,
  .comment-footer, .reaction-btn.add-reaction, .attachments-bulk-bar,
  .comment-attachment-actions, .comment-attachment-checkbox { display: none !important; }
  .comment { break-inside: avoid; border-bottom: 1px solid var(--border-light); padding-bottom: 12px; margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .comment-attachment-preview img { transition: none; }
  .emoji-picker { animation: none; }
}
/* === widgets/checklists.css === */
/**
 * checklists.css
 * Виджет чек-листов с задачами и статусами
 */

/* ============================================
   CHECKLISTS WIDGET
   ============================================ */
.checklists-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 !important;
}

.checklists-widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checklists-widget-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

/* ============================================
   CHECKLIST HEADER
   ============================================ */
.checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.checklist-info h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.checklist-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.checklist-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   CHECKLIST PROGRESS
   ============================================ */
.checklist-progress {
  margin-top: 12px;
}

.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--success-hover));
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

/* ============================================
   CHECKLIST SECTIONS
   ============================================ */
.checklist-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.checklist-section {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.checklist-section-header {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.checklist-section-header:hover {
  background: var(--bg-hover);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-toggle {
  font-size: 12px;
  transition: transform 0.2s;
}

.checklist-section.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-progress {
  font-size: 12px;
  color: var(--text-secondary);
}

.checklist-section-body {
  padding: 0;
}

.checklist-section.collapsed .checklist-section-body {
  display: none;
}

/* ============================================
   CHECKLIST ITEMS (задачи)
   ============================================ */
.checklist-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-item:hover {
  background: var(--bg-hover);
}

.checklist-item.completed .item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ============================================
   ITEM CHECKBOX
   ============================================ */
.item-checkbox {
  position: relative;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-base);
  margin-top: 2px;
}

.item-checkbox:hover {
  border-color: var(--success);
}

.item-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.item-checkbox.checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

/* ============================================
   ITEM CONTENT
   ============================================ */
.item-content {
  flex: 1;
  min-width: 0;
}

.item-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 6px;
  word-wrap: break-word;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.item-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-assignee-avatar {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.item-assignee-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-due-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.item-due-date.overdue {
  color: var(--error);
  font-weight: 600;
}

.item-priority {
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.item-priority.high {
  background: var(--error-light);
  color: var(--error);
}

.item-priority.medium {
  background: var(--warning-light);
  color: var(--warning);
}

.item-priority.low {
  background: var(--success-light);
  color: var(--success);
}

/* ============================================
   ITEM ACTIONS
   ============================================ */
.item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.checklist-item:hover .item-actions {
  opacity: 1;
}

.item-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.item-action-btn.delete:hover {
  background: var(--error-light);
  color: var(--error);
}

/* ============================================
   ADD ITEM BUTTON
   ============================================ */
.add-item-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-item-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

/* ============================================
   ADD ITEM FORM
   ============================================ */
.add-item-form {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-hover);
}

.add-item-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 8px;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.add-item-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.add-item-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   FILTER BUTTONS
   ============================================ */
.checklist-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.filter-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.checklist-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.checklist-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.checklist-empty-text {
  font-size: 14px;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.checklists-widget-body::-webkit-scrollbar {
  width: 6px;
}

.checklists-widget-body::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.checklists-widget-body::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.checklists-widget-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .checklist-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .checklist-meta {
    flex-direction: column;
    gap: 8px;
  }
  
  .checklist-item {
    flex-direction: column;
    gap: 8px;
  }
  
  .item-actions {
    opacity: 1;
    width: 100%;
    justify-content: flex-end;
  }
  
  .item-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* === widgets/calendar.css === */
/**
 * calendar.css
 * Виджет календаря — все стили консолидированы из JS в CSS
 * Toast UI Calendar + кастомная темизация + popups + picker
 * 
 * Структура:
 *   1. Container & Header
 *   2. Toolbar (навигация, виды, actions)
 *   3. Calendar Content (Toast UI overrides)
 *   4. Event Templates (внутри Toast UI)
 *   5. Field Mapping Dialog
 *   6. Notifications
 *   7. Event Popup (field events)
 *   8. Reminder Popup
 *   9. Comments Dialog
 *  10. Month/Year Picker
 *  11. Empty / Fallback states
 *  12. Print
 *  13. Responsive
 *  14. Dark Mode
 */

/* ============================================
   1. CONTAINER & HEADER
   ============================================ */

.calendar-widget-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Заголовок */
.calendar-widget-container .calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.calendar-widget-container .calendar-header .widget-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-widget-container .calendar-header .widget-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Скрыть header виджета когда внутри drawer */
.cal-drawer-calendar-wrap .calendar-widget-container .calendar-header {
  display: none !important;
}


/* ============================================
   2. TOOLBAR
   ============================================ */

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* --- Navigation --- */
.calendar-toolbar .calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-toolbar .btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.calendar-toolbar .btn-nav:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.calendar-toolbar .btn-nav:active {
  transform: scale(0.97);
}

/* Заголовок периода */
.calendar-toolbar .calendar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 160px;
  padding: 0 8px;
  user-select: none;
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.calendar-toolbar .calendar-title:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* --- View Switcher --- */
.calendar-view-switcher {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.calendar-view-switcher .view-btn {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.calendar-view-switcher .view-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.calendar-view-switcher .view-btn.active {
  color: var(--primary);
  background: var(--bg-primary);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

/* --- Extra Actions --- */
.calendar-extra-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.calendar-extra-actions .btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.calendar-extra-actions .btn-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}


/* ============================================
   3. CALENDAR CONTENT — Toast UI Overrides
   ============================================ */

.calendar-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* --- Toast UI: общие --- */
.calendar-content .toastui-calendar-layout {
  font-family: var(--font-family) !important;
  background: var(--bg-primary) !important;
  border: none !important;
}

.calendar-content .toastui-calendar-layout,
.calendar-content .toastui-calendar-month,
.calendar-content .toastui-calendar-week-view {
  border: none !important;
}

/* --- Day names --- */
.calendar-content .toastui-calendar-day-names {
  border-bottom: 1px solid var(--border) !important;
  overflow: visible !important;
}

.calendar-content .toastui-calendar-day-name {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-secondary) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.03em;
  padding: 10px 0 !important;
}

.calendar-content .toastui-calendar-day-name.toastui-calendar-holiday {
  color: var(--error) !important;
}

/* --- Month view cells --- */
.calendar-content .toastui-calendar-daygrid-cell {
  border-color: var(--border-light) !important;
  transition: background 0.15s ease;
}

.calendar-content .toastui-calendar-daygrid-cell:hover {
  background: var(--bg-hover) !important;
}

/* Date number */
.calendar-content .toastui-calendar-grid-cell-date {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  padding: 6px 8px !important;
}

/* Today accent */
.calendar-content .toastui-calendar-grid-cell-date.toastui-calendar-grid-cell-today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary) !important;
  color: #fff !important;
  border-radius: var(--radius-full);
  font-weight: 700 !important;
}

/* Other month days */
.calendar-content .toastui-calendar-grid-cell-date.toastui-calendar-grid-cell-other-month {
  color: var(--text-disabled) !important;
}

/* --- Week/Day view --- */
.calendar-content .toastui-calendar-timegrid-hour-rows {
  font-size: 12px !important;
  color: var(--text-muted) !important;
}

.calendar-content .toastui-calendar-timegrid-time-column {
  border-right: 1px solid var(--border-light) !important;
  background: var(--bg-secondary) !important;
}

.calendar-content .toastui-calendar-timegrid-hour-row {
  border-bottom: 1px solid var(--border-light) !important;
}

/* Current time indicator */
.calendar-content .toastui-calendar-timegrid-current-time {
  color: var(--error) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
}

.calendar-content .toastui-calendar-timegrid-now-indicator {
  border-top: 2px solid var(--error) !important;
}

.calendar-content .toastui-calendar-timegrid-now-indicator::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--error);
}

/* --- Events --- */
.calendar-content .toastui-calendar-event {
  border-radius: var(--radius-sm) !important;
  font-size: 12px !important;
  cursor: pointer !important;
  transition: box-shadow 0.15s ease, transform 0.15s ease !important;
}

.calendar-content .toastui-calendar-event:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-1px);
  z-index: 10 !important;
}

.calendar-content .toastui-calendar-weekday-event-block,
.calendar-content .toastui-calendar-month-event {
  border-radius: var(--radius-sm) !important;
  margin: 1px 2px !important;
}

.calendar-content .toastui-calendar-event-resize-handle {
  background: rgba(255, 255, 255, 0.3) !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
}

/* "+N more" */
.calendar-content .toastui-calendar-weekday-exceed-in-month,
.calendar-content .toastui-calendar-month-more-events {
  font-size: 11px !important;
  color: var(--text-secondary) !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  padding: 2px 6px !important;
  border-radius: var(--radius-sm) !important;
  transition: all 0.15s ease;
}

.calendar-content .toastui-calendar-weekday-exceed-in-month:hover,
.calendar-content .toastui-calendar-month-more-events:hover {
  color: var(--primary) !important;
  background: var(--primary-light) !important;
}

/* See more container */
.calendar-content .toastui-calendar-see-more-container {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 8px !important;
}

/* Drag guides */
.calendar-content .toastui-calendar-guide-creation,
.calendar-content .toastui-calendar-guide-move {
  opacity: 0.6 !important;
  border-radius: var(--radius-sm) !important;
}

.calendar-content .toastui-calendar-time-date-schedule-block-focused {
  box-shadow: 0 0 0 2px var(--primary) !important;
}

/* Scrollbar */
.calendar-content .toastui-calendar-timegrid-container::-webkit-scrollbar {
  width: 6px;
}

.calendar-content .toastui-calendar-timegrid-container::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: var(--radius-sm);
}

.calendar-content .toastui-calendar-timegrid-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-400);
}

/* --- Month cells: fix event text overlap --- */
.toastui-calendar-month .toastui-calendar-daygrid-cell {
  overflow-y: auto;
  overflow-x: hidden;
}
.toastui-calendar-daygrid-cell::-webkit-scrollbar {
  width: 3px;
}
.toastui-calendar-daygrid-cell::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

/* "+N more" button — hide word "more", compact */
.toastui-calendar-month .toastui-calendar-grid-cell-more-events,
.toastui-calendar-month .toastui-calendar-month-more-events {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--primary, #4A90E2) !important;
  padding: 0 4px !important;
  line-height: 1.4 !important;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

/* Hide "more" text via font-size trick — replace with CSS content */
.toastui-calendar-weekday-exceed-in-month,
.toastui-calendar-month-exceed-in-month {
  font-size: 0 !important;
}
.toastui-calendar-weekday-exceed-in-month::after,
.toastui-calendar-month-exceed-in-month::after {
  font-size: 11px !important;
  font-weight: 600;
  color: var(--primary, #4A90E2);
  content: attr(data-count);
}

/* Event blocks in month — prevent text overflow */
.toastui-calendar-month .toastui-calendar-weekday-event-block {
  margin-bottom: 1px;
  overflow: hidden;
}
.toastui-calendar-month .toastui-calendar-weekday-event-title {
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ensure event dot + text don't overflow cell */
.toastui-calendar-weekday-event-dot {
  flex-shrink: 0;
  margin-right: 4px;
}


/* ============================================
   4. EVENT TEMPLATES
   ============================================ */

.event-content {
  padding: 2px 4px;
  line-height: 1.3;
  overflow: hidden;
}

.event-content .event-time {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 1px;
  white-space: nowrap;
}

.event-content .event-title {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
  margin: 0;
}

.event-content .event-location {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.event-content .event-attendees {
  font-size: 10px;
  opacity: 0.8;
  margin-top: 1px;
}

.event-allday-content {
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}


/* ============================================
   5. FIELD MAPPING DIALOG
   ============================================ */

.field-mapping-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: 0;
  width: 480px;
  max-width: 90vw;
  box-shadow: var(--shadow-2xl);
  animation: scaleIn 0.2s var(--ease-out);
  overflow: hidden;
}

.field-mapping-dialog .fm-header {
  padding: 20px 24px 0;
}

.field-mapping-dialog .fm-header h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-mapping-dialog .fm-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.field-mapping-dialog .fm-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-mapping-dialog .fm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-mapping-dialog .fm-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-mapping-dialog .fm-field label .fm-required {
  color: var(--error);
  margin-left: 2px;
}

.field-mapping-dialog .fm-field select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.15s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239e9e9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field-mapping-dialog .fm-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

.field-mapping-dialog .fm-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field-mapping-dialog .fm-footer .btn {
  min-width: 100px;
}


/* ============================================
   6. NOTIFICATIONS (напоминания)
   ============================================ */

.calendar-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  padding: 16px 20px;
  max-width: 340px;
  width: calc(100vw - 48px);
  z-index: var(--z-notification);
  animation: calFadeInUp 0.35s var(--ease-out);
}

.calendar-notification-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.calendar-notification-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-notification-title::before {
  content: '🔔';
  font-size: 16px;
}

.calendar-notification-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.calendar-notification-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.calendar-notification-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.calendar-notification-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}


/* ============================================
   7. EVENT POPUP (field events)
   Перенесено из CalendarWidget.js
   ============================================ */

@keyframes calPopupFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cal-event-popup {
  background: var(--bg-primary, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  padding: 16px;
  animation: calPopupFadeIn 0.15s ease;
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.cal-event-popup::-webkit-scrollbar {
  width: 4px;
}

.cal-event-popup::-webkit-scrollbar-thumb {
  background: var(--color-gray-300, #d1d5db);
  border-radius: 2px;
}

/* Header */
.cep-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.cep-color {
  width: 4px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.cep-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  line-height: 1.3;
}

.cep-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted, #999);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.12s ease;
}

.cep-close:hover {
  background: var(--bg-hover, #f0f0f0);
  color: var(--text-primary, #333);
}

/* Time */
.cep-time {
  font-size: 13px;
  color: var(--text-secondary, #555);
  margin-bottom: 8px;
}

/* Loading */
.cep-loading {
  font-size: 13px;
  color: var(--text-muted, #999);
  padding: 12px 0;
  text-align: center;
}

/* Fields */
.cep-fields {
  border-top: 1px solid var(--border-light, #f5f5f5);
  padding-top: 10px;
  margin-bottom: 10px;
}

.cep-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  gap: 10px;
  border-bottom: 1px solid var(--border-light, #f8f8f8);
}

.cep-field:last-child {
  border-bottom: none;
}

.cep-field-label {
  font-size: 12px;
  color: var(--text-muted, #888);
  flex-shrink: 0;
  min-width: 80px;
}

.cep-field-value {
  font-size: 13px;
  color: var(--text-primary, #333);
  text-align: right;
  white-space: normal;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

/* Footer */
.cep-footer {
  border-top: 1px solid var(--border-light, #f0f0f0);
  padding-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.cep-open-btn {
  padding: 8px 14px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  font-size: 13px;
  cursor: pointer;
  color: var(--primary, #4A90E2);
  font-weight: 500;
  transition: all 0.15s ease;
}

.cep-open-btn:hover {
  background: var(--primary-light, #f0f5ff);
  border-color: var(--primary, #4A90E2);
}

/* Comments button inside popup */
.cep-comments-btn {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  background: var(--primary-light, #f8f9ff);
  font-size: 13px;
  cursor: pointer;
  color: var(--primary, #4A90E2);
  font-weight: 500;
  transition: all 0.15s ease;
  text-align: center;
}

.cep-comments-btn:hover {
  background: var(--primary-lighter, #eef2ff);
  border-color: var(--primary, #4A90E2);
}

/* Utility classes for popup field rendering */
.cep-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}

.cep-address-line {
  font-size: 12px;
  margin-bottom: 2px;
  white-space: normal;
  word-break: break-word;
}

.cep-contact-line {
  font-size: 12px;
  margin-bottom: 2px;
}

.cep-contact-link {
  color: var(--primary, #4A90E2);
  text-decoration: none;
}

.cep-contact-link:hover {
  text-decoration: underline;
}

.cep-relation-line {
  font-size: 12px;
  margin-bottom: 2px;
}

.cep-relation-link {
  color: var(--primary, #4A90E2);
  text-decoration: none;
  cursor: pointer;
}

.cep-relation-link:hover {
  text-decoration: underline;
}

.cep-table-count {
  color: var(--text-muted, #888);
  font-size: 12px;
}


/* ============================================
   8. REMINDER POPUP
   Перенесено из CalendarWidget.js
   ============================================ */

.cep-reminder-comment {
  background: var(--warning-light, #fef9f0);
  border-left: 3px solid var(--error-light, #FF6B6B);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  margin: 8px 0;
}

.cep-reminder-comment-label {
  font-size: 11px;
  color: var(--text-muted, #999);
  margin-bottom: 4px;
  font-weight: 500;
}

.cep-reminder-comment-text {
  font-size: 13px;
  color: var(--text-primary, #333);
  line-height: 1.4;
  word-break: break-word;
}

.cep-reminder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light, #f0f0f0);
  margin-top: 8px;
}

.cep-action-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary, #555);
  font-weight: 500;
  transition: all 0.15s ease;
  text-align: center;
}

.cep-action-btn:hover {
  background: var(--primary-light, #f5f8ff);
  border-color: var(--primary, #4A90E2);
  color: var(--primary, #4A90E2);
}

.cep-delete-reminder {
  color: var(--error, #cc4444);
}

.cep-delete-reminder:hover {
  background: var(--error-light, #fff5f5);
  border-color: var(--error, #cc4444);
  color: var(--error, #cc4444);
}


/* ============================================
   9. COMMENTS DIALOG
   Перенесено из CalendarWidget.js
   ============================================ */

@keyframes calDialogFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes calDialogSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.cal-comments-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: calDialogFadeIn 0.2s ease;
}

.cal-comments-dialog {
  background: var(--bg-primary, #fff);
  border-radius: 14px;
  width: 600px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: calDialogSlideUp 0.2s ease;
  overflow: hidden;
}

.ccd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.ccd-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
}

.ccd-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted, #999);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.ccd-close:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #333);
}

.ccd-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 200px;
}

.ccd-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted, #999);
  font-size: 14px;
}

@keyframes calSpinnerSpin {
  to { transform: rotate(360deg); }
}

.ccd-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border, #eee);
  border-top-color: var(--primary, #4A90E2);
  border-radius: 50%;
  animation: calSpinnerSpin 0.7s linear infinite;
}

.ccd-body .widget-container {
  box-shadow: none;
  border: none;
}

.ccd-body .comments-container {
  max-height: 50vh;
  overflow-y: auto;
}


/* ============================================
   10. MONTH / YEAR PICKER
   Перенесено из CalendarWidget.js
   ============================================ */

.cal-month-year-picker {
  background: var(--bg-primary, #fff);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 16px;
  width: 300px;
  animation: calPopupFadeIn 0.15s ease;
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

/* Year row */
.myp-year-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}

.myp-year-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  min-width: 60px;
  text-align: center;
}

.myp-year-nav {
  background: none;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary, #555);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.myp-year-nav:hover {
  background: var(--bg-hover, #f0f0f0);
  border-color: var(--text-muted, #ccc);
}

/* Months grid */
.myp-months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.myp-month-btn {
  padding: 8px 4px;
  border: 1px solid var(--border-light, #eee);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary, #333);
  transition: all 0.15s ease;
}

.myp-month-btn:hover {
  background: var(--primary-light, #f0f5ff);
  border-color: var(--primary-lighter, #c0d0f0);
}

.myp-month-btn.active {
  background: var(--primary, #4A90E2);
  color: #fff;
  border-color: var(--primary, #4A90E2);
}

.myp-month-btn.now:not(.active) {
  border-color: var(--primary, #4A90E2);
  color: var(--primary, #4A90E2);
  font-weight: 600;
}

/* Years grid */
.myp-years-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border-top: 1px solid var(--border-light, #f0f0f0);
  padding-top: 12px;
}

.myp-year-btn {
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary, #666);
  transition: all 0.15s ease;
}

.myp-year-btn:hover {
  background: var(--primary-light, #f0f5ff);
  color: var(--text-primary, #333);
}

.myp-year-btn.active {
  background: var(--primary, #4A90E2);
  color: #fff;
}

.myp-year-btn.now:not(.active) {
  color: var(--primary, #4A90E2);
  font-weight: 700;
}


/* ============================================
   11. EMPTY / FALLBACK STATES
   ============================================ */

.calendar-empty,
.calendar-content .calendar-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  height: 100%;
}

.calendar-empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
  line-height: 1;
}

.calendar-empty-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.calendar-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.calendar-content .calendar-fallback button {
  margin-top: 16px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.calendar-content .calendar-fallback button:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}


/* ============================================
   12. PRINT
   ============================================ */

@media print {
  .calendar-widget-container {
    border: none;
    box-shadow: none;
  }

  .calendar-toolbar,
  .calendar-header .widget-actions,
  .calendar-notification,
  .cal-event-popup,
  .cal-month-year-picker {
    display: none !important;
  }

  .calendar-content {
    height: auto !important;
    overflow: visible !important;
  }

  .calendar-content .toastui-calendar-event:hover {
    box-shadow: none !important;
    transform: none !important;
  }
}


/* ============================================
   13. RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .calendar-toolbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .calendar-toolbar .calendar-title {
    font-size: 13px;
    min-width: auto;
    order: -1;
    flex-basis: 100%;
    text-align: center;
    padding: 0 0 4px;
  }

  .calendar-view-switcher .view-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .calendar-extra-actions {
    gap: 2px;
  }

  .calendar-content {
    height: 500px !important;
  }

  .calendar-notification {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }

  .field-mapping-dialog {
    width: calc(100vw - 32px);
  }

  .cal-event-popup {
    width: calc(100vw - 32px);
    max-width: 340px;
  }

  .cal-comments-dialog {
    width: 95vw;
    max-height: 85vh;
  }
}

@media (max-width: 480px) {
  .calendar-widget-container .calendar-header {
    padding: 10px 12px;
  }

  .calendar-widget-container .calendar-header .widget-title {
    font-size: 14px;
  }

  .calendar-extra-actions {
    display: none;
  }

  .calendar-content {
    height: 400px !important;
  }

  .cal-month-year-picker {
    width: calc(100vw - 32px);
    max-width: 300px;
  }
}


/* ============================================
   14. DARK MODE
   ============================================ */

[data-theme="dark"] .calendar-content .toastui-calendar-layout {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-day-name {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-daygrid-cell {
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-grid-cell-date {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-timegrid-time-column {
  background: var(--bg-secondary) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-timegrid-hour-row {
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-content .toastui-calendar-see-more-container {
  background: var(--bg-secondary) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .field-mapping-dialog .fm-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* Dark mode — popups */
[data-theme="dark"] .cal-event-popup {
  background: var(--bg-secondary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cal-month-year-picker {
  background: var(--bg-secondary);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cal-comments-dialog {
  background: var(--bg-secondary);
}

[data-theme="dark"] .cep-reminder-comment {
  background: rgba(255, 107, 107, 0.08);
}
/* === widgets/charts.css === */
/**
 * charts.css
 * Виджет графиков и диаграмм (Chart.js)
 */

/* ============================================
   CHARTS WIDGET
   ============================================ */
.charts-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 !important;
}

.charts-widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.charts-widget-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container {
  position: relative;
  flex: 1;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  max-width: 100%;
  max-height: 100%;
}

/* ============================================
   CHART CONTROLS
   ============================================ */
.chart-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chart-type-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.chart-type-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-type-btn:hover {
  color: var(--text-primary);
}

.chart-type-btn.active {
  background: var(--bg-primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.chart-type-icon {
  font-size: 16px;
}

/* ============================================
   CHART OPTIONS
   ============================================ */
.chart-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-option-btn {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.chart-option-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.chart-option-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   CHART LEGEND (кастомная)
   ============================================ */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.chart-legend-item:hover {
  opacity: 0.7;
}

.chart-legend-item.hidden {
  opacity: 0.3;
  text-decoration: line-through;
}

.chart-legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.chart-legend-label {
  font-size: 13px;
  color: var(--text-primary);
}

.chart-legend-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-left: 4px;
}

/* ============================================
   CHART STATS (метрики)
   ============================================ */
.chart-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.chart-stat-card {
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.chart-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.chart-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-stat-change {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 600;
}

.chart-stat-change.positive {
  color: var(--success);
}

.chart-stat-change.negative {
  color: var(--error);
}

/* ============================================
   CHART DATA TABLE (таблица данных)
   ============================================ */
.chart-data-table {
  margin-top: 16px;
  overflow-x: auto;
}

.chart-data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.chart-data-table th {
  background: var(--bg-secondary);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
}

.chart-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.chart-data-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ============================================
   CHART CONFIG FORM
   ============================================ */
.chart-config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-data-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-source-option {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
}

.data-source-option:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.data-source-option input[type="radio"] {
  margin-right: 10px;
}

.data-source-option.selected {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ============================================
   CHART EMPTY STATE
   ============================================ */
.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.chart-empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.chart-empty-text {
  font-size: 14px;
  margin-bottom: 8px;
}

.chart-empty-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   CHART LOADING
   ============================================ */
.chart-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.chart-loading .spinner {
  margin-bottom: 16px;
}

.chart-loading-text {
  font-size: 14px;
}

/* ============================================
   CHART ERROR
   ============================================ */
.chart-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--error);
  text-align: center;
}

.chart-error-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.chart-error-text {
  font-size: 14px;
  margin-bottom: 16px;
}

.chart-error-retry {
  padding: 8px 16px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-base);
}

.chart-error-retry:hover {
  background: var(--danger-hover);
}

/* ============================================
   SPECIFIC CHART TYPES
   ============================================ */

/* Pie/Doughnut Chart */
.chart-container.chart-pie,
.chart-container.chart-doughnut {
  max-width: 400px;
  margin: 0 auto;
}

/* Radar Chart */
.chart-container.chart-radar {
  max-width: 500px;
  margin: 0 auto;
}

/* Polar Chart */
.chart-container.chart-polar {
  max-width: 450px;
  margin: 0 auto;
}

/* ============================================
   CHART TOOLTIPS (кастомные)
   ============================================ */
.chart-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.chart-tooltip.show {
  opacity: 1;
}

.chart-tooltip-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.chart-tooltip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.chart-tooltip-color {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.charts-widget-body::-webkit-scrollbar {
  width: 6px;
}

.charts-widget-body::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.charts-widget-body::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.charts-widget-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .chart-controls {
    flex-direction: column;
  }
  
  .chart-type-selector {
    width: 100%;
  }
  
  .chart-type-btn {
    flex: 1;
    justify-content: center;
  }
  
  .chart-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .chart-legend {
    flex-direction: column;
    gap: 8px;
  }
  
  .chart-container {
    min-height: 250px;
  }
}
/* === widgets/maps-widget.css === */
/**
 * maps-widget.css
 * Виджет карты с Leaflet
 */

/* ============================================
   MAPS WIDGET CONTAINER
   ============================================ */
.maps-widget-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.maps-widget-container .widget-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.maps-widget-container .widget-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-secondary);
}

/* ============================================
   LEAFLET MAP CONTAINER
   ============================================ */
.leaflet-map-container {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 0;
}

/* Leaflet container override */
.leaflet-container {
  font-family: var(--font-family);
  background: var(--bg-secondary);
}

/* ============================================
   MAP POPUP
   ============================================ */
.map-popup {
  padding: 8px;
  min-width: 200px;
}

.map-popup h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.map-popup p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-primary);
}

.map-popup p strong {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  margin: 12px;
  line-height: 1.5;
}

.leaflet-popup-tip {
  background: var(--bg-primary);
  border: 1px solid var(--border);
}

/* Dark mode popup */
[data-theme="dark"] .leaflet-popup-content-wrapper {
  background: var(--bg-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .leaflet-popup-tip {
  background: var(--bg-secondary);
}

/* ============================================
   MAP CONTROLS (Leaflet overrides)
   ============================================ */
.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-control-scale {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a,
.leaflet-control-layers-toggle {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border) !important;
  transition: var(--transition-base);
}

.leaflet-control-zoom a:hover {
  background-color: var(--bg-hover) !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

/* Layers control */
.leaflet-control-layers-expanded {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  padding: 12px !important;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.leaflet-control-layers-base label:hover,
.leaflet-control-layers-overlays label:hover {
  color: var(--primary);
}

.leaflet-control-layers-separator {
  border-top: 1px solid var(--border) !important;
  margin: 8px -12px !important;
}

/* Scale control */
.leaflet-control-scale-line {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border) !important;
  border-top: none !important;
  color: var(--text-primary) !important;
  font-size: 11px;
  padding: 2px 6px;
}

/* ============================================
   MARKER CLUSTERS
   ============================================ */
.marker-cluster {
  background-color: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
}

.marker-cluster div {
  background-color: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster-small div {
  width: 30px;
  height: 30px;
}

.marker-cluster-medium div {
  width: 40px;
  height: 40px;
}

.marker-cluster-large div {
  width: 50px;
  height: 50px;
  font-size: 16px;
}

/* ============================================
   CUSTOM MARKERS
   ============================================ */
.waypoint-marker {
  background: transparent;
  border: none;
}

.circle-marker-icon,
.pin-marker-icon,
.custom-marker-icon {
  background: transparent;
  border: none;
}

/* ============================================
   MEASUREMENT TOOL
   ============================================ */
.measurement-hint {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  user-select: none;
}

[data-theme="dark"] .measurement-hint {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
}

.measurement-label {
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: none;
  box-shadow: var(--shadow-md);
}

.measurement-result-popup .leaflet-popup-content {
  margin: 8px;
}

.measurement-result h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.measurement-result .result-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin: 8px 0 12px 0;
}

/* ============================================
   ROUTE LAYER
   ============================================ */
.route-popup h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.route-popup p {
  margin: 4px 0;
  font-size: 13px;
}

.step-popup p {
  margin: 4px 0;
  font-size: 13px;
}

.step-popup i {
  margin-right: 4px;
  color: var(--primary);
}

.alt-route-popup h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================
   DROPDOWN MENU (экспорт и т.д.)
   ============================================ */
.maps-widget-container .dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px 0;
  z-index: var(--z-dropdown);
  margin-top: 4px;
}

.maps-widget-container .dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-base);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.maps-widget-container .dropdown-menu .dropdown-item:hover {
  background: var(--bg-hover);
}

.maps-widget-container .dropdown-menu .dropdown-item i {
  font-size: 16px;
  color: var(--text-secondary);
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */
.maps-widget-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-modal);
  background: var(--bg-primary);
}

.map-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-max);
}

/* ============================================
   LOADING STATE
   ============================================ */
.maps-content .loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-muted);
}

.maps-content .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

/* ============================================
   ERROR STATE
   ============================================ */
.maps-content .alert {
  margin: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.maps-content .alert-warning {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: var(--text-primary);
}

.maps-content .alert i {
  font-size: 20px;
  color: var(--warning);
  flex-shrink: 0;
}

/* ============================================
   LEGEND
   ============================================ */
.leaflet-control-legend {
  background: var(--bg-primary);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  min-width: 150px;
}

.leaflet-control-legend h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   COORDINATES CONTROL
   ============================================ */
.leaflet-control-coordinates {
  background: var(--bg-primary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-family: var(--font-family-mono);
  color: var(--text-primary);
}

/* ============================================
   TOOLTIPS
   ============================================ */
.leaflet-tooltip {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
}

.leaflet-tooltip:before {
  border-top-color: var(--bg-inverse);
}

/* ============================================
   SEARCH INPUT (в header)
   ============================================ */
.maps-widget-container .form-control {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 13px;
  transition: var(--transition-base);
}

.maps-widget-container .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.maps-widget-container .form-control::placeholder {
  color: var(--text-muted);
}

/* ============================================
   BUTTONS IN HEADER
   ============================================ */
.maps-widget-container .widget-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.maps-widget-container .widget-actions .btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 6px;
}

.maps-widget-container .widget-actions .btn i {
  font-size: 14px;
}

/* ============================================
   HEATMAP (leaflet.heat)
   ============================================ */
.leaflet-heatmap-layer {
  opacity: 0.7;
}

/* ============================================
   ATTRIBUTION
   ============================================ */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.8) !important;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm) 0 0 0;
}

[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.8) !important;
  color: var(--text-primary);
}

.leaflet-control-attribution a {
  color: var(--primary);
  text-decoration: none;
}

.leaflet-control-attribution a:hover {
  text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .maps-widget-container .widget-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .maps-widget-container .widget-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .maps-widget-container .widget-actions .form-control {
    width: 100%;
  }
  
  .maps-widget-container .widget-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Leaflet controls стек вертикально */
  .leaflet-top.leaflet-right {
    right: 10px;
    top: 10px;
  }
  
  .leaflet-bottom.leaflet-right {
    right: 10px;
    bottom: 10px;
  }
  
  .leaflet-control-zoom {
    margin-bottom: 8px !important;
  }
}

@media (max-width: 480px) {
  .leaflet-popup-content-wrapper {
    max-width: 250px;
  }
  
  .map-popup {
    min-width: auto;
  }
  
  .measurement-hint {
    font-size: 12px;
    padding: 8px 16px;
  }
  
  /* Скрыть attribution на маленьких экранах */
  .leaflet-control-attribution {
    display: none;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .maps-widget-container .widget-header,
  .maps-widget-container .widget-actions,
  .leaflet-control-zoom,
  .leaflet-control-layers,
  .measurement-hint {
    display: none !important;
  }
  
  .maps-widget-container .widget-content {
    height: auto !important;
    min-height: 600px;
  }
  
  .leaflet-map-container {
    page-break-inside: avoid;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.leaflet-container:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.leaflet-control-zoom a:focus,
.leaflet-control-layers-toggle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   CUSTOM LEAFLET BUTTON
   ============================================ */
.leaflet-bar button,
.leaflet-control-button {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border) !important;
  transition: var(--transition-base);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 16px;
}

.leaflet-bar button:hover,
.leaflet-control-button:hover {
  background: var(--bg-hover) !important;
}

.leaflet-bar button:last-child {
  border-bottom: none !important;
}

/* ============================================
   DARK MODE OVERRIDES
   ============================================ */
[data-theme="dark"] .leaflet-container {
  background: #1a1a1a;
}

[data-theme="dark"] .leaflet-control-zoom a,
[data-theme="dark"] .leaflet-control-layers-toggle,
[data-theme="dark"] .leaflet-control-layers-expanded {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .leaflet-control-zoom a:hover {
  background-color: var(--bg-hover) !important;
}

[data-theme="dark"] .marker-cluster {
  background-color: var(--primary-light);
}

[data-theme="dark"] .marker-cluster div {
  background-color: var(--primary);
}

/* ============================================
   POPUP LINKS & FORMATTING
   ============================================ */
.map-popup {
  font-family: var(--font-family);
  max-width: 320px;
}

.map-popup .popup-title {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.map-popup .popup-title-link {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-base);
}

.map-popup .popup-title-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.map-popup .popup-code {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.map-popup .popup-field {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
}

.map-popup .popup-field strong {
  color: var(--text-secondary);
  display: inline-block;
  min-width: 100px;
}

.map-popup .popup-field-value {
  color: var(--text-primary);
}

/* HANDBOOK field links */
.map-popup .popup-handbook-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.map-popup .popup-handbook-link {
  color: var(--primary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: inline-block;
  transition: var(--transition-base);
  font-size: 13px;
}

.map-popup .popup-handbook-link:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

.map-popup .popup-handbook-value {
  color: var(--text-primary);
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: inline-block;
  font-size: 13px;
}

/* Dark mode */
[data-theme="dark"] .map-popup .popup-title-link {
  color: var(--primary-light);
}

[data-theme="dark"] .map-popup .popup-title-link:hover {
  color: var(--primary);
}

[data-theme="dark"] .map-popup .popup-handbook-link {
  background: rgba(33, 150, 243, 0.2);
}

[data-theme="dark"] .map-popup .popup-handbook-link:hover {
  background: var(--primary);
  color: white;
}

/* ============================================
   FIELDS (специальные типы полей)
   ============================================ */
/* === fields/special-fields.css === */
/**
 * special-fields.css
 * Специальные типы полей: rating, slider, progress, color, etc.
 */

/* ============================================
   RATING FIELD (звездочки)
   ============================================ */
.rating-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rating-star {
  font-size: 24px;
  color: var(--border);
  cursor: pointer;
  transition: var(--transition-base);
  user-select: none;
}

.rating-star:hover,
.rating-star.filled {
  color: var(--color-yellow-500);
}

.rating-star.half {
  position: relative;
  color: var(--border);
}

.rating-star.half::before {
  content: '★';
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: var(--color-yellow-500);
}

.rating-field.readonly .rating-star {
  cursor: default;
}

.rating-value {
  margin-left: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Размеры */
.rating-field.rating-sm .rating-star {
  font-size: 18px;
}

.rating-field.rating-lg .rating-star {
  font-size: 32px;
}

/* ============================================
   SLIDER FIELD (ползунок)
   ============================================ */
.slider-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-input {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-base);
}

.slider-input::-webkit-slider-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.slider-input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-base);
}

.slider-input::-moz-range-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.slider-value {
  min-width: 50px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   PROGRESS FIELD (прогресс-бар)
   ============================================ */
.progress-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-container {
  width: 100%;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--success-hover));
  border-radius: var(--radius-xl);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
}

.progress-bar-fill.progress-warning {
  background: linear-gradient(90deg, var(--warning), var(--color-orange-600));
}

.progress-bar-fill.progress-danger {
  background: linear-gradient(90deg, var(--error), var(--danger-hover));
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================
   COLOR FIELD (цветовой пикер)
   ============================================ */
.color-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-picker-input {
  width: 60px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition-base);
}

.color-picker-input:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.color-picker-input input[type="color"] {
  width: 100%;
  height: 100%;
  border: none;
  cursor: pointer;
}

.color-value {
  font-family: monospace;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.color-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-preset {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition-base);
}

.color-preset:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.color-preset.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ============================================
   SWITCH FIELD (переключатель)
   ============================================ */
.switch-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.switch-toggle {
  position: relative;
  width: 50px;
  height: 26px;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.3s;
}

.switch-toggle input[type="checkbox"] {
  display: none;
}

.switch-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: var(--radius-full);
  transition: transform 0.3s;
  box-shadow: var(--shadow-sm);
}

.switch-toggle input[type="checkbox"]:checked + .switch-slider {
  transform: translateX(24px);
}

.switch-toggle.checked {
  background: var(--success);
}

.switch-label {
  font-size: 14px;
  color: var(--text-primary);
  user-select: none;
}

/* ============================================
   TAGS FIELD (теги)
   ============================================ */
.tags-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 42px;
  background: var(--bg-primary);
}

.tags-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.tag-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: var(--transition-base);
}

.tag-remove:hover {
  color: var(--error);
}

.tags-input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  padding: 4px;
  font-size: 14px;
  background: transparent;
  color: var(--text-primary);
}

/* ============================================
   ICON FIELD (выбор иконки)
   ============================================ */
.icon-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.icon-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.icon-preview {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 28px;
  color: var(--text-secondary);
}

.icon-picker-btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition-base);
}

.icon-picker-btn:hover {
  background: var(--primary-hover);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.icon-option {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 24px;
  transition: var(--transition-base);
  color: var(--text-secondary);
}

.icon-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.icon-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   TIME FIELD (время)
   ============================================ */
.time-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.time-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: monospace;
  width: 100px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.time-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   DURATION FIELD (длительность)
   ============================================ */
.duration-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.duration-input {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.duration-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.duration-unit {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================
   SIGNATURE FIELD (подпись)
   ============================================ */
.signature-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signature-canvas {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: crosshair;
  background: var(--bg-primary);
}

.signature-canvas.signed {
  border-style: solid;
  border-color: var(--success);
}

.signature-actions {
  display: flex;
  gap: 8px;
}

.signature-clear {
  padding: 6px 12px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-base);
}

.signature-clear:hover {
  background: var(--danger-hover);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .icon-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .tags-container {
    min-height: 60px;
  }
  
  .color-presets {
    max-width: 100%;
  }
}
/* === fields/multiple.css === */
/**
 * multiple.css
 * Поля с множественными значениями (multiple select, chips, etc.)
 */

/* ============================================
   MULTIPLE VALUES CONTAINER
   ============================================ */
.multiple-values-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   MULTIPLE VALUES DISPLAY
   ============================================ */
.multiple-values-display {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
}

.multiple-values-display.inline {
  flex-direction: row;
  flex-wrap: wrap;
}

.multiple-values-display::-webkit-scrollbar {
  width: 6px;
}

.multiple-values-display::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.multiple-values-display::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.multiple-values-display::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

.multiple-value-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition-base);
}

.multiple-value-item:hover {
  box-shadow: var(--shadow-sm);
}

.multiple-value-text {
  flex: 1;
  color: var(--text-primary);
}

.multiple-value-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: var(--transition-base);
}

.multiple-value-remove:hover {
  color: var(--error);
}

/* ============================================
   CHIPS (тэги с удалением)
   ============================================ */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 42px;
  background: var(--bg-primary);
}

.chips-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition-base);
}

.chip:hover {
  background: var(--primary);
  color: white;
}

.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: currentColor;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: var(--transition-base);
}

.chip-remove:hover {
  color: var(--error);
}

.chip-input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  padding: 6px;
  font-size: 14px;
  background: transparent;
  color: var(--text-primary);
}

/* ============================================
   MULTIPLE SELECT DROPDOWN
   ============================================ */
.multiple-select-field {
  position: relative;
}

.multiple-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.multiple-select-trigger:hover {
  border-color: var(--primary);
}

.multiple-select-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.multiple-select-placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.multiple-select-count {
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.multiple-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.multiple-select-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.multiple-select-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.multiple-select-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.multiple-select-options {
  list-style: none;
  padding: 4px;
  margin: 0;
}

.multiple-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.multiple-select-option:hover {
  background: var(--bg-hover);
}

.multiple-select-option input[type="checkbox"] {
  cursor: pointer;
}

.multiple-select-option-label {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.multiple-select-option.selected {
  background: var(--primary-light);
}

.multiple-select-actions {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--bg-primary);
}

/* ============================================
   BATCH SELECT DIALOG
   ============================================ */
.batch-select-values {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-select-search {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.batch-select-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.batch-select-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.batch-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-base);
}

.batch-select-item:last-child {
  border-bottom: none;
}

.batch-select-item:hover {
  background: var(--bg-hover);
}

.batch-select-item input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.batch-select-item-content {
  flex: 1;
}

.batch-select-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.batch-select-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.batch-select-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.batch-select-count {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.batch-select-count strong {
  color: var(--primary);
  font-weight: 700;
}

/* ============================================
   HANDBOOK MULTIPLE FIELD (справочник с множественным выбором)
   ============================================ */
.handbook-multiple-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.handbook-multiple-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 42px;
}

.handbook-multiple-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition-base);
}

.handbook-multiple-item:hover {
  box-shadow: var(--shadow-sm);
}

.handbook-multiple-item-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-base);
}

.handbook-multiple-item-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.handbook-multiple-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: var(--transition-base);
}

.handbook-multiple-item-remove:hover {
  color: var(--error);
}

.handbook-multiple-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.multiple-values-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.multiple-select-dropdown::-webkit-scrollbar,
.batch-select-list::-webkit-scrollbar {
  width: 6px;
}

.multiple-select-dropdown::-webkit-scrollbar-track,
.batch-select-list::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.multiple-select-dropdown::-webkit-scrollbar-thumb,
.batch-select-list::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.multiple-select-dropdown::-webkit-scrollbar-thumb:hover,
.batch-select-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .multiple-select-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .chips-container {
    min-height: 60px;
  }
  
  .batch-select-list {
    max-height: 300px;
  }
}

/* ========================================
   🔥 LABELED MULTIPLE FIELDS
   Множественные поля с метками
   ======================================== */

.labeled-multiple-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.labeled-multiple-inputs {
  display: flex;
  gap: 8px;
  flex: 1;
}

.labeled-multiple-inputs select.labeled-select {
  flex: 0 0 180px;
  min-width: 180px;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  background-color: var(--input-bg, #fff);
  font-size: 14px;
  transition: border-color 0.2s;
}

.labeled-multiple-inputs select.labeled-select:focus {
  outline: none;
  border-color: var(--primary-color, #0066cc);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.labeled-multiple-inputs input.labeled-value {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  background-color: var(--input-bg, #fff);
  font-size: 14px;
  transition: border-color 0.2s;
}

.labeled-multiple-inputs input.labeled-value:focus {
  outline: none;
  border-color: var(--primary-color, #0066cc);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.labeled-multiple-row .btn-remove-value {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-top: 2px;
}

/* Disabled/Readonly состояния */
.labeled-multiple-inputs select.labeled-select:disabled,
.labeled-multiple-inputs input.labeled-value:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
  .labeled-multiple-inputs {
    flex-direction: column;
    gap: 6px;
  }
  
  .labeled-multiple-inputs select.labeled-select {
    flex: 1;
    max-width: 100%;
  }
  
  .labeled-multiple-inputs input.labeled-value {
    min-width: 100%;
  }
}

/* Стили для ошибок валидации */
.labeled-multiple-row.has-error select.labeled-select,
.labeled-multiple-row.has-error input.labeled-value {
  border-color: var(--error-color, #dc3545);
}

.labeled-multiple-row.has-error select.labeled-select:focus,
.labeled-multiple-row.has-error input.labeled-value:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}
/* === fields/address-field.css === */
/**
 * address-field.css
 * Стили для компонента AddressField
 */

/* ============================================
   ADDRESS FIELD WRAPPER
   ============================================ */
.address-field-wrapper {
  width: 100%;
  margin-bottom: var(--space-sm);
}

/* ============================================
   INPUT SECTION (основной input + статус)
   ============================================ */
.address-input-section {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.address-input-wrapper {
  flex: 1;
  position: relative;
}

.address-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition-base);
}

.address-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.address-input:disabled {
  background: var(--bg-disabled);
  cursor: not-allowed;
  color: var(--text-disabled);
}

/* ============================================
   SUGGESTIONS DROPDOWN
   ============================================ */
.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: -1px;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: var(--bg-hover);
}

/* ============================================
   ADDRESS STATUS
   ============================================ */
.address-status {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.address-status-text {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-map-adjust {
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.btn-map-adjust:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

/* ============================================
   TOGGLE DETAILS BUTTON
   ============================================ */
.btn-toggle-details {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition-base);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-toggle-details:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-toggle-details:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.toggle-icon {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 12px;
}

/* ============================================
   ADDRESS DETAILS (раскрывающаяся секция)
   ============================================ */
.address-details {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  animation: fadeInDown 0.3s ease-out;
}

/* ============================================
   ADDRESS STRUCTURE (поля внутри details)
   ============================================ */
.address-structure {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.address-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.address-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.address-form-group-small {
  min-width: 100px;
  flex: 0 0 100px;
}

.address-form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.address-form-group input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition-base);
}

.address-form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.address-form-group input:disabled {
  background: var(--bg-disabled);
  cursor: not-allowed;
  color: var(--text-disabled);
}

.address-form-group input[required] {
  border-left: 3px solid var(--primary);
}

/* ============================================
   COORDINATES DISPLAY
   ============================================ */
.address-coordinates {
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.address-coordinates strong {
  color: var(--text-primary);
  font-weight: 600;
}

.address-coordinates small {
  color: var(--text-muted);
  font-size: 12px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .address-input-section {
    flex-direction: column;
    gap: 8px;
  }
  
  .address-status {
    width: 100%;
    justify-content: space-between;
  }
  
  .address-form-row {
    grid-template-columns: 1fr;
  }
  
  .address-form-group-small {
    min-width: auto;
    flex: 1;
  }
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */
[data-theme="dark"] .address-suggestions {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .address-details {
  background: var(--bg-tertiary);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* === fields/table-field.css === */
/**
 * table-field.css
 * Табличные поля (редактируемые таблицы в полях)
 */

/* ============================================
   TABLE FIELD CONTAINER
   ============================================ */
.table-field-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  overflow: hidden;
}

/* ============================================
   TABLE FIELD TOOLBAR
   ============================================ */
.table-field-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.table-field-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.table-field-actions {
  display: flex;
  gap: 8px;
}

.table-field-action-btn {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-field-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.table-field-action-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.table-field-action-btn.primary:hover {
  background: var(--primary-hover);
}

/* ============================================
   TABLE FIELD WRAPPER
   ============================================ */
.table-field-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
  -webkit-overflow-scrolling: touch;
}

/* В fullscreen-модалке таблица растёт свободно */
.modal-fullscreen .table-field-wrapper {
  max-height: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Sticky thead работает внутри wrapper-скролла */
.modal-fullscreen .table-field-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-secondary, #f8f9fa);
}

/* Sticky tfoot снизу */
.modal-fullscreen .table-field-tfoot {
  position: sticky;
  bottom: 0;
  z-index: 9;
}

.modal-fullscreen .table-field-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.modal-fullscreen .modal-body {
  display: flex;
  flex-direction: column;
}

.modal-fullscreen .modal-body > div {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.table-field-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-field-wrapper::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.table-field-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-sm);
}

.table-field-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   TABLE FIELD TABLE
   ============================================ */
.table-field-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-field-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-field-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table-field-table th.actions-column {
  width: 80px;
  text-align: center;
}

.table-field-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-primary);
  min-width: 120px;
}

.table-field-table tbody tr:hover {
  background: var(--bg-hover);
}

.table-field-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   TABLE FIELD CELL
   ============================================ */
.table-field-cell {
  position: relative;
}

.table-field-cell-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--text-primary);
  transition: var(--transition-base);
}

.table-field-cell-input:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.table-field-cell-input:focus {
  outline: none;
  background: var(--bg-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.table-field-cell-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.table-field-cell-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.table-field-cell-checkbox {
  display: flex;
  justify-content: center;
}

.table-field-cell-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ============================================
   TABLE FIELD ROW ACTIONS
   ============================================ */
.table-field-row-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.table-field-table tbody tr:hover .table-field-row-actions {
  opacity: 1;
}

.table-field-row-action {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-field-row-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.table-field-row-action.delete:hover {
  background: var(--error-light);
  color: var(--error);
}

.table-field-row-action.move {
  cursor: grab;
}

.table-field-row-action.move:active {
  cursor: grabbing;
}

/* ============================================
   TABLE FIELD DRAGGING
   ============================================ */
.table-field-row.dragging {
  opacity: 0.5;
  background: var(--primary-light);
}

.table-field-row.drag-over {
  border-top: 3px solid var(--primary);
}

/* ============================================
   TABLE FIELD ADD ROW
   ============================================ */
.table-field-add-row {
  padding: 12px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
}

.table-field-add-btn {
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.table-field-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   TABLE FIELD VALIDATION
   ============================================ */
.table-field-cell.error .table-field-cell-input {
  border-color: var(--error);
  background: var(--error-light);
}

.table-field-cell-error {
  position: absolute;
  bottom: -20px;
  left: 0;
  font-size: 11px;
  color: var(--error);
  white-space: nowrap;
}

/* ============================================
   TABLE FIELD EMPTY STATE
   ============================================ */
.table-field-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.table-field-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.table-field-empty-text {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ============================================
   TABLE FIELD TOTALS ROW (tfoot)
   ============================================ */
.table-field-tfoot {
  position: sticky;
  bottom: 0;
  z-index: 9;
}

.table-field-totals-row {
  background: #fefce8;
}

.table-field-totals-row td {
  padding: 10px 12px !important;
  border-top: 2px solid #eab308 !important;
  border-bottom: 2px solid #eab308 !important;
  font-weight: 700;
  font-size: 14px;
  color: #92400e;
  background: #fefce8 !important;
}

.table-field-totals-row td:first-child {
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #78350f;
}

.table-field-totals-row .has-total {
  background: #fef3c7 !important;
}

.table-field-totals-row .total-value {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: #92400e;
}

/* Hover на totals не нужен */
.table-field-table tfoot tr:hover td {
  background: #fefce8 !important;
}

/* ============================================
   TABLE FIELD SUMMARY
   ============================================ */
.table-field-summary {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.table-field-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-field-summary-label {
  font-weight: 500;
}

.table-field-summary-value {
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   TABLE FIELD COLUMN CONFIG
   ============================================ */
.table-field-column-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.column-config-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.column-config-drag {
  cursor: grab;
  color: var(--text-muted);
  font-size: 18px;
}

.column-config-drag:active {
  cursor: grabbing;
}

.column-config-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.column-config-type {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 120px;
}

.column-config-remove {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 18px;
  transition: var(--transition-base);
}

.column-config-remove:hover {
  background: var(--error-light);
  color: var(--error);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .table-field-wrapper {
    max-height: 400px;
  }
  
  .table-field-table {
    font-size: 13px;
  }
  
  .table-field-table th,
  .table-field-table td {
    padding: 8px;
  }
  
  .table-field-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .table-field-actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .table-field-action-btn {
    flex: 1;
  }
}

/* Loading состояние для строки */
.table-field-row.loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.table-field-row.loading::after {
  content: "⏳ Загрузка данных банка...";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #2196f3;
  font-size: 12px;
  font-weight: 500;
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
}

.btn-load-bank-info:hover {
  background: #1976d2 !important;
  transform: scale(1.05);
  transition: all 0.2s;
}

.btn-load-bank-info:active {
  transform: scale(0.95);
}

/* ============================================
   TABLE COLUMN EDITOR — MODERN LOOK
   ============================================ */

.table-columns-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Карточка колонки */
.table-column-row {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Заголовок */
.table-column-row .column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.column-header strong {
  font-size: 15px;
  font-weight: 600;
}

/* Кнопки ↑ ↓ × */
.column-controls {
  display: flex;
  gap: 4px;
}

.column-controls button {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.column-controls button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.column-controls .btn-remove-column:hover {
  background: var(--error-light);
  color: var(--error);
}

/* Ряды полей */
.table-column-row .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Типы (HANDBOOK / SELECT / FORMULA) */
.column-handbook-select,
.column-select-options,
.column-formula-config {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Чекбоксы компактнее */
.table-column-row label {
  font-size: 14px;
  gap: 8px;
}

/* MULTI select */
.table-column-row select[multiple] {
  min-height: 110px;
}

/* Кнопка добавить колонку */
.table-columns-editor .btn-add-column {
  align-self: stretch;
}

/* READONLY */
.table-columns-editor [disabled] {
  opacity: 0.65;
}

/* Mobile */
@media (max-width: 768px) {
  .table-column-row {
    padding: 14px;
  }

  .table-column-row .form-row {
    grid-template-columns: 1fr;
  }

  .column-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ============================================
   HANDBOOK CHECKBOXES - HOVER FIX
   ============================================ */
.handbook-checkbox-label {
  transition: background 0.2s;
}

.handbook-checkbox-label:hover {
  background: #f5f5f5 !important;
}

.handbook-checkbox-label input[type="checkbox"] {
  pointer-events: auto !important;
  cursor: pointer !important;
  min-width: 18px;
  min-height: 18px;
}

/* Убедиться что чекбокс кликабельный */
.multiple-handbooks-select input[type="checkbox"] {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

/* ============================================
   TABLE FIELD TOOLTIP (preview popup)
   ============================================ */
.table-preview,
.labeled-multiple-preview {
  display: inline-flex;
  align-items: center;
}

.table-preview-text,
.labeled-preview-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  white-space: nowrap;
}

.table-preview-text:hover,
.labeled-preview-text:hover {
  background: var(--primary-light);
}

.table-preview-text .info-icon,
.labeled-preview-text .info-icon {
  font-size: 12px;
  opacity: 0.6;
}

.table-tooltip,
.labeled-tooltip {
  position: fixed;
  z-index: 10001;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow-x: auto;
  overflow-y: auto;
  max-width: min(600px, calc(100vw - 24px));
  max-height: min(400px, calc(100vh - 24px));
  overscroll-behavior: contain;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  -webkit-overflow-scrolling: touch;
}

.table-tooltip.visible,
.labeled-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

.table-tooltip .tooltip-table,
.labeled-tooltip .tooltip-table,
.table-field-popup .tooltip-table {
  border-collapse: collapse;
  font-size: 13px;
  width: max-content;
  min-width: 100%;
}

.table-tooltip-scroll {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.table-popup-trigger {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  white-space: nowrap;
}

.table-popup-trigger:hover {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

.table-field-popup {
  position: fixed;
  z-index: 10001;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: auto;
  max-width: min(600px, calc(100vw - 24px));
  max-height: min(400px, calc(100vh - 24px));
}

.table-field-popup .table-tooltip-scroll {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.table-tooltip .tooltip-table thead,
.labeled-tooltip .tooltip-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-tooltip .tooltip-table th,
.table-tooltip .tooltip-table thead th,
.labeled-tooltip .tooltip-table th,
.labeled-tooltip .tooltip-table thead th,
.table-field-popup .tooltip-table th,
.table-field-popup .tooltip-table thead th {
  padding: 8px 12px !important;
  background: #f8f9fa !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  color: #616161 !important;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border) !important;
  text-align: left;
  white-space: nowrap;
}

.table-tooltip .tooltip-table td,
.labeled-tooltip .tooltip-table td,
.table-field-popup .tooltip-table td {
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--border-light) !important;
  color: var(--text-primary) !important;
  background: var(--bg-primary) !important;
  line-height: 1.4;
  max-width: 300px;
  max-height: 3.6em;
  white-space: normal;
  word-break: break-word;
  overflow-y: auto;
  vertical-align: top;
}

.table-tooltip .tooltip-table tbody tr:hover td,
.labeled-tooltip .tooltip-table tbody tr:hover td,
.table-field-popup .tooltip-table tbody tr:hover td {
  background: var(--bg-hover) !important;
}

.table-tooltip .tooltip-table tbody tr:last-child td,
.labeled-tooltip .tooltip-table tbody tr:last-child td,
.table-field-popup .tooltip-table tbody tr:last-child td {
  border-bottom: none !important;
}

.table-tooltip .tooltip-table tfoot td,
.table-field-popup .tooltip-table tfoot td {
  padding: 8px 12px !important;
  background: #f8f9fa !important;
  border-top: 2px solid var(--border) !important;
  font-weight: 600;
}

/* ============================================
   TOOLTIP MOBILE
   ============================================ */
@media (max-width: 768px) {
  .table-tooltip,
  .labeled-tooltip {
    max-width: calc(100vw - 16px);
    max-height: 50vh;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
  }

  .table-tooltip .tooltip-table th,
  .labeled-tooltip .tooltip-table th {
    padding: 6px 8px;
    font-size: 11px;
  }

  .table-tooltip .tooltip-table td,
  .labeled-tooltip .tooltip-table td {
    padding: 6px 8px;
    font-size: 12px;
    max-width: 120px;
  }
}

/* ============================================
   TABLE FIELD - CELL MIN WIDTHS BY TYPE
   ============================================ */
.table-field-table td .address-compact-cell,
.table-field-table td .labeled-multiple-cell.labeled-address-cell {
  min-width: 280px;
}

.table-field-table td .address-compact-input {
  min-width: 200px;
}

.table-field-table td .labeled-multiple-cell {
  min-width: 200px;
}

.table-field-table .table-field-input[type="text"],
.table-field-table .table-field-input[type="email"],
.table-field-table .table-field-input[type="tel"],
.table-field-table .table-field-input[type="url"] {
  min-width: 140px;
}

.table-field-table .table-field-input[type="number"] {
  min-width: 100px;
}

.table-field-table .table-field-input[type="date"],
.table-field-table .table-field-input[type="datetime-local"] {
  min-width: 150px;
}

/* Drag handle и actions — фиксированная ширина */
.table-field-drag-handle {
  min-width: 40px !important;
  max-width: 40px;
}

.table-field-actions {
  min-width: 50px !important;
  max-width: 60px;
}

/* ============================================
   TABLE FIELD - FULLSCREEN MODAL MOBILE
   ============================================ */
@media (max-width: 768px) {
  .table-edit-dialog-container .table-field-wrapper {
    max-height: calc(100vh - 180px);
  }
  
  .table-edit-dialog-container .table-field-table td {
    padding: 6px 8px;
  }
  
  .table-edit-dialog-container .table-field-table th {
    padding: 8px;
    font-size: 12px;
  }
  
  /* Адрес на мобилке — шире */
  .table-field-table td .address-compact-cell {
    min-width: 250px;
  }
  
  .table-field-table td .labeled-address-item {
    min-width: 240px;
  }
}

/* ============================================
   TOOLTIP TABLE — CELL MIN WIDTHS
   ============================================ */
.table-tooltip .tooltip-table td,
.table-tooltip .tooltip-table th {
  min-width: 100px;
  white-space: nowrap;
}

.table-tooltip .tooltip-table td a {
  white-space: nowrap;
}

/* Адресные ячейки в tooltip — разрешить перенос но с min-width */
.table-tooltip .tooltip-table td a[href*="maps"] {
  white-space: normal;
  min-width: 200px;
  display: inline-block;
}
/* === fields/condition-builder.css === */
/**
 * autocomplete.css
 * Автодополнение для различных типов полей
 */

/* ============================================
   AUTOCOMPLETE CONTAINER
   ============================================ */
.autocomplete-container {
  position: relative;
  width: 100%;
}

/* ============================================
   AUTOCOMPLETE INPUT
   ============================================ */
.autocomplete-input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.autocomplete-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.autocomplete-input.loading {
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='8' stroke='%232196f3' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.autocomplete-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.autocomplete-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-dropdown.hidden {
  display: none;
}

/* ============================================
   AUTOCOMPLETE OPTIONS
   ============================================ */
.autocomplete-options {
  list-style: none;
  padding: 4px;
  margin: 0;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.autocomplete-option:hover {
  background: var(--bg-hover);
}

.autocomplete-option.selected,
.autocomplete-option.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================
   OPTION CONTENT
   ============================================ */
.autocomplete-option-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  font-size: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.autocomplete-option-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-600) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.autocomplete-option-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.autocomplete-option-content {
  flex: 1;
  min-width: 0;
}

.autocomplete-option-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-option-meta,
.autocomplete-option-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-option-highlight {
  background: var(--color-yellow-200);
  font-weight: 600;
}

/* ============================================
   AUTOCOMPLETE GROUPS
   ============================================ */
.autocomplete-group {
  margin-bottom: 4px;
}

.autocomplete-group-header {
  padding: 8px 12px;
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ============================================
   AUTOCOMPLETE ACTIONS
   ============================================ */
.autocomplete-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--primary-light);
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  transition: var(--transition-base);
  position: sticky;
  bottom: 0;
}

.autocomplete-action:hover {
  background: var(--primary);
  color: white;
}

.autocomplete-action-icon {
  font-size: 18px;
}

/* ============================================
   AUTOCOMPLETE EMPTY
   ============================================ */
.autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.autocomplete-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ============================================
   AUTOCOMPLETE LOADING
   ============================================ */
.autocomplete-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

.autocomplete-loading .spinner {
  margin: 0 auto 8px;
}

.autocomplete-loading-text {
  font-size: 13px;
}

/* ============================================
   AUTOCOMPLETE SEARCH BOX (в dropdown)
   ============================================ */
.autocomplete-search-box {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.autocomplete-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.autocomplete-search-input:focus {
  border-color: var(--primary);
}

/* ============================================
   AUTOCOMPLETE DIVIDER
   ============================================ */
.autocomplete-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============================================
   AUTOCOMPLETE FOOTER
   ============================================ */
.autocomplete-footer {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  position: sticky;
  bottom: 0;
}

/* ============================================
   MENTION AUTOCOMPLETE (для @упоминаний)
   ============================================ */
.mention-autocomplete {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 250px;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-base);
}

.mention-option:hover,
.mention-option.active {
  background: var(--bg-hover);
}

.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-600) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.mention-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.mention-username {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ============================================
   TAG AUTOCOMPLETE (для #тегов)
   ============================================ */
.tag-autocomplete {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 200px;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-base);
}

.tag-option:hover,
.tag-option.active {
  background: var(--bg-hover);
}

.tag-color {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.tag-name {
  font-size: 13px;
  color: var(--text-primary);
}

.tag-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
}

/* ============================================
   EMOJI AUTOCOMPLETE (для :emoji:)
   ============================================ */
.emoji-autocomplete {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 280px;
}

.emoji-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-base);
}

.emoji-option:hover,
.emoji-option.active {
  background: var(--bg-hover);
}

.emoji-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.emoji-name {
  font-size: 13px;
  color: var(--text-primary);
}

.emoji-shortcode {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  margin-left: auto;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.autocomplete-dropdown::-webkit-scrollbar,
.mention-autocomplete::-webkit-scrollbar,
.tag-autocomplete::-webkit-scrollbar,
.emoji-autocomplete::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track,
.mention-autocomplete::-webkit-scrollbar-track,
.tag-autocomplete::-webkit-scrollbar-track,
.emoji-autocomplete::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb,
.mention-autocomplete::-webkit-scrollbar-thumb,
.tag-autocomplete::-webkit-scrollbar-thumb,
.emoji-autocomplete::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover,
.mention-autocomplete::-webkit-scrollbar-thumb:hover,
.tag-autocomplete::-webkit-scrollbar-thumb:hover,
.emoji-autocomplete::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   KEYBOARD NAVIGATION
   ============================================ */
.autocomplete-option.keyboard-selected {
  background: var(--primary-light);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .autocomplete-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .mention-autocomplete,
  .tag-autocomplete,
  .emoji-autocomplete {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    min-width: auto;
  }
}
/* === fields/field-selectors.css === */
/**
 * field-selectors.css
 * Селекторы полей и типов данных
 */

/* ============================================
   FIELD SELECTOR (выбор поля)
   ============================================ */
.field-selector {
  position: relative;
}

.field-selector-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition-base);
  min-height: 42px;
}

.field-selector-trigger:hover {
  border-color: var(--primary);
}

.field-selector-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.field-selector-placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.field-selector-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
}

.field-selector-icon {
  font-size: 16px;
  color: var(--text-secondary);
}

.field-selector-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}

/* ============================================
   FIELD SEARCH
   ============================================ */
.field-selector-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.field-selector-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.field-selector-search input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   FIELD OPTIONS
   ============================================ */
.field-selector-options {
  padding: 4px;
}

.field-selector-group {
  margin-bottom: 8px;
}

.field-selector-group-header {
  padding: 8px 12px;
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 50px;
  z-index: 5;
}

.field-selector-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
}

.field-selector-option:hover {
  background: var(--bg-hover);
}

.field-selector-option.selected {
  background: var(--primary-light);
  color: var(--primary);
}

.field-option-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  flex-shrink: 0;
}

.field-option-content {
  flex: 1;
  min-width: 0;
}

.field-option-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-option-code {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 2px;
}

.field-option-badge {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ============================================
   FIELD TYPE BADGES
   ============================================ */
.field-type-text { background: var(--primary-light); color: var(--primary); }
.field-type-number { background: var(--warning-light); color: var(--warning); }
.field-type-date { background: var(--color-purple-100); color: var(--color-purple-700); }
.field-type-boolean { background: var(--success-light); color: var(--success); }
.field-type-select { background: var(--color-pink-100); color: var(--color-pink-700); }
.field-type-multiple { background: var(--color-teal-100); color: var(--color-teal-700); }
.field-type-handbook { background: var(--color-yellow-100); color: var(--color-yellow-700); }
.field-type-file { background: var(--color-purple-100); color: var(--color-purple-700); }

/* ============================================
   HANDBOOK FIELD SELECTOR
   ============================================ */
.handbook-field-selector {
  position: relative;
}

.handbook-field-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition-base);
}

.handbook-field-trigger:hover {
  border-color: var(--primary);
}

.handbook-field-selected {
  display: flex;
  align-items: center;
  gap: 8px;
}

.handbook-field-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.handbook-field-code {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.handbook-field-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 350px;
  overflow-y: auto;
  z-index: 1000;
}

.handbook-field-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-base);
}

.handbook-field-option:hover {
  background: var(--bg-hover);
}

.handbook-field-option:last-child {
  border-bottom: none;
}

.handbook-field-option.selected {
  background: var(--primary-light);
}

/* ============================================
   ITEM FIELD SELECTOR (для элементов)
   ============================================ */
.item-field-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-field-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-field-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
}

.item-field-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.item-field-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.item-field-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.item-field-info {
  flex: 1;
  min-width: 0;
}

.item-field-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.item-field-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================
   FIELD TYPE SELECTOR (выбор типа поля)
   ============================================ */
.field-type-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.field-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-base);
}

.field-type-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.field-type-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.field-type-icon {
  font-size: 32px;
  color: var(--text-secondary);
}

.field-type-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.field-type-description {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.field-selector-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.field-selector-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.field-selector-empty-text {
  font-size: 14px;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.field-selector-dropdown::-webkit-scrollbar,
.handbook-field-dropdown::-webkit-scrollbar {
  width: 6px;
}

.field-selector-dropdown::-webkit-scrollbar-track,
.handbook-field-dropdown::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.field-selector-dropdown::-webkit-scrollbar-thumb,
.handbook-field-dropdown::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.field-selector-dropdown::-webkit-scrollbar-thumb:hover,
.handbook-field-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* ============================================
   HANDBOOK SELECT (для выбора элементов)
   ============================================ */
.handbook-select {
  position: relative;
  width: 100%;
}

.select-input {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  min-height: 38px;
  transition: var(--transition-base);
}

.select-input:hover {
  border-color: var(--primary);
}

.handbook-select[data-open="true"] .select-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.select-value {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
}

.select-value:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

.select-clear {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  margin-right: 4px;
  line-height: 1;
}

.select-clear:hover {
  color: var(--danger);
}

.select-arrow {
  margin-left: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  transition: transform 0.2s;
}

.handbook-select[data-open="true"] .select-arrow {
  transform: rotate(180deg);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.select-search {
  padding: 8px;
  border: none;
  border-bottom: 1px solid var(--border-light);
  outline: none;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.select-search:focus {
  background: var(--bg-secondary);
}

.select-options {
  overflow-y: auto;
  flex: 1;
}

.select-option {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
}

.select-option:hover {
  background: var(--bg-hover);
}

.select-option:last-child {
  border-bottom: none;
}

.option-value {
  font-size: 14px;
  color: var(--text-primary);
}

.option-handbook {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.option-code {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.select-no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .field-selector-dropdown,
  .handbook-field-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .field-type-selector {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }
  
  .field-type-card {
    padding: 12px;
  }
  
  .field-type-icon {
    font-size: 28px;
  }
}

/* ============================================
   🔥 POLYMORPHIC: Dropdown выбора справочника
   ============================================ */

/* Анимация появления */
@keyframes handbookSelectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Основной контейнер dropdown */
.handbook-selection-dropdown {
  position: fixed !important;
  background: var(--bg-primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 220px;
  max-width: 320px;
  overflow: hidden;
  z-index: 999999 !important;
  animation: handbookSelectionFadeIn 0.2s ease;
}

/* Заголовок */
.handbook-selection-header {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

/* Список справочников */
.handbook-selection-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

/* Scrollbar для списка */
.handbook-selection-list::-webkit-scrollbar {
  width: 6px;
}

.handbook-selection-list::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

.handbook-selection-list::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-xs);
}

.handbook-selection-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

/* Опция (справочник) */
.handbook-selection-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin: 2px 4px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  font-size: 14px;
  color: var(--text-primary);
}

.handbook-selection-option:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.handbook-selection-option:active {
  background: var(--primary-light);
  transform: scale(0.98);
}

/* ============================================
   RESPONSIVE: Polymorphic Dropdown
   ============================================ */
@media (max-width: 768px) {
  .handbook-selection-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .handbook-selection-list {
    max-height: 50vh;
  }
}

/* ============================================
   HANDBOOK CHIPS (мульти-выбор справочников)
   ============================================ */
.handbook-chips-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.handbook-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.handbook-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--primary);
  transition: var(--transition-base);
}

.handbook-chip:hover {
  background: var(--primary);
  color: white;
}

.handbook-chip:hover .chip-remove {
  color: white;
}

.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 50%;
  transition: var(--transition-base);
}

.chip-remove:hover {
  color: var(--error);
}

/* ============================================
   FEATURES (дополнительные фичи)
   ============================================ */
/* === features/markdown.css === */
/**
 * markdown.css
 * Markdown редактор — стили под реальную разметку MarkdownEditor.js
 *
 * Реальные классы из JS:
 *   .markdown-editor                  — главный контейнер
 *   .markdown-editor-toolbar          — панель инструментов
 *   .toolbar-btn / .toolbar-btn-toggle — кнопки тулбара
 *   .toolbar-divider                  — разделитель между группами
 *   .markdown-editor-container        — обёртка textarea + preview
 *   .markdown-editor-textarea-wrapper — обёртка textarea
 *   .markdown-editor-textarea         — textarea
 *   .markdown-editor-preview-wrapper  — обёртка preview
 *   .markdown-editor-preview          — preview контент
 *   .markdown-editor-footer           — счётчик символов
 *   .markdown-editor-files            — прикреплённые файлы
 *   .markdown-editor-actions          — кнопки «Отправить» / «Отмена»
 *   .file-preview-item                — превью файла
 *   .autocomplete-dropdown            — дропдаун автодополнения
 */

/* ============================================
   MAIN CONTAINER
   ============================================ */
.markdown-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.markdown-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Drag & drop active */
.markdown-editor.drag-over {
  border-color: var(--primary);
  border-style: dashed;
  background: var(--primary-light);
}

.markdown-editor.drag-over::after {
  content: '📎 Перетащите файлы сюда';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  z-index: 10;
  border-radius: var(--radius-lg);
  pointer-events: none;
}

[data-theme="dark"] .markdown-editor.drag-over::after {
  background: rgba(26, 26, 26, 0.85);
}

/* ============================================
   TOOLBAR  (.markdown-editor-toolbar)
   ============================================ */
.markdown-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  min-height: 42px;
}

/* ---- Toolbar button ---- */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.toolbar-btn:active {
  background: var(--bg-active);
  transform: scale(0.95);
}

.toolbar-btn.active,
.toolbar-btn-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---- Toolbar divider ---- */
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ============================================
   EDITOR INNER CONTAINER
   ============================================ */
.markdown-editor .markdown-editor-container {
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

/* ---- Textarea wrapper ---- */
.markdown-editor-textarea-wrapper {
  position: relative;
}

/* ---- Textarea ---- */
.markdown-editor-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 400px;
  padding: 14px 16px;
  border: none;
  outline: none;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  line-height: var(--line-height-relaxed);
  resize: vertical;
}

.markdown-editor-textarea::placeholder {
  color: var(--text-muted);
}

/* ---- Preview wrapper ---- */
.markdown-editor-preview-wrapper {
  border-top: 1px solid var(--border-light);
  max-height: 300px;
  overflow-y: auto;
}

/* ---- Preview content ---- */
.markdown-editor-preview {
  padding: 14px 16px;
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
}

.markdown-preview-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Preview typography */
.markdown-editor-preview h1,
.markdown-editor-preview h2,
.markdown-editor-preview h3 {
  margin: 16px 0 8px;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.markdown-editor-preview h1 { font-size: var(--font-size-2xl); border-bottom: 2px solid var(--border-light); padding-bottom: 6px; }
.markdown-editor-preview h2 { font-size: var(--font-size-xl); border-bottom: 1px solid var(--border-light); padding-bottom: 4px; }
.markdown-editor-preview h3 { font-size: var(--font-size-lg); }

.markdown-editor-preview p { margin: 0 0 10px; }
.markdown-editor-preview p:last-child { margin-bottom: 0; }

.markdown-editor-preview strong { font-weight: var(--font-weight-semibold); }
.markdown-editor-preview em { font-style: italic; }
.markdown-editor-preview del { text-decoration: line-through; color: var(--text-muted); }

.markdown-editor-preview a { color: var(--primary); text-decoration: none; }
.markdown-editor-preview a:hover { text-decoration: underline; }

.markdown-editor-preview code {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-red-600);
}

[data-theme="dark"] .markdown-editor-preview code {
  color: var(--color-red-300);
}

.markdown-editor-preview pre {
  margin: 12px 0;
  padding: 14px;
  background: var(--color-gray-900);
  color: var(--color-green-400);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.markdown-editor-preview pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-editor-preview blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--primary);
  background: var(--primary-light);
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-editor-preview blockquote p { margin: 0; }

.markdown-editor-preview ul,
.markdown-editor-preview ol {
  margin: 10px 0;
  padding-left: 24px;
}

.markdown-editor-preview li { margin: 4px 0; }

.markdown-editor-preview hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.markdown-editor-preview img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 8px 0;
}

.markdown-editor-preview .mention {
  color: var(--primary);
  font-weight: var(--font-weight-semibold);
  background: var(--primary-light);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
}

.markdown-editor-preview .item-link {
  color: var(--primary);
  font-weight: var(--font-weight-medium);
  border-bottom: 1px dotted var(--primary);
  text-decoration: none;
}

.markdown-editor-preview .hashtag {
  color: var(--color-purple-600);
  font-weight: var(--font-weight-medium);
}

.markdown-editor-preview .markdown-table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
}

.markdown-editor-preview .markdown-table th {
  background: var(--bg-secondary);
  padding: 8px 12px;
  text-align: left;
  font-weight: var(--font-weight-semibold);
  border: 1px solid var(--border);
}

.markdown-editor-preview .markdown-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.markdown-editor-preview .task-item {
  list-style: none;
  margin-left: -20px;
}

.markdown-editor-preview .task-item input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--primary);
}

/* ============================================
   FOOTER (char counter)
   ============================================ */
.markdown-editor-footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.char-counter {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ============================================
   ATTACHED FILES (.markdown-editor-files)
   ============================================ */
.markdown-editor-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px;
}

.markdown-editor-files:empty {
  display: none;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  max-width: 200px;
  transition: var(--transition-fast);
}

.file-preview-item:hover {
  border-color: var(--border);
}

.file-preview-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.file-preview-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.file-preview-name {
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.file-preview-remove {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.file-preview-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* ============================================
   ACTIONS (submit / cancel)
   ============================================ */
.markdown-editor-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 350px;
  overflow-y: auto;
  z-index: var(--z-popover);
  animation: fadeInUp 0.12s var(--ease-out);
}

.autocomplete-dropdown::-webkit-scrollbar { width: 5px; }
.autocomplete-dropdown::-webkit-scrollbar-track { background: transparent; }
.autocomplete-dropdown::-webkit-scrollbar-thumb { background: var(--color-gray-300); border-radius: var(--radius-full); }

/* Search box inside dropdown */
.autocomplete-search-box {
  position: sticky;
  top: 0;
  padding: 8px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  z-index: 1;
}

.autocomplete-search-input {
  width: 100%;
  padding: 7px 12px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.autocomplete-search-input:focus {
  border-color: var(--primary);
}

.autocomplete-search-input::placeholder {
  color: var(--text-muted);
}

/* Option */
.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.autocomplete-option:hover {
  background: var(--bg-hover);
}

/* Action option (← Назад, 🔍 Поиск) */
.autocomplete-option.autocomplete-action {
  color: var(--primary);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
}

.autocomplete-option.autocomplete-action:hover {
  background: var(--primary-light);
}

/* Divider */
.autocomplete-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* Avatar (for user autocomplete) */
.autocomplete-option-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-blue-500), var(--color-purple-500));
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

/* Icon (for item/handbook autocomplete) */
.autocomplete-option-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* Info block */
.autocomplete-option-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.autocomplete-option-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option-email,
.autocomplete-option-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
.autocomplete-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ============================================
   FULLSCREEN
   ============================================ */
.markdown-editor.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  border-radius: 0;
  border: none;
}

.markdown-editor.fullscreen .markdown-editor-textarea {
  max-height: none;
  flex: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .markdown-editor-toolbar {
    padding: 4px 6px;
    gap: 1px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .toolbar-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 5px;
    font-size: var(--font-size-xs);
  }

  .toolbar-divider {
    height: 16px;
    margin: 0 2px;
  }

  .markdown-editor-textarea {
    padding: 10px 12px;
    min-height: 60px;
  }

  .markdown-editor-actions {
    padding: 8px 12px;
  }

  .file-preview-item {
    max-width: 160px;
  }

  .autocomplete-dropdown {
    max-height: 250px;
  }
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] .markdown-editor-toolbar {
  background: var(--bg-secondary);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .toolbar-btn:hover {
  background: var(--bg-hover);
}

[data-theme="dark"] .markdown-editor-footer {
  background: var(--bg-secondary);
}

[data-theme="dark"] .markdown-editor-actions {
  background: var(--bg-secondary);
}

[data-theme="dark"] .file-preview-item {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

[data-theme="dark"] .autocomplete-dropdown {
  background: var(--bg-primary);
  border-color: var(--border);
}

[data-theme="dark"] .autocomplete-search-input {
  background: var(--bg-tertiary);
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  .markdown-editor-toolbar,
  .markdown-editor-footer,
  .markdown-editor-actions,
  .markdown-editor-files { display: none !important; }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .autocomplete-dropdown { animation: none; }
  .toolbar-btn { transition: none; }
}
/* === features/autocomplete.css === */
/**
 * autocomplete.css
 * Автодополнение для различных типов полей
 */

/* ============================================
   AUTOCOMPLETE CONTAINER
   ============================================ */
.autocomplete-container {
  position: relative;
  width: 100%;
}

/* ============================================
   AUTOCOMPLETE INPUT
   ============================================ */
.autocomplete-input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
}

.autocomplete-input:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.autocomplete-input.loading {
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='8' stroke='%232196f3' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.autocomplete-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.autocomplete-clear:hover {
  background: #f5f5f5;
  color: #333;
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-dropdown.hidden {
  display: none;
}

/* ============================================
   AUTOCOMPLETE OPTIONS
   ============================================ */
.autocomplete-options {
  list-style: none;
  padding: 4px;
  margin: 0;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.autocomplete-option:hover {
  background: #f5f5f5;
}

.autocomplete-option.selected,
.autocomplete-option.active {
  background: #e3f2fd;
  color: #1976d2;
}

/* ============================================
   OPTION CONTENT
   ============================================ */
.autocomplete-option-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 18px;
  color: #666;
  flex-shrink: 0;
}

.autocomplete-option-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.autocomplete-option-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.autocomplete-option-content {
  flex: 1;
  min-width: 0;
}

.autocomplete-option-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-option-meta,
.autocomplete-option-email {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-option-highlight {
  background: #ffeb3b;
  font-weight: 600;
}

/* ============================================
   AUTOCOMPLETE GROUPS
   ============================================ */
.autocomplete-group {
  margin-bottom: 4px;
}

.autocomplete-group-header {
  padding: 8px 12px;
  background: #f9f9f9;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ============================================
   AUTOCOMPLETE ACTIONS
   ============================================ */
.autocomplete-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f0f8ff;
  border-top: 1px solid #e0e0e0;
  cursor: pointer;
  font-weight: 600;
  color: #2196f3;
  transition: background 0.2s;
  position: sticky;
  bottom: 0;
}

.autocomplete-action:hover {
  background: #e3f2fd;
}

.autocomplete-action-icon {
  font-size: 18px;
}

/* ============================================
   AUTOCOMPLETE EMPTY
   ============================================ */
.autocomplete-empty {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.autocomplete-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ============================================
   AUTOCOMPLETE LOADING
   ============================================ */
.autocomplete-loading {
  padding: 20px;
  text-align: center;
  color: #999;
}

.autocomplete-loading .spinner {
  margin: 0 auto 8px;
}

.autocomplete-loading-text {
  font-size: 13px;
}

/* ============================================
   AUTOCOMPLETE SEARCH BOX (в dropdown)
   ============================================ */
.autocomplete-search-box {
  padding: 8px;
  border-bottom: 1px solid #e0e0e0;
  background: #f9f9f9;
  position: sticky;
  top: 0;
  z-index: 10;
}

.autocomplete-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.autocomplete-search-input:focus {
  border-color: #2196f3;
}

/* ============================================
   AUTOCOMPLETE DIVIDER
   ============================================ */
.autocomplete-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* ============================================
   AUTOCOMPLETE FOOTER
   ============================================ */
.autocomplete-footer {
  padding: 8px 12px;
  background: #f9f9f9;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
  color: #666;
  text-align: center;
  position: sticky;
  bottom: 0;
}

/* ============================================
   MENTION AUTOCOMPLETE (для @упоминаний)
   ============================================ */
.mention-autocomplete {
  position: absolute;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 250px;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.mention-option:hover,
.mention-option.active {
  background: #f5f5f5;
}

.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.mention-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.mention-username {
  font-size: 12px;
  color: #999;
  margin-left: 4px;
}

/* ============================================
   TAG AUTOCOMPLETE (для #тегов)
   ============================================ */
.tag-autocomplete {
  position: absolute;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 200px;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.tag-option:hover,
.tag-option.active {
  background: #f5f5f5;
}

.tag-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.tag-name {
  font-size: 13px;
  color: #333;
}

.tag-count {
  margin-left: auto;
  font-size: 11px;
  color: #999;
  padding: 2px 6px;
  background: #f5f5f5;
  border-radius: 10px;
}

/* ============================================
   EMOJI AUTOCOMPLETE (для :emoji:)
   ============================================ */
.emoji-autocomplete {
  position: absolute;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 280px;
}

.emoji-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.emoji-option:hover,
.emoji-option.active {
  background: #f5f5f5;
}

.emoji-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.emoji-name {
  font-size: 13px;
  color: #333;
}

.emoji-shortcode {
  font-size: 11px;
  color: #999;
  font-family: monospace;
  margin-left: auto;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.autocomplete-dropdown::-webkit-scrollbar,
.mention-autocomplete::-webkit-scrollbar,
.tag-autocomplete::-webkit-scrollbar,
.emoji-autocomplete::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track,
.mention-autocomplete::-webkit-scrollbar-track,
.tag-autocomplete::-webkit-scrollbar-track,
.emoji-autocomplete::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb,
.mention-autocomplete::-webkit-scrollbar-thumb,
.tag-autocomplete::-webkit-scrollbar-thumb,
.emoji-autocomplete::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover,
.mention-autocomplete::-webkit-scrollbar-thumb:hover,
.tag-autocomplete::-webkit-scrollbar-thumb:hover,
.emoji-autocomplete::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* ============================================
   KEYBOARD NAVIGATION
   ============================================ */
.autocomplete-option.keyboard-selected {
  background: #e3f2fd;
  outline: 2px solid #2196f3;
  outline-offset: -2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .autocomplete-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
  }
  
  .mention-autocomplete,
  .tag-autocomplete,
  .emoji-autocomplete {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50vh;
    border-radius: 16px 16px 0 0;
    min-width: auto;
  }
}
/* === features/media-viewer.css === */
/**
 * media-viewer.css
 * Просмотрщик медиа — стили под реальную разметку MediaViewer.js
 *
 * Реальные классы:
 *   .media-viewer-overlay (.active)     — фоновый слой
 *   .media-viewer-backdrop              — кликабельный фон для закрытия
 *   .media-viewer-container             — основной контейнер
 *   .media-viewer-header                — шапка (title + actions)
 *   .media-viewer-title                 — название файла (textContent)
 *   .media-viewer-actions               — обёртка кнопок
 *   .media-viewer-btn                   — кнопка действия (download, close)
 *   .media-viewer-content               — область контента
 *   .media-viewer-nav                   — контейнер навигации
 *   .media-viewer-nav-btn .prev/.next   — кнопки навигации
 *   .media-viewer-footer                — подвал (counter + size)
 *   .media-viewer-counter               — "2 / 5"
 *   .media-viewer-size                  — размер файла
 *   .media-viewer-image (.zoomed)       — изображение
 *   .media-viewer-video                 — видео
 *   .media-viewer-pdf                   — контейнер PDF
 *   .pdf-toolbar / .pdf-nav-btn         — тулбар PDF
 *   .pdf-page-info / .pdf-page-input    — навигация по страницам
 *   .pdf-zoom-level                     — уровень зума PDF
 *   .pdf-container / .pdf-canvas        — канвас PDF
 *   .media-viewer-unsupported           — неподдерживаемый формат
 *   .media-viewer-loading               — загрузка
 *   .media-viewer-error                 — ошибка
 */

/* ============================================
   OVERLAY
   ============================================ */
.media-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.media-viewer-overlay.active {
  opacity: 1;
}

/* ============================================
   BACKDROP (click to close)
   ============================================ */
.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

/* ============================================
   CONTAINER
   ============================================ */
.media-viewer-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 92vw;
  height: 92vh;
  max-width: 1400px;
  max-height: 920px;
  z-index: 1;
}

/* ============================================
   HEADER
   ============================================ */
.media-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  flex-shrink: 0;
}

.media-viewer-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ============================================
   ACTION BUTTONS (download, close)
   ============================================ */
.media-viewer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.media-viewer-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.media-viewer-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.08);
}

/* Close = red accent */
.media-viewer-btn[data-action="close"] {
  background: rgba(244, 67, 54, 0.7);
}

.media-viewer-btn[data-action="close"]:hover {
  background: rgba(244, 67, 54, 1);
}

.media-viewer-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.media-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  min-height: 0;
}

/* ============================================
   NAVIGATION
   ============================================ */
.media-viewer-nav {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.media-viewer-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease, transform 0.15s ease;
}

.media-viewer-nav-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: translateY(-50%) scale(1.08);
}

.media-viewer-nav-btn svg {
  width: 28px;
  height: 28px;
}

.media-viewer-nav-btn.prev {
  left: 16px;
}

.media-viewer-nav-btn.next {
  right: 16px;
}

/* ============================================
   FOOTER
   ============================================ */
.media-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex-shrink: 0;
}

.media-viewer-counter {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.media-viewer-size {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

/* ============================================
   IMAGE VIEWER
   ============================================ */
.media-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.3s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.media-viewer-image.zoomed {
  cursor: zoom-out;
}

/* ============================================
   VIDEO VIEWER
   ============================================ */
.media-viewer-video {
  max-width: 100%;
  max-height: 100%;
  outline: none;
  border-radius: var(--radius-md);
}

/* ============================================
   PDF VIEWER
   ============================================ */
.media-viewer-pdf {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* PDF toolbar */
.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.pdf-nav-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pdf-nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.pdf-page-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
}

.pdf-page-input {
  width: 48px;
  padding: 4px 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s ease;
  /* hide arrows */
  appearance: textfield;
  -moz-appearance: textfield;
}

.pdf-page-input::-webkit-inner-spin-button,
.pdf-page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pdf-page-input:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.pdf-zoom-level {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  min-width: 42px;
  text-align: center;
}

/* PDF canvas container */
.pdf-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  background: rgba(128, 128, 128, 0.15);
}

.pdf-canvas {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-sm);
}

/* PDF scrollbar */
.pdf-container::-webkit-scrollbar { width: 8px; height: 8px; }
.pdf-container::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); }
.pdf-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: var(--radius-full); }
.pdf-container::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.35); }

/* ============================================
   UNSUPPORTED FORMAT
   ============================================ */
.media-viewer-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 32px;
  text-align: center;
}

.unsupported-icon {
  font-size: 72px;
  line-height: 1;
  opacity: 0.6;
}

.unsupported-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  word-break: break-all;
  max-width: 400px;
}

.unsupported-hint {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   LOADING
   ============================================ */
.media-viewer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 15px;
  padding: 40px;
}

/* ============================================
   ERROR
   ============================================ */
.media-viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 100, 100, 0.85);
  font-size: 15px;
  padding: 40px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .media-viewer-container {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
  }

  .media-viewer-header {
    padding: 12px 16px;
    border-radius: 0;
  }

  .media-viewer-title {
    font-size: 13px;
  }

  .media-viewer-btn {
    width: 36px;
    height: 36px;
  }

  .media-viewer-btn svg {
    width: 18px;
    height: 18px;
  }

  .media-viewer-nav-btn {
    width: 44px;
    height: 44px;
  }

  .media-viewer-nav-btn svg {
    width: 22px;
    height: 22px;
  }

  .media-viewer-nav-btn.prev { left: 8px; }
  .media-viewer-nav-btn.next { right: 8px; }

  .media-viewer-footer {
    padding: 8px 16px;
    border-radius: 0;
  }

  .pdf-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
  }

  .unsupported-icon {
    font-size: 56px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .media-viewer-overlay {
    transition: none;
  }

  .media-viewer-image {
    transition: none;
  }

  .media-viewer-btn,
  .media-viewer-nav-btn {
    transition: none;
  }
}
/* === features/templates.css === */
/**
 * templates.css
 * Стили шаблонов: CommentTemplateManagerDialog + ChecklistTemplateDialog
 *
 * CommentTemplateManagerDialog классы:
 *   .template-manager                  — корневой контейнер
 *   .template-list-section             — блок списка шаблонов
 *   .section-header                    — заголовок секции (h4 + кнопка)
 *   .templates-list                    — список шаблонов
 *   .template-item                     — элемент списка (info + actions)
 *   .template-info                     — название + текст шаблона
 *   .template-text                     — превью текста шаблона
 *   .template-actions                  — кнопки (вставить, изменить, удалить)
 *   .template-form-section             — блок формы создания/редактирования
 *   .available-variables               — секция доступных переменных
 *   .variables-search                  — поиск по переменным
 *   .variables-group                   — группа переменных (h5 + grid)
 *   .variables-grid                    — сетка переменных
 *   .variable-tag                      — тег переменной (code + small)
 *   .template-preview                  — превью шаблона
 *   .preview-content                   — контент превью
 *   .form-actions                      — кнопки формы
 *   .empty-state                       — пустой список
 *
 * ChecklistTemplateDialog классы:
 *   .checklist-template-form           — корневой контейнер
 *   .sections-container                — контейнер секций
 *   .sections-empty                    — пустое состояние секций
 *   .template-section                  — секция чек-листа
 *   .template-section-header           — заголовок секции
 *   .template-items-container          — контейнер пунктов
 *   .template-item (внутри checklist)  — строка пункта
 */

/* ============================================
   COMMENT TEMPLATE MANAGER
   ============================================ */

/* Корневой контейнер */
.template-manager {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Секция списка */
.template-list-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Заголовок секции (общий для обоих диалогов) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   TEMPLATES LIST
   ============================================ */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Элемент списка шаблонов (CommentTemplateManager) */
.templates-list .template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.templates-list .template-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.template-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-info strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.template-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Кнопки действий шаблона */
.templates-list .template-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================
   TEMPLATE FORM SECTION
   ============================================ */
.template-form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.template-form-section form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.template-form-section .section-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

/* Формы внутри шаблонов — наследуют стили из forms.css */

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* ============================================
   AVAILABLE VARIABLES
   ============================================ */
.available-variables {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-top: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.available-variables > strong {
  font-size: 14px;
  color: var(--text-primary);
}

/* Поиск переменных */
.variables-search {
  margin-bottom: 4px;
}

.variables-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.variables-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 25, 118, 210), 0.12);
}

.variables-search input::placeholder {
  color: var(--text-muted);
}

/* Группа переменных */
.variables-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variables-group h5 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Сетка переменных */
.variables-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Тег переменной */
.variable-tag {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 240px;
}

.variable-tag:hover {
  border-color: var(--primary);
  background: var(--primary-light, rgba(25, 118, 210, 0.06));
  box-shadow: var(--shadow-xs);
}

.variable-tag code {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  font-family: var(--font-family-mono, monospace);
  word-break: break-all;
}

.variable-tag small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   TEMPLATE PREVIEW (текстовый)
   ============================================ */
.template-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.template-preview > strong {
  font-size: 14px;
  color: var(--text-primary);
}

.preview-content {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

/* ============================================
   CHECKLIST TEMPLATE FORM
   ============================================ */
.checklist-template-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Контейнер секций */
.sections-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Секция чек-листа */
.template-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--bg-secondary);
}

.template-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

/* Номер секции (кружок) */
.template-section-header > span:first-child {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

/* Контейнер пунктов */
.template-items-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Пункт чек-листа (внутри ChecklistTemplateDialog) */
.template-items-container .template-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.template-items-container .template-item:hover {
  border-color: var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .templates-list .template-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .templates-list .template-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
  }

  .variables-grid {
    gap: 4px;
  }

  .variable-tag {
    max-width: 100%;
  }

  .template-items-container .template-item {
    flex-wrap: wrap;
  }
}

/* ============================================
   КОНЕЦ ИМПОРТОВ
   ============================================ */

/**
 * Структура файла:
 * 
 * 1. tokens.css - Design tokens (raw values)
 * 2. variables.css - Semantic variables + Dark mode support
 * 3. base.css - Base styles, focus states, print, scrollbar
 * 4. animations.css - Keyframes & animation utilities
 * 5. layouts.css - Layout templates
 * 6. buttons.css - Button components
 * 7. forms.css - Form components
 * 8. tables.css - Table components
 * 9. utilities-extended.css - Extended utility classes
 * 
 * Затем: components, panels, widgets, fields, features
 * 
 * - tokens.css (design tokens)
 * - animations.css (готовые анимации)
 * - layouts.css (layout templates)
 * - utilities-extended.css (расширенные utilities)
 * - Обновлен variables.css (dark mode)
 * - Обновлен base.css (focus, print, scrollbar)
 */