/* ═══════════════════════════════════════════════════════════
   ЯМед Поддержка — Application CSS
   ─ Исправлены: дублирования, обрезанный transition, невалидный filter
   ─ Улучшены: цвета, отступы, типографика, анимации, тёмная тема
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS-переменные ────────────────────────────────────── */

:root {
  --emed-accent:         #2563eb;
  --emed-accent-strong:  #1d4ed8;
  --emed-accent-light:   rgba(37, 99, 235, 0.1);
  --emed-surface:        rgba(255, 255, 255, 0.82);
  --emed-surface-solid:  #ffffff;
  --emed-border:         rgba(15, 23, 42, 0.08);
  --emed-shadow:         0 4px 24px rgba(15, 23, 42, 0.07);
  --emed-shadow-lg:      0 12px 40px rgba(15, 23, 42, 0.1);
  --emed-radius:         18px;
  --emed-radius-sm:      12px;
  --emed-transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Фон страницы ───────────────────────────────────────── */

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at top left,  rgba(37, 99, 235, 0.09), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.09), transparent 24%),
    linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
}

body.dark-mode {
  --emed-surface:        rgba(17, 24, 39, 0.86);
  --emed-surface-solid:  #111827;
  --emed-border:         rgba(148, 163, 184, 0.14);
  --emed-shadow:         0 4px 24px rgba(2, 6, 23, 0.28);
  --emed-shadow-lg:      0 12px 40px rgba(2, 6, 23, 0.38);
  background:
    radial-gradient(circle at top left,  rgba(37, 99, 235, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(6, 182, 212, 0.12), transparent 22%),
    linear-gradient(180deg, #08111f 0%, #0f172a 100%);
}

/* ─── Z-индексы (поверх app-header = 999999) ────────────── */

.modal-backdrop  { z-index: 1000100 !important; }
.modal           { z-index: 1000150 !important; }
.toast-container { z-index: 1000200 !important; }

/* ─── Логотип ────────────────────────────────────────────── */

.header-brand-img.emed-logo {
  height: 2.25rem;
  width: auto;
}

/* Скрываем ненужные логотипы */
.side-header .desktop-logo,
.side-header .light-logo1 {
  display: none;
}

/* Светлая тема: логотип без фильтра */
body:not(.dark-mode) .side-header .light-logo1 {
  display: block;
  filter: none;
}

/* Тёмная тема: светлый логотип */
body.dark-mode .side-header .desktop-logo {
  display: block;
  filter: none;
}

/* Тёмная тема: скрываем светлый логотип (style.css ставит !important, перекрываем) */
body.dark-mode .side-header .light-logo1 {
  display: none !important;
}

/* ─── Заголовок страницы ─────────────────────────────────── */

.page-header {
  margin: 1.1rem 0 1.4rem;
}

.emed-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.emed-kicker {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--emed-accent-light);
  color: var(--emed-accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.emed-page-title,
.page-title {
  font-weight: 800;
  letter-spacing: -0.025em;
}

/* ─── Карточки ───────────────────────────────────────────── */

.card,
.emed-card {
  border: 1px solid var(--emed-border);
  border-radius: var(--emed-radius);
  box-shadow: var(--emed-shadow);
  background: var(--emed-surface);
  transition: box-shadow var(--emed-transition), transform var(--emed-transition),
              border-color var(--emed-transition);
}

.card:not(.executor-load-panel):hover {
  box-shadow: var(--emed-shadow-lg);
}

.card-header {
  border-bottom-color: var(--emed-border);
}

/* ─── Формы ──────────────────────────────────────────────── */

.form-control,
.form-select,
.input-group > .form-control,
.input-group > .form-select {
  min-height: 44px;
  max-width: 100%;
  transition: border-color var(--emed-transition), box-shadow var(--emed-transition),
              background-color var(--emed-transition);
}

.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

textarea.form-control {
  min-height: 100px;
}

.input-group {
  flex-wrap: nowrap;
}

.input-group > .btn {
  flex-shrink: 0;
}

.input-group > .form-control:focus {
  z-index: 3;
}

/* ─── Кнопки ─────────────────────────────────────────────── */

.btn {
  white-space: normal;
  word-break: break-word;
  transition: background-color var(--emed-transition), color var(--emed-transition),
              border-color var(--emed-transition), box-shadow var(--emed-transition),
              transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity var(--emed-transition);
}

.btn:active {
  transform: scale(0.965);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.32);
}

.btn-outline-primary:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.18);
}

.card-header .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

/* ─── Sidebar: логотип и название ───────────────────────── */

/* Развёрнутое состояние: полный логотип + «ЯМед Поддержка» */
.sidebar-brand-mini { display: none; }
.sidebar-brand-full { display: inline; }

/* Свёрнутое состояние (sidenav-toggled): только «ЯМед» */
.sidebar-mini.sidenav-toggled .sidebar-logo-full {
  display: none !important;
}
.sidebar-mini.sidenav-toggled .sidebar-brand-full {
  display: none !important;
}
.sidebar-mini.sidenav-toggled .sidebar-brand-mini {
  display: inline !important;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Hover-раскрытие (sidenav-toggled-open): возвращаем полный вид */
.sidebar-mini.sidenav-toggled.sidenav-toggled-open .sidebar-logo-full {
  display: block !important;
}
.sidebar-mini.sidenav-toggled.sidenav-toggled-open .sidebar-brand-full {
  display: inline !important;
}
.sidebar-mini.sidenav-toggled.sidenav-toggled-open .sidebar-brand-mini {
  display: none !important;
}

/* ─── Sidebar ────────────────────────────────────────────── */

.app-sidebar {
  display: flex;
  flex-direction: column;
}

.main-sidemenu {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: calc(100vh - 74px);
}

.side-menu {
  flex: 1;
}

.emed-sidebar-summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.5rem;
  padding: 0.85rem;
  border: 1px solid var(--emed-border);
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.05);
  transition: background var(--emed-transition), border-color var(--emed-transition),
              margin var(--emed-transition), padding var(--emed-transition),
              justify-content var(--emed-transition);
}

/* Текстовый блок внутри summary — скрывается при сворачивании */
.emed-sidebar-summary__text {
  overflow: hidden;
  transition: opacity var(--emed-transition), width var(--emed-transition);
}

