/* === СОВРЕМЕННЫЕ СТИЛИ ДЛЯ ТЕХНИЧЕСКОЙ ПОДДЕРЖКИ === */

/* Основные стили */
:root {
  --primary-color: #17228e;
  --primary-light: #2d3eb1;
  --primary-dark: #0f1659;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-bg: #f8f9fa;
  --border-color: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f0f2f5;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Хедер */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.95) 0%, rgba(30, 64, 175, 0.95) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  padding: 10px 24px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  flex: 1;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  padding: 6px;
  flex-shrink: 0;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.menu-toggle:focus {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}

.nav-menu {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-menu a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-menu a:hover {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.nav-menu a.active {
  background: rgba(255, 255, 255, 0.22);
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  text-align: right;
}

.user-info h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.user-info p {
  margin: 0;
  font-size: 11px;
  opacity: 0.75;
  line-height: 1.2;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Основной контент */
.main-content {
  padding: 24px;
  margin: 24px;
  margin-bottom: 80px;
  background-color: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

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

/* Карточки */
.card {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--light-bg);
}

.card-body {
  padding: 20px;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-align: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.92) 0%, rgba(59, 130, 246, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.95) 0%, rgba(30, 64, 175, 0.95) 100%);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
  color: white;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: rgba(248, 249, 250, 0.95);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.12);
}

.btn-danger {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.92) 0%, rgba(200, 35, 51, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, rgba(200, 35, 51, 0.95) 0%, rgba(176, 31, 45, 0.95) 100%);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.92) 0%, rgba(33, 136, 56, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, rgba(33, 136, 56, 0.95) 0%, rgba(30, 122, 50, 0.95) 100%);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Формы */
.form-container {
  max-width: 600px;
}

