:root {
  --bg: #0f1117;
  --surface: #181c27;
  --surface2: #1e2235;
  --surface-hover: #222535;
  --border: #2a2f45;
  --border-subtle: rgba(255,255,255,0.07);
  --accent: #3b82f6;
  --accent2: #6366f1;
  --accent-hover: #2563eb;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --muted: #64748b;
  --muted2: #94a3b8;
  --error: #ef4444;
  --success: #10b981;
  --mono: 'JetBrains Mono', monospace;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Навігація ── */
nav {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
}

/* ── Центрована сторінка (для login/register) ── */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 56px);
  padding: 1rem;
  overflow-y: auto;
}

.auth-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.auth-brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.auth-wrap .card {
  width: 100%;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* ── Форми ── */
.form-group {
  margin-bottom: 1.2rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: var(--accent);
}

/* ── Кнопки ── */
.btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background-color 0.15s;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
  width: 100%;
  text-align: center;
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background-color: var(--surface-hover);
  color: var(--text);
}

/* ── Флеш-повідомлення ── */
.flash-list {
  list-style: none;
  margin-bottom: 1.2rem;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.flash-error {
  background-color: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

.flash-success {
  background-color: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--success);
}

.flash-info {
  background-color: rgba(79, 142, 247, 0.1);
  border: 1px solid rgba(79, 142, 247, 0.25);
  color: var(--accent);
}

/* ── Посилання під формою ── */
.form-footer {
  margin-top: 1.4rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.form-footer a {
  color: var(--accent);
  text-decoration: none;
}

.form-footer a:hover {
  text-decoration: underline;
}

/* ── Дашборд ── */
.page-content {
  padding: 2.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 600;
}

.page-header p {
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.badge {
  display: inline-block;
  background-color: rgba(79, 142, 247, 0.12);
  color: var(--accent);
  border: 1px solid rgba(79, 142, 247, 0.25);
  border-radius: 20px;
  padding: 0.2rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
}

/* ════════════════════════════════════════
   APP LAYOUT (sidebar shell)
   ════════════════════════════════════════ */

.app-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 8px 5px;
  display: block;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted2);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.sidebar-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.sidebar-item.active {
  background: rgba(59,130,246,0.12);
  color: var(--accent);
  border-color: rgba(59,130,246,0.2);
}

.sidebar-item-dim {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-doctor-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: 9px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  transition: background 0.15s;
}

.sidebar-doctor-card:hover {
  background: var(--surface2);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-doctor-info {
  flex: 1;
  min-width: 0;
}

.sidebar-doctor-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-doctor-role {
  font-size: 11px;
  color: var(--muted);
}

.sidebar-logout-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sidebar-logout-btn:hover {
  background: var(--surface2);
  color: var(--red);
}

.sidebar-logout-btn svg {
  width: 15px;
  height: 15px;
}

/* ── App main area ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

.app-topbar {
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.app-topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-topbar-date {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}

.topbar-btn svg {
  width: 13px;
  height: 13px;
}

.topbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.topbar-btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-subtle);
}

.topbar-btn-ghost:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.topbar-btn-success {
  background: rgba(16,185,129,0.12);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.2);
}

.app-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ════════════════════════════════════════
   CONSULTATION VIEW
   ════════════════════════════════════════ */

.consultation-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

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

.block-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
  min-width: 0;
}

.block-card:hover {
  border-color: rgba(59,130,246,0.25);
}

.block-card-icd {
  background: linear-gradient(135deg, rgba(59,130,246,0.07), rgba(99,102,241,0.05));
  border-color: rgba(99,102,241,0.2);
}

.block-header {
  padding: 12px 14px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border-subtle);
}

.block-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.block-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted2);
  letter-spacing: 0.2px;
}