/* ── Свёрнутый сайдбар ── */
.sidebar-mini.sidenav-toggled .emed-sidebar-summary {
  justify-content: center;
  gap: 0;
  margin: 1.5rem 0.75rem;
  padding: 0.6rem;
}

.sidebar-mini.sidenav-toggled .emed-sidebar-summary__text {
  display: none;
}

/* Аватар в свёрнутом состоянии: фиксируем видимость и размер */
.sidebar-mini.sidenav-toggled .emed-sidebar-summary .avatar {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  line-height: 2.5rem;
  background-color: rgba(37, 99, 235, 0.18) !important;
  color: #fff !important;
  font-size: 1rem;
  font-weight: 700;
}

/* ── Hover-раскрытие: возвращаем полный вид ── */
.sidebar-mini.sidenav-toggled.sidenav-toggled-open .emed-sidebar-summary {
  justify-content: flex-start;
  gap: 0.85rem;
  margin: 1.5rem;
  padding: 0.85rem;
}

.sidebar-mini.sidenav-toggled.sidenav-toggled-open .emed-sidebar-summary__text {
  display: block;
}

/* ─── Sidebar: пункты меню ───────────────────────────────── */

.side-menu__item {
  transition: background-color var(--emed-transition), color var(--emed-transition),
              padding-left 0.18s ease;
  border-radius: 10px;
}

.side-menu__item:hover {
  padding-left: calc(1.5rem + 3px);
}

.side-menu__icon {
  transition: transform 0.2s ease, color var(--emed-transition);
}

.side-menu__item:hover .side-menu__icon {
  transform: scale(1.12);
}

/* Активный пункт: цветная полоска слева */
.side-menu__item.active {
  position: relative;
}

.side-menu__item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--emed-accent);
}

/* ─── Header ─────────────────────────────────────────────── */

.app-header .nav-link {
  transition: color var(--emed-transition), background-color var(--emed-transition),
              transform 0.15s ease;
  border-radius: 10px;
}

.app-header .nav-link:hover {
  transform: scale(1.07);
}

/* ─── Уведомления (dropdown) ─────────────────────────────── */

/* Dropdown-контейнер уведомлений: нужен для корректного absolute-позиционирования меню */
.dropdown:has(.emed-notifications) {
  position: relative;
}

.emed-notifications {
  width: min(420px, calc(100vw - 2rem));
  /* Popper.js отключён (data-bs-display="static") — позиционируем через CSS */
  position: absolute !important;
  top: calc(100% + 6px) !important;
  right: 0 !important;
  left: auto !important;
  transform: none !important;
  margin-top: 0 !important;
}

.emed-notifications .dropdown-item {
  transition: background-color var(--emed-transition), border-radius var(--emed-transition);
  border-radius: 10px;
}

/* Прокручиваемый список уведомлений: ограничиваем высоту, чтобы колесо мыши
   скроллило внутри дропдауна, а не страницу. overscroll-behavior не даёт
   событию всплыть на body, когда список долистан до края. */
.emed-notifications-list {
  max-height: min(60vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.emed-notifications-clear {
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}

.emed-notifications-clear:hover {
  color: var(--primary-bg-color, #0d6efd) !important;
}

/* Колокольчик: нужен relative для позиционирования бейджа */
.nav-link.icon {
  position: relative;
}

/* Кнопка переключения звука */
.btn-sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: inherit;
  opacity: 0.55;
  transition: opacity var(--emed-transition), transform 0.15s ease;
}

.btn-sound-toggle:hover {
  opacity: 1;
  transform: scale(1.12);
}

.btn-sound-toggle .sound-icon-off {
  color: #94a3b8;
}

/* Бейдж с количеством уведомлений на колокольчике */
.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.28rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1rem;
  border-radius: 999px;
  pointer-events: none;
}

/* Пульсирующий индикатор */
.pulse-danger {
  animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%       { transform: scale(1.5); opacity: 0.65; }
}

/* ─── Dropdown ───────────────────────────────────────────── */

.dropdown-menu {
  transition: opacity var(--emed-transition), transform var(--emed-transition);
  transform: none !important;
}

.dropdown-item {
  transition: background-color 0.15s ease, color 0.15s ease;
  border-radius: 8px;
}

.dropdown-item:hover {
}

/* ─── Аватары ────────────────────────────────────────────── */

.main-img-user,
.avatar {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  /* Не даём флекс-контейнерам сжимать/растягивать аватарку */
  flex-shrink: 0;
  flex-grow: 0;
  aspect-ratio: 1;
}

/* Аватарка через background-image: всегда квадратная и круглая */
.avatar.cover-image {
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover !important;
  display: inline-block;
}

.main-img-user:hover,
.avatar:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

/* ─── Таблицы ────────────────────────────────────────────── */

.table tbody tr {
  transition: background-color 0.14s ease;
}

.emed-table-compact td,
.emed-table-compact th {
  vertical-align: middle;
}

.emed-table-wrap {
  overflow-x: auto;
}

.emed-table-wrap table {
  min-width: 980px;
}

/* ─── Строки заявок ──────────────────────────────────────── */

.ticket-row-link {
  color: inherit;
  font-weight: 600;
  transition: color var(--emed-transition);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

#ticket-table table td,
#ticket-table table th {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  vertical-align: middle;
}

#ticket-table table td:nth-child(2) {
  max-width: 320px;
}

.ticket-row-link:hover {
  color: var(--emed-accent-strong);
}

.ticket-row-new {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.07), rgba(37, 99, 235, 0.015));
}

.ticket-row-new td:first-child {
  box-shadow: inset 4px 0 0 #2563eb;
}

.ticket-row-urgent {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.09), rgba(245, 158, 11, 0.015));
}

.ticket-row-urgent td:first-child {
  box-shadow: inset 4px 0 0 #f59e0b;
}

.ticket-row-critical {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.09), rgba(220, 38, 38, 0.015));
}

.ticket-row-critical td:first-child {
  box-shadow: inset 4px 0 0 #dc2626;
}

.ticket-row-critical .ticket-row-link {
  color: #dc2626;
  font-weight: 600;
}

/* Индикатор комментариев */
.ticket-has-comments td:first-child {
  position: relative;
}

.ticket-has-comments td:first-child::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #0ea5e9;
}

/* ─── Статусные бейджи ───────────────────────────────────── */

