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

/* Основные стили */
: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-x: auto;
}

.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;
  white-space: nowrap;
}

.sla-badge {
  white-space: nowrap;
}

.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);
}

/* ======== Notification Toast (всплывашка нового уведомления) ======== */
.notification-toast {
  width: 360px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  cursor: pointer;
  flex-shrink: 0;
}
.notification-toast.show {
  transform: translateX(0);
}
.notification-toast-link,
.notification-toast-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.notification-toast-link:hover {
  background: var(--light-bg);
}
.notification-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--light-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary-color);
}
.notification-toast-content {
  flex: 1;
  min-width: 0;
}
.notification-toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}
.notification-toast-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Современные 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;
  flex-shrink: 0;
  overflow: hidden;
}

/* Фильтры */
.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;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .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 {
    gap: 12px;
    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;
  }
  
  /* Уведомления (мобильные) */
  #notificationMenu.notification-menu {
    position: fixed;
    top: 48px;
    right: 0;
    left: 0;
    bottom: 0;
    border-radius: 0;
    width: 100% !important;
    max-width: none;
    max-height: none;
    z-index: 10000;
    animation: mobileDropdownIn 0.25s ease;
  }
  #notificationMenu.notification-menu.open {
    display: flex !important;
  }
  .notification-backdrop.open {
    display: block;
    top: 48px;
    z-index: 9999;
  }
  .notification-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .notification-menu-header {
    padding: 12px 16px;
  }
  .notification-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
  .notification-mark-all-btn {
    padding: 8px 16px;
    font-size: 12px;
  }
  .notification-item {
    padding: 10px 16px;
  }
  .notification-toast {
    width: auto;
    transform: translateY(-120%);
  }
  .notification-toast.show {
    transform: translateY(0);
  }
  #toast-container {
    top: 60px !important;
    right: 8px !important;
    left: 8px !important;
  }
  
  /* 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;
  }

  /* Dropdown menu — на мобильных открываем вправо, а не влево */
  .user-dropdown-menu {
    right: auto;
    left: 0;
  }



  /* Settings page */
  .settings-section-header {
    padding: 14px 16px;
  }
  .settings-section-content {
    padding: 14px 16px;
  }
  .settings-section-header h2 {
    font-size: 14px;
  }
  .settings-section-icon {
    width: 36px;
    height: 36px;
  }
  .settings-section-icon svg {
    width: 18px;
    height: 18px;
  }
  .info-item {
    align-items: center;
    text-align: left;
    gap: 8px;
    padding: 10px 12px;
  }
  .info-label {
    min-width: auto;
    font-size: 11px;
  }
  .info-value {
    font-size: 13px;
  }
  .device-item {
    gap: 8px;
    padding: 10px 12px;
  }
  .device-item span[style*="white-space:nowrap"] {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .device-remove {
    flex-shrink: 0;
  }
}

/* Маленькие телефоны */
@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;
  }

  /* Settings page */
  .settings-section-header {
    padding: 12px 12px;
  }
  .settings-section-content {
    padding: 12px;
  }
  .settings-section-header h2 {
    font-size: 13px;
  }
  .settings-section-header p {
    font-size: 11px;
  }
  .settings-section-icon {
    width: 32px;
    height: 32px;
  }
  .settings-section-icon svg {
    width: 16px;
    height: 16px;
  }
  .device-item span[style*="white-space:nowrap"] {
    font-size: 11px;
    overflow-x: auto;
    max-width: 100%;
  }
}

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

.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.escalation {
  background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
}

.escalation-rule-item .rule-fields {
  flex-wrap: wrap;
}

.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;
}

.report-details {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.detail-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #374151;
  min-width: 140px;
  font-size: 14px;
}

/* === ЛОАДЕР === */
.app-loader-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.app-loader-overlay.active {
  display: flex;
  opacity: 1;
}