.block-body {
  padding: 12px 14px;
  flex: 1;
  min-height: 0;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.block-body:has(textarea),
.block-body:has(.icd-code-input) {
  justify-content: flex-start;
}

.block-waiting {
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

.icd-placeholder {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--border);
  text-align: center;
}

.block-footer {
  padding: 7px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-badge {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  letter-spacing: 0.3px;
}

.block-wordcount {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

/* Shimmer */
.shimmer {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface2) 25%, rgba(255,255,255,0.04) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

.shimmer.w-full  { width: 100%; }
.shimmer.w-3q   { width: 75%; }
.shimmer.w-half { width: 50%; }

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

/* ── Record Bar ── */
.record-bar {
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  flex-shrink: 0;
}

.mic-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--red), #dc2626);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: mic-glow 2s ease-in-out infinite;
}

.mic-btn svg {
  width: 19px;
  height: 19px;
  color: white;
}

@keyframes mic-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(239,68,68,0.3); }
  50%       { box-shadow: 0 0 22px rgba(239,68,68,0.6); }
}

.mic-btn.recording {
  animation: mic-record-pulse 0.75s ease-in-out infinite;
}

@keyframes mic-record-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(239,68,68,0.7), 0 0 40px rgba(239,68,68,0.3); transform: scale(1); }
  50%       { box-shadow: 0 0 32px rgba(239,68,68,1.0), 0 0 64px rgba(239,68,68,0.5); transform: scale(1.06); }
}

.mic-btn:disabled {
  opacity: 0.5;
  cursor: default;
  animation: none;
}

.waveform {
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.wave-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave-anim 1s ease-in-out infinite;
}

@keyframes wave-anim {
  0%, 100% { transform: scaleY(0.25); }
  50%       { transform: scaleY(1); }
}

.record-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.record-timer {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: 1.5px;
  flex-shrink: 0;
  min-width: 42px;
  text-align: right;
}

.kbd {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted2);
}

/* ── Кнопка копіювання блоку ── */
.block-copy-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.block-copy-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.block-copy-btn svg {
  width: 13px;
  height: 13px;
}

/* ── Редаговані блоки (textarea + icd inputs) ── */
.block-textarea {
  width: 100%;
  min-width: 0;
  min-height: 120px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  font-family: 'Inter', sans-serif;
  resize: none;
  outline: none;
  padding: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.block-textarea::placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.icd-code-input {
  display: block;
  width: 100%;
  font-size: 26px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent2);
  text-align: center;
  letter-spacing: 1px;
  background: transparent;
  border: none;
  outline: none;
  padding: 4px 0;
}

.icd-name-input {
  display: block;
  width: 100%;
  font-size: 12px;
  color: var(--muted2);
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  padding: 4px 0;
  font-family: 'Inter', sans-serif;
}

.icd-code-input::placeholder,
.icd-name-input::placeholder {
  color: var(--muted);
  font-style: italic;
}

/* ── Заповнені блоки (після AI) ── */
.block-text {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

.icd-code {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent2);
  text-align: center;
  letter-spacing: 1px;
}

.icd-name {
  font-size: 12px;
  color: var(--muted2);
  text-align: center;
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Settings page ── */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.75rem;
}

/* ── Панель пацієнта ── */
.patient-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  flex-shrink: 0;
}

.patient-bar svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.patient-bar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}

.patient-name-input {
  flex: 1;
  max-width: 340px;
  background: var(--surface2);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
}

.patient-name-input:focus {
  border-color: var(--accent);
}

.patient-name-input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

/* ── Журнал прийомів ── */
.journal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.journal-toolbar {
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.journal-search-input {
  flex: 1;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 7px 14px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
}

.journal-search-input:focus { border-color: var(--accent); }
.journal-search-input::placeholder { color: var(--muted); }

.journal-count {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journal-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 18px;
  transition: border-color 0.15s;
}

.journal-row:hover {
  border-color: rgba(59,130,246,0.3);
}

.journal-row-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  flex-shrink: 0;
}

.jdate-day {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--mono);
}

.jdate-time {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}