.ticket-status-badge {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.ticket-status-badge:hover {
  opacity: 0.85;
  transform: scale(1.03);
}

.ticket-status-badge--new          { background: rgba(59, 130, 246, 0.13);  color: #1d4ed8; }
.ticket-status-badge--in_progress  { background: rgba(245, 158, 11, 0.15);  color: #b45309; }
.ticket-status-badge--waiting      { background: rgba(168, 85, 247, 0.13);  color: #7e22ce; }
.ticket-status-badge--resolved     { background: rgba(34, 197, 94, 0.15);   color: #15803d; }
.ticket-status-badge--closed       { background: rgba(100, 116, 139, 0.14); color: #475569; }

/* ─── Детали заявки: мета-информация ─────────────────────── */

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
}

.ticket-description {
  white-space: pre-wrap;
  line-height: 1.65;
}

/* ─── Правая колонка деталей ─────────────────────────────── */

.ticket-side-stack {
  display: grid;
  gap: 1rem;
}

.ticket-participant-list,
.ticket-help-history {
  display: grid;
  gap: 0.75rem;
}

.ticket-participant-item,
.ticket-help-history__item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--emed-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  transition: border-color var(--emed-transition), background-color var(--emed-transition),
              transform var(--emed-transition);
}

.ticket-help-history__item {
  display: block;
}

.ticket-participant-item:hover {
  border-color: var(--emed-accent);
  transform: translateX(3px);
}

/* ─── Chat / комментарии ─────────────────────────────────── */

/* ─── Строка деталей заявки: обе колонки одинаковой высоты ─ */

.ticket-detail-row {
  align-items: stretch;
}

/* Карточка чата: заполняет всё пространство левой колонки
   после карточки с информацией о заявке                   */
.ticket-chat-card {
  flex: 1 1 0;       /* растягиваемся на остаток высоты     */
  min-height: 0;     /* flex-дочерний может сжиматься ниже  */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ticket-chat-card .main-content-app {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Тело чата: больше не фиксированная высота — растягивается */
.main-content-body-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}

#ChatBody {
  flex: 1 1 0;       /* заполняет пространство между хедером и формой */
  min-height: 0;     /* позволяет скроллиться, не распирая карточку    */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem 1.25rem 0.5rem;
  background: #fff;
}

#ChatBody .content-inner {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0;
}

#ChatBody .media {
  margin-bottom: 0;
}

#ChatBody::-webkit-scrollbar        { width: 6px; }
#ChatBody::-webkit-scrollbar-thumb  {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.55);
}

/* Временна́я метка */
#ChatBody .main-chat-time {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.2rem 0;
  color: #64748b;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#ChatBody .main-chat-time::before,
#ChatBody .main-chat-time::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: rgba(148, 163, 184, 0.28);
}

#ChatBody .main-chat-time span {
  padding: 0 0.85rem;
  background: #fff;
}

.main-content-body-chat .main-chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.main-content-body-chat .main-chat-header h6 {
  margin-bottom: 0.2rem;
  font-size: 1.15rem;
}

/* Контейнер отдельного комментария */
#comment-list .media {
  align-items: flex-end;
  gap: 0.85rem;
}

#ChatBody .content-inner .comment-continuation {
  margin-top: -0.4rem;
}

#comment-list .main-img-user {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
}

#comment-list .media-body {
  max-width: calc(100% - 80px);
}

/* Пузырь сообщения */
#comment-list .main-msg-wrapper {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 0.2rem;
  padding: 0.45rem 0.85rem;
  border-radius: 1.2rem;
  background: #e8ebf3;
  color: #172554;
  line-height: 1.5;
  box-shadow: none;
  transition: box-shadow var(--emed-transition);
}

#comment-list .main-msg-wrapper:hover {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.09);
}

/* Входящие (исполнитель) */
#comment-list .chat-left .main-msg-wrapper {
  background: #f1f5f9;
  color: #1e293b;
  border-top-left-radius: 0.55rem;
}

/* Входящие — заявитель */
#comment-list .chat-left.comment-requester .main-msg-wrapper {
  background: #d1fae5;
  color: #064e3b;
}

/* Входящие — исполнитель */
#comment-list .chat-left.comment-executor .main-msg-wrapper {
  background: #fff7ed;
  color: #9a3412;
  border-left: 3px solid #fdba74;
}

/* Исходящие (свои) */
#comment-list .chat-right .main-msg-wrapper {
  background: #d9d4ff;
  color: #2e1065;
  border-top-right-radius: 0.55rem;
}

#comment-list .chat-right .media-body {
  text-align: right;
}

#comment-list .chat-right .text-muted   { justify-content: flex-end; }
#comment-list .chat-left  .text-muted   { justify-content: flex-start; }

#comment-list .text-muted.fs-12 {
  gap: 0.5rem !important;
  color: #64748b !important;
  font-size: 0.78rem !important;
}

#comment-list .main-msg-wrapper a {
  color: inherit;
}

/* Закреплённый комментарий */
.comment-pinned .main-msg-wrapper {
  background: rgba(251, 191, 36, 0.13);
  border: 1px dashed rgba(217, 119, 6, 0.48);
}

.comment-pinned {
  transition: border-color var(--emed-transition);
}

/* ─── Telegram-style сообщения ──────────────────────────── */

/* Строка сообщения */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.12rem 0.5rem;
}

.msg-row--cont {
  padding-top: 0.02rem;
}

/* Исходящие: разворачиваем строку справа налево */
.msg-row--out {
  flex-direction: row-reverse;
}

/* Скрываем аватар у исходящих и ghosted */
.msg-row--out .msg-avatar {
  display: none;
}

.msg-avatar--ghost {
  visibility: hidden;
  pointer-events: none;
}

/* Аватар */
.msg-avatar {
  flex: 0 0 auto;
  align-self: flex-end;
}

/* Группа: пузырь + кнопки действий */
.msg-group {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: min(72%, 520px);
}

.msg-row--out .msg-group {
  align-items: flex-end;
}

.msg-row--in .msg-group {
  align-items: flex-start;
}

/* ── Пузырь ── */
.msg-bubble {
  position: relative;
  padding: 0.48rem 0.72rem 0.3rem;
  border-radius: 16px;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.18s ease;
}

.msg-bubble:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* Исходящие: фиолетовый, хвост справа снизу */
.msg-row--out .msg-bubble {
  background: linear-gradient(145deg, #ddd9ff 0%, #cdc6ff 100%);
  color: #2e1065;
  border-radius: 16px 16px 4px 16px;
}

/* Входящие базовый (если нет --executor / --requester) */
.msg-row--in .msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-radius: 4px 16px 16px 16px;
}

