/* ===== Плотность интерфейса: «компактная» по умолчанию, «крупная» — переключатель в меню ☰ ===== */
:root { --ux-tap: 38px; --ux-tap-lg: 42px; --ux-pad: 12px; --ux-gap: 10px; --ux-body: 15px; }
html[data-density="comfortable"] { --ux-tap: 44px; --ux-tap-lg: 48px; --ux-pad: 16px; --ux-gap: 12px; --ux-body: 16px; }

/*
 * ux.css — общий слой удобства использования (UX/UI-ревизия, сентябрь 2026).
 * Подключается ПОСЛЕ основных стилей страницы (и index.html, и отдельных
 * страниц вроде lab/uzi/booking), поэтому здесь можно переопределять, не
 * трогая старые правила. Токены цвета берём из :root страницы (--sage-dark,
 * --card, --line и т.д.) — своих не заводим.
 */

/* ===================== Доступность и общее поведение ===================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Двойной тап не зумит страницу (это лишь задержка кнопок), но щипок остаётся
   доступным — раньше масштабирование было заблокировано целиком. */
body { touch-action: manipulation; }

/* Видимый фокус для клавиатуры (Windows/Mac). !important — чтобы победить
   разрозненные outline:none в старых правилах; мышью и касанием не срабатывает. */