.icd-tag {
  display: inline-block;
  background: rgba(99,102,241,0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.journal-row-info {
  flex: 1;
  min-width: 0;
}

.journal-patient-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-diagnosis {
  font-size: 12px;
  color: var(--muted2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.journal-complaints-preview {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journal-diagnosis {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.journal-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon-delete {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon-delete:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}

.journal-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.journal-empty p {
  font-size: 14px;
  margin-bottom: 1rem;
}

/* ── Транскрипт (details/summary) ── */
.transcript-block {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}

.transcript-block summary {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.3px;
  user-select: none;
}

.transcript-block summary:hover { color: var(--text); }

.transcript-block p {
  padding: 12px 16px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted2);
  white-space: pre-wrap;
  border-top: 1px solid var(--border-subtle);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Template Selector (Dashboard) ── */
.template-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 24px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}
.template-selector-label {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.template-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.template-chips::-webkit-scrollbar { display: none; }
.template-chip {
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted2);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.template-chip:hover {
  border-color: rgba(59,130,246,0.4);
  color: var(--text);
}
.template-chip.active {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.4);
  color: var(--accent);
}
.template-chips-link {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
  margin-left: auto;
}
.template-chips-link:hover { color: var(--accent); }

/* ── Templates Management Page ── */
.templates-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.templates-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.template-card-system { opacity: 0.75; }
.template-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.template-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.template-card-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(100,116,139,0.12);
  color: var(--muted);
  border-radius: 20px;
  width: fit-content;
  margin-top: 6px;
}
.template-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn-edit-template {
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn-edit-template:hover { border-color: var(--accent); color: var(--accent); }
.btn-del-template {
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: 6px;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
}
.btn-del-template:hover { background: rgba(239,68,68,0.08); }

/* Template form panel */
.template-form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.template-form-panel h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}
.tform-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.tform-label {
  font-size: 11.5px;
  color: var(--muted);
}
.tform-input, .tform-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.tform-input:focus, .tform-textarea:focus {
  border-color: rgba(59,130,246,0.5);
}
.tform-textarea {
  min-height: 200px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
}
.tform-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.tform-save-btn {
  padding: 8px 20px;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.35);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.tform-save-btn:hover { background: rgba(59,130,246,0.25); }
.tform-cancel-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.templates-empty-hint {
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
}

/* ── Template card role + block tags ── */
.template-card-role {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted2);
  margin-top: 2px;
}
.template-card-blocks-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.block-tag {
  font-size: 10.5px;
  padding: 2px 8px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 20px;
  color: var(--accent);
  white-space: nowrap;
}
.block-tag-more {
  background: rgba(100,116,139,0.12);
  border-color: var(--border);
  color: var(--muted);
}

/* ── Block editor in template form ── */
.tform-row {
  display: flex;
  gap: 14px;
}
.tform-blocks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.btn-add-block {
  font-size: 12px;
  padding: 4px 12px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
}
.btn-add-block:hover { background: rgba(59,130,246,0.2); }
.block-editor-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.block-editor-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.block-editor-row .block-name-input {
  flex: 1;
}
.block-type-select {
  width: 100px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.block-type-select:focus { border-color: rgba(59,130,246,0.5); }
.btn-del-block {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 6px;
  color: #ef4444;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-del-block:hover { background: rgba(239,68,68,0.1); }
.tform-blocks-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Mic selector in record-bar ── */
.mic-selector {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  color: var(--muted);
  margin-left: 8px;
}
.mic-device-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  max-width: 170px;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}
.mic-device-select:hover { border-color: rgba(59,130,246,0.35); color: var(--text); }
.mic-device-select:focus { border-color: rgba(59,130,246,0.5); color: var(--text); }

/* ── PDF block selector panel ── */
.pdf-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 220px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.pdf-panel-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.pdf-panel-blocks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.pdf-block-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.pdf-block-check input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.pdf-panel-actions {
  display: flex;
  gap: 8px;
}

/* Make topbar-actions position:relative for absolute panel */
.app-topbar-actions { position: relative; }


/* ════════════════════════════════════════════════════════
   МАРКЕТИНГ / ЛЕНДИНГ
   ════════════════════════════════════════════════════════ */
.mk-body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  margin: 0;
}
.mk-body a { text-decoration: none; }

/* ── Кнопки ── */
.mk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mk-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.mk-btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.mk-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.mk-btn-ghost:hover { background: var(--surface-hover); border-color: var(--accent); }
.mk-btn-lg { padding: 14px 28px; font-size: 15px; }

/* ── Навігація ── */
.mk-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15,17,23,0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.mk-nav-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.mk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.mk-brand-ai {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mk-nav-links {
  display: flex;
  gap: 26px;
  margin-left: auto;
}
.mk-nav-links a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.mk-nav-links a:hover { color: var(--text); }
.mk-nav-actions { display: flex; gap: 10px; }

/* ── Flash ── */
.mk-flash-wrap { max-width: 1140px; margin: 16px auto 0; padding: 0 24px; }

/* ── Hero ── */
.mk-hero { padding: 80px 24px 70px; overflow: hidden; }
.mk-hero-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 56px;
  align-items: center;
}
.mk-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.3);
  color: #93c5fd;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 22px;
}
.mk-hero-title {
  font-size: 52px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}
.mk-grad {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mk-hero-sub {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 32px;
  max-width: 520px;
}
.mk-hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 26px; }
.mk-hero-points { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted2); font-size: 14px; }