.form-group {
  margin-bottom: 20px;
}

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

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(23, 34, 142, 0.1);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-actions {
  margin-top: 28px;
  display: flex;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Таблицы */
.table-container {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

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

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
}

.table th {
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.92) 0%, rgba(30, 64, 175, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.table tr:nth-child(even) {
  background-color: rgba(248, 249, 250, 0.6);
}

.table tr:hover {
  background-color: rgba(30, 64, 175, 0.04);
}

.table td {
  font-size: 13px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

/* Статусы и бейджи */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Модальное окно */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

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

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

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

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

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--light-bg);
}

/* Современные Toast уведомления */
#toast-container {
  position: fixed !important;
  top: 80px !important;
  right: 20px !important;
  z-index: 99999 !important;
  display: flex !important;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto !important;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  min-width: 320px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.toast.toast-success {
  border-left: 5px solid #22c55e;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.06) 0%, #ffffff 100%);
}

.toast.toast-success .toast-icon {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.toast.toast-error {
  border-left: 5px solid #ef4444;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, #ffffff 100%);
}

.toast.toast-error .toast-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.toast.toast-info {
  border-left: 5px solid #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, #ffffff 100%);
}

.toast.toast-info .toast-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.toast-content {
  flex: 1;
}

.toast-message {
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  line-height: 1.4;
}

.toast-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.toast-close svg {
  width: 16px;
  height: 16px;
  color: #6b7280;
}

.toast.show {
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.hide {
  animation: toastOut 0.3s ease forwards;
}

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

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

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

/* Переключатель */
.toggle-switch {
  width: 48px;
  height: 26px;
  appearance: none;
  background-color: #ccc;
  border-radius: 26px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.toggle-switch:checked {
  background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch:checked::after {
  transform: translateX(22px);
}

/* Справочники */
.reference-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.reference-book-card {
  background: white;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.reference-book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.reference-book-card h3 {
  margin: 0 0 8px 0;
  color: var(--primary-color);
  font-size: 18px;
}

.reference-book-card p {
  color: var(--text-secondary);
  margin: 0 0 16px 0;
  font-size: 14px;
}

/* Пагинация */
.pagination {
  display: flex;
  justify-content: center;
  margin-top: 24px;
  gap: 8px;
}

.pagination a,
.pagination span {
  padding: 8px 14px;
  text-decoration: none;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.pagination a:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination .current {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination .disabled {
  color: #ccc;
  cursor: not-allowed;
}

/* Аваatar пользователя */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

/* Фильтры */
.filters-block {
  background: var(--light-bg);
  padding: 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Список файлов */
.file-list {
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--light-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all 0.2s;
}

.file-item:hover {
  background: #e9ecef;
}

.file-preview {
  width: 44px;
  height: 44px;
  margin-right: 14px;
  flex-shrink: 0;
}

.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.file-preview.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: var(--radius-sm);
  font-size: 20px;
}

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

.file-info .file-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

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

.file-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

.file-remove {
  background: none;
  border: none;
  color: var(--danger-color);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.file-remove:hover {
  background: rgba(220, 53, 69, 0.1);
}

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

.file-preview-btn:hover {
  background: rgba(23, 34, 142, 0.1);
}

/* Цветовой индикатор */
.color-circle {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid white;
  vertical-align: middle;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Чекбоксы */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: var(--light-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 14px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 14px;
  transition: all 0.2s;
}

.checkbox-label:hover {
  background: var(--light-bg);
}

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

/* Алерты */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 500;
}

.alert-danger {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-success {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-notice,
.alert-alert {
  display: none;
}

/* Счетчики */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

/* Заголовки страниц */
.page-header {
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.95) 0%, rgba(30, 64, 175, 0.95) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  padding: 20px 24px;
  margin: -24px -24px 24px -24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.page-header h1 {
  margin: 0 0 6px 0;
  font-size: 24px;
  font-weight: 600;
}

.page-header p {
  margin: 0;
  opacity: 0.85;
  font-size: 13px;
}

/* Кнопки фильтров */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.filter-tab.active {
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.92) 0%, rgba(30, 64, 175, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

.filter-tab:not(.active) {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.filter-tab:hover:not(.active) {
  border-color: rgba(30, 64, 175, 0.3);
  color: var(--primary-color);
  background: rgba(255, 255, 255, 0.95);
}

/* Поиск */
.search-box {
  position: relative;
  max-width: 320px;
}

.search-box input {
  padding-left: 44px;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

/* Действия в таблицах */
.action-buttons {
  display: flex;
  gap: 8px;
}

/* Скрытые flash сообщения */
.hidden-flash {
  display: none;
}

/* === АДАПТИВНОСТЬ === */

/* Планшеты и небольшие десктопы */
@media (max-width: 1199px) {
  .main-content {
    margin: 16px;
    padding: 20px;
  }
  .email-split-container {
    flex-direction: column;
    min-height: auto !important;
  }
  .email-list-panel {
    width: 100% !important;
    max-height: none !important;
  }
  .email-preview-panel {
    width: 100% !important;
    max-height: none !important;
    display: none;
  }
  .email-preview-panel.show {
    display: block;
  }
  .email-list-panel.hide {
    display: none;
  }
  .preview-back-btn {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
  }
  .preview-back-btn:hover {
    background: var(--light-bg);
  }
  .reference-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}

/* Планшеты */
@media (max-width: 991px) {
  .header {
    padding: 8px 16px;
  }
  .nav-menu {
    gap: 4px;
  }
  .nav-menu a {
    font-size: 12px;
    padding: 5px 10px;
  }
  .user-info h2 {
    font-size: 12px;
  }
  .user-info p {
    font-size: 10px;
  }
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  .main-content {
    margin: 12px;
    padding: 16px;
  }
  .content-header h1 {
    font-size: 20px;
  }
  .table th,
  .table td {
    padding: 8px 10px;
    font-size: 12px;
  }
  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .filter-tab {
    white-space: nowrap;
  }
  .reference-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
  }
  .reference-book-card {
    padding: 18px;
  }
  .search-box {
    max-width: 240px;
  }
  .preview-empty {
    min-height: 200px;
  }
  .form-container {
    max-width: 100%;
  }
  .event-header {
    padding: 12px;
  }
  .event-card {
    margin-bottom: 8px;
  }
  .rules-fields select,
  .rules-fields input {
    min-width: 150px;
  }
}

/* Телефоны */
@media (max-width: 767px) {
  /* Хедер */
  .header {
    padding: 6px 12px;
  }
  .header-content {
    flex-wrap: wrap;
  }
  .nav-menu {
    display: none;
    flex-direction: column;
    width: 100%;
    order: 3;
    padding: 8px 0;
    gap: 4px;
  }
  .nav-menu.open {
    display: flex;
  }
  .nav-menu a {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 14px;
  }
  .menu-toggle {
    display: flex !important;
  }
  .user-section {
    gap: 6px;
  }
  .user-info {
    display: none;
  }
  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
  .logout-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  
  /* Основной контент */
  .main-content {
    margin: 6px;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 40px;
  }
  .content-header {
    gap: 8px;
  }
  .content-header h1 {
    font-size: 17px;
  }
  
  /* Карточки */
  .card-body {
    padding: 12px;
  }
  .card-header {
    padding: 10px 12px;
  }
  
  /* Кнопки */
  .btn {
    padding: 6px 12px;
    font-size: 12px;
    gap: 5px;
  }
  .btn-lg {
    padding: 10px 18px;
    font-size: 14px;
  }
  .btn-sm {
    padding: 4px 10px;
    font-size: 11px;
  }
  
  /* Формы */
  .form-container {
    max-width: 100%;
  }
  .form-actions {
    flex-direction: column;
  }
  .form-actions .btn {
    width: 100%;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .form-row .form-group {
    margin-bottom: 16px;
  }
  
  /* Таблицы */
  .table-container {
    overflow-x: auto;
    border-radius: 8px;
  }
  .table th,
  .table td {
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
  .table th {
    font-size: 10px;
  }
  .table th:nth-child(n+6),
  .table td:nth-child(n+6) {
    display: none;
  }
  .table .action-buttons {
    flex-direction: column;
    gap: 4px;
  }
  .table .action-buttons .btn {
    font-size: 10px;
    padding: 3px 8px;
  }
  
  /* Фильтры */
  .filters-block {
    padding: 12px;
    margin-bottom: 14px;
  }
  .filters-form {
    flex-direction: column;
    gap: 10px;
  }
  .filter-group {
    width: 100%;
  }
  .filter-tabs {
    gap: 6px;
  }
  .filter-tab {
    font-size: 12px;
    padding: 5px 10px;
  }
  
  /* Поиск */
  .search-box {
    max-width: 100%;
    min-width: auto;
    width: 100%;
  }
  
  /* Модальное окно */
  .modal-content {
    margin: 5% auto;
    width: 94%;
    max-width: none;
  }
  .modal-header {
    padding: 12px 14px;
  }
  .modal-body {
    padding: 14px;
  }
  .modal-footer {
    padding: 10px 14px;
  }
  
  /* Email */
  .tabs-modern {
    padding: 10px 12px 0 !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tab-modern {
    padding: 7px 10px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }
  .email-split-container {
    margin-top: 8px !important;
    gap: 8px;
  }
  .email-list-panel {
    padding: 0 12px !important;
  }
  .email-card {
    padding: 8px 10px !important;
    gap: 8px;
  }
  .email-card-left .avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }
  .email-sender {
    font-size: 12px;
  }
  .email-time {
    font-size: 10px;
  }
  .email-card-subject {
    font-size: 13px;
  }
  .email-card-preview {
    display: none;
  }
  .header-actions {
    gap: 4px;
  }
  .header-actions .btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .unread-count {
    font-size: 11px;
  }
  .idle-status {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  /* Просмотр письма (превью) */
  .preview-header-main {
    flex-direction: column;
    gap: 8px;
  }
  .preview-header-right {
    width: 100%;
    justify-content: flex-start;
  }
  
  /* Справочники */
  .reference-books-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
  }
  .reference-book-card {
    padding: 14px;
  }
  .reference-book-card h3 {
    font-size: 14px;
  }
  
  /* Автоматизация */
  .automation-section {
    margin-bottom: 14px;
  }
  .automation-section-header {
    padding: 12px 14px;
    gap: 10px;
  }
  .automation-section-content {
    padding: 0 14px 14px;
  }
  .automation-section-icon {
    width: 36px;
    height: 36px;
  }
  .automation-section-icon svg {
    width: 18px;
    height: 18px;
  }
  .automation-section-title {
    font-size: 15px;
  }
  .setting-item {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }
  .setting-item:hover {
    transform: none;
  }
  
  /* Пагинация */
  .pagination {
    gap: 4px;
    flex-wrap: wrap;
  }
  .pagination a,
  .pagination span {
    padding: 5px 8px;
    font-size: 12px;
  }
  
  /* Заголовки страниц */
  .page-header {
    padding: 14px 12px;
    margin: -12px -12px 14px -12px;
  }
  .page-header h1 {
    font-size: 18px;
  }
  
  /* Toast */
  #toast-container {
    right: 8px !important;
    left: 8px !important;
    top: 60px !important;
  }
  .toast {
    min-width: auto;
    max-width: none;
    padding: 12px 14px;
  }
  
  /* Auth */
  .auth-wrapper {
    max-width: 360px;
  }
  .auth-container {
    padding: 24px !important;
    border-radius: 16px !important;
  }
  .auth-container h1 {
    font-size: 22px;
  }
  .auth-form .form-control {
    padding: 12px 14px;
  }
  .submit-btn {
    padding: 14px 24px;
    font-size: 15px;
  }
  
  /* SLA индикатор */
  .sla-indicator {
    flex-wrap: wrap;
    gap: 6px;
  }
  .sla-badge {
    font-size: 12px;
    padding: 4px 10px;
  }
  
  /* Ticket шапка */
  .ticket-header-card {
    padding: 14px;
  }
  .ticket-header-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .ticket-number {
    flex-wrap: wrap;
  }
  .ticket-number-value {
    font-size: 16px;
  }
  .ticket-subject-header {
    font-size: 15px;
    margin-top: 4px;
    width: 100%;
  }
  
  /* Email preview внутри show */
  .preview-from-to {
    flex-direction: column;
    gap: 4px;
  }
  
  /* Telegram события */
  .telegram-event {
    padding: 10px 12px;
  }
  .telegram-event-icon {
    width: 32px;
    height: 32px;
  }
  
  /* Чекбоксы */
  .checkbox-group {
    gap: 6px;
    padding: 8px;
  }
  .checkbox-label {
    padding: 6px 10px;
    font-size: 13px;
  }
  
  /* Файлы */
  .file-item {
    padding: 8px 12px;
  }
  .file-preview {
    width: 32px;
    height: 32px;
    margin-right: 10px;
  }
  
  /* Recipients grid */
  .recipients-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  /* Event card */
  .event-body {
    padding: 0 12px 12px;
  }
  .event-header {
    padding: 10px 12px;
  }
  
  /* User select */
  .user-select-list {
    max-height: 120px;
  }
}

/* Маленькие телефоны */
@media (max-width: 479px) {
  .main-content {
    margin: 4px;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 30px;
  }
  .header {
    padding: 4px 8px;
  }
  .content-header h1 {
    font-size: 15px;
  }
  .btn {
    font-size: 11px;
    padding: 5px 8px;
  }
  .table th,
  .table td {
    padding: 4px 5px;
    font-size: 10px;
  }
  .filter-tab {
    font-size: 11px;
    padding: 4px 8px;
  }
  .reference-books-grid {
    grid-template-columns: 1fr;
  }
  .tabs-modern {
    padding: 8px 8px 0 !important;
  }
  .tab-modern {
    font-size: 11px !important;
    padding: 5px 8px !important;
  }
  .header-actions .btn {
    font-size: 10px;
    padding: 4px 6px;
  }
  .modal-content {
    margin: 2% auto;
    width: 98%;
  }
  .auth-container {
    padding: 18px !important;
  }
  .recipients-grid {
    grid-template-columns: 1fr;
  }
  .page-header {
    padding: 12px 10px;
    margin: -8px -8px 12px -8px;
  }
}

/* === СТИЛИ АВТОМАТИЗАЦИИ === */

.automation-page {
  max-width: 1200px;
  margin: 0 auto;
}

.automation-section {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.automation-section:hover {
  box-shadow: var(--shadow-md);
}

.automation-section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.automation-section-header:hover {
  background: #f8f9fa;
}

.automation-section-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.automation-section-icon.ticket-creation {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.automation-section-icon.telegram {
  background: linear-gradient(135deg, #0088cc 0%, #00d4ff 100%);
}

.automation-section-icon.email,
.automation-section-icon.email-sync {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
}

.automation-section-icon.status-transitions {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.automation-section-icon.auto-assign {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.automation-section-icon svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.automation-section-info {
  flex: 1;
}

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

.automation-section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.automation-section-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--light-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.2s ease;
}

.automation-section.collapsed .automation-section-toggle {
  transform: rotate(-90deg);
}

.automation-section-toggle:hover {
  background: var(--border-color);
}

.automation-section-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.automation-section-content {
  padding: 0 24px 24px 24px;
  border-top: 1px solid var(--border-color);
}

.automation-section.collapsed .automation-section-content {
  display: none;
}

/* Настройки чекбоксов */
.setting-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--light-bg);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.setting-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.setting-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.setting-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.setting-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.setting-toggle input:checked + .setting-slider {
  background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
}

.setting-toggle input:checked + .setting-slider:before {
  transform: translateX(22px);
}

.setting-info {
  flex: 1;
}

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

.setting-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Правила email */
.rules-container {
  background: white;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rules-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-title svg {
  width: 18px;
  height: 18px;
  color: var(--info-color);
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--light-bg);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.rule-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.rule-drag {
  cursor: grab;
  color: var(--text-secondary);
  padding: 4px;
}

.rule-drag:active {
  cursor: grabbing;
}

.rule-content {
  flex: 1;
}

.rule-type {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.rule-fields {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-fields select,
.rule-fields input {
  flex: 1;
  min-width: 200px;
}

.rule-actions {
  display: flex;
  gap: 8px;
}

.rule-number {
  width: 28px;
  height: 28px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Email события */
.event-card {
  background: var(--light-bg);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.event-card:last-child {
  margin-bottom: 0;
}

.event-card:hover {
  border-color: var(--primary-light);
}

.event-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}

.event-card.expanded {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.event-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.event-icon svg {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.event-info {
  flex: 1;
}

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

.event-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--success-color);
  color: white;
  font-weight: 500;
}

.event-expand {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.event-card.expanded .event-expand {
  transform: rotate(180deg);
}

.event-expand svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.event-body {
  padding: 0 16px 16px 16px;
  display: none;
  border-top: 1px solid var(--border-color);
}

.event-card.expanded .event-body {
  display: block;
  padding-top: 16px;
}

.recipients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.recipient-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.recipient-chip:hover {
  border-color: var(--primary-light);
  background: #f0f4ff;
}

.recipient-chip.selected {
  border-color: var(--success-color);
  background: rgba(40, 167, 69, 0.08);
}

.recipient-chip input {
  display: none;
}

.recipient-chip-check {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.recipient-chip.selected .recipient-chip-check {
  background: var(--success-color);
  border-color: var(--success-color);
}

.recipient-chip-check svg {
  width: 12px;
  height: 12px;
  color: white;
  opacity: 0;
}

.recipient-chip.selected .recipient-chip-check svg {
  opacity: 1;
}

.recipient-chip span {
  font-size: 13px;
  color: var(--text-primary);
}

/* User select */
.user-select-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.user-select-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-select-label svg {
  width: 16px;
  height: 16px;
  color: var(--info-color);
}

.user-select-list {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-height: 160px;
  overflow-y: auto;
}

.user-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border-color);
}

.user-select-item:last-child {
  border-bottom: none;
}

.user-select-item:hover {
  background: var(--light-bg);
}

.user-select-item.selected {
  background: rgba(40, 167, 69, 0.08);
}

.user-select-item input {
  display: none;
}

.user-select-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.user-select-item.selected .user-select-checkbox {
  background: var(--success-color);
  border-color: var(--success-color);
}

.user-select-checkbox svg {
  width: 12px;
  height: 12px;
  color: white;
  opacity: 0;
}

.user-select-item.selected .user-select-checkbox svg {
  opacity: 1;
}

.user-select-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.user-select-name {
  font-size: 13px;
  color: var(--text-primary);
}

/* Telegram events */
.telegram-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--light-bg);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.telegram-event:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.telegram-event:last-child {
  margin-bottom: 0;
}

.telegram-event-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.telegram-event-icon svg {
  width: 20px;
  height: 20px;
  color: #0088cc;
}

.telegram-event-info {
  flex: 1;
}

.telegram-event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.telegram-event-status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.telegram-event-status.active {
  color: var(--success-color);
}

/* Email link icon in ticket registry */
.email-link {
  transition: all 0.2s ease !important;
}
.email-link:hover {
  background-color: #0d6efd !important;
}
.email-link:hover svg {
  fill: #ffffff !important;
  color: #ffffff !important;
}

.preview-back-btn {
  display: none;
}

/* === БЕЙДЖИ ОТПРАВИТЕЛЯ === */
.sender-info-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.sender-info-badge.system {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.sender-info-badge.synced {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}


/* Lightweight reusable styles for email forms */
/* Lightweight reusable styles for email forms */
.email-form-card { margin: 20px; }
.email-form-card .card-header { display:flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); background: #fff; }
.email-form-card .card-body { padding: 16px 20px; }
.email-form-body { padding-top: 0; }
.email-form-row { margin-bottom: 16px; }
.email-form-row label { display: block; font-weight: 600; font-size: 14px; color: var(--text-primary); margin-bottom: 6px; }
.email-form-input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
.email-form-actions { display:flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.attachment-upload { display: block; }
.file-label { display:inline-flex; align-items:center; gap:8px; padding:8px 12px; border-radius:6px; background:#f3f4f6; border:1px solid #e5e7eb; cursor:pointer; }
.file-label:hover { background:#e5e7eb; }
.attachment-list { margin-top:8px; }

/* Email autocomplete */
.to-email-autocomplete { width: 100%; }
.multiselect-container { width: 100%; position: relative; background: #fff; border: 2px solid #e5e7eb; border-radius: 10px; padding: 4px 8px; }
.multiselect-container:focus-within { border-color: #6366f1; }
.multiselect-input { flex: 1; min-width: 120px; padding: 8px 12px; font-size: 14px; outline: none; border: none; background: transparent; box-sizing: border-box; }
.multiselect-input:focus { border-color: #6366f1; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 1000; max-height: 200px; overflow-y: auto; display: none; margin-top: 4px; }
.autocomplete-item { padding: 10px 14px; cursor: pointer; font-size: 14px; color: #374151; transition: background 0.15s; }
.autocomplete-item:hover { background: #f3f4f6; }
.selected-recipient { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 16px; font-size: 13px; color: #4338ca; cursor: default; }
.selected-recipient .remove { cursor: pointer; color: #6366f1; font-weight: 700; font-size: 14px; line-height: 1; margin-left: 2px; }
.selected-recipient .remove:hover { color: #ef4444; }

/* Email drop zone */
.email-drop-zone { border: 2px dashed #d1d5db; border-radius: 12px; padding: 40px 20px; text-align: center; cursor: pointer; transition: all 0.2s; background: #fafafa; }
.email-drop-zone:hover { border-color: #6366f1; background: #f5f3ff; }
.email-drop-zone.drag-over { border-color: #6366f1; background: #eef2ff; }
.email-drop-zone svg { display: block; margin: 0 auto 12px; color: #9ca3af; }
.email-drop-zone span { display: block; font-size: 14px; color: #6b7280; }
.email-drop-zone input[type="file"] { display: none; }

/* Email files preview */
.email-files-preview { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.email-file-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; width: 100%; max-width: 320px; }
.email-file-item .file-preview-img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.email-file-item svg { flex-shrink: 0; color: #6b7280; }
.email-file-item .file-info { flex: 1; min-width: 0; }
.email-file-item .file-name { display: block; font-size: 13px; font-weight: 500; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-file-item .file-size { display: block; font-size: 11px; color: #9ca3af; margin-top: 2px; }
.email-file-remove { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; border-radius: 6px; background: transparent; cursor: pointer; color: #9ca3af; flex-shrink: 0; transition: all 0.15s; }
.email-file-remove:hover { background: #fee2e2; color: #ef4444; }

/* === EMAIL NOTIFICATION OPTIONS === */
.email-options {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-top: none;
  padding: 16px 20px;
  margin-bottom: 16px;
  margin-top: -1px;
}

.email-options-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.email-options .option-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-options .option-label {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.email-options .form-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.email-options .recipients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.email-options .recipient-item {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}

.email-options .recipient-item:hover {
  background: #f3f4f6;
}

.email-options .recipient-item.selected {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.email-options .recipient-item input {
  display: none;
}

.email-options .user-select-multiple {
  min-height: 80px;
  padding: 6px;
}