:focus-visible {
  outline: 2px solid var(--sage-dark, #4C8A5E) !important;
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }
.ux-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Поля ввода 16px на сенсорных экранах: меньше — и Safari на iPhone
   приближает страницу при фокусе (и не возвращает обратно). */
@media (max-width: 1023px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
  select, textarea {
    font-size: 16px !important;
  }
}

/* ===================== Диалоги, листы и тосты ===================== */
#ux-layer { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }
.ux-backdrop {
  position: absolute; inset: 0; pointer-events: auto;
  background: rgba(8, 12, 9, .55);
  animation: uxFade .16s ease both;
}
.ux-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: auto;
  margin: 0 auto; max-width: 520px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--card, #fff); color: var(--ink, #23261F);
  border: 1px solid var(--line, #E1E6DC); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .28);
  animation: uxSheetUp .22s cubic-bezier(.2, .8, .2, 1) both;
  font-family: var(--font-sans, system-ui, sans-serif);
}
.ux-grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line, #E1E6DC); margin: 0 auto 14px; }
.ux-title { font-size: 19px; font-weight: 700; margin: 0 0 6px; line-height: 1.25; }
.ux-text { font-size: 15.5px; line-height: 1.5; color: var(--muted, #6E7568); white-space: pre-line; margin: 0; }
.ux-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.ux-icon {
  width: var(--ux-tap); height: var(--ux-tap); border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sage-soft, #E6EEE8); color: var(--sage-dark, #4C8A5E);
}
.ux-icon.danger { background: var(--flag-bg, #F3E2DE); color: var(--flag, #B54B3C); }
.ux-icon svg, .ux-row-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ux-actions { display: flex; flex-direction: column; gap: 10px; }
.ux-btn {
  min-height: 52px; padding: 0 18px; border-radius: 14px; width: 100%;
  border: 1px solid var(--line, #E1E6DC); background: var(--subtle, #F5F7F3); color: var(--ink, #23261F);
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.ux-btn.primary { background: var(--sage-dark, #4C8A5E); border-color: transparent; color: var(--card, #fff); }
[data-theme="dark"] .ux-btn.primary { color: #0B1A10; }
.ux-btn.danger { background: var(--flag, #B54B3C); border-color: transparent; color: #fff; }
[data-theme="dark"] .ux-btn.danger { color: #1A0B08; }
.ux-input {
  width: 100%; min-height: var(--ux-tap-lg); padding: 0 14px; margin-bottom: 14px; border-radius: 12px;
  border: 1px solid var(--line, #E1E6DC); background: var(--subtle, #F5F7F3); color: var(--ink, #23261F);
  font: inherit; font-size: 16px !important;
}
.ux-choice-list { display: flex; flex-direction: column; margin: 0 -20px 12px; max-height: 50vh; overflow-y: auto; }
.ux-row {
  width: 100%; min-height: 56px; display: flex; align-items: center; gap: 14px; padding: 8px 20px;
  background: none; border: 0; border-top: 1px solid var(--line, #E1E6DC); text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.ux-row:first-child { border-top: 0; }
.ux-row:active { background: var(--subtle, #F5F7F3); }
.ux-row[disabled] { opacity: .55; cursor: default; }
.ux-row-ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; background: var(--subtle, #F5F7F3);
  display: inline-flex; align-items: center; justify-content: center;
}
.ux-row-ico.ok { background: var(--sage-soft, #E6EEE8); color: var(--sage-dark, #4C8A5E); }
.ux-row-ico.warn { background: var(--flag-bg, #F3E2DE); color: var(--flag, #B54B3C); }
.ux-row-body { flex: 1; min-width: 0; }
.ux-row-title { display: block; font-size: 16px; font-weight: 600; }
.ux-row-sub { display: block; font-size: 13.5px; color: var(--muted, #6E7568); }
.ux-section-label {
  font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted, #6E7568); padding: 4px 0 8px;
}

@media (min-width: 768px) {
  .ux-sheet {
    top: 50%; bottom: auto; transform: translateY(-50%); max-width: 460px;
    border: 1px solid var(--line, #E1E6DC); border-radius: 22px; padding-bottom: 22px;
    animation: uxPop .2s ease both;
  }
  .ux-grabber { display: none; }
}

.ux-toast-wrap {
  position: absolute; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.ux-toast {
  pointer-events: auto; max-width: 480px; width: 100%;
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; min-height: 52px;
  border-radius: 16px; background: var(--ink, #23261F); color: var(--bg, #EEF1ED);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: 15px; font-weight: 600; line-height: 1.35;
  font-family: var(--font-sans, system-ui, sans-serif);
  animation: uxToastIn .22s ease both;
}
.ux-toast.err { background: var(--flag, #B54B3C); color: #fff; }
[data-theme="dark"] .ux-toast.err { color: #1A0B08; }
.ux-toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ux-toast button {
  min-height: var(--ux-tap); min-width: var(--ux-tap); padding: 0 12px; border-radius: 12px; border: 0; background: transparent;
  color: inherit; font: inherit; font-weight: 700; cursor: pointer;
}
.ux-toast .ux-toast-act { color: var(--sage-dark, #6FD68C); }
.ux-toast.err .ux-toast-act { color: inherit; text-decoration: underline; }
@keyframes uxFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes uxSheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes uxPop { from { opacity: 0; transform: translateY(-46%); } to { opacity: 1; transform: translateY(-50%); } }
@keyframes uxToastIn { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ux-backdrop, .ux-sheet, .ux-toast { animation: none !important; }
}

/* ===================== Карта пациента: шапка, вкладки, навигация по разделам ===================== */
/* overflow-x:clip вместо hidden — hidden делает экран «прокручиваемым
   предком» и ломает position:sticky у шапки. */
#detail-screen { overflow-x: hidden; overflow-x: clip; }
#detail-sticky { display: contents; }
#detail-more-btn, #detail-subline, #visit-section-nav, #detail-rail { display: none; }
#detail-screen .section, #detail-screen .chart-section { scroll-margin-top: calc(var(--sticky-h, 160px) + 8px); }

@media (max-width: 1023px) {
  /* Закреплённый блок: шапка + строка безопасности + вкладки. Остальное
     (степпер, баннеры) прокручивается вместе с содержимым. */
  #detail-sticky {
    display: block; position: sticky; top: 0; z-index: 30;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  #detail-header { background: none; border-bottom: 0; }
  #safety-strip {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    padding: 0 16px 10px; gap: 8px;
  }
  #safety-strip::-webkit-scrollbar { display: none; }
  .safety-chip { font-size: 12.5px; padding: 6px 12px; flex-shrink: 0; }
  #case-tabs { background: transparent; border-top: 1px solid var(--line); border-bottom: 0; padding: 0 4px; }
  .case-tab {
    min-height: 56px; padding: 8px 2px 6px; font-size: 12.5px; font-weight: 600;
    border-bottom: 3px solid transparent; position: relative; justify-content: center;
  }
  .case-tab svg { width: 22px; height: 22px; }
  .case-tab.active { border-bottom-color: var(--sage-dark); }
  .case-tab-badge { position: absolute; top: 8px; right: calc(50% - 22px); width: 9px; height: 9px; }
  #detail-sticky.compact #safety-strip, #detail-sticky.compact #visit-section-nav { display: none !important; }

  /* Чипы-якоря разделов «Приёма» — только на вкладке «Приём». */
  #visit-section-nav.show {
    display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none;
    border-top: 1px solid var(--line);
  }
  #visit-section-nav::-webkit-scrollbar { display: none; }
  .vsn-chip {
    flex: 0 0 auto; min-height: var(--ux-tap); padding: 0 16px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--subtle); color: var(--muted);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  }
  .vsn-chip.active { background: var(--sage-soft); color: var(--sage-dark); border-color: transparent; }

  #stage-stepper { padding: 10px 16px; }
  .stage-bar-label { font-size: 12.5px; }

  /* Зоны нажатия (--ux-tap) внутри карточки. Значки «i» остаются
     маленькими визуально — зону нажатия расширяет ::after. */
  #detail-screen :is(button, select, [role="button"], .header-pill-btn):not(.info-icon-btn):not(.vsn-chip):not(.case-tab),
  #detail-screen input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]) {
    min-height: var(--ux-tap);
  }
  #detail-screen :is(.draft-btn, .exam-voice-btn, .icon-btn) { min-width: var(--ux-tap); min-height: var(--ux-tap); }
  .exam-voice-btn { width: var(--ux-tap); height: var(--ux-tap); top: 4px; right: 4px; }
  .exam-input-wrap textarea { padding-right: 56px; }
  :where(.info-icon-btn) { position: relative; }
  .info-icon-btn::after { content: ""; position: absolute; inset: -14px; }
  .draft-actions { gap: 6px; }
  /* Нижняя граница размера текста внутри карточки (раньше встречались 9,5–11,5px). */
  #detail-screen :is(.header-pill-btn, #doctor-chat-toggle-btn, .add-file-btn, .chart-add-row button, .video-warning) { font-size: 13.5px; }
  #detail-screen :is(.header-pill-btn, .add-file-btn) { padding-left: 14px; padding-right: 14px; }
  #detail-screen :is(.chart-fields-row label, .field-group label) { font-size: 13px; }
  #detail-screen .experimental-badge { font-size: 11px; }
  #exam-findings-status, #local-status-status { font-size: 12.5px; }

  .fab-btn { min-height: 52px; font-size: 15px; }
  .doctor-tab { min-height: 52px; font-size: 12px; }
}

/* Телефон: компактная шапка «назад · имя · меню». Редкие действия
   (печать, QR, заверение) уходят в лист «⋯» — см. openDetailActionsSheet. */
@media (max-width: 767px) {
  #detail-header { display: block; padding: 6px 8px 4px 4px; min-height: 60px; }
  #detail-header .time { display: none; }
  .detail-header-info { display: grid; grid-template-columns: var(--ux-tap) minmax(0, 1fr) var(--ux-tap); grid-template-rows: auto auto; column-gap: 4px; gap: 0 4px; align-items: center; }
  .detail-header-name { grid-column: 2; grid-row: 1; }
  .detail-header-name .title {
    font-size: 18px; font-weight: 700; -webkit-mask-image: none; mask-image: none;
    text-overflow: ellipsis; padding-top: 2px;
  }
  .detail-header-actions { display: contents; }
  .detail-header-actions .back {
    grid-column: 1; grid-row: 1 / span 2; width: var(--ux-tap); height: var(--ux-tap); min-height: var(--ux-tap); padding: 0; flex: none;
    border: 0; border-radius: 14px; font-size: 0; color: var(--ink); position: relative;
  }
  .detail-header-actions .back::before {
    content: ""; position: absolute; inset: 0; margin: auto; width: 24px; height: 24px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 18l-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 18l-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  #patient-qr-btn, #print-btn, #doctor-confirm-status { display: none !important; }
  #detail-more-btn {
    display: inline-flex; grid-column: 3; grid-row: 1 / span 2; width: var(--ux-tap); height: var(--ux-tap); align-items: center; justify-content: center;
    border: 0; border-radius: 14px; background: transparent; color: var(--ink); cursor: pointer;
  }
  #detail-more-btn svg { width: 24px; height: 24px; }
  #detail-subline {
    display: flex; grid-column: 2; grid-row: 2; align-items: center; gap: 6px; min-width: 0;
    font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #detail-subline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage-dark); flex-shrink: 0; }
}

/* ===================== Планшет (768–1023px): боковая рейка и две колонки ===================== */
@media (min-width: 768px) and (max-width: 1023px) {
  body:has(#doctor-tabs[style*="flex"]) { padding-left: 76px; }
  #doctor-tabs {
    top: 0; right: auto; width: 76px; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 14px 6px; border-top: 0; border-right: 1px solid var(--line); overflow-y: auto;
  }
  #doctor-tabs-logo { display: flex; justify-content: center; padding: 4px 0 14px; }
  #doctor-tabs-logo span { display: none; }
  #doctor-tabs-logo img { width: 34px; height: 34px; border-radius: 10px; }
  .doctor-tab { flex: 0 0 auto; padding: 10px 2px; font-size: 11.5px; }
  .doctor-tab.active { background: var(--sage-soft); }
  #list-screen, #home-screen { padding-bottom: 24px; }
  .floating-action-bar.visible { left: 92px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); max-width: 520px; }

  /* Карта на планшете: основная колонка + правая панель (безопасность, разделы, действия).
     Атрибутный селектор — чтобы не перебить display:none, который ставит JS у скрытой карты. */
  #detail-screen { max-width: 1000px; }
  #detail-screen[style*="display: block"] {
    display: grid !important; grid-template-columns: minmax(0, 1fr) 260px; column-gap: 20px; align-content: start;
  }
  #detail-screen[style*="display: block"] > * { grid-column: 1; }
  #detail-screen[style*="display: block"] > #detail-sticky { grid-column: 1 / -1; }
  #detail-screen[style*="display: block"] > #detail-rail {
    display: flex; grid-column: 2; grid-row: 2 / span 40; align-self: start;
    position: sticky; top: calc(var(--sticky-h, 160px) + 12px); flex-direction: column; gap: 12px; margin: 12px 16px 0 0;
    max-height: calc(100vh - var(--sticky-h, 160px) - 24px); max-height: calc(100dvh - var(--sticky-h, 160px) - 24px); overflow-y: auto;
  }
  /* Шапка на планшете в одну строку: имя слева, кнопки справа. */
  .detail-header-info { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .detail-header-actions { width: auto; flex: none; }
  .detail-header-actions .header-print-btn, #doctor-confirm-status { flex: none; }
  #detail-header { padding: 10px 16px; align-items: center; }
  /* Безопасность и разделы уже в правой панели — в закреплённой шапке они дублировались бы. */
  #safety-strip, #visit-section-nav { display: none !important; }
  #detail-header .time { display: none; }
  #detail-header .detail-header-name .title { font-size: 19px; }
  .rail-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md, 18px); padding: 14px; }
  .rail-lbl { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
  .rail-chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .rail-chips .safety-chip { flex-shrink: 1; white-space: normal; }
  .rail-empty { font-size: 13.5px; color: var(--muted); }
  .rail-toc, .rail-act {
    display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 12px; border-radius: 12px; border: 0;
    background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
  }
  .rail-toc.on { background: var(--sage-soft); color: var(--sage-dark); }
  .rail-act { border: 1px solid var(--line); background: var(--subtle); color: var(--ink); margin-top: 8px; }
  .rail-act:first-of-type { margin-top: 0; }
}

/* ===================== Главная врача на широком экране ===================== */
@media (min-width: 1280px) {
  #home-content {
    max-width: 1240px; display: grid; grid-template-columns: minmax(0, 1fr) 400px;
    column-gap: 32px; align-items: start; grid-auto-flow: row dense;
  }
  #home-content > * { grid-column: 2; }
  #home-content > #notif-prompt-card, #home-content > #pending-payments-card { grid-column: 1 / -1; }
  #home-content > #home-queue-section { grid-column: 1; grid-row: auto / span 8; }
  /* Очередь пуста → одна колонка, без пустой левой половины. */
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) { grid-template-columns: minmax(0, 1fr); }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) > * { grid-column: 1; }
}

/* ===================== Главная: читаемые плитки на всех экранах ===================== */
.qa-grid-compact .qa-btn { min-height: 52px; padding: 10px 12px; }
.qa-grid-compact .qa-btn span { font-size: 13.5px; }
.qa-grid-compact .qa-btn-icon { width: 32px; height: 32px; }
.qa-grid-compact .qa-btn-icon svg { width: 17px; height: 17px; }
.home-stat-row .stat-label, .home-stat-row-compact .stat-label { font-size: 12.5px; }
.home-stat-row-compact .stat-value { font-size: 20px; }
.home-quicklink { min-height: 52px; }
.home-quicklink span { font-size: 14px; }

@media (min-width: 1280px) {
  #home-header .home-search-row, #home-header .home-eyebrow, #home-header .home-title { max-width: 1240px; }
  /* Очередь пуста: плитки в четыре колонки, чтобы экран не выглядел пустым. */
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) { max-width: 1100px; }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) .qa-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) .home-quicklinks-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Очередь работы: читаемые размеры */
.queue-row .queue-name { font-size: 15px; }
.queue-row .queue-summary { font-size: 13.5px; }
.queue-row .queue-time { font-size: 12.5px; }
.queue-row .queue-type { font-size: 11.5px; }
@media (min-width: 1024px) {
  .queue-row .queue-name { font-size: 15.5px; }
  .queue-row .queue-summary { font-size: 14px; }
}

/* Подсказка быстрого поиска (Ctrl/Cmd + K) — только там, где есть боковая панель. */
#doctor-tabs-hint { display: none; }
@media (min-width: 1024px) {
  #doctor-tabs-hint {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: auto; min-height: var(--ux-tap); padding: 0 12px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--subtle); color: var(--muted);
    font: inherit; font-size: 13.5px; cursor: pointer;
  }
  #doctor-tabs-hint kbd {
    font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; color: var(--ink);
    padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card);
  }
}

@media (max-width: 1023px) {
  #detail-screen .narrative-status-badge { font-size: 11.5px; }
  #detail-screen .count-badge { font-size: 12px; }
  #detail-screen .escalation-card .time, #detail-screen .time { font-size: 12px; }
}

@media (max-width: 1023px) {
  #detail-screen :is(.cs-label, .btn-tiny, .frh-meta, .vf-reliability, .vf-warning) { font-size: 12px; }
  #detail-screen .vf-section-label { font-size: 11.5px; }
}

/* ===================== Складные разделы «Приёма» ===================== */
.ux-fold-h { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; cursor: pointer; user-select: none; }
.ux-fold-sum { flex: 1; min-width: 0; text-align: right; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-fold-chev {
  width: 22px; height: 22px; flex-shrink: 0; background: var(--muted); transition: transform .18s ease;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ux-fold-open > .ux-fold-h .ux-fold-chev { transform: rotate(180deg); }
.ux-fold-body[hidden] { display: none; }
.ux-fold-body { padding-top: 4px; }

/* ==========================================================================
   Карточный вид содержимого карты пациента (по утверждённым рендерам):
   разделы — карточки, единые кнопки, «Важное» списком, «Запись приёма» крупным блоком.
   ========================================================================== */
:root { --ux-on-fill: #fff; }
[data-theme="dark"] { --ux-on-fill: #0B1A10; }

/* ---------- Карточки ---------- */
#detail-screen .section, #detail-screen .chart-section {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md, 18px);
  margin: 12px 16px; padding: 16px;
}
#detail-screen .chart-section-critical { margin: 12px 16px; }
#detail-screen .section h3, #detail-screen .chart-section h3 {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted);
}
/* Контейнеры, внутри которых свои карточки/блоки — без собственной рамки. */
#detail-screen #summary-extra-panel.section {
  background: none; border: 0; padding: 0; margin: 12px 16px; display: flex; flex-direction: column; gap: 12px;
}
#detail-screen #summary-extra-panel .narrative-block {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md, 18px); padding: 16px; margin: 0;
}
#detail-screen #narrative-panel .narrative-block + .narrative-block { border-top: 1px solid var(--line); padding-top: 14px; }
#detail-screen.desktop-pane .section, #detail-screen.desktop-pane #finalize-section { padding: 18px 24px; }
#detail-screen.desktop-pane #summary-extra-panel.section { padding: 0; }
@media (min-width: 1024px) {
  #detail-screen.desktop-pane .section, #detail-screen.desktop-pane .chart-section { margin-left: 24px; margin-right: 24px; }
}

/* ---------- Текст блоков сводки ---------- */
.narrative-block h4 {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--sage-dark); margin: 0 0 6px;
}
.narrative-block p { font-size: 16px; line-height: 1.55; }
.narrative-status-badge { font-size: 11.5px; letter-spacing: .03em; padding: 3px 9px; font-weight: 600; }
.narrative-block-actions { gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.narrative-block-actions button[onclick*="startEdit"]::before {
  content: ""; width: 16px; height: 16px; background: currentColor; flex-shrink: 0;
  -webkit-mask: var(--ux-ico-pencil) center / contain no-repeat; mask: var(--ux-ico-pencil) center / contain no-repeat;
}

/* ---------- Единые кнопки ---------- */
#detail-screen .btn-primary, #detail-screen .btn-secondary,
#detail-screen .narrative-block-actions button, #detail-screen .narrative-addition-actions button {
  min-height: var(--ux-tap-lg); padding: 0 18px; border-radius: 14px; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
}
#detail-screen .btn-secondary { background: var(--subtle); color: var(--ink); }
#detail-screen .btn-primary { background: var(--sage-dark); color: var(--ux-on-fill); border-color: transparent; }
#detail-screen .narrative-block-actions button, #detail-screen .narrative-addition-actions button { min-height: var(--ux-tap); padding: 0 14px; font-size: 14px; }
#detail-screen .header-pill-btn {
  min-height: var(--ux-tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--subtle); color: var(--ink); font-size: 14px; font-weight: 600;
}
#detail-screen .chart-add-row button { border-radius: 12px; font-weight: 600; }
#detail-screen input, #detail-screen textarea, #detail-screen select { border-radius: 12px; }
#detail-screen .chart-fields-row input, #detail-screen textarea { padding: 10px 12px; min-height: var(--ux-tap-lg); }
#detail-screen textarea { min-height: 96px; line-height: 1.5; }

/* ---------- «Важное» ---------- */
#detail-screen #alerts-section.section { padding: 0; overflow: hidden; }
#alerts-header { padding: 4px 8px 4px 16px; min-height: 52px; }
#alerts-header h3 { font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); font-family: var(--font-sans); }
#alerts-header .count-badge {
  background: var(--flag-bg); color: var(--flag); font-size: 13px; min-width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 7px;
}
#alerts-body .redflag-alert, #alerts-body .atypical-alert, #alerts-body .escalation-card {
  position: relative; display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 16px 12px 64px;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; color: var(--ink);
  font-size: 15.5px; font-weight: 600; line-height: 1.35;
}
#alerts-body .escalation-card { justify-content: space-between; align-items: flex-start; }
#alerts-body .escalation-card .scenario { font-size: 15.5px; font-weight: 600; }
#alerts-body .escalation-card .notes { font-size: 13.5px; font-weight: 400; margin-top: 2px; }
#alerts-body .escalation-card .time { font-size: 12.5px; white-space: nowrap; }
#alerts-body .redflag-alert .aa-link { display: block; margin-top: 2px; color: var(--sage-dark); font-size: 13.5px; font-weight: 600; text-decoration: none; }
#alerts-body .redflag-alert::before, #alerts-body .escalation-card::before, #alerts-body .atypical-alert::before {
  content: ""; position: absolute; left: 16px; top: 12px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--flag-bg);
}
#alerts-body .redflag-alert::after, #alerts-body .escalation-card::after, #alerts-body .atypical-alert::after {
  content: ""; position: absolute; left: 24px; top: 20px; width: 20px; height: 20px; background: var(--flag);
  -webkit-mask: var(--ux-ico-alert) center / contain no-repeat; mask: var(--ux-ico-alert) center / contain no-repeat;
}
#alerts-body .escalation-card:not(.esc-A_immediate_threat)::before { background: var(--clay-soft); }
#alerts-body .escalation-card:not(.esc-A_immediate_threat)::after { background: var(--clay-dark); -webkit-mask-image: var(--ux-ico-bell); mask-image: var(--ux-ico-bell); }
#alerts-body .atypical-alert::before { background: var(--info-bg); }
#alerts-body .atypical-alert::after { background: var(--info-ink); }
#alerts-body > div:not(:empty) ~ div:not(:empty) { border-top: 0; margin-top: 0; padding-top: 0; }
#alerts-body #escalations-container { margin: 0; }
#alerts-body .escalation-card { margin-bottom: 0; }
.alerts-actions { display: flex; gap: 10px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.alerts-actions button { flex: 1; }
:root {
  --ux-ico-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
  --ux-ico-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 0 1-3.4 0'/%3E%3C/svg%3E");
  --ux-ico-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E");
}

/* ---------- «Запись приёма» ---------- */
#detail-screen #recording-section {
  background: var(--sage-soft); border: 0; border-radius: var(--radius-md, 18px); margin: 12px 16px; padding: 16px;
}
.rc-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-right: 28px; }
.rc-hero-ico {
  width: var(--ux-tap-lg); height: var(--ux-tap-lg); border-radius: 50%; background: var(--sage-dark); color: var(--ux-on-fill);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rc-hero-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rc-hero-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.rc-hero-sub { font-size: 13.5px; color: var(--muted); }
#recording-start-btn {
  min-height: 52px; border-radius: 14px; box-shadow: none; background: var(--sage-dark); color: var(--ux-on-fill);
  font-size: 16px; font-weight: 700;
}
#recording-start-btn .rc-btn-icon { display: none; }
#recording-start-btn .rc-btn-flow b { font-weight: 700; }

/* ---------- Плавающая кнопка ---------- */
.fab-btn { background: var(--sage-dark); color: var(--ux-on-fill); box-shadow: 0 8px 24px rgba(0, 0, 0, .28); font-weight: 700; }

#detail-screen #alerts-header h3 { font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }
#alerts-body .aa-icon { display: none; }
#alerts-body .redflag-alert, #alerts-body .atypical-alert { min-height: 60px; }
#detail-screen .alerts-actions button { padding: 0 10px; font-size: 14.5px; white-space: nowrap; }

/* Кнопки шапки карты (планшет/десктоп) — в общем стиле кнопок. */
@media (min-width: 768px) {
  #detail-header .header-print-btn {
    min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--subtle); color: var(--ink); font-size: 13.5px; font-weight: 600;
  }
  #detail-header .header-print-btn:hover { border-color: var(--sage); color: var(--sage-dark); }
  #detail-header .header-confirm-done { color: var(--sage-dark); background: var(--sage-soft); border-color: transparent; }
  #detail-header .detail-header-name .title { font-size: 20px; font-weight: 700; }
}

#detail-screen .chart-add-row { display: flex; gap: 8px; align-items: stretch; }
#detail-screen .chart-add-row input { flex: 1; min-width: 0; width: auto; }
#detail-screen .chart-add-row button { flex-shrink: 0; }
#detail-screen .chart-item-row { border-radius: 12px; }
#detail-screen .chart-item-acts button { min-height: 40px; border-radius: 10px; font-size: 13px; font-weight: 600; }

/* Заголовки модулей: кнопки переносятся на новую строку, а не выпирают за карточку. */
#detail-screen :is(#second-opinion-header, #consilium-header, #syndromes-header, #narrative-header, #questions-header, .chart-section-head) {
  flex-wrap: wrap; gap: 8px 10px;
}
#detail-screen .header-actions { flex-wrap: wrap; margin-left: auto; }
#detail-screen :is(select, .custom-select-btn) { max-width: 100%; }

#detail-screen #apply-template-wrap { flex-wrap: wrap; gap: 8px; }
#detail-screen #apply-template-wrap > select { flex: 1 1 100%; }
#detail-screen #apply-template-wrap > button { flex: 1 1 auto; }

/* ---------- Главная: очередь и счётчики ---------- */
.home-section-title { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; }
.queue-row { padding: 14px 16px; gap: 14px; border-radius: 14px; margin-bottom: 8px; }
.queue-row .queue-bar { width: 4px; }
.queue-row .queue-type { padding: 3px 8px; border-radius: 6px; letter-spacing: .05em; }
.queue-row .queue-summary { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.home-stat-row-compact .home-stat-card { padding: 12px 12px; border-radius: 16px; }
.home-stat-row-compact .stat-value { font-size: 22px; }
@media (min-width: 1024px) {
  .home-stat-row-compact .stat-value { font-size: 28px; }
  .home-stat-row-compact .stat-label { font-size: 13px; }
}

/* ==========================================================================
   Пациентский чат и вход: зоны нажатия и читаемость
   ========================================================================== */
/* Мелкие кнопки остаются такими же на вид — зону нажатия расширяет ::after. */
:where(.bubble-speak-btn, #camera-btn, #attach-btn, #conversation-mode-btn-input, #patient-own-profile-btn, #forgot-password-btn) { position: relative; }
.bubble-speak-btn::after, #camera-btn::after, #attach-btn::after, #conversation-mode-btn-input::after, #patient-own-profile-btn::after {
  content: ""; position: absolute; inset: -6px;
}
#forgot-password-btn { min-height: var(--ux-tap); display: inline-flex; align-items: center; justify-content: center; }
#onboarding-modal-footer button { min-height: var(--ux-tap-lg); border-radius: 14px; font-weight: 600; }
#onboarding-modal-body button { min-height: var(--ux-tap); }
.theme-switch-btn, .lang-switch-btn, .a11y-btn { min-height: 40px; min-width: 40px; }

/* Шрифт поля ввода 16px (против zoom на iOS) — плейсхолдер остаётся в одну строку. */
#text-input::placeholder { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* ---------- Главная врача: сводка дня и расписание на сегодня ---------- */
.home-summary { font-size: 15px; color: var(--muted); margin: 2px 0 12px; }
.home-summary:empty { display: none; }
#home-today-section { margin: 16px 0 14px; }
.today-row {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 16px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
}
.today-row:active { background: var(--subtle); }
.today-time { font-family: var(--font-mono); font-size: 15px; font-weight: 600; min-width: 52px; color: var(--ink); }
.today-name { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-state { font-size: 12.5px; color: var(--muted); }
.today-row.past { opacity: .6; }

/* ==========================================================================
   Доработка карточного вида: заголовки модулей, шевроны, единые кнопки
   ========================================================================== */
#detail-screen .section h3, #detail-screen .chart-section h3 {
  font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 0 0 10px;
}
#detail-screen :is(#narrative-header, #syndromes-header, #consilium-header, #second-opinion-header, #questions-header, .chart-section-head) h3 { margin: 0; }
#detail-screen .chart-section-critical h3 { color: var(--clay-dark); }
#detail-screen .chart-section-muted h3 { font-weight: 600; color: var(--muted); }

/* «Свернуть/Развернуть» — шеврон вместо текстовой пилюли (текст остаётся доступным названием). */
#detail-screen button.ux-chev {
  font-size: 0 !important; width: var(--ux-tap); min-width: var(--ux-tap); padding: 0 !important; border: 0 !important; background: transparent !important; color: var(--muted); position: relative; flex: none;
}
#detail-screen button.ux-chev::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; background: currentColor; transition: transform .18s ease;
  -webkit-mask: var(--ux-ico-chev) center / contain no-repeat; mask: var(--ux-ico-chev) center / contain no-repeat;
}
#detail-screen button.ux-chev[aria-expanded="false"]::before { transform: rotate(180deg); }
:root {
  --ux-ico-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 15l-6-6-6 6'/%3E%3C/svg%3E");
}

/* Кнопки вкладки «Общение» и «Обновить анализ» — в общем стиле. */
#detail-screen :is(#doctor-chat-toggle-btn, #video-call-btn, #update-analysis-btn) {
  min-height: var(--ux-tap-lg); border-radius: 14px; border: 1px solid var(--line); background: var(--subtle); color: var(--ink); font-size: 15px; font-weight: 600;
}
#detail-screen :is(#doctor-chat-toggle-btn, #video-call-btn).active { background: var(--clay-dark); border-color: transparent; color: #fff; }
#detail-screen #dialogue-toggle { min-height: 52px; font-size: 15px; font-weight: 600; color: var(--ink); }
#detail-screen .video-warning { border-radius: 14px; padding: 12px 14px; line-height: 1.5; }

@media (max-width: 1023px) {
  #detail-screen textarea { resize: none; }
}
#detail-screen #doctor-chat-toggle-btn { white-space: nowrap; padding: 0 16px; }

/* ==========================================================================
   Список пациентов: карточка «имя · статус / возраст и дата / метки / действия»
   ========================================================================== */
.session-row { padding: 14px 16px; border-radius: 18px; margin-bottom: 10px; gap: 0; }
.session-row.has-red-flag { border-left: 4px solid var(--flag); }
.sr-top { align-items: center; gap: 10px; }
.sr-top .id { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.session-row .badge { font-size: 12px; padding: 4px 10px; font-weight: 600; letter-spacing: .02em; }
.session-row .meta { font-size: 13.5px; margin-top: 4px; }
.session-row .rs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.session-row .rs-actions { display: flex; align-items: stretch; gap: 8px; margin-top: 12px; }
.sr-chip, .session-row .sub-text, .session-row .mine-mark, .session-row .doctor-mark, .session-row .referral-mark, .session-row .dup-mark {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--subtle); color: var(--muted); border: 0;
}
.sr-chip.warn { background: var(--clay-soft); color: var(--clay-dark); }
.session-row .mine-mark { background: var(--sage-soft); color: var(--sage-dark); }
.session-row .dup-mark { background: var(--flag-bg); color: var(--flag); }
.session-row .claim-btn {
  flex: 1; min-height: var(--ux-tap); border-radius: 12px; border: 0; background: var(--sage-soft); color: var(--sage-dark);
  font-size: 14.5px; font-weight: 700; padding: 0 14px;
}
.session-row .pp-open-btn {
  width: var(--ux-tap); min-width: var(--ux-tap); height: var(--ux-tap); border-radius: 12px; border: 1px solid var(--line); background: var(--subtle); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
}
.session-row .claim-btn + .pp-open-btn { margin-left: 0; }
.session-row .pp-open-btn svg { width: 20px; height: 20px; }
.session-count-badge { min-height: 40px; padding: 0 12px; font-size: 13px; font-weight: 600; }

/* Фильтры списка — сегментированные переключатели. */
#sort-bar { gap: 10px; }
#sort-bar .segment-group {
  display: flex; gap: 4px; padding: 4px; background: var(--subtle); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; scrollbar-width: none;
}
#sort-bar .segment-group::-webkit-scrollbar { display: none; }
#sort-bar .segment-btn {
  flex: 1 0 auto; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
#sort-bar .segment-btn.active { background: var(--card); color: var(--sage-dark); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
[data-theme="dark"] #sort-bar .segment-btn.active { background: var(--sage-soft); box-shadow: none; }
#patient-search-row { min-height: var(--ux-tap-lg); border-radius: 14px; }
#patient-search-input { min-height: var(--ux-tap); }

/* ---------- «Приём»: строка действий под полем осмотра — [микрофон] [Шаблоны] [Сохранить] ---------- */
#detail-screen .exam-input-wrap textarea { padding-right: 12px; }
#detail-screen .exam-actions-row { display: flex; flex-wrap: nowrap; gap: 10px; align-items: stretch; margin-top: 12px; }
#detail-screen .exam-actions-row .exam-voice-btn {
  position: static; flex: none; width: var(--ux-tap-lg); height: var(--ux-tap-lg); min-height: var(--ux-tap-lg); border-radius: 14px;
  border: 1px solid var(--line); background: var(--subtle); color: var(--ink); order: 0;
}
#detail-screen .exam-actions-row .btn-secondary { flex: 1; order: 1; }
#detail-screen .exam-actions-row .btn-primary { flex: 1; order: 2; }
.exam-mic-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#detail-screen .exam-voice-btn.listening { background: var(--flag); border-color: var(--flag); color: #fff; }
#detail-screen #exam-findings-status, #detail-screen #local-status-status { margin: 8px 0 0; min-height: 0; }

/* ---------- Карта пациента (аллергии, диагнозы, препараты…) ---------- */
#detail-screen .chart-section.chart-section-critical { background: var(--clay-soft); border-color: var(--clay); }
#detail-screen .chart-add-row input {
  border: 1px solid var(--line); background: var(--subtle); color: var(--ink); min-height: var(--ux-tap-lg); padding: 0 12px; border-radius: 12px;
}
#detail-screen .chart-add-row button { min-height: var(--ux-tap-lg); padding: 0 16px; border: 1px solid transparent; background: var(--sage-soft); color: var(--sage-dark); }
#detail-screen .chart-item-row { background: var(--subtle); border: 1px solid var(--line); padding: 8px 8px 8px 12px; }
#detail-screen .chart-item-row.proposed { background: var(--clay-soft); border-color: var(--clay); }
#detail-screen .chart-item-text { font-size: 15.5px; }
#detail-screen .chart-item-acts button { min-height: 40px; padding: 0 12px; border: 0; }
#detail-screen .chart-item-acts button.reject { background: var(--flag-bg); color: var(--flag); }
#detail-screen .chart-item-acts button.confirm { background: var(--sage-dark); color: var(--ux-on-fill, #fff); }
#detail-screen .ux-fold:not(.ux-fold-open) .ux-fold-h { margin-bottom: 0; }
#detail-screen :is(.section-hint, .section p.hint, .consilium-warning) { font-size: 14px; line-height: 1.5; }

/* ---------- План: пункты черновика — текст сверху, подписанные действия снизу (телефон/планшет) ---------- */
@media (max-width: 1023px) {
  #detail-screen .draft-row { flex-wrap: wrap; gap: 8px; padding: 12px 0; }
  #detail-screen .draft-row > div:first-child { flex: 1 1 100%; }
  #detail-screen .draft-row .text { font-size: 16px; line-height: 1.45; }
  #detail-screen .draft-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  #detail-screen .draft-btn {
    flex: 1 1 28%; min-height: var(--ux-tap); padding: 0 8px; font-size: 14px; font-weight: 600; border-radius: 12px;
    border: 1px solid var(--line); background: var(--subtle); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  }
  #detail-screen .draft-btn.accept { color: var(--sage-dark); }
  #detail-screen .draft-btn.accept.active { background: var(--sage-dark); border-color: transparent; color: var(--ux-on-fill, #fff); }
  #detail-screen .draft-btn.reject { color: var(--flag); }
  #detail-screen .draft-btn.reject.active { background: var(--flag-bg); border-color: transparent; }
  #detail-screen .draft-btn.accept::after { content: "Принять"; }
  #detail-screen .draft-btn.edit::after { content: "Изменить"; }
  #detail-screen .draft-btn.reject::after { content: "Отклонить"; }
  #detail-screen .draft-btn.refer-toggle::after { content: "Записать"; }
  #detail-screen .draft-edit-input { min-height: var(--ux-tap-lg); }
}
#detail-screen #apply-template-wrap > button { background: var(--subtle); border: 1px solid var(--line); color: var(--ink); font-weight: 600; border-radius: 12px; font-size: 15px; }
#detail-screen .chart-item-row { flex-wrap: wrap; row-gap: 8px; }
#detail-screen .chart-item-text { flex: 1 1 60%; min-width: 0; }
#detail-screen .chart-item-acts { display: inline-flex; gap: 8px; margin-left: auto; }
#detail-screen .add-file-btn { background: var(--sage-soft); border: 1px solid transparent; color: var(--sage-dark); border-radius: 12px; font-weight: 600; }