/* ── Hero mockup ── */
.mk-hero-visual { display: flex; justify-content: center; }
.mk-mock {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6);
}
.mk-mock-bar { display: flex; gap: 6px; margin-bottom: 16px; }
.mk-mock-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mk-mock-rec {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #fca5a5; margin-bottom: 16px;
}
.mk-mock-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--red);
  animation: mkpulse 1.4s ease-in-out infinite;
}
@keyframes mkpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.mk-mock-block {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}
.mk-mock-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.mk-mock-line { display: block; height: 7px; border-radius: 4px; background: var(--border); margin-bottom: 7px; }
.mk-mock-line.short { width: 60%; }
.mk-mock-icd { color: var(--accent); font-weight: 700; font-family: var(--mono); }

/* ── Секції ── */
.mk-section { max-width: 1140px; margin: 0 auto; padding: 72px 24px; }
.mk-section-alt { max-width: none; background: var(--surface); border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.mk-section-alt > * { max-width: 1140px; margin-left: auto; margin-right: auto; }
.mk-section-head { text-align: center; margin-bottom: 48px; }
.mk-section-head h2 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 12px; }
.mk-section-head p { font-size: 17px; color: var(--text-muted); margin: 0; }

/* ── Можливості ── */
.mk-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.mk-feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.mk-feature:hover { border-color: var(--accent); transform: translateY(-3px); }
.mk-feature-ico {
  width: 46px; height: 46px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,0.12);
  color: var(--accent);
  margin-bottom: 16px;
}
.mk-feature-ico svg { width: 24px; height: 24px; }
.mk-feature h3 { font-size: 18px; margin: 0 0 8px; }
.mk-feature p { font-size: 14px; line-height: 1.6; color: var(--text-muted); margin: 0; }