/* Входящие — заявитель: изумрудный */
.msg-row--requester .msg-bubble {
  background: linear-gradient(145deg, #e6f9f1 0%, #d4f5e6 100%);
  color: #064e3b;
  border-radius: 4px 16px 16px 16px;
}

/* Входящие — исполнитель: тёплый */
.msg-row--executor .msg-bubble {
  background: linear-gradient(145deg, #fff4eb 0%, #ffe9d0 100%);
  color: #7c2d12;
  border-radius: 4px 16px 16px 16px;
  border-left: 2.5px solid #fdba74;
}

/* Закреплённое сообщение */
.msg-row--pinned .msg-bubble {
  background: rgba(251, 191, 36, 0.12) !important;
  border: 1.5px dashed rgba(217, 119, 6, 0.42) !important;
}

/* ── Метка «Закреплено» ── */
.msg-pin-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.71rem;
  font-weight: 700;
  color: #b45309;
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
  opacity: 0.85;
}

/* ── Имя автора ── */
.msg-author {
  font-size: 0.77rem;
  font-weight: 700;
  margin-bottom: 0.18rem;
  letter-spacing: 0.01em;
}

.msg-row--requester .msg-author { color: #059669; }
.msg-row--executor  .msg-author { color: #ea580c; }
.msg-row--in        .msg-author { color: var(--emed-accent-strong); }

/* ── Цитата ответа ── */
.msg-quote {
  display: flex;
  flex-direction: column;
  padding: 0.32rem 0.52rem;
  margin-bottom: 0.4rem;
  border-left: 3px solid rgba(100, 116, 139, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(0, 0, 0, 0.05);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-quote:hover {
  background: rgba(0, 0, 0, 0.08);
}

.msg-row--out .msg-quote {
  border-left-color: rgba(119, 101, 255, 0.45);
  background: rgba(119, 101, 255, 0.08);
}

.msg-row--requester .msg-quote {
  border-left-color: rgba(5, 150, 105, 0.5);
  background: rgba(5, 150, 105, 0.07);
}

.msg-row--executor .msg-quote {
  border-left-color: rgba(234, 88, 12, 0.45);
  background: rgba(234, 88, 12, 0.07);
}

.msg-quote-author {
  font-weight: 700;
  font-size: 0.76rem;
  margin-bottom: 0.08rem;
  color: #475569;
}

.msg-row--out .msg-quote-author { color: #6d5bdb; }

.msg-quote-text {
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  font-size: 0.8rem;
}

/* ── Текст сообщения ── */
.msg-text {
  font-size: 0.9rem;
  line-height: 1.52;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Галочки прочтения ── */

/* Скрываем на входящих сообщениях */
.msg-row--in .msg-receipt,
.msg-row--them .msg-receipt {
  display: none;
}

.msg-receipt {
  display: inline-flex;
  align-items: center;
  margin-left: 0.18rem;
  flex-shrink: 0;
  position: relative;
  cursor: default;
}

.msg-receipt-icon {
  width: 16px;
  height: 9px;
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.25s ease;
}

/* Прочитано — синие/акцентные галочки */
.msg-receipt--read .msg-receipt-icon {
  color: #60a5fa;
}

/* Тёмная тема */
body.dark-mode .msg-receipt-icon {
  color: rgba(148, 163, 184, 0.6);
}

body.dark-mode .msg-receipt--read .msg-receipt-icon {
  color: #93c5fd;
}

/* Исходящие фиолетовые пузыри (светлая тема) */
.msg-row--out .msg-receipt-icon {
  color: rgba(78, 56, 180, 0.45);
}

.msg-row--out .msg-receipt--read .msg-receipt-icon {
  color: #2563eb;
}

/* Тултип «кто прочитал» при наведении */
.msg-receipt[data-readers] {
  position: relative;
}

.msg-receipt[data-readers]::after {
  content: attr(data-readers);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(15, 23, 42, 0.88);
  color: #f0f6ff;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.28rem 0.55rem;
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
}

.msg-receipt[data-readers]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* ── Футер: время и «изм.» ── */

/*
  Telegram-трюк: футер с float:right «уступает» место тексту
  и прижимается к правому нижнему углу пузыря.
*/
.msg-footer {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  float: right;
  margin-top: 0.18rem;
  margin-left: 0.55rem;
  margin-bottom: -0.15rem;
  font-size: 0.68rem;
  opacity: 0.6;
  white-space: nowrap;
  user-select: none;
}

/* Clearfix внутри bubble после float */
.msg-bubble::after {
  content: "";
  display: table;
  clear: both;
}

.msg-edited {
  font-style: italic;
  font-size: 0.68rem;
}

/* ── Вложения ── */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.msg-attachments--only {
  margin-top: 0;
}

/* Изображение */
.msg-img-wrap {
  position: relative;
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
}

.msg-img {
  display: block;
  max-width: 200px;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msg-img-wrap:hover .msg-img {
  transform: scale(1.03);
}

.msg-img-dl {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: #334155;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  text-decoration: none;
  transform: scale(0.8);
  backdrop-filter: blur(4px);
}

.msg-img-wrap:hover .msg-img-dl {
  opacity: 1;
  transform: scale(1);
}

/* Файл-вложение */
.msg-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.msg-file:hover {
  background: rgba(0, 0, 0, 0.09);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  color: inherit;
}

.msg-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 7px;
  font-size: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.msg-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.18rem;
}

.msg-file-name {
  font-size: 0.81rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.msg-file-actions {
  display: flex;
  gap: 0.6rem;
}

.msg-file-btn {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--emed-accent-strong);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.msg-file-btn:hover {
  opacity: 1;
  text-decoration: underline;
  color: var(--emed-accent-strong);
}

.msg-file-dl-icon {
  margin-left: auto;
  font-size: 0.88rem;
  opacity: 0.5;
  flex-shrink: 0;
}

/* ── Кнопки действий (появляются при наведении) ── */
.msg-actions {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.82);
  display: flex;
  align-items: center;
  gap: 0.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: rgba(255, 255, 255, 0.97);
  border-radius: 20px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.13), 0 1px 4px rgba(0, 0, 0, 0.07);
  padding: 0.22rem 0.35rem;
  white-space: nowrap;
  z-index: 5;
}

.msg-group:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

/* Для исходящих — панель слева от пузыря */
.msg-row--out .msg-actions {
  right: calc(100% + 0.45rem);
  left: auto;
}

/* Для входящих — панель справа от пузыря */
.msg-row--in .msg-actions {
  left: calc(100% + 0.45rem);
  right: auto;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: #64748b;
  font-size: 0.82rem;
  padding: 0;
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
  line-height: 1;
}

.msg-action-btn:hover {
  background: rgba(100, 116, 139, 0.12);
  color: #334155;
  transform: scale(1.12);
}

.msg-action-btn--danger {
  color: #94a3b8;
}

.msg-action-btn--danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  transform: scale(1.12);
}

.msg-action-btn--active {
  color: #f59e0b;
}

.msg-action-btn--active:hover {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

/* ─── Тёмная тема: сообщения ─────────────────────────────── */

body.dark-mode .msg-row--out .msg-bubble {
  background: linear-gradient(145deg, rgba(109, 94, 255, 0.38) 0%, rgba(88, 72, 230, 0.32) 100%);
  color: #ede9fe;
}

body.dark-mode .msg-row--in .msg-bubble {
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
}

body.dark-mode .msg-row--requester .msg-bubble {
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
}

body.dark-mode .msg-row--executor .msg-bubble {
  background: rgba(251, 146, 60, 0.14);
  color: #fed7aa;
  border-left-color: rgba(251, 146, 60, 0.42);
}

body.dark-mode .msg-row--pinned .msg-bubble {
  background: rgba(251, 191, 36, 0.1) !important;
  border-color: rgba(217, 119, 6, 0.36) !important;
}

body.dark-mode .msg-quote {
  background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .msg-quote:hover {
  background: rgba(255, 255, 255, 0.09);
}

body.dark-mode .msg-quote-author {
  color: #94a3b8;
}

body.dark-mode .msg-row--out .msg-quote {
  background: rgba(119, 101, 255, 0.12);
}

body.dark-mode .msg-file {
  background: rgba(255, 255, 255, 0.07);
}

body.dark-mode .msg-file:hover {
  background: rgba(255, 255, 255, 0.11);
}

body.dark-mode .msg-file-icon {
  background: rgba(15, 23, 42, 0.6);
}

body.dark-mode .msg-actions {
  background: rgba(30, 41, 59, 0.97);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode .msg-action-btn {
  color: #94a3b8;
}

body.dark-mode .msg-action-btn:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
}

body.dark-mode .msg-action-btn--danger {
  color: #64748b;
}

body.dark-mode .msg-action-btn--danger:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
}

body.dark-mode .msg-img-dl {
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
}

/* ─── Форма комментария ──────────────────────────────────── */

#comment-form-wrapper {
  padding: 0.65rem 1.25rem 0.9rem;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  background: #fff;
}

#comment-form-wrapper .main-chat-footer {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.main-chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
  padding: 0.9rem !important;
  border-top: 1px solid var(--emed-border);
}

.main-chat-footer input[type="file"] {
  display: none;
}

.main-chat-footer textarea.form-control {
  min-height: 44px;
  max-height: 120px;
  resize: none;
  flex: 1;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: #fff;
  color: inherit;
  padding: 0.75rem 0.95rem;
}

.main-chat-footer textarea.form-control::placeholder {
  color: #64748b;
}

/* Кнопка «прикрепить» */
.emed-drop-trigger {
  /* Размер и форма */
  position: relative !important; /* нужен для абсолютного позиционирования иконки */
  display: inline-block !important; /* override nav-link display */
  flex-shrink: 0;
  width: 2.6rem !important;
  height: 2.6rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 999px;
  border: 1.5px solid rgba(148, 163, 184, 0.42);

  /* Цвет и фон */
  color: #64748b;
  background: transparent;
  cursor: pointer;

  /* Тень-свечение: изначально прозрачная */
  box-shadow:
    0 0 0   0 rgba(119, 101, 255, 0),
    0 0 0   0 rgba(119, 101, 255, 0);

  transition:
    border-color  0.25s ease,
    color         0.25s ease,
    background    0.25s ease,
    box-shadow    0.35s ease,
    transform     0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Иконка внутри: абсолютный центр — не зависит от padding/line-height/display */
.emed-drop-trigger i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  line-height: 1;
  font-size: 1rem;
  pointer-events: none;
}

.emed-drop-trigger:hover {
  border-color: #7765ff;
  color: #7765ff;
  background: rgba(119, 101, 255, 0.07);
  transform: scale(1.1);

  /* Двойное свечение: ближнее мягкое + дальнее рассеянное */
  box-shadow:
    0 0  8px  2px rgba(119, 101, 255, 0.35),
    0 0 22px  6px rgba(119, 101, 255, 0.15);
}

.emed-drop-trigger:active {
  transform: scale(0.95);
  box-shadow:
    0 0  4px  1px rgba(119, 101, 255, 0.4),
    0 0 12px  3px rgba(119, 101, 255, 0.2);
}

/* ── Пульсирующее свечение при фокусе (клавиатура / a11y) ── */
.emed-drop-trigger:focus-visible {
  outline: none;
  border-color: #7765ff;
  color: #7765ff;
  animation: dropTriggerPulse 1.4s ease-in-out infinite;
}

@keyframes dropTriggerPulse {
  0%, 100% {
    box-shadow:
      0 0  6px 1px rgba(119, 101, 255, 0.3),
      0 0 18px 4px rgba(119, 101, 255, 0.1);
  }
  50% {
    box-shadow:
      0 0 10px 3px rgba(119, 101, 255, 0.55),
      0 0 28px 8px rgba(119, 101, 255, 0.2);
  }
}

/* Кнопка «отправить» */
#comment-form .btn.btn-icon.btn-primary {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #7765ff, #6b4eff);
  box-shadow: 0 8px 22px rgba(107, 78, 255, 0.26);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

#comment-form .btn.btn-icon.btn-primary:hover {
  background: linear-gradient(135deg, #8576ff, #755cff);
  transform: scale(1.08);
}

/* Выпадающий список файлов */
.dropzone-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  width: 220px;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 0.85rem;
  background: #fff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.11);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.dropzone-list--inline {
  position: static;
  width: auto;
  opacity: 1;
  visibility: visible;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.25rem 0;
  border-radius: 0;
}

/* ─── Непрочитанные комментарии ─────────────────────────── */

/* Кнопка-бейдж в хедере чата */
.unread-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.72rem 0.3rem 0.55rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.18s ease, opacity 0.3s ease;
  white-space: nowrap;
  animation: unreadBadgePop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.unread-badge:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.unread-badge:active {
  transform: scale(0.96);
}

.unread-badge--done {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

.unread-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.unread-badge-label {
  font-size: 0.76rem;
}

/* ─── PDF Preview Offcanvas ──────────────────────────────── */

.pdf-offcanvas {
  width: 70vw !important;
  top: 3.5rem !important;
  height: calc(100vh - 3.5rem) !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border-left: 1px solid var(--emed-border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
}

/* Шапка: всегда видна, следует за скролом (sticky) */
.pdf-offcanvas__header {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: inherit;
  border-bottom: 1px solid var(--emed-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pdf-offcanvas__title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(70vw - 6rem);
}

.pdf-offcanvas__close {
  flex-shrink: 0;
}

/* Тело: iframe занимает всё оставшееся пространство */
.pdf-offcanvas__body {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pdf-offcanvas__frame {
  width: 100%;
  height: 100%;
  border: none;
  flex: 1 1 0;
}

/* ── Тёмная тема ── */
body.dark-mode .pdf-offcanvas {
  background: #0f172a;
  border-left-color: rgba(148, 163, 184, 0.14);
  box-shadow: -8px 0 32px rgba(2, 6, 23, 0.38);
  color: #f0f6ff;
}

body.dark-mode .pdf-offcanvas__header {
  background: #0f172a;
  border-bottom-color: rgba(148, 163, 184, 0.14);
}

body.dark-mode .pdf-offcanvas__title {
  color: #f0f6ff;
}

body.dark-mode .pdf-offcanvas__close {
  filter: invert(1) brightness(1.5);
}

/* Адаптив: на мобильных — полная ширина */
@media (max-width: 768px) {
  .pdf-offcanvas {
    width: 100vw !important;
  }
  .pdf-offcanvas__title {
    max-width: calc(100vw - 5rem);
  }
}

/* Cropper.js styles */
.img-container img {
  max-width: 100%;
}

#cropperModal .modal-body {
  background-color: #f8f9fa;
}

#cropperModal .img-container {
  min-height: 400px;
  max-height: 600px;
  width: 100%;
}

/* Разделитель «N непрочитанных» между сообщениями */
.unread-divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.6rem 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.3), transparent);
}

.unread-divider span {
  padding: 0.22rem 0.9rem;
  margin: 0 0.6rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.09);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.unread-divider--done {
  opacity: 0;
  transform: scaleY(0);
  pointer-events: none;
}

/* Лёгкая подсветка непрочитанных сообщений */
.msg-row--unread .msg-bubble {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18),
              0 2px 12px rgba(37, 99, 235, 0.08) !important;
}

/* Тёмная тема */
body.dark-mode .unread-badge {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

body.dark-mode .unread-divider span {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

body.dark-mode .unread-divider::before,
body.dark-mode .unread-divider::after {
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.25), transparent);
}

body.dark-mode .msg-row--unread .msg-bubble {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22),
              0 2px 12px rgba(59, 130, 246, 0.1) !important;
}