.app-loader-spinner {
  position: relative;
  width: 56px;
  height: 56px;
}

.app-loader-spinner::before,
.app-loader-spinner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  animation: appLoaderSpin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.app-loader-spinner::before {
  width: 100%;
  height: 100%;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
}

.app-loader-spinner::after {
  width: 70%;
  height: 70%;
  top: 15%;
  left: 15%;
  border: 3px solid transparent;
  border-top-color: var(--primary-light);
  animation-direction: reverse;
  animation-duration: 0.9s;
}

@keyframes appLoaderSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.app-loader-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.app-loader-dots {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.app-loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: appLoaderBounce 1.4s ease-in-out infinite both;
}

.app-loader-dot:nth-child(1) { animation-delay: -0.32s; }
.app-loader-dot:nth-child(2) { animation-delay: -0.16s; }
.app-loader-dot:nth-child(3) { animation-delay: 0s; }

@keyframes appLoaderBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* === PWA PAGE LOADER === */
.pwa-loader {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.pwa-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.pwa-loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: appLoaderSpin 0.8s linear infinite;
}

/* === УВЕДОМЛЕНИЯ (КОЛОКОЛЬЧИК) === */
.notification-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notification-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

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

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.notification-badge.hidden {
  display: none;
}

.notification-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  width: 380px;
  max-height: 480px;
  display: none;
  z-index: 1001;
  overflow: hidden;
  animation: dropdownIn 0.2s ease;
  flex-direction: column;
}

.notification-menu.open {
  display: flex;
}

.notification-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

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

.notification-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.notification-count {
  background: var(--primary-color);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notification-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.notification-tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.notification-tab:hover {
  color: var(--text-primary);
}
.notification-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.notification-mark-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
  width: 100%;
}

.notification-mark-all-btn:hover {
  background: var(--light-bg);
}

.notification-mark-all-btn svg {
  flex-shrink: 0;
}

.notification-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  transition: background 0.15s ease;
  border-bottom: 1px solid #f0f0f0;
}

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

.notification-item.unread {
  background: rgba(23, 34, 142, 0.03);
  border-left: 3px solid var(--primary-color);
}

.notification-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--light-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.notification-item-content,
.notification-item-link,
.notification-item-body {
  flex: 1;
  min-width: 0;
}
.notification-item-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.notification-item-link:hover {
  color: inherit;
}

.notification-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.3;
}

.notification-item-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-item-text.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

.notification-expand-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}

.notification-expand-btn:hover {
  text-decoration: underline;
}

.notification-user-highlight {
  color: var(--primary-color);
  font-weight: 600;
}

.notification-you-suffix {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 400;
  margin-left: 2px;
}

.notification-toast-title .notification-user-highlight,
.notification-toast-text .notification-user-highlight {
  color: var(--primary-color);
}

.notification-item-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.notification-item-read-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.notification-item-read-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.notification-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.notification-empty svg {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.notification-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.notification-backdrop.open {
  display: block;
}

/* === ВЫПАДАЮЩЕЕ МЕНЮ ПОЛЬЗОВАТЕЛЯ === */
.user-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-dropdown-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 2px;
  transition: all 0.2s ease;
}

.user-dropdown-btn:hover,
.user-dropdown-btn.active {
  background: rgba(255, 255, 255, 0.2);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  min-width: 200px;
  display: none;
  z-index: 1001;
  overflow: hidden;
  animation: dropdownIn 0.2s ease;
}

.user-dropdown-menu.open {
  display: block;
}

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

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

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

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

.user-dropdown-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

.user-dropdown-item.danger {
  color: var(--danger-color);
}

.user-dropdown-item.danger svg {
  color: var(--danger-color);
}

.user-dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.user-dropdown-backdrop.open {
  display: block;
}

/* === СТРАНИЦА НАСТРОЕК === */
.settings-page {
  max-width: 800px;
  margin: 0 auto;
}

.settings-section {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--light-bg);
}

