:root {
  --ink: #12171c;
  --text: #1d262e;
  --muted: #5f6d7a;
  --line: #d5dde6;
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --bg: #e8eef4;
  --primary: #0d7c74;
  --primary-hover: #0a635d;
  --primary-soft: #d8f1ee;
  --accent: #e8ff4d;
  --danger: #c0392b;
  --warn: #d97706;
  --ok: #0f766e;
  --shadow: 0 20px 50px rgba(18, 23, 28, 0.1);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --blue: #0d7c74;
  --amber: #d97706;
  --red: #c0392b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(13, 124, 116, 0.14), transparent 55%),
    radial-gradient(700px 360px at 100% 10%, rgba(232, 255, 77, 0.18), transparent 50%),
    linear-gradient(180deg, #f5f8fb 0%, var(--bg) 45%, #dde7f0 100%);
}

.app-shell {
  min-height: 100vh;
}

.tabs-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid rgba(213, 221, 230, 0.9);
  backdrop-filter: blur(14px);
}

.nav-brand {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

/* Кабинет / очередь — на всю ширину экрана */
body.cabinet-wide .container,
body.queue-wide .container {
  max-width: none;
  width: 100%;
  padding: 0 20px 32px;
}

body.cabinet-wide .tabs-nav,
body.queue-wide .tabs-nav {
  padding-left: 20px;
  padding-right: 20px;
}

body.cabinet-wide #page-engineer .workspace-panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 12px 0 0;
  backdrop-filter: none;
}

body.cabinet-wide #page-engineer .engineer-toolbar,
body.cabinet-wide #page-engineer .engineer-boards-section,
body.cabinet-wide #page-engineer .engineer-chats-panel,
body.cabinet-wide #page-engineer .engineer-create-panel,
body.cabinet-wide #page-engineer .admin-panel,
body.cabinet-wide #page-engineer .engineer-metrics {
  box-shadow: 0 10px 28px rgba(18, 23, 28, 0.06);
}

body.cabinet-wide #ticketDetails.details {
  margin-top: 14px;
}