/* ── Як працює ── */
.mk-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.mk-step { text-align: center; padding: 10px; }
.mk-step-num {
  width: 52px; height: 52px; margin: 0 auto 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.mk-step h3 { font-size: 19px; margin: 0 0 10px; }
.mk-step p { font-size: 14px; line-height: 1.6; color: var(--text-muted); margin: 0; max-width: 300px; margin-left: auto; margin-right: auto; }

/* ── Тарифи ── */
.mk-pricing { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; align-items: stretch; }
.mk-plan {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
}
.mk-plan-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 20px 50px -25px rgba(59,130,246,0.6); }
.mk-plan-tag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 14px; border-radius: 999px;
}
.mk-plan-name { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.mk-plan-price { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.mk-plan-period { font-size: 14px; font-weight: 500; color: var(--muted); }
.mk-plan-tagline { font-size: 13px; color: var(--text-muted); margin: 6px 0 18px; }
.mk-plan-features { list-style: none; padding: 0; margin: 0 0 22px; flex: 1; }
.mk-plan-features li {
  position: relative;
  padding: 7px 0 7px 26px;
  font-size: 14px;
  color: var(--text);
  border-top: 1px solid var(--border-subtle);
}
.mk-plan-features li::before {
  content: "✓";
  position: absolute; left: 0; top: 7px;
  color: var(--green); font-weight: 700;
}
.mk-plan-cta { width: 100%; }
.mk-pricing-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 22px; }

/* ── FAQ ── */
.mk-faq { max-width: 760px; margin: 0 auto; }
.mk-faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 20px;
  margin-bottom: 12px;
}
.mk-faq-item summary {
  cursor: pointer;
  padding: 16px 0;
  font-size: 16px;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mk-faq-item summary::-webkit-details-marker { display: none; }
.mk-faq-item summary::after { content: "+"; color: var(--accent); font-size: 22px; font-weight: 400; }
.mk-faq-item[open] summary::after { content: "−"; }
.mk-faq-item p { margin: 0 0 16px; color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* ── Фінальний заклик ── */
.mk-cta-band {
  text-align: center;
  padding: 80px 24px;
  background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(99,102,241,0.12));
  border-top: 1px solid var(--border-subtle);
}
.mk-cta-band h2 { font-size: 32px; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.02em; }
.mk-cta-band p { font-size: 17px; color: var(--text-muted); margin: 0 0 28px; }

/* ── Футер ── */
.mk-footer { background: var(--surface); border-top: 1px solid var(--border-subtle); }
.mk-footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 52px 24px 32px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
}
.mk-footer-tagline { color: var(--text-muted); font-size: 14px; margin: 14px 0 0; max-width: 280px; }
.mk-footer-col h4 { font-size: 14px; margin: 0 0 14px; color: var(--text); }
.mk-footer-col a { display: block; color: var(--text-muted); font-size: 14px; padding: 5px 0; }
.mk-footer-col a:hover { color: var(--text); }
.mk-footer-bottom {
  border-top: 1px solid var(--border-subtle);
  padding: 20px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Адаптив ── */
@media (max-width: 880px) {
  .mk-nav-links { display: none; }
  .mk-hero-inner { grid-template-columns: 1fr; gap: 40px; }
  .mk-hero-title { font-size: 38px; }
  .mk-hero-visual { order: -1; }
  .mk-features { grid-template-columns: 1fr; }
  .mk-steps { grid-template-columns: 1fr; }
  .mk-pricing { grid-template-columns: 1fr; }
  .mk-footer-inner { grid-template-columns: 1fr; }
  .mk-section-head h2 { font-size: 27px; }
}

/* Примітка під блоком МКХ-10: це не діагноз, а підказка AI */
.icd-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  font-style: italic;
}

/* Згода пацієнта на дашборді */
.consent-row { padding: 12px 1.5rem 0; flex-shrink: 0; }
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  cursor: pointer;
}
.consent-check input { margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.consent-check a { color: var(--accent); }
.consent-row.consent-required .consent-check { color: var(--red); }
.consent-row.consent-required .consent-check input { outline: 2px solid var(--red); outline-offset: 2px; }

/* Сторінка політики конфіденційності */
.mk-legal h2 { font-size: 18px; margin: 26px 0 8px; color: var(--text); }
.mk-legal p { color: var(--text-muted); line-height: 1.65; margin: 0 0 12px; font-size: 15px; }
.mk-legal a { color: var(--accent); }

/* Лічильник нових звернень у сайдбарі */
.sidebar-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Зворотний зв'язок (feedback) */
.fb-card { max-width: 720px; }
.fb-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.fb-item-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.fb-item-msg { font-size: 14px; color: var(--text); line-height: 1.55; white-space: pre-wrap; }
.fb-reply {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface2);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}
.fb-reply-label { font-size: 11px; color: var(--accent); font-weight: 600; display: block; margin-bottom: 4px; }
.fb-textarea {
  width: 100%;
  min-height: 90px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.fb-status-new { color: var(--amber); }
.fb-status-done { color: var(--green); }

/* Банер ліміту прийомів (тариф Free) */
.plan-usage {
  margin: 12px 1.5rem 0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.plan-usage a { color: var(--accent); font-weight: 600; }
.plan-usage-full {
  color: #fca5a5;
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.08);
}