/* ==========================================================================
   «Приёмы», «График», «Профиль» и полоса стадии
   ========================================================================== */
.appt-group-title { font-family: var(--font-sans); font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 18px 2px 10px; }
.appt-line { padding: 14px 16px; border-radius: 16px; gap: 14px; min-height: 64px; }
.appt-line .when-col { font-size: 17px; font-weight: 700; }
.appt-line .nm { font-size: 16.5px; font-weight: 700; }
.appt-line .sub { font-size: 13.5px; }
.appt-line .tags { font-size: 12.5px; font-style: normal; color: var(--muted); margin-top: 4px; }

#schedule-pane h3, #dprofile-pane h3 { font-family: var(--font-sans); font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 20px 2px 10px; }
#schedule-pane .section-hint, #dprofile-pane .section-hint { font-size: 14px; line-height: 1.5; }
.sched-row { min-height: 56px; padding: 6px 6px 6px 16px; border-radius: 14px; gap: 12px; }
.sched-row .day { font-size: 15.5px; font-weight: 600; }
.sched-row .hours { font-size: 15px; }
.sched-row .del { width: var(--ux-tap); height: var(--ux-tap); border-radius: 12px; font-size: 22px; background: var(--flag-bg); color: var(--flag); border: 0; }
#schedule-pane select, #schedule-pane input { min-height: var(--ux-tap-lg); border-radius: 12px; }
#schedule-pane button:not(.del) { min-height: var(--ux-tap-lg); border-radius: 12px; font-size: 15px; font-weight: 600; padding: 0 18px; }