/* ─── Пагинация ──────────────────────────────────────────── */

.ticket-pagination .page-link {
  border-radius: 10px;
  transition: background-color var(--emed-transition), color var(--emed-transition),
              border-color var(--emed-transition), transform var(--emed-transition);
}

.ticket-pagination .page-link:hover {
  transform: scale(1.04);
}

/* ─── Пустое состояние ───────────────────────────────────── */

.emed-empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: #64748b;
}

/* ─── Вспомогательные компоненты ─────────────────────────── */

.emed-panel {
  border: 1px solid var(--emed-border);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
}

.emed-management-grid .card {
  height: 100%;
}

.emed-step-card {
  position: sticky;
  top: 92px;
}

.emed-step-item {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem 0;
}

.emed-step-item + .emed-step-item {
  border-top: 1px solid var(--emed-border);
}

.emed-step-item.is-active .emed-step-index {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
}

.emed-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2.1rem;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: var(--emed-accent-light);
  color: var(--emed-accent-strong);
  font-weight: 700;
  transition: background 0.2s ease, transform 0.2s ease;
}

.emed-step-item:hover .emed-step-index {
  transform: scale(1.1);
}

.emed-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.emed-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.emed-form-stack .form-label {
  font-weight: 600;
}

.emed-helper {
  color: #64748b;
  font-size: 0.875rem;
}

