/* Med AI — админка в стиле стоматологии */
:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #5eead4;
  --bg: #f0fdfa;
  --bg-card: #ffffff;
  --text: #134e4a;
  --text-muted: #64748b;
  --border: #99f6e4;
  --accent: #14b8a6;
  --success: #d1fae5;
  --shadow: 0 1px 3px rgba(13, 148, 136, 0.08);
  --shadow-hover: 0 4px 12px rgba(13, 148, 136, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 50%, #f0fdfa 100%);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  line-height: 1.6;
}

/* Навигация — отключаем drag у ссылок, чтобы клик срабатывал даже при лёгком движении мыши */
nav a {
  -webkit-user-drag: none;
  user-drag: none;
}

nav {
  background: var(--bg-card);
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  border-bottom: 2px solid var(--border);
}

nav a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

nav a:hover {
  background: var(--bg);
  color: var(--primary);
}

nav a:first-child {
  font-weight: 700;
  color: var(--primary);
}

.tour-trigger {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
}

.tour-trigger:hover {
  color: var(--primary);
  background: var(--bg);
}

/* Основной контент */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  font-size: 1.75rem;
  color: var(--primary-dark);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  color: var(--primary-dark);
  margin: 1.5rem 0 0.75rem;
  font-weight: 600;
}

h3 {
  font-size: 1rem;
  color: var(--primary);
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 1rem;
  color: var(--text);
}

/* Карточки */
.card {
  display: block;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-link .card-main {
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.card-link .card-main:hover {
  color: var(--primary);
}
.card-link .card-secondary {
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.card-link .card-secondary:hover {
  text-decoration: underline;
}

.card .type {
  display: inline-block;
  background: var(--bg);
  color: var(--primary);
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-left: 0.5rem;
}

/* Секции */
section {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Транскрипция — сворачиваемая секция */
.transcript-section .transcript-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.transcript-section .transcript-toggle:hover {
  color: var(--primary);
}
.transcript-section .transcript-arrow {
  font-size: 0.75em;
  transition: transform 0.2s;
}
.transcript-section .transcript-body {
  margin-top: 0.25rem;
}
.transcript-section h2 {
  margin: 0 0 0.25rem 0;
}

/* Транскрипция, анализ */
.transcript, .analysis, .notes {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

/* SRT-транскрипция: компактный чат-стиль (не pre-wrap) */
.transcript.transcript-srt {
  white-space: normal;
  line-height: 1.4;
  font-size: 0.9rem;
}

.markdown {
  white-space: normal;
  font-size: 0.95rem;
  line-height: 1.7;
}

.markdown h1, .markdown h2, .markdown h3 { color: var(--primary-dark); }
.markdown strong { color: var(--primary); }
.markdown ul, .markdown ol { margin: 0.5rem 0; padding-left: 1.5rem; }

/* Таблицы в markdown */
.notes.markdown {
  overflow-x: auto;
}
.markdown table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.markdown th, .markdown td {
  padding: 0.65rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
  vertical-align: top;
}
.markdown th {
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.markdown td {
  background: var(--bg-card);
}
.markdown tbody tr:hover td {
  background: var(--bg);
}

/* Аудио */
.audio {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.audio audio {
  width: 100%;
  max-width: 400px;
}

/* Следующий шаг */
.next-step {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--success) 0%, #a7f3d0 100%);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}

.next-step h2 { margin-top: 0; }

/* Книга продаж */
.book-main {
  max-width: 720px;
}
.book-header {
  margin-bottom: 2rem;
}
.book-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.book-intro {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.6;
}
.book-toc {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}
.book-toc-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}
.book-toc-item:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  background: var(--bg);
}
.book-toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
}
.book-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.book-section {
  scroll-margin-top: 1rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.book-section h2 {
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  font-size: 1.25rem;
}
.book-next-step {
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}
.book-next-step h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Вкладки */
.tabs {
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.2s;
  white-space: nowrap;
}

.tab:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-content {
  display: none;
  padding: 1rem 0;
}

.tab-content.active {
  display: block;
}

/* План лечения — таблица этапов */
.plan-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.plan-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.plan-table thead th {
  background: var(--primary);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--primary-dark);
}
.plan-col-num { width: 3rem; text-align: center; }
.plan-col-stage { width: 12rem; }
.plan-col-details { }
.plan-table tbody tr {
  transition: background 0.15s;
}
.plan-table tbody tr:hover {
  background: var(--bg);
}
.plan-table tbody tr:nth-child(even) {
  background: rgba(240, 253, 250, 0.5);
}
.plan-table tbody tr:nth-child(even):hover {
  background: var(--bg);
}
.plan-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.plan-table tbody tr:last-child td {
  border-bottom: none;
}
.plan-num {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
}
.plan-stage {
  font-weight: 600;
  color: var(--primary-dark);
}
.plan-details ul {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.plan-details li {
  margin: 0.25rem 0;
  color: var(--text);
}

/* Fallback: план в виде markdown */
.plan-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.plan-content h4 {
  color: var(--primary-dark);
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}
.plan-content h4:first-child {
  margin-top: 0;
}
.plan-content ul, .plan-content ol {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.5rem;
}
.plan-content li {
  margin: 0.3rem 0;
  line-height: 1.5;
}

/* Inline next-step */
.next-step-inline {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--success);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.plan-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Структура приёма — дерево с раскрывающимися секциями */
.structure-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.structure-tree {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  margin-bottom: 1rem;
}
.tree-branch {
  margin: 0.25rem 0;
}
.tree-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-dark);
  transition: background 0.2s;
}
.tree-toggle:hover {
  background: var(--bg);
}
.tree-arrow {
  font-size: 0.7rem;
  color: var(--primary);
  transition: transform 0.2s;
}
.tree-label {
  flex: 1;
}
.tree-count {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}
.tree-children {
  margin-left: 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}
.tree-items {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  list-style: disc;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}
.tree-items li {
  margin: 0.35rem 0;
  white-space: normal;
}

/* Памятка для пациента — чистый документ, один лист, готов к PDF */
.memo-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
}
.memo-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Документ-памятка */
.memo-document {
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  max-width: 780px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  line-height: 1.7;
  color: #1e293b;
  font-size: 0.95rem;
  outline: none;
}
.memo-document:focus {
  box-shadow: 0 2px 12px rgba(13, 148, 136, 0.12);
  border-color: var(--primary-light);
}

/* Шапка документа */
.memo-doc-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--primary);
}
.memo-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}
.memo-patient-name {
  font-size: 1.05rem;
  color: #64748b;
  margin: 0.35rem 0 0;
}