/* Полоса стадии: подпись дублирует статус в шапке — на телефоне остаётся только полоса. */
@media (max-width: 767px) {
  #stage-stepper .stage-bar-label { display: none; }
  #stage-stepper { padding: 10px 16px 4px; }
  .stage-bar { height: 6px; border-radius: 3px; }
}
.sched-row .day { min-width: 112px; }
.appt-line .who .tags { font-size: 13px; font-style: normal; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.appt-line .who .sub { font-size: 14px; }

/* ==========================================================================
   Компактная плотность (по умолчанию): больше информации на экране.
   Переключатель «Размер элементов» в меню ☰ возвращает крупный вид.
   ========================================================================== */

/* ---------- Карточки и тексты ---------- */
#detail-screen .section, #detail-screen .chart-section, #detail-screen .chart-section.chart-section-critical {
  margin: var(--ux-gap) 12px; padding: var(--ux-pad) 14px;
}
#detail-screen #summary-extra-panel.section { margin: var(--ux-gap) 12px; gap: var(--ux-gap); padding: 0; }
#detail-screen #summary-extra-panel .narrative-block { padding: var(--ux-pad) 14px; }
#detail-screen #recording-section { margin: var(--ux-gap) 12px; padding: 12px 14px; }
.narrative-block p { font-size: var(--ux-body); line-height: 1.5; }
.narrative-block-actions { margin-top: 8px; }
#detail-screen .section h3, #detail-screen .chart-section h3 { font-size: 16px; margin-bottom: 8px; }
#detail-screen .narrative-block-actions button, #detail-screen .narrative-addition-actions button { font-size: 13.5px; padding: 0 12px; }
#detail-screen .btn-primary, #detail-screen .btn-secondary { font-size: 14.5px; }
.rc-hero { margin-bottom: 10px; }
.rc-hero-ico { width: 40px; height: 40px; }
.rc-hero-ico svg { width: 20px; height: 20px; }
#recording-start-btn { min-height: var(--ux-tap-lg); font-size: 15px; }
#detail-screen .chart-item-text { font-size: 15px; }
#detail-screen .draft-row .text { font-size: var(--ux-body); }