.emed-stat-card .avatar {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.emed-stat-card .h3 {
  transition: color 0.3s ease;
}

.emed-confirm-card .card-body {
  padding: 1.75rem;
}

.emed-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.9rem;
  border-radius: 16px;
  background: rgba(239, 68, 68, 0.11);
  font-size: 1.35rem;
}

.emed-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.emed-soft-note {
  padding: 0.8rem 1rem;
  border: 1px solid var(--emed-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
}

.emed-ws-status {
  font-size: 0.78rem;
  color: #64748b;
}

/* ─── Нагрузка исполнителей ──────────────────────────────── */

.executor-load-toggle {
  color: inherit;
}

.executor-load-toggle:hover {
  color: inherit;
}

.executor-load-toggle__meta {
  display: inline-flex;
  align-items: center;
}

.executor-load-toggle__icon {
  transition: transform 0.28s ease;
}

.executor-load-toggle[aria-expanded="true"] .executor-load-toggle__icon {
  transform: rotate(180deg);
}

.executor-load-panel {
  transition: height 0.3s ease, opacity 0.3s ease;
}

.executor-load-panel.collapsing { opacity: 0.5; }
.executor-load-panel.show       { opacity: 1;   }

/* ─── Мастер регистрации ─────────────────────────────────── */

.registration-wizard .content {
  min-height: 0;
  padding-top: 1.4rem;
}

.registration-wizard .steps {
  margin-bottom: 1rem;
}

.registration-wizard .steps ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.registration-wizard .steps li {
  width: 100%;
}

.registration-wizard .steps a {
  border-radius: 16px;
}

.registration-wizard-summary dt {
  color: #64748b;
}

.registration-wizard-summary dd {
  font-weight: 600;
}

/* ─── Страница входа ─────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%,  rgba(56, 189, 248, 0.2), transparent 22%),
    radial-gradient(circle at 90% 15%,  rgba(96, 165, 250, 0.2), transparent 24%),
    radial-gradient(circle at 20% 85%,  rgba(14, 165, 233, 0.16), transparent 20%),
    linear-gradient(135deg, #f3fbff 0%, #e0f2fe 35%, #dbeafe 100%);
  background-size: 120% 120%;
  animation: authGradientShift 16s ease-in-out infinite;
}

.auth-page {
  min-height: calc(100vh - 2rem);
  display: flex;
  align-items: center;
}

.auth-brand-panel {
  padding: 1.4rem;
  border: 1px solid var(--emed-border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.07), rgba(14, 165, 233, 0.03));
}

.emed-login-card {
  overflow: hidden;
}

.emed-login-card::before {
  content: "";
  display: block;
  height: 5px;
  background: linear-gradient(90deg, #2563eb, #06b6d4, #22c55e);
}

@keyframes authGradientShift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* ─── Модальные окна ─────────────────────────────────────── */

#announcementModal .modal-content {
  border-radius: 18px;
  overflow: hidden;
}