/* Вступительный блок памятки */
.memo-section-intro {
  margin-bottom: 1.75rem;
}
.memo-intro-text {
  padding-left: 0;
  font-size: 1.05rem;
  line-height: 1.75;
  color: #334155;
}
.memo-intro-text p {
  margin: 0 0 0.5rem;
}
.memo-intro-text p:last-child {
  margin-bottom: 0;
}

/* Секции документа */
.memo-section {
  margin-bottom: 1.5rem;
  padding-bottom: 0;
}
.memo-section:last-of-type {
  margin-bottom: 1rem;
}
.memo-section-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 0 0 0.5rem;
  padding-bottom: 0;
  border-bottom: none;
}
.memo-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.memo-section-body {
  padding-left: 2.25rem;
}
.memo-section-body p {
  margin: 0 0 0.5rem;
  color: #334155;
}
.memo-section-body p:last-child {
  margin-bottom: 0;
}

/* Текст внутри секций — markdown */
.memo-text {
  color: #334155;
}
.memo-text h1, .memo-text h2, .memo-text h3, .memo-text h4 {
  font-size: 1rem;
  color: var(--primary-dark);
  margin: 1rem 0 0.4rem;
  font-weight: 600;
}
.memo-text h1:first-child, .memo-text h2:first-child,
.memo-text h3:first-child, .memo-text h4:first-child {
  margin-top: 0;
}
.memo-text ul, .memo-text ol {
  margin: 0.3rem 0 0.6rem;
  padding-left: 1.25rem;
}
.memo-text li {
  margin: 0.2rem 0;
}
.memo-text strong {
  color: var(--primary-dark);
}