/* ---------- Шапка карты, вкладки, нижняя навигация ---------- */
@media (max-width: 1023px) {
  .case-tab { min-height: 50px; padding-top: 6px; font-size: 12px; }
  .case-tab svg { width: 20px; height: 20px; }
  .doctor-tab { min-height: 48px; }
  #stage-stepper { padding: 8px 14px 2px; }
  .fab-btn { min-height: var(--ux-tap-lg); font-size: 14.5px; }
  .floating-action-bar.visible { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 767px) {
  #detail-header { min-height: 52px; }
  .detail-header-name .title { font-size: 17px; }
}

/* ---------- «Важное» — компактный список без больших кнопок ---------- */
#alerts-header { min-height: 44px; padding: 2px 4px 2px 14px; }
#detail-screen #alerts-header h3 { font-size: 16px; margin: 0; }
.alerts-viewed-btn {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--sage-soft); color: var(--sage-dark);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
#alerts-body .redflag-alert, #alerts-body .atypical-alert, #alerts-body .escalation-card {
  padding: 8px 14px 8px 54px; min-height: 0; font-size: 14.5px; gap: 8px;
}
#alerts-body .redflag-alert::before, #alerts-body .escalation-card::before, #alerts-body .atypical-alert::before { left: 14px; top: 8px; width: 28px; height: 28px; }
#alerts-body .redflag-alert::after, #alerts-body .escalation-card::after, #alerts-body .atypical-alert::after { left: 20px; top: 14px; width: 16px; height: 16px; }
#alerts-body .redflag-alert, #alerts-body .atypical-alert { min-height: 44px; }
#alerts-body .escalation-card .scenario { font-size: 14.5px; }
#alerts-body .escalation-card .notes { font-size: 13px; margin-top: 0; }
#alerts-body .redflag-alert .aa-link { font-size: 13px; }
/* Тревожный симптом из эскалации дублирует список «Тревожные признаки» выше — прячем дубль. */
#alerts-body:has(.redflag-alert) .escalation-card.esc-A_immediate_threat { display: none; }