.settings-section-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-section-header p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.settings-section-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-section-icon svg {
  width: 22px;
  height: 22px;
}

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

.settings-section-icon.icon-notifications {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.settings-section-content {
  padding: 20px 24px;
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--light-bg);
  border-radius: var(--radius-sm);
}

.info-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.device-group {
  margin-bottom: 12px;
}

.device-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.device-group-label svg {
  width: 16px;
  height: 16px;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--light-bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
}

.device-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.device-remove:hover {
  color: var(--danger-color);
  background: rgba(220, 53, 69, 0.1);
}

.push-settings-form .setting-item {
  margin-bottom: 0;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper .form-control {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.05);
}

/* === ЧАТ (ЛИЧНЫЕ СООБЩЕНИЯ) === */

.chat-btn {
  position: relative;
}

.chat-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  width: 380px;
  height: 520px;
  display: none;
  z-index: 1001;
  overflow: hidden;
  animation: dropdownIn 0.2s ease;
  flex-direction: column;
}

.chat-menu.open {
  display: flex;
}

.chat-menu.dragging {
  transition: none !important;
  animation: none !important;
  user-select: none;
}

.chat-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(21, 44, 91, 0.95) 0%, rgba(30, 64, 175, 0.95) 100%);
  color: white;
  flex-shrink: 0;
  cursor: move;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-menu-header h3,
.chat-menu-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.chat-back-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  padding: 6px;
  color: white;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.chat-back-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-menu-header .notification-close-btn {
  color: rgba(255, 255, 255, 0.7);
  font-size: 24px;
  padding: 2px 6px;
  border-radius: 6px;
}

.chat-menu-header .notification-close-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

/* Search */
.chat-search {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  flex-shrink: 0;
  background: #fafbfc;
}

.chat-search-input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.44.856a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E") no-repeat 12px center;
}

.chat-search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(23, 34, 142, 0.08);
}

.chat-search-input::placeholder {
  color: #aaa;
}

.chat-search-results {
  position: absolute;
  top: 100%;
  left: 14px;
  right: 14px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  border: 1px solid #eee;
}

.chat-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-search-result:first-child {
  border-radius: 12px 12px 0 0;
}

.chat-search-result:last-child {
  border-radius: 0 0 12px 12px;
}

.chat-search-result:hover {
  background: #f0f4ff;
}

.chat-search-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 14px 4px;
}

.chat-search-message {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.chat-search-msg-info {
  width: 100%;
}

.chat-search-msg-who {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.chat-search-msg-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-search-msg-preview mark {
  background: #fff3b0;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.chat-search-msg-time {
  font-size: 10px;
  color: #bbb;
  margin-top: 2px;
}

/* Conversation list */
.chat-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-list::-webkit-scrollbar {
  width: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 12px;
  flex-shrink: 0;
}

.chat-list-item:hover {
  background: #f0f4ff;
}

.chat-list-item:active {
  background: #e6ecff;
  transform: scale(0.99);
}

.chat-list-item.unread {
  background: rgba(23, 34, 142, 0.04);
}

.chat-list-item.unread:hover {
  background: rgba(23, 34, 142, 0.08);
}

.chat-list-item.unread .chat-list-name {
  color: var(--primary-color);
}

.chat-list-avatar {
  width: 44px;
  height: 44px;
  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: 15px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(23, 34, 142, 0.2);
  position: relative;
}

.chat-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #4caf50;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
  animation: chatOnlinePulse 2s ease-in-out infinite;
}

@keyframes chatOnlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(76, 175, 80, 0); }
}

.chat-view-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-view-status .chat-online-dot {
  position: static;
  width: 8px;
  height: 8px;
  border-width: 1.5px;
  border-color: rgba(255, 255, 255, 0.6);
  animation: none;
}

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

.chat-list-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.chat-list-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-time {
  font-size: 11px;
  color: #aaa;
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-list-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-list-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  line-height: 1.4;
}