.modal.show .modal-dialog {
  animation: modalSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-26px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Toast-уведомления ──────────────────────────────────── */

.toast {
  animation: toastSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(36px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ─── Анимации входа контента ────────────────────────────── */

.main-content.app-content {
  animation: pageFadeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* Карточки в сетке: постепенное появление */
.row > [class*="col-"] > .card {
  animation: cardEntrance 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.row > [class*="col-"]:nth-child(1) > .card { animation-delay: 0.02s; }
.row > [class*="col-"]:nth-child(2) > .card { animation-delay: 0.06s; }
.row > [class*="col-"]:nth-child(3) > .card { animation-delay: 0.10s; }
.row > [class*="col-"]:nth-child(4) > .card { animation-delay: 0.14s; }

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

/* ─── Хлебные крошки ─────────────────────────────────────── */

.breadcrumb-item a {
  transition: color 0.14s ease;
}

/* ─── Глобальный загрузчик ───────────────────────────────── */

#global-loader {
  transition: opacity 0.18s ease;
}

/* ─── HTMX индикаторы ────────────────────────────────────── */

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-indicator {
  display: none;
}

/* Шиммер-загрузка (скелетон) */
[aria-busy="true"] {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}

[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.16) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}

/* ─── Вложения в комментариях (файлы) ───────────────────── */

.comment-file-attachment {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(128, 128, 128, 0.18) !important;
  border-radius: 10px;
  background: rgba(128, 128, 128, 0.04);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--emed-transition), background var(--emed-transition),
              box-shadow var(--emed-transition);
}

.comment-file-attachment:hover {
  border-color: rgba(37, 99, 235, 0.35) !important;
  background: rgba(37, 99, 235, 0.04);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
  color: inherit;
}

.comment-file-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: #fff;
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.comment-file-name {
  max-width: 200px;
  font-size: 0.82rem;
  font-weight: 500;
}

body.dark-mode .comment-file-icon-wrap {
  background: rgba(30, 41, 59, 0.9);
}

/* ─── Ответ на комментарий (цитата) ─────────────────────── */

.comment-reply-quote {
  font-size: 0.84rem;
  background: rgba(128, 128, 128, 0.08);
  border-left: 3px solid rgba(128, 128, 128, 0.38);
  border-radius: 0 6px 6px 0;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
}

/* Панель «ответ на комментарий» перед полем ввода */
.reply-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.5rem 0.75rem 0;
  padding: 0.45rem 0.65rem;
  border-left: 3px solid rgba(100, 116, 139, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(100, 116, 139, 0.08);
  font-size: 0.83rem;
  color: #64748b;
}

.reply-context-bar #reply-author {
  font-size: 0.83rem;
  color: #475569;
}

.reply-context-bar #reply-text {
  font-size: 0.83rem;
  max-width: 280px;
  color: #64748b;
}

.reply-context-close {
  color: #94a3b8;
  flex-shrink: 0;
  line-height: 1;
}

.reply-context-close:hover {
  color: #ef4444;
}

body.dark-mode .reply-context-bar {
  background: rgba(100, 116, 139, 0.14);
  border-left-color: rgba(148, 163, 184, 0.4);
  color: #94a3b8;
}

body.dark-mode .reply-context-bar #reply-author {
  color: #cbd5e1;
}

body.dark-mode .reply-context-bar #reply-text {
  color: #94a3b8;
}

/* Кнопка «применить статус» в ticket_status_card */
.ticket-status-apply-btn {
  width: 38px;
  flex-shrink: 0;
}

/* Dropzone cursor */
.dropzone-clickable {
  cursor: pointer;
}

/* ─── Dropzone ───────────────────────────────────────────── */

.dropzone {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.dropzone:hover,
.dropzone.bg-light {
  border-color: var(--emed-accent) !important;
  background-color: rgba(37, 99, 235, 0.03) !important;
}

/* ─── Поиск / кнопки форм ────────────────────────────────── */

.card-body .btn-outline-primary[type="submit"] {
  transition: background-color var(--emed-transition), color var(--emed-transition),
              border-color var(--emed-transition), box-shadow var(--emed-transition),
              transform 0.15s ease;
}

.card-body .btn-outline-primary[type="submit"]:hover {
  transform: translateY(-1px);
}

/* ─── Границы с hover ────────────────────────────────────── */

.border.rounded-3 {
  transition: border-color var(--emed-transition), box-shadow var(--emed-transition);
}

.border.rounded-3:hover {
  border-color: rgba(37, 99, 235, 0.38) !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.09);
}

/* ─── Переключатель sidebar ──────────────────────────────── */

.app-sidebar__toggle {
  transition: color var(--emed-transition), transform 0.22s ease;
}

.app-sidebar__toggle:hover {
  transform: scale(1.08);
}

/* ─── Focus ring ─────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--emed-accent);
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--emed-accent);
  outline-offset: 3px;
}

/* ─── Изображения / лайтбокс ─────────────────────────────── */

.hover-scale {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.hover-scale:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14) !important;
  z-index: 1;
}

.object-fit-cover      { object-fit: cover; }
.transition-all        { transition: all 0.2s ease; }
.hover-opacity-100:hover { opacity: 1 !important; }