/* ---------- Список пациентов: 4–5 карточек на экран ---------- */
.session-row { padding: 10px 12px; border-radius: 14px; margin-bottom: 8px; }
.sr-top .id { font-size: 15.5px; }
.session-row .badge { font-size: 11.5px; padding: 3px 9px; }
.session-row .meta { font-size: 13px; margin-top: 2px; }
.session-row .sr-bottom { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.session-row .sr-bottom .rs-chips { flex: 1 1 auto; margin: 0; min-width: 0; }
.session-row .rs-chips:empty { display: none; }
.session-row .sr-bottom .rs-actions { flex: none; margin: 0; align-items: center; }
.sr-chip, .session-row .sub-text, .session-row .mine-mark, .session-row .doctor-mark, .session-row .referral-mark, .session-row .dup-mark { height: 22px; padding: 0 8px; font-size: 12px; }
.session-row .claim-btn { flex: none; min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.session-row .pp-open-btn { width: 34px; min-width: 34px; height: 34px; min-height: 34px; border-radius: 10px; margin-left: 0; position: relative; }
.session-row .pp-open-btn::after { content: ""; position: absolute; inset: -4px; }
.session-row .pp-open-btn svg { width: 18px; height: 18px; }
.session-count-badge { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
#patient-search-row { min-height: 42px; margin-top: 8px; padding: 0 12px; }
#patient-search-input { min-height: 40px; }
#sort-bar { gap: 8px; padding-top: 8px; }
#sort-bar .segment-group { padding: 3px; border-radius: 12px; }
#sort-bar .segment-btn { min-height: 34px; padding: 0 12px; font-size: 13.5px; }

/* ---------- Приёмы / График / Главная ---------- */
.appt-line { padding: 10px 14px; min-height: 0; border-radius: 14px; }
.appt-line .nm { font-size: 15.5px; }
.appt-line .when-col { font-size: 16px; }
.appt-line .who .tags { margin-top: 2px; }
.today-row { min-height: 44px; padding: 6px 14px; margin-bottom: 6px; }
.queue-row { padding: 10px 14px; margin-bottom: 6px; }
.sched-row { min-height: 48px; }
.qa-grid-compact .qa-btn { min-height: 46px; padding: 8px 10px; }
.home-quicklink { min-height: 46px; }

/* ---------- Запись на приём и чат (общие размеры берутся из переменных) ---------- */

/* ---------- «Крупные» элементы: возвращаем просторные отступы ---------- */
html[data-density="comfortable"] #detail-screen .section,
html[data-density="comfortable"] #detail-screen .chart-section,
html[data-density="comfortable"] #detail-screen .chart-section.chart-section-critical { margin: 12px 16px; padding: 16px; }
html[data-density="comfortable"] #detail-screen #summary-extra-panel.section { margin: 12px 16px; gap: 12px; padding: 0; }
html[data-density="comfortable"] #detail-screen #summary-extra-panel .narrative-block { padding: 16px; }
html[data-density="comfortable"] #detail-screen #recording-section { margin: 12px 16px; padding: 16px; }
html[data-density="comfortable"] .session-row { padding: 14px 16px; border-radius: 18px; margin-bottom: 10px; }
html[data-density="comfortable"] .sr-top .id { font-size: 16.5px; }
html[data-density="comfortable"] .session-row .meta { font-size: 13.5px; margin-top: 4px; }
html[data-density="comfortable"] .session-row .claim-btn { min-height: 44px; }
html[data-density="comfortable"] .session-row .pp-open-btn { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
html[data-density="comfortable"] #alerts-body .redflag-alert,
html[data-density="comfortable"] #alerts-body .atypical-alert,
html[data-density="comfortable"] #alerts-body .escalation-card { padding: 12px 16px 12px 64px; font-size: 15.5px; }
html[data-density="comfortable"] #alerts-body .redflag-alert::before,
html[data-density="comfortable"] #alerts-body .escalation-card::before,
html[data-density="comfortable"] #alerts-body .atypical-alert::before { left: 16px; top: 12px; width: 36px; height: 36px; }
html[data-density="comfortable"] #alerts-body .redflag-alert::after,
html[data-density="comfortable"] #alerts-body .escalation-card::after,
html[data-density="comfortable"] #alerts-body .atypical-alert::after { left: 24px; top: 20px; width: 20px; height: 20px; }
html[data-density="comfortable"] .appt-line { padding: 14px 16px; }
html[data-density="comfortable"] .today-row { min-height: 52px; }
@media (max-width: 1023px) {
  html[data-density="comfortable"] .case-tab { min-height: 56px; }
  html[data-density="comfortable"] .doctor-tab { min-height: 52px; }
}
#detail-screen .alerts-viewed-btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
#alerts-body .esc-count { font-weight: 700; color: var(--muted); font-size: 13px; }
#alerts-body .redflag-alert .rf-text, #alerts-body .atypical-alert .rf-text { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
#alerts-body .escalation-card { align-items: center; }

/* ==========================================================================
   «Полный диалог» и «Файлы пациента»
   ========================================================================== */
#detail-screen #dialogue-toggle {
  width: 100%; min-height: var(--ux-tap-lg); padding: 0; gap: 10px; color: var(--ink); font-size: 16px; font-weight: 700; text-align: left;
}
#dialogue-label { flex: 1; }
#dialogue-count { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--subtle); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
#dialogue-count:empty { display: none; }
#dialogue-arrow {
  font-size: 0; width: 22px; height: 22px; flex: none; background: var(--muted); transition: transform .18s ease;
  -webkit-mask: var(--ux-ico-chevdown) center / contain no-repeat; mask: var(--ux-ico-chevdown) center / contain no-repeat;
}
#dialogue-toggle[aria-expanded="true"] #dialogue-arrow { transform: rotate(180deg); }
:root {
  --ux-ico-chevdown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
#dialogue-content { border-left: 0; padding-left: 0; margin-top: 10px; color: var(--ink); font-size: 14.5px; line-height: 1.45; }
#dialogue-content .dlg-list { display: flex; flex-direction: column; gap: 8px; }
#dialogue-content .dlg-msg { max-width: 90%; padding: 8px 12px; border-radius: 14px; background: var(--subtle); border: 1px solid var(--line); align-self: flex-start; }
#dialogue-content .dlg-msg.patient { background: var(--card); }
#dialogue-content .dlg-msg.agent { background: var(--subtle); color: var(--muted); }
#dialogue-content .dlg-msg.doctor { background: var(--sage-soft); border-color: transparent; align-self: flex-end; }
#dialogue-content .dlg-msg.system { align-self: center; background: none; border: 0; font-size: 12.5px; color: var(--muted); max-width: 100%; }
#dialogue-content .dlg-who { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
#dialogue-content .dlg-msg.patient .dlg-who { color: var(--sage-dark); }
#dialogue-content .dlg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
#dialogue-content .dlg-more {
  width: 100%; min-height: 36px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 12px; background: none; color: var(--sage-dark);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}

/* Файлы пациента */
#detail-screen .files-block-head { margin-bottom: 8px; }
#detail-screen .file-row { border-radius: 14px; padding: 10px 12px; gap: 8px; background: var(--subtle); margin-bottom: 8px; }
#detail-screen .file-row-head { font-size: 13px; gap: 8px; }
#detail-screen .file-row-head .file-source-icon, #detail-screen .file-row-head .file-type-icon { font-size: 18px; }
#detail-screen .file-row-head .frh-meta { font-size: 13px; }
#detail-screen .file-row-actions { gap: 8px; }
#detail-screen .file-row-actions button {
  min-height: var(--ux-tap); border-radius: 10px; font-size: 13.5px; font-weight: 600; padding: 0 12px; border: 0; background: var(--card); color: var(--ink);
}
#detail-screen .file-row-actions button.primary { background: var(--sage-dark); color: var(--ux-on-fill, #fff); }
#detail-screen .file-row-actions button.danger { background: var(--flag-bg); color: var(--flag); }
#detail-screen .file-row-actions.single-action button { padding: 0 18px; }
#detail-screen .btn-tiny { min-height: var(--ux-tap); border-radius: 10px; font-size: 13.5px; font-weight: 600; padding: 0 14px; }
#detail-screen .audio-player-wrap audio { width: 100%; }

/* ==========================================================================
   Действия «Обновить анализ / Пометить разобранным», кнопка «наверх», журнал контактов
   ========================================================================== */
/* На «Общении» и «Приёме» эти кнопки не нужны. */
#detail-screen[data-case-tab="dialogue"] #finalize-section,
#detail-screen[data-case-tab="visit"] #finalize-section { display: none !important; }
@media (max-width: 1023px) {
  /* Телефон/планшет: действия — в умной плавающей кнопке и меню «⋯» (на планшете — в правой панели). */
  #update-analysis-btn, #mark-reviewed-btn { display: none !important; }
  #detail-screen #finalize-section { background: none; border: 0; padding: 0; margin: 0; }
  #update-analysis-progress[style*="block"] {
    position: fixed; top: calc(8px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; z-index: 60; margin: 0;
    background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  }
}
#detail-more-btn { position: relative; }
#detail-more-btn.has-dot::after { content: ""; position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--clay-dark); border: 2px solid var(--bg); box-sizing: content-box; }

#ux-scroll-top {
  position: fixed; right: 14px; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 46;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2); display: none; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