.page-section {
  display: block;
  animation: pageIn 320ms ease both;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  width: 100vw;
  min-height: min(78vh, 680px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  color: #f4f8f7;
  background:
    linear-gradient(115deg, rgba(10, 16, 20, 0.88) 12%, rgba(13, 124, 116, 0.55) 70%, rgba(18, 23, 28, 0.35)),
    repeating-linear-gradient(
      -18deg,
      rgba(255, 255, 255, 0.04) 0 2px,
      transparent 2px 14px
    ),
    linear-gradient(160deg, #101820, #163c39 48%, #0d7c74);
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -35% 35%;
  height: 70%;
  background: radial-gradient(circle, rgba(232, 255, 77, 0.28), transparent 62%);
  pointer-events: none;
  animation: glowPulse 5s ease-in-out infinite;
}

.hero-inner {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 56px 0 48px;
  position: relative;
  z-index: 1;
}

.brand-mark {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 5.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: #fff;
  animation: brandIn 700ms ease both;
}

.hero h1 {
  margin: 0 0 14px;
  max-width: 14ch;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.8vw, 2.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #fff;
  animation: riseIn 750ms 80ms ease both;
}

.hero-lead,
.hero .hint {
  margin: 0;
  max-width: 38ch;
  color: rgba(244, 248, 247, 0.86);
  font-size: 1.08rem;
  animation: riseIn 750ms 140ms ease both;
}

.hero-actions {
  margin-top: 26px;
  animation: riseIn 750ms 200ms ease both;
}

.hero-cta {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 14px 24px;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, background 160ms ease;
}

.hero-cta:hover {
  transform: translateY(-2px);
  background: #f3ff7a;
}

.below-fold {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

/* ===== Panels / forms ===== */
.panel,
.card,
.collapsible-card,
.department-panel,
.engineer-create-panel,
.admin-panel,
.engineer-toolbar,
.engineer-metrics,
.engineer-boards-section,
.engineer-chats-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel h2,
.card h2,
.engineer-header h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.hint,
.meta {
  color: var(--muted);
}

.hint {
  margin: 0 0 12px;
}

.section-head {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.section-icon {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 124, 116, 0.18);
}

button {
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 650;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary,
#faqSuggestBtn,
#engineerLogoutBtn,
#refreshEngineerChatsBtn,
#cabinetReloadBtn,
#queueLoadMoreBtn,
#cabinetLoadMoreBtn {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.btn-secondary:hover,
#faqSuggestBtn:hover,
#engineerLogoutBtn:hover,
#refreshEngineerChatsBtn:hover,
#cabinetReloadBtn:hover {
  background: var(--surface-2) !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.filters input,
.filters select {
  min-width: 160px;
  flex: 1;
}

.compact-checkbox {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.compact-checkbox input {
  width: auto;
}

details.panel > summary,
details.card > summary,
.collapsible-card > summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

.collapsible-content {
  margin-top: 12px;
}

.identity-panel,
.faq,
.error {
  margin-top: 10px;
}

.identity-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid #b7e4de;
  margin-bottom: 14px;
}

.identity-panel strong {
  font-size: 0.95rem;
}

.identity-panel span {
  color: var(--muted);
  font-size: 0.9rem;
}

.identity-warn {
  background: #fff4d6;
  border-color: #f0d48a;
}

.identity-panel-ticket {
  margin-top: 0;
}

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

.onboarding-section,
.onboarding-preview {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.onboarding-preview-grid,
.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.attachments-list {
  padding-left: 18px;
}

/* ===== Chat ===== */
.chat-shell {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfeff, #f2f7f8);
}

.chat-topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
}

.chat-title-wrap strong {
  font-size: 1rem;
}

.chat-title-wrap span,
.chat-list-email,
.chat-list-preview,
.chat-list-footer {
  color: var(--muted);
  font-size: 0.86rem;
}

.chat-status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.chat-identity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.chat-box {
  min-height: 160px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
}

.chat-line {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.chat-line.user {
  background: var(--primary-soft);
}

.chat-line.assistant {
  background: var(--surface-2);
}

.chat-line-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chat-quick-btn {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  border-radius: 999px !important;
  padding: 7px 12px !important;
  font-size: 0.88rem !important;
}

.chat-input-row,
.chat-actions-row {
  display: flex;
  gap: 8px;
}

.chat-input-row {
  margin-bottom: 8px;
}

/* ===== Queue ===== */
.queue-page {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

.queue-page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.queue-page-head h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.queue-page-head .hint {
  margin: 0;
}

.queue-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.queue-summary-item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(18, 23, 28, 0.04);
  display: grid;
  gap: 2px;
}

.queue-summary-item strong {
  font-size: 1.35rem;
  font-family: var(--display);
  color: var(--ink);
  line-height: 1.1;
}

.queue-summary-item span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.queue-summary-item.warn-summary strong {
  color: #b45309;
}

.queue-toolbar {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(18, 23, 28, 0.04);
  margin-bottom: 0;
}

.queue-toolbar #queueSearchId {
  min-width: 140px;
  max-width: 180px;
  flex: 0 1 180px;
}

.queue-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  align-items: start;
}

.queue-table-wrap {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 10px 28px rgba(18, 23, 28, 0.05);
  min-height: 280px;
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.queue-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 750;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.queue-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f6;
  vertical-align: middle;
}

.queue-row {
  cursor: pointer;
  transition: background 140ms ease;
}

.queue-row:hover,
.queue-row.is-selected {
  background: #f3faf8;
}

.queue-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.queue-col-id {
  white-space: nowrap;
}

.queue-col-id strong {
  display: block;
  font-size: 0.98rem;
}

.queue-pos {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-hover);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 1px 7px;
}

.queue-pos.is-muted {
  background: var(--surface-2);
  color: var(--muted);
}

.queue-row-title {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.queue-col-main .meta {
  font-size: 0.8rem;
}

.queue-assignee {
  font-size: 0.86rem;
  font-weight: 600;
  color: #334155;
}

.queue-col-when {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.queue-row.priority-high td:first-child,
.queue-row.priority-urgent td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}

.queue-row.priority-urgent td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.queue-peek {
  position: sticky;
  top: 72px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(18, 23, 28, 0.05);
  min-height: 220px;
}

.queue-peek-card h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.4rem;
}

.queue-peek-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
}

.queue-peek-facts {
  margin: 12px 0;
}

.ticket,
.compact-ticket,
.list-ticket {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px;
}

.list-ticket header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.queue-empty {
  text-align: center;
  padding: 42px 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.queue-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1.05rem;
}

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

  .queue-peek {
    position: static;
  }
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.status-badge,
.priority-badge,
.queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}

.queue-badge {
  background: #fff4d6;
  border-color: #f0d48a;
  color: #8a5a00;
}

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

