.card {
    transition: 0.2s;
}
.btn {
    font-size: 1.2rem;
    font-weight: bold;
}
.table-responsive {
    overflow-x: auto;
}
.table th, .table td {
    white-space: nowrap;
}
.container {
    max-width: 100% !important;
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}
/* Уменьшаем основной шрифт */
body {
    font-size: 0.9rem;
}
/* Таблицу делаем компактнее */
.table {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}
.table th, .table td {
    padding: 0.4rem 0.5rem;
    white-space: nowrap; /* или normal, если не хотим переносить */
}
/* Для кнопок внутри таблицы */
.btn-sm {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

.navbar-custom {
    background-color: #2b5e91 !important; /* свой цвет */
}
/* Карточки с кнопками на странице оператора */
.card-body .btn {
    font-size: 0.9rem;
}
/* Для модальных окон */
.modal-content {
    font-size: 0.9rem;
}
/* Фиксированная таблица с переносом текста */
.table-fixed {
    table-layout: fixed;
    width: 100%;
}
.table-fixed td, .table-fixed th {
    word-wrap: break-word;
    white-space: normal;
    vertical-align: middle;
}
/* Ширины заданы через colgroup в HTML, но можно и через классы */
/* Шапка */
.navbar .nav-link {
    padding: 0.5rem 1rem;
}
.navbar .nav-item {
    margin-right: 0.5rem;
}
@media (max-width: 576px) {
    .navbar .container {
        flex-direction: column;
        align-items: stretch;
    }
    .navbar .nav {
        justify-content: center;
        flex-wrap: wrap;
    }
    .navbar .nav-item {
        margin-right: 0.3rem;
    }
    .navbar .ms-auto {
        margin-left: 0 !important;
        justify-content: center;
    }
}

/* ========== Стили для страниц помощи ========== */
.help-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 0;
}
.help-container .subhead {
    font-size: 1.1rem;
    color: #475569;
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin-bottom: 2rem;
}
.help-container .note {
    background: #e0f2fe;
    border-left: 4px solid #3b82f6;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.help-container .warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.help-container .success {
    background: #dcfce7;
    border-left: 4px solid #22c55e;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.help-container .badge {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}
.help-container .badge.blue { background: #3b82f6; }
.help-container .badge.green { background: #22c55e; }
.help-container .badge.yellow { background: #eab308; }
.help-container .badge.orange { background: #f59e0b; }
.help-container .badge.red { background: #ef4444; }
.help-container .badge.gray { background: #6b7280; }
.help-container .badge.purple { background: #8b5cf6; }
.help-container .badge.sky { background: #06b6d4; }
.help-container .badge.indigo { background: #6366f1; }

.help-container .diagram {
    background: #f1f5f9;
    padding: 1.5rem;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre;
    overflow-x: auto;
    margin: 1.2rem 0;
    line-height: 1.8;
    color: #0f172a;
}
.help-container .diagram .table-name { color: #8b5cf6; font-weight: bold; }
.help-container .diagram .fk { color: #3b82f6; }
.help-container .diagram .pk { color: #22c55e; }
.help-container .diagram .arrow { color: #f59e0b; }
.help-container .diagram .comp { color: #8b5cf6; font-weight: bold; }
.help-container .diagram .db { color: #22c55e; font-weight: bold; }
.help-container .diagram .net { color: #f59e0b; font-weight: bold; }

.help-container .flow-chart {
    background: #f1f5f9;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre;
    overflow-x: auto;
    margin: 1.2rem 0;
    line-height: 1.8;
}
.help-container .endpoint {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
}
.help-container .endpoint .method {
    display: inline-block;
    padding: 0.2rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-right: 0.8rem;
}
.help-container .method.get { background: #dbeafe; color: #1d4ed8; }
.help-container .method.post { background: #dcfce7; color: #15803d; }
.help-container .method.put { background: #fef3c7; color: #b45309; }
.help-container .method.delete { background: #fee2e2; color: #b91c1c; }
.help-container .endpoint .path {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}
.help-container .step {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
}
.help-container .step strong { color: #0f172a; }
.help-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0 1.8rem;
}
.help-container th, .help-container td {
    border: 1px solid #cbd5e1;
    padding: 0.7rem 1rem;
    text-align: left;
    vertical-align: top;
}
.help-container th {
    background: #f1f5f9;
    font-weight: 600;
}
.help-container .btn-demo {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    color: #fff;
    font-size: 0.8rem;
}
.help-container .btn-demo.danger { background: #ef4444; }
.help-container .btn-demo.warning { background: #eab308; }
.help-container .btn-demo.primary { background: #3b82f6; }
.help-container .btn-demo.success { background: #22c55e; }
.help-container .btn-demo.secondary { background: #6b7280; }
.help-container code {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    color: #1e293b;
}
.help-container pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1rem 0 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.help-container pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.9rem;
}
.help-container .cmd { color: #a5f3fc; }
.help-container .highlight { background: #fef9c3; padding: 0.1rem 0.3rem; border-radius: 4px; }
@media (max-width: 640px) {
    .help-container .diagram { font-size: 0.7rem; }
    .help-container pre { font-size: 0.75rem; }
}

  .mermaid-wrapper {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: 16px;
    padding: 24px;
    margin: 32px 0;
    box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.15);
    position: relative;
    overflow: hidden;
  }

  .mermaid-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #ec4899, #f59e0b);
  }

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

  .mermaid-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #c2d9fd;
    margin: 0;
  }

  .mermaid-title .icon {
    font-size: 1.5rem;
  }

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

  .mermaid-btn {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #475569;
  }

  .mermaid-btn:hover {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
    transform: translateY(-1px);
  }

  .mermaid-canvas {
    background: white;
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
    text-align: center;
  }

.mermaid-canvas svg {
  background: #ffffff;
  border-radius: 12px;
}

  /* Модалка для полноэкранного просмотра */
  .mermaid-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .mermaid-modal.active { display: flex; }
  .mermaid-modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
    position: relative;
  }
  .mermaid-modal-close {
    position: absolute;
    top: 10px; right: 10px;
    background: #ef4444;
    color: white;
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
  }
/* -------- */
  :root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --operator-bg: #ffffff;
    --specialist-bg: #2563eb;
    --operator-text: #0f172a;
    --specialist-text: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  }

  * { box-sizing: border-box; }

  .chat-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* ===== HEADER ===== */
  .chat-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
  }

  .chat-header-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
  }

  .chat-header-icon svg { width: 26px; height: 26px; stroke: #fff; }

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

  .chat-header-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header-meta {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
  }

  .chat-header-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74,222,128,0.3);
    animation: pulse 2s infinite;
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
  }

  /* ===== MESSAGES ===== */
  .chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background-image:
      radial-gradient(circle at 20% 10%, rgba(37,99,235,0.03) 0%, transparent 50%),
      radial-gradient(circle at 80% 90%, rgba(37,99,235,0.03) 0%, transparent 50%);
  }

  .chat-messages::-webkit-scrollbar { width: 6px; }
  .chat-messages::-webkit-scrollbar-track { background: transparent; }
  .chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
  }

  .message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: slideIn 0.3s ease-out;
  }

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

  .message.operator { align-self: flex-start; }
  .message.specialist { align-self: flex-end; flex-direction: row-reverse; }

  .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    color: #fff;
  }

  .message.operator .message-avatar {
    background: linear-gradient(135deg, #f59e0b, #d97706);
  }

  .message.specialist .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
  }

  .message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .message.operator .message-bubble {
    background: var(--operator-bg);
    color: var(--operator-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
  }

  .message.specialist .message-bubble {
    background: var(--specialist-bg);
    color: var(--specialist-text);
    border-bottom-right-radius: 4px;
  }

  .message-author {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.85;
  }

  .message.operator .message-author { color: var(--primary); }
  .message.specialist .message-author { color: rgba(255,255,255,0.9); }

  .message-text {
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-wrap;
  }

  .message-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.6;
    text-align: right;
  }

  .message-image {
    max-width: 240px;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 6px;
    display: block;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
  }

  .message-image:hover { transform: scale(1.02); }

  .system-message {
    align-self: center;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin: 4px 0;
  }

  .empty-state {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
  }

  .empty-state svg {
    width: 64px;
    height: 64px;
    stroke: #cbd5e1;
    margin-bottom: 12px;
  }

  .empty-state h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    color: var(--text);
  }

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

  /* ===== INPUT ===== */
  .chat-input-area {
    background: var(--surface);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
  }

  .preview-container {
    display: none;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--bg);
    border-radius: 10px;
    position: relative;
  }

  .preview-container.active { display: flex; gap: 8px; flex-wrap: wrap; }

  .preview-item {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
  }

  .preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: var(--bg);
    color: var(--secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
  }

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

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

  .chat-textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14.5px;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
  }

  .chat-textarea:focus { border-color: var(--primary); }

  .send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
  }

  .send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  }

  .send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
  }

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

  /* ===== MODAL ===== */
  .image-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s;
  }

  .image-modal.active { display: flex; }

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

  .modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
  }

  .modal-close:hover { background: rgba(255,255,255,0.25); }

  .image-modal img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
  }

  /* ===== RESPONSIVE ===== */
  @media (max-width: 768px) {
    .chat-wrapper {
      padding: 8px;
      height: calc(100vh - 120px);
      gap: 8px;
    }

    .chat-header {
      padding: 12px 14px;
      border-radius: 12px;
    }

    .chat-header-icon { width: 40px; height: 40px; }
    .chat-header-icon svg { width: 22px; height: 22px; }
    .chat-header-title { font-size: 15px; }
    .chat-header-meta { font-size: 12px; }

    .chat-messages {
      padding: 14px;
      border-radius: 12px;
      gap: 10px;
    }

    .message { max-width: 90%; }
    .message-avatar { width: 32px; height: 32px; font-size: 12px; }
    .message-bubble { padding: 9px 12px; }
    .message-text { font-size: 14px; }
    .message-image { max-width: 200px; }

    .chat-input-area { padding: 10px; border-radius: 12px; }
    .icon-btn, .send-btn { width: 40px; height: 40px; }
  }

  @media (max-width: 480px) {
    .chat-wrapper {
      padding: 4px;
      height: calc(100vh - 110px);
    }

    .chat-header {
      padding: 10px 12px;
      gap: 10px;
    }

    .chat-header-icon { width: 36px; height: 36px; }
    .chat-header-title { font-size: 14px; }
    .chat-header-meta { flex-direction: column; gap: 2px; font-size: 11px; }

    .message { max-width: 95%; gap: 6px; }
    .message-avatar { width: 28px; height: 28px; font-size: 11px; }
    .message-bubble { padding: 8px 10px; border-radius: 12px; }
    .message-text { font-size: 13.5px; }
    .message-image { max-width: 180px; }

    .chat-textarea { font-size: 14px; padding: 9px 12px; }
  }

  @media (min-width: 1024px) {
    .chat-wrapper {
      max-width: 1000px;
      height: calc(100vh - 150px);
    }
  }