#ux-scroll-top.show { display: flex; }
#ux-scroll-top.above-fab { bottom: calc(74px + var(--ux-tap-lg) + 22px + env(safe-area-inset-bottom, 0px)); }
#ux-scroll-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 768px) { #ux-scroll-top, #ux-scroll-top.above-fab { bottom: 24px; right: 24px; } }

#contact-log-section .cl-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.35; }
#contact-log-section .cl-row:first-child { border-top: 0; }
#contact-log-section .cl-time { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); min-width: 92px; flex: none; }
#contact-log-section .cl-text { flex: 1; min-width: 0; }
#contact-log-section .cl-text::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--muted); }
#contact-log-section .cl-patient_request .cl-text::before, #contact-log-section .cl-agent_help .cl-text::before { background: var(--clay-dark); }
#contact-log-section .cl-callback_requested .cl-text::before { background: var(--info-ink); }
#contact-log-section .cl-callback_done .cl-text::before, #contact-log-section .cl-doctor_chat .cl-text::before, #contact-log-section .cl-appointment .cl-text::before { background: var(--sage-dark); }
#contact-log-section .cl-more { width: 100%; min-height: 34px; margin-top: 6px; border: 1px dashed var(--line); border-radius: 10px; background: none; color: var(--sage-dark); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }

/* ==========================================================================
   Чат врача с пациентом — в стиле «современного» чата пациента
   ========================================================================== */
#doctor-chat-panel.open { background: var(--bg); }
#doctor-chat-panel.open #dcf-topbar {
  padding: 8px 10px 8px 6px; gap: 6px; background: var(--bg); border-bottom: 1px solid var(--line); min-height: 60px;
}
#dcf-topbar .dcf-back {
  width: var(--ux-tap-lg); height: var(--ux-tap-lg); padding: 0; border: 0; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 14px; flex: none;
}
.dcf-back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dcf-name { font-size: 17px; font-weight: 700; }
.dcf-actions { gap: 6px; }
.dcf-actions button {
  width: var(--ux-tap-lg); height: var(--ux-tap-lg); border: 0; background: var(--subtle); color: var(--ink);
}
.dcf-actions button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dcf-actions button.active { background: var(--clay-dark); color: #fff; }

#doctor-chat-panel.open #doctor-chat-messages {
  border: 0; border-radius: 0; background: var(--bg); padding: 14px 14px 8px; margin: 0;
}
#doctor-chat-messages .bubble-row { margin: 4px 0; }
#doctor-chat-messages .bubble {
  max-width: 82%; padding: 9px 13px; font-size: 15px; line-height: 1.4; border-radius: 18px; border: 0;
  box-shadow: none; overflow-wrap: anywhere;
}
#doctor-chat-messages .bubble.patient { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
#doctor-chat-messages .bubble.doctor { background: var(--sage-dark); color: var(--ux-on-fill, #fff); border-bottom-right-radius: 6px; }
[data-theme="dark"] #doctor-chat-messages .bubble.doctor { background: var(--sage-soft); color: var(--ink); }
/* Ответы ассистента — без пузыря, как в чате пациента. */
#doctor-chat-messages .bubble.agent { background: none; border: 0; padding: 6px 4px; color: var(--muted); max-width: 92%; }
#doctor-chat-messages .msg-ticks { color: rgba(255, 255, 255, .7); }
#doctor-chat-messages .msg-ticks.read { color: #cdeeff; }

/* Строка ввода — тёмная «таблетка», как у пациента. */
#doctor-chat-panel.open #doctor-chat-input-bar {
  margin: 6px 10px calc(10px + env(safe-area-inset-bottom, 0px)); padding: 5px 5px 5px 6px; gap: 6px;
  background: #1c1c1e; border: 0; border-radius: 28px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
#doctor-chat-input {
  background: transparent; border: 0; color: #fff; padding: 0 6px; min-height: 40px; border-radius: 0;
}
#doctor-chat-input::placeholder { color: rgba(255, 255, 255, .5); }
#doctor-chat-input:focus-visible { outline: none !important; }
#doctor-chat-input-bar button { width: 44px; height: 44px; min-width: 44px; }
#doctor-chat-input-bar #dcf-attach-btn { background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85); border: 0; }
#doctor-chat-input-bar #dcf-compose-btn { background: var(--sage-dark); color: var(--ux-on-fill, #fff); }
#doctor-chat-input-bar #dcf-compose-btn.listening { background: var(--flag); }

/* ==========================================================================
   Пациентский чат: рамка фокуса и кнопка отмены записи
   ========================================================================== */
#text-input:focus-visible, #doctor-chat-input:focus-visible, #patient-search-input:focus-visible { outline: none !important; }
#patient-search-row:focus-within { outline: 2px solid var(--sage-dark); outline-offset: 1px; }
/* Во время обычной записи корзина полностью закрывает кнопку разговорного режима. */
body:not(.conversation-active) #text-input-wrap.recording #conversation-mode-btn-input { visibility: hidden; }
#voice-cancel-btn { z-index: 4; }
[data-design="modern"] #voice-cancel-btn { background: #1c1c1e; width: 34px; height: 34px; left: 6px; bottom: 5px; }
#voice-cancel-btn { background: var(--card); }