.status-open { color: #0f766e; background: #d9f3ef; border-color: #a7ddd5; }
.status-in-progress { color: #1d4ed8; background: #e0eaff; border-color: #bfd0ff; }
.status-waiting { color: #a16207; background: #fff4d6; border-color: #f0d48a; }
.status-resolved { color: #166534; background: #ddf7e5; border-color: #b5e6c4; }
.status-closed { color: #475569; background: #e8eef4; border-color: #cbd5e1; }

.priority-badge-low { color: #475569; }
.priority-badge-normal { color: #0f766e; }
.priority-badge-high { color: #a16207; }
.priority-badge-urgent { color: #b91c1c; }

/* ===== Cabinet ===== */
.login-panel {
  max-width: 560px;
  margin: 28px auto;
}

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

.engineer-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.engineer-subtabs,
.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.engineer-subtab-btn,
.chat-tab-btn {
  background: var(--surface-2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.engineer-subtab-btn.active,
.chat-tab-btn.active {
  background: var(--ink) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.subtab-badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 11px;
}

.departments-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.board,
.list-mode {
  display: grid;
  gap: 12px;
}

.kanban-section {
  padding: 16px 16px 18px;
}

.kanban-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.kanban-section-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.kanban-hint {
  margin: 0;
  font-size: 0.9rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  width: 100%;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-gutter: stable;
}

body.cabinet-wide .board {
  gap: 16px;
  min-height: 52vh;
}

.board-column {
  position: relative;
  min-width: 0;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(213, 221, 230, 0.95);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 246, 249, 0.92));
  padding: 12px;
  box-shadow: 0 8px 24px rgba(18, 23, 28, 0.04);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.board-column::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
}

.board-column.column-open::before { background: #0f766e; }
.board-column.column-in-progress::before { background: #2563eb; }
.board-column.column-waiting::before { background: #d97706; }
.board-column.column-resolved::before { background: #16a34a; }
.board-column.column-closed::before { background: #64748b; }

.board-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
}

.board-column-head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.board-column.drop-target {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(13, 124, 116, 0.12);
  transform: translateY(-2px);
}

.column-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
  flex: 1;
}

.column-body .drop-hint {
  margin: auto 0;
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed #c7d2de;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.85rem;
}

.column-count {
  min-width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(18, 23, 28, 0.07);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.compact-ticket {
  position: relative;
  cursor: grab;
  padding: 12px 12px 12px 14px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 4px 14px rgba(18, 23, 28, 0.04);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.compact-ticket::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: #94a3b8;
}

.compact-ticket.priority-low::before { background: #94a3b8; }
.compact-ticket.priority-normal::before { background: var(--primary); }
.compact-ticket.priority-high::before { background: var(--warn); }
.compact-ticket.priority-urgent::before { background: var(--danger); }

.compact-ticket:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 12px 26px rgba(18, 23, 28, 0.1);
}

.compact-ticket.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.board-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.board-card-id {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.board-card-title {
  display: block;
  margin: 0 0 6px;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--ink);
  font-weight: 700;
}

.board-card-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.board-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.board-card-assignee {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.board-card-attach {
  font-size: 0.75rem;
  color: var(--muted);
}

.compact-ticket .priority-badge {
  padding: 2px 7px;
  font-size: 11px;
}

.compact-actions,
.ticket-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.compact-actions button {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.primary-action,
[data-take-ticket] {
  background: #12171c !important;
}

.details,
#ticketDetails {
  margin-top: 16px;
  padding: 0;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

#ticketDetails > .hint,
#ticketDetails > .error,
#ticketDetails > p {
  padding: 18px;
}

.details-open {
  animation: panelIn 280ms ease both;
}

.ticket-detail {
  display: grid;
  gap: 0;
}

.ticket-detail-hero {
  padding: 16px 20px 14px;
  background:
    linear-gradient(135deg, rgba(13, 124, 116, 0.1), rgba(232, 255, 77, 0.12) 55%, rgba(255, 255, 255, 0.9)),
    #f7fafc;
  border-bottom: 1px solid var(--line);
}

.ticket-detail-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ticket-detail-id {
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.ticket-detail-badges {
  margin: 0;
}

.ticket-detail-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(1.25rem, 1.8vw, 1.55rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ticket-detail-desc {
  margin: 0;
  color: #334155;
  white-space: pre-wrap;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.ticket-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ticket-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink);
}

.ticket-chip.muted-chip {
  color: var(--muted);
  font-weight: 500;
}

.ticket-action-bar {
  position: sticky;
  top: 64px;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) auto minmax(320px, 1.4fr);
  gap: 12px 16px;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(18, 23, 28, 0.05);
}

.ticket-action-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ticket-side-label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ticket-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0d7c74, #163c39);
  color: #fff;
  font-weight: 750;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.ticket-requester-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ticket-requester-name {
  font-size: 1rem;
  line-height: 1.2;
  color: var(--ink);
}

.ticket-person-meta {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-inline-link {
  color: var(--primary-hover);
  text-decoration: none;
  font-weight: 650;
}

.ticket-inline-link:hover {
  text-decoration: underline;
}

.ticket-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ticket-action-buttons .primary-action,
.ticket-action-buttons .btn-secondary,
.ticket-mail-btn {
  white-space: nowrap;
}

.ticket-mail-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 10px 14px !important;
}

.ticket-take-btn {
  background: #0d7c74 !important;
}

.ticket-action-work {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}

.ticket-assignee-inline {
  display: grid;
  gap: 2px;
  min-width: 110px;
  margin-right: 4px;
}

.ticket-assignee-inline strong {
  font-size: 0.92rem;
}

.ticket-inline-field {
  min-width: 120px;
  margin: 0;
  font-size: 0.75rem;
}

.ticket-inline-field select {
  padding: 8px 10px;
  min-width: 130px;
}

.ticket-reassign-inline {
  display: flex;
  gap: 6px;
  align-items: end;
}

.ticket-reassign-inline .ticket-inline-field {
  min-width: 150px;
}

.ticket-reassign-inline .btn-secondary {
  padding: 8px 12px;
}

.ticket-task-ref {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
}

.ticket-detail-body {
  padding: 16px 20px 20px;
  display: grid;
  gap: 12px;
  max-width: 920px;
}

.ticket-facts-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.ticket-facts-card h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.ticket-facts-list {
  margin: 0;
  display: grid;
  gap: 8px;
}

.ticket-fact-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f6;
}

.ticket-fact-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ticket-fact-row dt {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.ticket-fact-row dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: pre-wrap;
}

.ticket-discussion {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.ticket-discussion-head h4,
.ticket-history-details summary {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.ticket-comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  align-items: start;
}

.ticket-comment-form textarea {
  min-height: 64px;
}

.ticket-comment-form button {
  align-self: stretch;
  min-width: 110px;
}

.ticket-history-details {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.ticket-history-details summary {
  cursor: pointer;
  font-weight: 700;
  margin: 0;
}

.ticket-history-details[open] summary {
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  .ticket-action-bar {
    grid-template-columns: 1fr;
    position: static;
  }

  .ticket-action-work {
    justify-content: flex-start;
  }

  .ticket-comment-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .ticket-fact-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .ticket-action-buttons {
    width: 100%;
  }

  .ticket-action-buttons .primary-action,
  .ticket-action-buttons .ticket-mail-btn {
    flex: 1;
  }
}

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.comment,
.history-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 8px;
}

.ticket-history {
  margin-bottom: 14px;
}

.assignee-line {
  margin: 10px 0;
}

.status-summary,
.report-kpi-grid,
.report-priority-grid,
.report-trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.summary-item,
.report-day,
.priority-chip {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.summary-item strong,
.report-day strong {
  display: block;
  font-size: 1.35rem;
}

.reports-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.assignee-load-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.admin-staff-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.admin-staff-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.admin-staff-item.inactive {
  opacity: 0.65;
}

.admin-dept-checks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.engineer-chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
}

.engineer-chat-sidebar {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.engineer-chat-list-item {
  width: 100%;
  text-align: left;
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
  background: #fff !important;
  color: var(--ink) !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px !important;
}

.engineer-chat-list-item.active {
  background: var(--primary-soft) !important;
}

.engineer-chat-detail {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  min-height: 360px;
}

.engineer-chat-messages {
  max-height: 280px;
  overflow: auto;
  margin: 10px 0;
}

.engineer-message {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface-2);
}

.engineer-message.user { background: var(--primary-soft); }
.engineer-message.engineer { background: #e8eef4; }

.engineer-chat-reply,
.engineer-chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes brandIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

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

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

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

@media (max-width: 1200px) {
  .board {
    grid-template-columns: repeat(5, minmax(220px, 1fr));
  }
}

@media (max-width: 980px) {
  .board {
    grid-template-columns: repeat(5, minmax(210px, 1fr));
  }

  .departments-grid,
  .engineer-chat-layout,
  .grid,
  .row,
  .chat-identity-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body.cabinet-wide .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .kanban-section {
    padding: 12px;
  }

  .tabs-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .hero {
    min-height: 62vh;
  }

  .hero-inner {
    padding: 40px 0 32px;
  }

  .admin-staff-item,
  .engineer-header {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-input-row {
    flex-direction: column;
  }
}

/* Bitrix iframe: keep first screen usable */
@media (max-height: 720px) {
  .hero {
    min-height: 56vh;
  }
}