/* ─── Адаптив ────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .page-header {
    margin-top: 0.65rem;
  }

  .emed-page-header,
  .emed-card-title-row,
  .emed-section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .emed-step-card {
    position: static;
  }

  .main-chat-footer {
    flex-wrap: wrap;
  }

  .main-chat-footer textarea.form-control {
    width: 100%;
  }

  .registration-wizard .steps ul {
    grid-template-columns: 1fr;
  }

  .input-group {
    flex-wrap: wrap;
  }

  .input-group > .btn,
  .input-group > .form-control,
  .input-group > .form-select {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════
   ТЁМНАЯ ТЕМА
   ═══════════════════════════════════════════════════════════ */

/* Основной текст */
body.dark-mode,
body.dark-mode .page,
body.dark-mode .main-content,
body.dark-mode .card,
body.dark-mode .dropdown-menu,
body.dark-mode .modal-content,
body.dark-mode .offcanvas,
body.dark-mode .list-group-item,
body.dark-mode .table,
body.dark-mode .text-dark {
  color: #f0f6ff !important;
}

/* Заголовки и метки */
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6,
body.dark-mode .page-title,
body.dark-mode .card-title,
body.dark-mode .side-menu__label,
body.dark-mode .nav-link,
body.dark-mode .dropdown-item,
body.dark-mode label,
body.dark-mode .form-label,
body.dark-mode .col-form-label,
body.dark-mode .table th,
body.dark-mode .table td,
body.dark-mode .main-profile-menu .dropdown-item,
body.dark-mode .header-navheading,
body.dark-mode .notification-label,
body.dark-mode .main-notification-text,
body.dark-mode .main-notification-time,
body.dark-mode .main-header-center .form-control {
  color: #f0f6ff !important;
}

/* Второстепенный текст */
body.dark-mode p, body.dark-mode small, body.dark-mode span,
body.dark-mode li,
body.dark-mode .text-muted,
body.dark-mode .tx-muted,
body.dark-mode .text-secondary,
body.dark-mode .ticket-meta,
body.dark-mode .empty-state-text,
body.dark-mode .page-header .breadcrumb-item,
body.dark-mode .form-text,
body.dark-mode .registration-wizard-summary dt,
body.dark-mode .executor-load-toggle__meta,
body.dark-mode .main-mail-msg,
body.dark-mode .chat-msg-append,
body.dark-mode .chat-time,
body.dark-mode .main-notification-subtext {
  color: #c7deff !important;
}

/* Поля ввода */
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
body.dark-mode .form-control,
body.dark-mode .form-select {
  color: #f0f6ff !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder,
body.dark-mode .form-control::placeholder {
  color: #90adc7 !important;
  opacity: 1;
}

/* Кнопки в тёмной теме */
body.dark-mode .btn-light,
body.dark-mode .btn-outline-light,
body.dark-mode .badge.bg-light,
body.dark-mode .badge.text-dark {
  color: #f0f6ff !important;
}

body.dark-mode .btn-outline-secondary {
  color: #cbd5e1;
  border-color: #475569;
}

body.dark-mode .btn-outline-secondary:hover {
  color: #f8fafc;
  background-color: #334155;
  border-color: #64748b;
}

body.dark-mode .btn-outline-secondary.active,
body.dark-mode .btn-outline-secondary:active {
  color: #f8fafc;
  background-color: #475569;
  border-color: #64748b;
}

/* Ссылки */
body.dark-mode a:not(.btn):not(.ticket-status-badge) {
  color: #dbeafe;
}

body.dark-mode a:not(.btn):not(.ticket-status-badge):hover {
  color: #ffffff;
}

/* Панели и заметки */
body.dark-mode .emed-panel {
  background: rgba(15, 23, 42, 0.48);
}

body.dark-mode .emed-soft-note {
  background: rgba(15, 23, 42, 0.55);
}

/* Участники и история */
body.dark-mode .ticket-participant-item,
body.dark-mode .ticket-help-history__item {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.16);
}

/* Chat-область */
body.dark-mode #ChatBody,
body.dark-mode #comment-form-wrapper {
  background: rgba(15, 23, 42, 0.4);
}

body.dark-mode #ChatBody .main-chat-time span {
  background: rgba(15, 23, 42, 0.4);
}

/* Textarea в чате */
body.dark-mode .main-chat-footer textarea.form-control {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.88);
  color: #e2e8f0;
}

body.dark-mode .main-chat-footer textarea.form-control::placeholder {
  color: #94a3b8;
}

/* Исходящие сообщения в тёмной теме */
body.dark-mode #comment-list .chat-right .main-msg-wrapper {
  background: rgba(109, 94, 255, 0.3);
  color: #ede9fe;
}

/* Заявитель в тёмной теме */
body.dark-mode #comment-list .chat-left.comment-requester .main-msg-wrapper {
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
}

/* Исполнитель в тёмной теме */
body.dark-mode #comment-list .chat-left.comment-executor .main-msg-wrapper {
  background: rgba(251, 146, 60, 0.14);
  color: #fed7aa;
  border-left: 3px solid rgba(251, 146, 60, 0.38);
}

/* Кнопка прикрепить в тёмной теме */
body.dark-mode .emed-drop-trigger {
  border-color: rgba(148, 163, 184, 0.28);
  color: #94a3b8;
}

body.dark-mode .emed-drop-trigger:hover {
  border-color: #a78bfa;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.1);
  box-shadow:
    0 0  8px  2px rgba(167, 139, 250, 0.4),
    0 0 22px  6px rgba(167, 139, 250, 0.18);
}

/* Выпадающий список файлов в тёмной теме */
body.dark-mode .dropzone-list {
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
}

/* Закреплённый комментарий в тёмной теме */
body.dark-mode .comment-pinned .main-msg-wrapper,
body.dark-mode .comment-pinned .main-msg-wrapper a {
  color: inherit;
}
@ k e y f r a m e s   h i g h l i g h t - f a d e   {   0 %   {   b a c k g r o u n d - c o l o r :   r g b a ( 3 7 ,   9 9 ,   2 3 5 ,   0 . 1 ) ;   }   1 0 0 %   {   b a c k g r o u n d - c o l o r :   t r a n s p a r e n t ;   }   }   . m s g - r o w - - h i g h l i g h t   . m s g - b u b b l e   {   a n i m a t i o n :   h i g h l i g h t - f a d e   3 s   e a s e - i n - o u t ;   b o r d e r :   1 p x   s o l i d   r g b a ( 3 7 ,   9 9 ,   2 3 5 ,   0 . 3 )   ! i m p o r t a n t ;   }  
 