/* ==========================================================================
   Отступ снизу карточки, чтобы плавающая кнопка не закрывала последние блоки
   ========================================================================== */
@media (max-width: 1023px) {
  #detail-screen { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  #detail-screen:has(.floating-action-bar.visible) { padding-bottom: calc(80px + var(--ux-tap-lg) + 34px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  #detail-screen { padding-bottom: 24px; }
  #detail-screen:has(.floating-action-bar.visible) { padding-bottom: calc(var(--ux-tap-lg) + 56px); }
}

/* ==========================================================================
   Главная врача на десктопе — как на утверждённом рендере
   ========================================================================== */
.home-new-patient-btn { display: none; }
.home-queue-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.home-queue-head .home-section-title { margin: 0; }
.home-queue-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.home-queue-filters:empty { display: none; }
.hq-chip {
  min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.hq-chip.on { background: var(--sage-soft); color: var(--sage-dark); border-color: transparent; }

@media (min-width: 900px) {
  #home-header { background: none; padding: 28px 40px 4px; }
  #home-header .home-eyebrow { font-size: 14px; }
  #home-header .home-title { font-size: 30px; font-weight: 800; }
  .home-summary { font-size: 15px; margin: 2px 0 16px; }
  #home-header .home-search-row { max-width: 1240px; gap: 12px; }
  #home-header .home-search-bar { flex: 0 1 460px; min-height: 44px; }
  .home-new-patient-btn {
    display: inline-flex; align-items: center; gap: 8px; margin-left: auto; min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px;
    background: var(--sage-dark); color: var(--ux-on-fill, #fff); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  }

  #home-content {
    display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 24px; align-items: start; grid-auto-flow: row dense;
    max-width: 1240px; padding-top: 14px;
  }
  #home-content > * { grid-column: 2; }
  #home-content > #notif-prompt-card, #home-content > #pending-payments-card { grid-column: 1 / -1; }
  #home-content > #home-queue-section { grid-column: 1; grid-row: auto / span 8; }
  /* Очередь пуста — на её месте расписание дня. */
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) { grid-template-columns: minmax(0, 1fr) 340px; max-width: 1240px; }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) > * { grid-column: 2; }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) > #home-today-section { grid-column: 1; grid-row: auto / span 8; }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) { grid-template-columns: minmax(0, 720px); }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) > * { grid-column: 1; }

  #home-queue-section, #home-today-section { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin: 0 0 16px; }
  .home-queue-head { padding: 16px 18px 12px; margin: 0; }
  .home-queue-head .home-section-title { font-size: 18px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }
  #home-queue-list .queue-row { border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 0; padding: 14px 18px; }
  #home-queue-list .queue-row:hover { background: var(--subtle); }
  #home-today-section > .home-section-title { padding: 16px 18px 8px; margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }
  #home-today-section .today-row { border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 0; padding: 10px 18px; }
  #home-today-section .today-row:hover { background: var(--subtle); }
  #home-today-section .queue-more-btn { margin: 8px 18px 14px; }
  #home-content .home-stat-row-compact { margin-bottom: 16px; }
  #home-content .home-stat-row-compact .home-stat-card { padding: 14px 16px; }
  #home-content .qa-grid-compact .qa-btn { min-height: 56px; }
}
@media (min-width: 1280px) {
  #home-content, #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])) { grid-template-columns: minmax(0, 1fr) 400px; }
}
@media (min-width: 900px) {
  #home-content .home-stat-row-compact .stat-label { white-space: normal; overflow: visible; }
}

/* ===================== Чип кабинета (сквозной вход) ===================== */
.ux-row-badge {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 12px; flex-shrink: 0;
  background: var(--clay-soft, #FBEEDF); color: var(--clay-dark, #9A5537);
  font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.ux-row-check { color: var(--sage-dark, #3A7550); display: inline-flex; flex-shrink: 0; }
.ux-row-check svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ux-room-chip {
  min-height: var(--ux-tap, 38px); max-width: 100%; padding: 0 10px 0 12px; border-radius: 999px;
  border: 1px solid var(--line, #E1E6DC); background: var(--card, #fff); color: var(--ink, #23261F);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.ux-room-chip:active { background: var(--subtle, #F5F7F3); }
.ux-room-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ux-room-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage-dark, #3A7550); flex-shrink: 0; }
.ux-room-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== «Профиль и настройки» ===================== */
.dprofile-card {
  text-align: center; padding: 24px 20px 20px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 16px;
}
.dprofile-photo-wrap {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--subtle); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line);
  display: flex; align-items: center; justify-content: center; margin: 0 auto; cursor: pointer;
  position: relative;
}
.dprofile-photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dprofile-photo-wrap .ph-placeholder { font-size: 34px; color: var(--muted); }
.dprofile-photo-edit-badge {
  position: absolute; bottom: -2px; right: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--sage); color: #fff; border: 2px solid var(--card);
  display: flex; align-items: center; justify-content: center;
}
.dprofile-name { font-size: 17px; font-weight: 700; color: var(--ink); margin-top: 12px; }
.dprofile-specialty-badge {
  display: inline-block; margin-top: 6px; padding: 4px 12px; border-radius: 999px;
  background: var(--sage-soft); color: var(--sage-dark); font-size: 12.5px; font-weight: 600;
}
.dprofile-degree-line { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.ux-room-slot { margin-left: auto; display: inline-flex; min-width: 0; }
.home-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.home-topline .home-eyebrow { flex: 1; min-width: 0; }
.home-room-slot { margin: 0; display: flex; flex-shrink: 0; }
#dprofile-hub { display: flex; flex-direction: column; gap: 16px; margin: 4px 0 18px; }
.hub-lbl { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 4px 6px; }
.hub-lbl-big { margin-top: 6px; }
.hub-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.hub-pad { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.hub-li {
  width: 100%; min-height: 50px; padding: 8px 14px; display: flex; align-items: center; gap: 12px;
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
}
.hub-card > .hub-li:first-child { border-top: 0; }
.hub-li:active { background: var(--subtle); }
.hub-li-static { cursor: default; }
.hub-li-static:active { background: none; }
.hub-li-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hub-li-t b { font-weight: 700; }
.hub-sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.hub-li > .hub-sub { flex: none; }
.hub-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hub-ico { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; background: var(--subtle); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.hub-ico.ok { background: var(--sage-soft); color: var(--sage-dark); }
.hub-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hub-cur { color: var(--sage-dark); display: inline-flex; }
.hub-cur svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hub-set-t { font-size: 14px; font-weight: 600; margin-top: 4px; }
.hub-seg { display: flex; gap: 3px; padding: 3px; background: var(--subtle); border: 1px solid var(--line); border-radius: 12px; }
.hub-seg button {
  flex: 1; min-height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.hub-seg button.on { background: var(--card); color: var(--sage-dark); box-shadow: 0 1px 3px rgba(0, 0, 0, .16); }
.hub-tg { position: relative; width: 46px; height: 28px; flex-shrink: 0; padding: 0; border: 0; border-radius: 14px; background: var(--line); cursor: pointer; transition: background .15s; }
.hub-tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.hub-tg.on { background: var(--sage-dark); }
.hub-tg.on::after { left: 21px; }
.hub-tg:disabled { opacity: .5; cursor: default; }
.hub-logout {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  color: var(--flag); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.hub-ver { text-align: center; font-size: 12px; color: var(--muted); margin: -6px 0 0; }

/* ===================== Планшет: главная на всю ширину, плавающая кнопка у нижнего края ===================== */
@media (min-width: 768px) and (max-width: 1023px) {
  #home-screen { max-width: none; margin: 0; }
  #home-header { padding-left: 28px; padding-right: 28px; }
  #home-content { padding-left: 28px; padding-right: 28px; }
  /* нижней навигации на планшете нет (рейка слева) — отступ 66px оставался от телефонной раскладки */
  .floating-action-bar.visible { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}

/* Планшет и узкий десктоп, очередь и расписание пусты: плитки на всю ширину вместо узкой колонки слева */
@media (min-width: 900px) and (max-width: 1279px) {
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) {
    grid-template-columns: minmax(0, 1fr); max-width: 1100px;
  }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) .qa-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) .home-quicklinks-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #home-content:has(#home-queue-section:is([style*="display:none"], [style*="display: none"])):has(#home-today-section:is([style*="display:none"], [style*="display: none"])) .home-stat-row-compact { max-width: none; }
}