.chat-unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 8px;
  box-shadow: 0 2px 6px rgba(23, 34, 142, 0.3);
}

.chat-empty {
  padding: 48px 24px;
  text-align: center;
  color: #bbb;
  font-size: 13px;
}

.chat-empty svg {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  opacity: 0.3;
}

/* Chat view */
.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f7f8fa;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

.message {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  animation: messageIn 0.2s ease;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

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

.message.own {
  align-self: flex-end;
}

.message:not(.own) {
  align-self: flex-start;
}

.message-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 3px;
  padding-left: 4px;
}

.message.own .message-author {
  display: none;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.message:not(.own) .message-bubble {
  background: white;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.message.own .message-bubble {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(23, 34, 142, 0.2);
}

.message-time {
  font-size: 10px;
  color: #bbb;
  margin-top: 3px;
  padding: 0 4px;
}

.message.own .message-time {
  text-align: right;
}

.chat-check {
  vertical-align: middle;
  margin-left: 3px;
  margin-top: -1px;
}

.chat-typing-bubble {
  display: flex;
  padding: 2px 0 8px 12px;
}

.chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f0f0f0;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-typing-dots span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingBubble 1.4s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBubble {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: white;
}

.chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 22px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f8f9fa;
}

.chat-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(23, 34, 142, 0.08);
  background: white;
}

.chat-input::placeholder {
  color: #aaa;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(23, 34, 142, 0.25);
}

.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(23, 34, 142, 0.35);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.chat-backdrop.open {
  display: block;
}

/* Context menu */
.chat-context-menu {
  position: fixed;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 20000;
  min-width: 160px;
  padding: 6px 0;
  animation: contextMenuIn 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

.chat-context-reactions {
  display: flex;
  gap: 2px;
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f0;
}

.chat-context-reaction {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s, transform 0.15s;
  line-height: 1;
}

.chat-context-reaction:hover {
  background: #f0f0f0;
  transform: scale(1.2);
}

.chat-context-reaction.active {
  background: #e3f2fd;
}

.chat-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-primary);
  text-align: left;
}

.chat-context-item:hover {
  background: #f5f5f5;
}

.chat-context-danger {
  color: #e53935;
}

.chat-context-danger:hover {
  background: #fef2f2;
}

/* Message reactions */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
  user-select: none;
  -webkit-user-select: none;
}

.message-reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.message-reaction:hover {
  background: #e0e0e0;
}

.message-reaction.active {
  background: #e3f2fd;
  border-color: var(--primary-color);
}

.message-reaction-count {
  font-size: 11px;
  color: #666;
}

.message.own .message-reaction-count {
  color: rgba(255, 255, 255, 0.8);
}

.message.own .message-reaction {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.message.own .message-reaction:hover {
  background: rgba(255, 255, 255, 0.3);
}

.message.own .message-reaction.active {
  background: rgba(255, 255, 255, 0.35);
  border-color: white;
}

.message-edited {
  font-size: 10px;
  color: #bbb;
  font-style: italic;
}

/* Mobile */
@media (max-width: 767px) {
  #chatMenu.chat-menu {
    position: fixed;
    top: 48px;
    right: 0;
    left: 0;
    bottom: 0;
    border-radius: 0;
    width: 100% !important;
    max-width: none;
    height: auto;
    max-height: none;
    z-index: 10000;
    animation: mobileDropdownIn 0.25s ease;
    overflow: hidden;
  }

  #chatMenu.chat-menu.open {
    display: flex !important;
  }

  .chat-backdrop.open {
    display: block;
    top: 0;
    z-index: 9999;
  }

  .chat-menu-header {
    cursor: default;
    border-radius: 0;
  }

  #chatMenu * {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  .chat-input {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }

  .chat-input-area {
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px) + env(keyboard-inset-height, 0px) + 4px);
  }
}
