/* =========================
   🧱 Общие стили страницы
   ========================= */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f9f9f9;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100vh;
  color: #1e293b;
}

/* =========================
   💬 Контейнер чата
   ========================= */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fff;
}

.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
}

.message {
  margin: 0.5rem 0;
}

/* =========================
   ⌨️ Поле ввода
   ========================= */
.input-container {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #e3e3e3;
  background: #fff;
  position: sticky;
  bottom: 0;
  z-index: 50;
}

input[type="text"] {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,0.3);
}

button {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  background: #f3f4f6;
  transition: background 0.2s ease;
}

button:hover {
  background: #e5e7eb;
}

/* =========================
   📜 История запросов
   ========================= */
.history-dropdown {
  position: absolute;
  background: white;
  border: 1px solid #ccc;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  top: -210px;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  font-size: 14px;
}

.history-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.history-item:hover {
  background-color: #f3f4f6;
}

/* =========================
   📊 Универсальные таблицы
   ========================= */
.data-table,
.data-table--wide {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border-spacing: 0;
}

.data-table th,
.data-table td,
.data-table--wide th,
.data-table--wide td {
  border-bottom: 1px solid #e5e7eb;
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
}

.data-table thead th,
.data-table--wide thead th {
  background: #f3f4f6;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tr:nth-child(even),
.data-table--wide tr:nth-child(even) {
  background: #fafafa;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: right;
  white-space: nowrap;
  padding-right: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* =========================
   ❓ Кнопка справки и боковая панель
   ========================= */
.help-btn {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #e3e3e3;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  transition: background 0.2s ease;
}

.help-btn:hover {
  background: #f8fafc;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.25s ease;
}

.help-overlay.show {
  background: rgba(0,0,0,0.45);
  pointer-events: auto;
}

.help-drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 50vw;
  max-width: 920px;
  min-width: 420px;
  background: #fff;
  border-left: 1px solid #e7e7e7;
  box-shadow: -8px 0 32px rgba(0,0,0,.18);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
}

.help-overlay.show .help-drawer {
  transform: translateX(0);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.help-title {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
}

.help-close {
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}

.help-close:hover {
  background: #f3f4f6;
}

.help-body {
  padding: 16px;
  overflow: auto;
  height: 100%;
}

/* =========================
   🚫 Фикс смещения при открытии панели помощи
   ========================= */
html.no-scroll, html.no-scroll body {
  overflow: hidden;
}

html.no-scroll {
  padding-right: var(--scrollbar-compensation, 0px);
  overflow-y: hidden;
}

/* =========================
   📈 Отчёты Priem / Hospitalization
   ========================= */
.priems-report {
  background: #f6f8fb;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.chat-table {
  margin-bottom: 18px;
}

.table-caption {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: #1e293b;
}

.chart-wrap { margin-top: 12px; }

.export-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.export-range {
  font-size: 0.9em;
  color: #6b7280;
}

.export-download {
  font-size: 1.2em;
  text-decoration: none;
}

.source-info {
  font-size: 0.85em;
  color: #6b7280;
  margin-top: 4px;
}

.report-separator {
  border: 0;
  height: 1px;
  background: #e5e7eb;
  margin: 20px 0;
}

.report-conclusion {
  padding: 14px 18px;
  border-left: 5px solid transparent;
  border-radius: 10px;
  background: #f8fafc;
  line-height: 1.5;
}

.report-conclusion__title { margin: 0 0 6px 0; font-weight: 700; }
.report-conclusion__list { margin: 6px 0 10px 16px; }
.report-conclusion__quality { font-weight: 600; }
.report-conclusion__quality--bad { color: #dc2626; }
.report-conclusion__quality--good { color: #f59e0b; }
.report-conclusion__quality--great { color: #16a34a; }
.report-conclusion__quality--excellent { color: #15803d; }

#voice-btn { transition: background 0.2s ease, color 0.2s ease; }
#voice-btn.listening {
  background-color: #d32f2f;
  color: #fff;
  border-radius: 6px;
}

/* =========================
   🔐 Авторизация
   ========================= */
.auth-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  padding: 2rem;
  background: #ffffff;
  border: 1px solid #e3e3e3;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.auth-container h2 {
  margin-bottom: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.auth-container input[type="text"],
.auth-container input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  box-sizing: border-box;
}

.auth-container input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,0.3);
  outline: none;
}

.auth-container button {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: background 0.25s ease;
}

.auth-container button:hover {
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
}

.auth-error {
  margin-top: 0.75rem;
  color: #dc2626;
  font-size: 0.9rem;
}

/* =========================
   💬 Полноэкранный чат после входа
   ========================= */
#chat-ui {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: #fff;
  overflow: hidden;
}

/* Верхняя панель */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: nowrap;
}

.user-info {
  font-weight: 500;
  color: #334155;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-btn {
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  color: #334155;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Анимация появления */
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* Утилита */
.hidden { display: none !important; }