/* Следующий шаг — акцент */
.memo-next-step-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--primary-dark);
  background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* Продающие списки */
.memo-selling-list {
  margin: 0.5rem 0 0;
  padding-left: 0;
  list-style: none;
}
.memo-selling-list li {
  margin: 0.6rem 0;
  padding-left: 1.4rem;
  position: relative;
  color: #334155;
  line-height: 1.65;
}
.memo-selling-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}
.memo-selling-list li strong {
  color: var(--primary-dark);
}

/* FAQ */
.memo-faq-list {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.memo-faq-list li {
  margin: 0.35rem 0;
  color: #475569;
}
.memo-section-faq .memo-section-title {
  border-bottom: none;
  padding-bottom: 0;
}

/* Футер документа */
.memo-doc-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}
.memo-doc-footer p {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0;
  font-style: italic;
}
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.2s, color 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-secondary {
  background: var(--bg);
  color: var(--primary-dark);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.memo-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--primary-dark);
}
.memo-status.error {
  color: #dc2626;
}

/* Чат */
#chat {
  margin-top: 1rem;
}

#messages {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.msg {
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  border-radius: var(--radius-sm);
  max-width: 85%;
}

.msg.user {
  background: var(--primary-light);
  margin-left: auto;
  color: var(--primary-dark);
}

.msg.bot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-right: auto;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

#chat-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

#chat-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2);
}

#chat-form button, .audio-recorder button, #upload-form button {
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

#chat-form button:hover, .audio-recorder button:hover, #upload-form button:hover {
  background: var(--primary-dark);
}

/* Kanban CRM */
main:has(.kanban) {
  max-width: 1200px;
}
.kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  margin-top: 1rem;
}
.kanban-column {
  min-width: 160px;
  max-width: 180px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.kanban-column-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.kanban-column-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--primary-dark);
  font-weight: 600;
}
.kanban-column-goal {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 2rem;
}
.kanban-column.kanban-drop-target {
  background: rgba(94, 234, 212, 0.2);
  outline: 2px dashed var(--primary);
}
.kanban-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: grab;
  transition: box-shadow 0.2s;
}
.kanban-card:hover {
  box-shadow: var(--shadow);
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card.kanban-card-dragging {
  opacity: 0.5;
}
.kanban-card-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  text-decoration: none;
  color: inherit;
}
.kanban-card-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 50%;
  font-size: 0.9rem;
}
.kanban-card-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0;
  padding: 0.4rem 0;
}

/* CRM, клиенты */
.issues {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: block;
  margin-top: 0.25rem;
}

/* Добавить */
.add-section {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#upload-form input[type="file"] {
  margin-right: 0.5rem;
  padding: 0.5rem;
}

#record-status, #upload-status {
  margin-left: 0.5rem;
  color: var(--primary);
  font-size: 0.9rem;
}

/* Этапы продаж */
.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.stage-card {
  flex: 1 1 280px;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.stage-card:hover {
  box-shadow: var(--shadow-hover);
}

.stage-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

.stage-card p {
  margin: 0.35rem 0;
  font-size: 0.9rem;
}

.transcript-role {
  font-weight: 600;
  color: var(--primary-dark);
}

.transcript-timeline {
  position: relative;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.transcript-timeline .timeline-bar {
  position: absolute;
  inset: 0;
  border-radius: 4px;
}

.transcript-timeline .timeline-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--primary);
  border-radius: 4px;
  width: 0;
  transition: width 0.1s linear;
}

/* Блоки транскрипции — компактный чат-стиль (как iMessage/Telegram) */
#transcript.transcript-srt {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.transcript-block {
  margin: 0;
  padding: 0.25em 0;
  border-bottom: 1px solid rgba(13, 148, 136, 0.12);
}
.transcript-block:last-child {
  border-bottom: none;
}

.transcript-block-header {
  display: flex;
  gap: 0.35em;
  align-items: baseline;
  margin: 0 0 0.15em 0;
  line-height: 1.2;
  font-size: 0.85em;
}

.transcript-block-body {
  margin: 0;
  padding: 0;
  line-height: 1.35;
  white-space: normal;
}

.transcript-block-body .transcript-segment {
  margin-right: 0.2em;
}

.transcript-line {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
  align-items: baseline;
  line-height: 1.4;
}

.transcript-time {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  cursor: pointer;
}

.transcript-time:hover {
  text-decoration: underline;
}

.transcript-line .transcript-segment {
  flex: 1;
}


/* SRT: клик только по времени в шапке блока */
.transcript-srt .transcript-time {
  cursor: pointer;
}

.transcript-srt .transcript-block.active {
  background: rgba(94, 234, 212, 0.2);
  border-radius: 4px;
  margin: 0 -4px;
  padding: 0.15em 4px;
}

.lead {
  font-size: 1.1rem;
  color: var(--primary-dark);
  margin-bottom: 1.5rem;
}

/* Списки */
main ul {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

main ul li {
  margin-bottom: 0.75rem;
}

main ul li a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
  display: inline-block;
  padding: 0.3rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}

main ul li a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Код */
code {
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Ссылки назад */
main > p > a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

main > p > a:hover {
  text-decoration: underline;
}

/* Сводка-карточки в шапке клиента */
.client-summary-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 140px;
  flex: 1;
}
.summary-card-step {
  flex: 2;
  border-left: 3px solid var(--primary);
}
.summary-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}
.summary-card-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.summary-card-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* Чек-лист */
.checklist-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.checklist-section {
  margin-bottom: 1.25rem;
}
.checklist-section h3 {
  font-size: 1rem;
  color: var(--primary-dark);
  margin: 0 0 0.5rem;
}
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}
.checklist li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.checklist li:last-child {
  border-bottom: none;
}
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
}
.checklist input[type="checkbox"] {
  margin-top: 0.25rem;
  accent-color: var(--primary);
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}
.checklist input[type="checkbox"]:checked + * {
  text-decoration: line-through;
  color: var(--text-muted);
}
.checklist-sales {
  background: var(--bg-light, #f8f9fb);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.checklist-sales h3 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin: 0 0 0.25rem;
}
.checklist-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-style: italic;
}
.checklist-sales .notes {
  font-size: 0.9rem;
  line-height: 1.6;
}
.checklist-sales .notes ol,
.checklist-sales .notes ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.checklist-sales .notes li {
  padding: 0.2rem 0;
  border-bottom: none;
}
.checklist-table table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  margin: 0.5rem 0;
}
.checklist-table th,
.checklist-table td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  text-align: left;
}
.checklist-table th {
  background: var(--bg-light, #f0f1f3);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.checklist li strong {
  color: var(--primary-dark);
}
/* Блок отправки памятки */
.memo-send-block {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-light, #f8f9fb);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.memo-send-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem;
}
.memo-send-contacts {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.memo-contact-field {
  flex: 1;
  min-width: 200px;
}
.memo-contact-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.memo-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text);
  background: white;
  box-sizing: border-box;
}
.memo-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.memo-send-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.btn-send {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-send:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(37,99,235,0.04);
}
.btn-send-wa:hover { border-color: #25d366; color: #25d366; }
.btn-send-tg:hover { border-color: #0088cc; color: #0088cc; }
.btn-send svg { flex-shrink: 0; }
.memo-send-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}
@media print {
  .memo-send-block { display: none !important; }
}

/* Печать / PDF — только памятка, чистый документ */
@media print {
  nav, .tabs, .next-step, .memo-toolbar,
  .btn, main > p > a, main > h1, main > section,
  .memo-doc-footer {
    display: none !important;
  }
  .tab-content:not(#patient) { display: none !important; }
  #patient { display: block !important; }
  .memo-document {
    box-shadow: none;
    border: none;
    padding: 1.5rem 0;
    max-width: none;
  }
  .memo-document[contenteditable] {
    -webkit-user-modify: read-only;
    outline: none;
  }
  .memo-section-icon {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .memo-next-step-text {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body { background: white; }
  main { max-width: none; padding: 1rem; }
}
