
/* ============================================================
   АРХИТЕКТУРНОЕ ПРИМЕЧАНИЕ
   ============================================================
   Все Web Components в /components используют LIGHT DOM (НЕ Shadow DOM).
   Это сделано НАМЕРЕННО:
   - глобальный CSS из этого файла применяется ко всем секциям
   - querySelectorAll() из app.js видит все элементы внутри компонентов
   - совместимость со скрин-ридерами выше
   - проще отладка через DevTools

   Минус: нет изоляции стилей — все классы и id должны быть уникальны
   во ВСЁМ приложении. При добавлении новых компонентов — проверять
   уникальность через `grep` по components/.
   ============================================================ */

  :root {
    /* Темная тема (по умолчанию) */
    /* #14: Палитра отличается от основной программы followup
       (там --accent: #3b82f6 синий). Если нужна единая семья — 
       замените --accent на #3b82f6 и --accent-dark на #2563eb. */
    --bg: #0d1520;
    --surface: #131e2c;
    --surface-alt: #18283a;
    --border: #24384f;
    --border-focus: #2dd4d4;
    --accent: #2dd4d4;
    --accent-dark: #1b8a8a;
    --accent-light: rgba(45,212,212,.12);
    --on-accent: #0d1520;            /* контрастный текст на акцентном фоне */
    --text: #e8eef6;
    --text-sec: #9fb2c8;
    --text-muted: #6b8099;
    --danger: #f0676b;            /* было #FF5252 — менее насыщенный коралловый, легче для глаз */
    --danger-bg: rgba(240,103,107,.12);
    --warning: #e8b84b;            /* мягкий янтарный (было хардкод var(--warning)) */
    --warning-bg: rgba(232,184,75,.12);
    --success: #3fcf8e;
    --success-bg: rgba(63,207,142,.12);
    --head: #e8eef6;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 20px rgba(0,0,0,.28);
    --tr: 0.25s ease;
    --glow: 0 0 20px rgba(45,212,212,.15);
    --input-bg: #18283a;
  }

  /* ============================================================
     СВЕТЛАЯ ТЕМА v2.3.1 — высококонтрастная (стиль MS Word)
     ============================================================
     Образец — Microsoft Word: ЧИСТО БЕЛЫЙ фон, ЧЁРНЫЙ текст,
     серый контур вокруг карточек, синий акцент.
     Никаких бежевых полутонов, никаких "приглушённых" цветов —
     максимальная читаемость, контраст текста к фону >12:1.
     ============================================================ */
  body.light-theme {
    --bg: #E5E5E5;                   /* серый фон вокруг "страниц" — как в Word */
    --surface: #FFFFFF;              /* карточки — чисто белый */
    --surface-alt: #F5F5F5;          /* вторичный фон таблиц/чипов — очень светлый серый */
    --border: #B0B0B0;               /* серая рамка как в Word — заметная */
    --border-focus: #2B7FBF;
    --accent: #2B7FBF;               /* офисный голубой — узнаваемый */
    --accent-dark: #1F5A8A;
    --accent-light: rgba(43,127,191,.10);
    --on-accent: #FFFFFF;
    --text: #000000;                 /* ЧЁРНЫЙ — как в документе */
    --text-sec: #404040;             /* тёмно-серый для подписей */
    --text-muted: #707070;
    --head: #000000;
    --danger: #C00000;               /* классический красный из Office */
    --danger-bg: rgba(192,0,0,.08);
    --warning: #BF8F00;              /* тёмно-золотой */
    --warning-bg: rgba(191,143,0,.10);
    --success: #2F7D2F;
    --success-bg: rgba(47,125,47,.10);
    --shadow: 0 0 0 1px #B0B0B0, 0 2px 4px rgba(0,0,0,.10);
    --glow: 0 0 0 2px rgba(43,127,191,.40);
    --input-bg: #FFFFFF;
  }

  /* Шапка — белая страница с серой рамкой как в Word */
  body.light-theme .page-header {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    box-shadow: 0 2px 6px rgba(0,0,0,.10);
  }
  body.light-theme .page-header .org-name { color: #000000; font-weight: 700; }
  body.light-theme .page-header .org-addr { color: #404040; }

  /* Шапки секций — светло-серый блок с чёрным текстом */
  body.light-theme .section-header {
    background: #F5F5F5;
    color: #000000;
    border-bottom: 1px solid #B0B0B0;
    font-weight: 700;
  }
  body.light-theme .section-header:hover {
    background: #EBEBEB;
  }
  body.light-theme .section-header .num {
    background: var(--accent);
    color: #FFFFFF;
  }
  body.light-theme .section {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
  }

  /* Поля ввода — белые с чёткой серой рамкой, чёрный текст */
  body.light-theme .field input,
  body.light-theme .field select,
  body.light-theme .field textarea,
  body.light-theme .mt input,
  body.light-theme .mt select {
    background: #FFFFFF;
    border: 1px solid #909090;
    color: #000000;
  }
  body.light-theme .field input::placeholder,
  body.light-theme .field textarea::placeholder { color: #909090; }
  body.light-theme .field input:hover,
  body.light-theme .field select:hover,
  body.light-theme .field textarea:hover {
    border-color: #404040;
  }
  body.light-theme .field input:focus,
  body.light-theme .field select:focus,
  body.light-theme .field textarea:focus,
  body.light-theme .mt input:focus,
  body.light-theme .mt select:focus {
    border-color: var(--accent);
    box-shadow: var(--glow);
    outline: none;
  }
  body.light-theme .field label {
    color: #000000;
    font-weight: 600;
  }

  /* Верхняя нав-панель — белая с серой рамкой */
  body.light-theme .top-nav-bar {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
  }
  body.light-theme .top-nav-btn {
    background: transparent;
    color: #000000;
    font-weight: 500;
  }
  body.light-theme .top-nav-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
  }
  body.light-theme .top-nav-btn.active {
    background: var(--accent);
    color: #FFFFFF;
  }
  body.light-theme .top-nav-btn .nav-num {
    background: #E0E0E0;
    color: #000000;
    font-weight: 700;
  }
  body.light-theme .top-nav-btn.active .nav-num {
    background: rgba(255,255,255,.30);
    color: #FFFFFF;
  }

  /* Сайдбар — белый */
  body.light-theme .sidebar {
    background: #FFFFFF;
    border-left: 1px solid #B0B0B0;
    box-shadow: -4px 0 12px rgba(0,0,0,.15);
  }
  body.light-theme .sidebar-btn,
  body.light-theme .sidebar-nav-link {
    color: #000000;
    background: transparent;
  }
  body.light-theme .sidebar-btn:hover,
  body.light-theme .sidebar-nav-link:hover {
    background: var(--accent-light);
    color: var(--accent);
  }
  body.light-theme .sidebar-btn svg { fill: #404040; }
  body.light-theme .sidebar-btn:hover svg { fill: var(--accent); }
  body.light-theme .sidebar h3 { color: var(--accent); }
  body.light-theme .sidebar-version { color: #909090; }
  body.light-theme .sidebar-credits { color: #909090; }
  body.light-theme .sidebar-sep { background: #B0B0B0; }

  /* FAB → правая краевая вкладка: тёмная в обеих темах (стиль в .fab) */

  /* Чипы */
  body.light-theme .symptom-chips .chip,
  body.light-theme .checkup-rec {
    background: #FFFFFF;
    border: 1px solid #909090;
    color: #000000;
  }
  body.light-theme .symptom-chips .chip:hover,
  body.light-theme .checkup-rec:hover {
    border-color: var(--accent);
    background: var(--accent-light);
  }
  body.light-theme .symptom-chips .chip.active {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
    font-weight: 600;
  }

  /* Таблица измерений */
  body.light-theme .mt th {
    background: #E0E0E0;
    color: #000000;
    border: 1px solid #B0B0B0;
    font-weight: 700;
  }
  body.light-theme .mt td {
    border: 1px solid #B0B0B0;
    color: #000000;
  }
  body.light-theme .mt tbody tr:hover td { background: #F5F5F5; }

  /* Модалки */
  body.light-theme .modal-overlay { background: rgba(0,0,0,.40); }
  body.light-theme .modal {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    box-shadow: 0 12px 36px rgba(0,0,0,.30);
  }
  body.light-theme .modal-head {
    background: #F5F5F5;
    border-bottom: 1px solid #B0B0B0;
    color: #000000;
  }

  /* Статус-плашки */
  body.light-theme .status-banner.status-info {
    background: var(--accent-light);
    color: var(--accent-dark);
    border-color: var(--accent);
  }
  body.light-theme .status-banner.status-warn {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning);
  }
  body.light-theme .status-banner.status-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
  }

  /* Графики истории */
  body.light-theme .history-chart {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
  }
  body.light-theme .history-empty,
  body.light-theme .history-summary {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    color: #000000;
  }

  /* Архив поиск */
  body.light-theme .archive-list {
    background: #FFFFFF;
    border: 1px solid #B0B0B0;
    box-shadow: 0 6px 18px rgba(0,0,0,.15);
  }
  body.light-theme .archive-item:hover,
  body.light-theme .archive-item:focus {
    background: var(--accent-light);
  }
  body.light-theme .archive-item { color: #000000; }
  body.light-theme .patient-finder-list { background: #FFFFFF; }
  body.light-theme .patient-finder-rec {
    background: #F5F5F5;
    border: 1px solid #B0B0B0;
  }

  /* Stepper */
  body.light-theme .stepper-btn {
    background: var(--accent);
    color: #FFFFFF;
    border: none;
    font-weight: 600;
  }
  body.light-theme .stepper-btn:hover { background: var(--accent-dark); }
  body.light-theme .stepper-btn:disabled { background: #C0C0C0; color: #707070; }

  /* Подсказка-иконка */
  body.light-theme .mt .norm-tip-icon {
    background: var(--accent);
    color: #FFFFFF;
  }
  body.light-theme .mt .norm-tip-popover {
    background: #FFFFFF;
    border: 2px solid var(--accent);
    color: #000000;
    box-shadow: 0 6px 18px rgba(0,0,0,.20);
  }

  /* Селект режима */
  body.light-theme .page-header h1 .mode-switcher {
    background: #FFFFFF;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    font-weight: 700;
  }
  body.light-theme .page-header h1 .mode-switcher .mode-switcher-icon {
    color: var(--accent);
  }
  body.light-theme .page-header h1 .mode-switcher:hover {
    background: var(--accent);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(43,127,191,.30);
  }
  body.light-theme .page-header h1 .mode-switcher:hover .mode-switcher-icon { color: #FFFFFF; }

  /* Дата протокола в шапке */
  body.light-theme .page-header .header-date-label { color: #404040; }
  body.light-theme .page-header .header-date-input {
    background: #FFFFFF;
    border: 1px solid #909090;
    color: #000000;
  }

  /* Stepper-progress */
  body.light-theme .stepper-progress { background: #E0E0E0; }
  body.light-theme .stepper-progress-bar { background: var(--accent); }

  /* Body */
  body.light-theme { color: #000000; }

  *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; min-height: 100vh; transition: background 0.3s, color 0.3s; }

  /* Шапка */
  .page-header { max-width: 1250px; margin: 12px auto 6px; background: var(--surface); color: var(--text); padding: 14px 18px 12px; text-align: center; position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
  .page-header h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; margin: 6px 0 4px; color: var(--head); }
  .page-header .org-name { font-size: 14px; font-weight: 700; color: var(--text); }
  .page-header .org-addr { font-size: 11px; font-weight: 400; color: var(--text-sec); margin-bottom: 2px; }
  .sidebar-version { padding: 8px 14px; font-size: 10px; color: var(--text-muted); text-align: right; letter-spacing: 0.5px; opacity: 0.6; }
  .sidebar-credits { padding: 0 14px 14px; font-size: 10px; line-height: 1.5; color: var(--text-muted); text-align: right; opacity: 0.6; }

  /* Селектор режима протокола внутри h1 — выглядит как заголовок,
     при наведении подсвечивается, можно переключить */
  .page-header { position: relative; }
  .page-header h1 .mode-switcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--accent-light);
    border: 1.5px solid var(--accent);
    color: var(--head);
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    padding: 6px 16px;
    border-radius: 24px;
    transition: all 0.18s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
  }
  .page-header h1 .mode-switcher .mode-switcher-icon {
    color: var(--accent);
    flex-shrink: 0;
    transition: transform 0.3s ease;
  }
  .page-header h1 .mode-switcher:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45,212,212,.30);
  }
  .page-header h1 .mode-switcher:hover .mode-switcher-icon {
    color: var(--on-accent);
    transform: rotate(180deg);
  }
  .page-header h1 .mode-switcher:active { transform: translateY(0); }
  .page-header h1 .mode-switcher:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }

  /* Дата протокола в правом верхнем углу шапки */
  .page-header .header-date-wrap {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-sec);
  }
  .page-header .header-date-label { font-weight: 500; }
  .page-header .header-date-input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11.5px;
    font-family: inherit;
    width: 130px;
    outline: none;
  }
  .page-header .header-date-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(45,212,212,.15); }

  @media (max-width: 600px) {
    .page-header .header-date-wrap { position: static; justify-content: center; margin-top: 4px; }
  }

  .container { max-width: 1250px; margin: 0 auto; padding: 10px 16px 40px; }

  /* === Верхняя панель навигации === */
  .top-nav-bar {
    position: sticky;
    top: 0;
    z-index: 4500;
    max-width: 1250px;
    margin: 0 auto 8px;
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;  /* iOS momentum */
    overscroll-behavior-x: contain;     /* не цепляем скролл страницы */
    scrollbar-width: thin;
    backdrop-filter: blur(6px);
    -ms-overflow-style: none;           /* IE/Edge — скрытая полоса */
    touch-action: pan-x;                /* horizontal pan на мобиле */
  }
  .top-nav-bar::-webkit-scrollbar { height: 6px; }
  .top-nav-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .top-nav-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: transparent;
    color: var(--text-sec);
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--tr);
  }
  .top-nav-btn .nav-num {
    background: var(--surface-alt);
    color: var(--text-sec);
    width: 20px; height: 20px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    font-family: 'Consolas', monospace;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--tr);
  }
  .top-nav-btn:hover { background: var(--accent-light); color: var(--accent); border-color: rgba(45,212,212,.25); }
  .top-nav-btn:hover .nav-num { background: var(--accent); color: var(--on-accent); }
  .top-nav-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
  .top-nav-btn.active .nav-num { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 6px rgba(45,212,212,.5); }
  .top-nav-btn.completed .nav-num { background: var(--success); color: #fff; }
  .top-nav-btn.hidden-btn { display: none; }

  @media print { .top-nav-bar { display: none !important; } }

  /* М6: на узких экранах верхняя панель сжимается до номеров без подписей */
  @media (max-width: 720px) {
    .top-nav-bar { gap: 2px; padding: 4px 6px; }
    .top-nav-btn { padding: 6px 8px; font-size: 0; min-width: 32px; justify-content: center; }
    .top-nav-btn .nav-num { width: 22px; height: 22px; font-size: 11px; }
    /* активная кнопка — показываем подпись чтобы было видно где находишься */
    .top-nav-btn.active { font-size: 12px; padding: 6px 12px; }
  }

  /* === Пошаговый режим (Stepper) === */
  /* По умолчанию stepper-controls скрыт. Показывается только в активной секции при body.stepper-mode */
  stepper-controls { display: none; }
  /* Stepper-mode имеет приоритет над модовыми правилами:
     даже если секция должна быть видна по режиму, в stepper-режиме показывается только активная */
  body.stepper-mode:not(.mode-analysis):not(.mode-archive):not(.mode-sgarbossa):not(.mode-vapvarp) .section:not(.stepper-active) { display: none !important; }
  body.stepper-mode:not(.mode-sgarbossa):not(.mode-vapvarp) .section.stepper-active { display: block !important; }
  body.stepper-mode .section.stepper-active stepper-controls { display: block; margin-top: 14px; }
  body.stepper-mode .section.stepper-active .section-header { cursor: default; }
  body.stepper-mode .section.stepper-active .section-header .chevron { display: none; }

  .stepper-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
  }
  .stepper-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 18px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr);
    flex-shrink: 0;
  }
  .stepper-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
  }
  .stepper-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .stepper-btn.stepper-next:not(:disabled) {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
  }
  .stepper-btn.stepper-next:not(:disabled):hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--on-accent); }
  .stepper-progress { flex: 1; min-width: 0; }
  .stepper-step-label {
    font-size: 11px;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: .5px;
    display: block;
    margin-bottom: 4px;
  }
  .stepper-step-label .stepper-cur { color: var(--accent); font-weight: 700; }
  .stepper-bar-line { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
  .stepper-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s; width: 0%; }

  @media print {
    stepper-controls { display: none !important; }
    body.stepper-mode .section { display: block !important; }
  }

  /* Кнопки и тулбар скрыты, так как есть боковое меню */
  .toolbar-vis { display: none; }
  
  .btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border: none; border-radius: var(--radius); font-family: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all var(--tr); letter-spacing: .2px; }
  .btn:hover { transform: translateY(-1px); box-shadow: var(--glow); }
  .btn-primary { background: var(--accent); color: var(--on-accent); }
  .btn-primary:hover { background: var(--accent-dark); }
  .btn-outline { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
  .btn-outline:hover { border-color: var(--accent); color: var(--accent); }

  /* Разделы */
  .section { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 6px; overflow: hidden; border: 1px solid var(--border); transition: all var(--tr); scroll-margin-top: 20px; }
  /* Секция 1 — без overflow:hidden, чтобы выпадушка автодополнения адреса не обрезалась */
  .section[data-sec="1"] { overflow: visible; }
  .section[data-sec="1"] .section-body { overflow: visible; }
  .section[data-sec="1"] .section-body.hidden { overflow: hidden; }
  .section:hover { box-shadow: 0 4px 20px rgba(45,212,212,.1); border-color: rgba(45,212,212,.25); }
  .section.hidden-section { display: none; }
  
  .section-header { background: var(--surface-alt); color: var(--text); border-left: 3px solid var(--accent); padding: 9px 14px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; transition: all var(--tr); }
  .section-header:hover { background: rgba(45,212,212,.06); }
  
  /* Кружок с номером. Добавлен класс .completed для зеленого цвета */
  .section-header .num { background: var(--accent); color: var(--on-accent); width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; font-family: 'Consolas', monospace; flex-shrink: 0; box-shadow: 0 0 8px rgba(45,212,212,.4); transition: all 0.3s ease; }
  .section-header .num.completed { background: var(--success); color: #fff; box-shadow: 0 0 8px rgba(63,207,142,.4); }
  
  .section-header .chevron { margin-left: auto; transition: transform .3s; font-size: 14px; color: var(--text-muted); }
  .section-header.collapsed .chevron { transform: rotate(-90deg); }
  
  .section-body { padding: 12px 16px 14px; overflow: hidden; transition: max-height .35s ease, opacity .25s; }
  .section-body.hidden { max-height: 0 !important; padding: 0 16px; opacity: 0; pointer-events: none; }

  /* Сетки */
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .form-grid .full { grid-column: 1 / -1; }
  .form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; }
  .form-grid-addr { display: grid; grid-template-columns: 2fr 1fr; gap: 10px 16px; }
  
  /* Адрес */
  .addr-wrap { position: relative; }
  .addr-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1.5px solid var(--accent); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 220px; overflow-y: auto; z-index: 100; display: none; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
  .addr-list.open { display: block; }
  .addr-list div { padding: 8px 12px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--text); transition: background .15s; }
  .addr-list div:hover, .addr-list div.active { background: var(--accent); color: var(--on-accent); }

  /* Поля ввода */
  .field { display: flex; flex-direction: column; gap: 4px; }
  .field label { font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .6px; }
  .field input, .field select, .field textarea { font-family: inherit; font-size: 13.5px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--input-bg); color: var(--text); transition: all var(--tr); outline: none; width: 100%; }
  .field input:hover, .field select:hover { border-color: rgba(45,212,212,.4); }
  .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,212,.15); background: var(--surface); }
  .field input::placeholder, .field textarea::placeholder { color: var(--text-muted); }
  
  /* Класс для подсветки ошибок валидации */
  .field input.has-error, .mt input.has-error, .mt select.has-error, .field select.has-error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
  .field input.has-warn, .mt input.has-warn, .mt select.has-warn, .field select.has-warn { border-color: var(--warning); box-shadow: 0 0 0 2px rgba(232,184,75,.15); }
  .field input.has-ok, .mt input.has-ok, .mt select.has-ok, .field select.has-ok { border-color: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
  .val-warn-error { border-left: 4px solid var(--danger) !important; }
  .val-warn-warn { border-left: 4px solid var(--warning) !important; }

  .field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%232dd4d4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
  .field textarea { resize: vertical; min-height: 56px; }

  /* Чекбоксы */
  .cb-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; color: var(--text); padding: 3px 0; font-weight: 400; }
  .cb-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
  
  /* Чипы для быстрого добавления (сопутствующие заболевания и т.п.) */
  .chip { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; transition: all 0.15s; font-family: inherit; line-height: 1.3; }
  .chip:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
  .chip:active { transform: scale(0.96); }

  /* Таблицы */
  .mt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; margin-top: 8px; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; table-layout: fixed; }
  .mt th { background: rgba(45,212,212,.1); color: var(--accent); padding: 10px 10px; font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; text-align: center; border-bottom: 1.5px solid var(--border); }
  .mt th:first-child { text-align: left; }
  .mt td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
  .mt tr:last-child td { border-bottom: none; }
  .mt td:first-child { font-weight: 600; background: var(--surface-alt); font-size: 11px; color: var(--text-sec); }
  /* Подсказка-иконка (?) рядом с параметром в таблице измерений.
     Появляется при ховере мышью на десктопе, при тапе/фокусе — на мобильном.
     В печать НЕ попадает (см. правило ниже + clone-фильтр в generatePrintView). */
  .mt .norm-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-left: 6px; cursor: help; vertical-align: middle; }
  .mt .norm-tip-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 700; font-family: 'Consolas', monospace; line-height: 1; user-select: none; transition: transform 0.15s; }
  .mt .norm-tip:hover .norm-tip-icon,
  .mt .norm-tip:focus .norm-tip-icon { transform: scale(1.15); box-shadow: 0 0 0 3px rgba(45,212,212,.25); }
  .mt .norm-tip-popover {
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    min-width: 220px;
    max-width: 320px;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
  }
  .mt .norm-tip:hover .norm-tip-popover,
  .mt .norm-tip:focus .norm-tip-popover,
  .mt .norm-tip:focus-within .norm-tip-popover { opacity: 1; visibility: visible; }
  /* Стрелочка слева */
  .mt .norm-tip-popover::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-style: solid;
    border-width: 6px 7px 6px 0;
    border-color: transparent var(--accent) transparent transparent;
  }
  /* На узких экранах — popover вниз а не вправо (вправо может вылезать за экран) */
  @media (max-width: 720px) {
    .mt .norm-tip-popover { left: auto; right: 0; top: calc(100% + 8px); transform: none; min-width: 200px; max-width: calc(100vw - 40px); }
    .mt .norm-tip-popover::before { left: auto; right: 8px; top: -7px; transform: none; border-width: 0 6px 7px 6px; border-color: transparent transparent var(--accent) transparent; }
  }
  /* В печать — никаких подсказок */
  @media print { .mt .norm-tip { display: none !important; } }
  .mt input, .mt select { width: 100%; border: 1.5px solid var(--border); border-radius: 6px; padding: 7px 8px; font-family: 'Consolas', monospace; font-size: 12.5px; text-align: center; outline: none; color: var(--text); background: var(--input-bg); transition: all var(--tr); }
  .mt input:hover, .mt select:hover { border-color: rgba(45,212,212,.4); }
  .mt input:focus, .mt select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(45,212,212,.15); }

  /* Осложнения */
  .comp-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
  .comp-row:last-child { border-bottom: none; }
  .comp-row .label { flex: 1; font-size: 13.5px; color: var(--text); }
  .tg { display: flex; border-radius: var(--radius); overflow: hidden; border: 1.5px solid var(--border); }
  .tg button { padding: 6px 16px; border: none; background: var(--surface); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-muted); transition: all var(--tr); }
  .tg button+button { border-left: 1.5px solid var(--border); }
  .tg button:hover { background: var(--surface-alt); }
  .tg button.a-no { background: var(--success-bg); color: var(--success); font-weight: 700; }
  .tg button.a-yes { background: var(--danger-bg); color: var(--danger); font-weight: 700; }

  /* Памятка */
  .rec-block { background: rgba(255,152,0,.06); border: 1.5px solid rgba(255,152,0,.3); border-radius: 8px; padding: 16px 18px; margin-top: 14px; }
  .rec-block h3 { font-size: 16px; font-weight: 700; color: var(--warning); margin-bottom: 8px; }
  .rec-block p { font-size: 12.5px; line-height: 1.6; margin-bottom: 6px; color: var(--text-sec); }
  .rec-block .warn { color: var(--warning); font-weight: 700; }

  /* Подписи */
  .signatures { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-top: 14px; transition: all 0.3s; }
  .sig-block { text-align: center; padding-top: 10px; background: var(--surface-alt); border-radius: var(--radius); padding: 12px 8px; }
  .sig-line { border-top: 1.5px solid var(--accent); margin: 30px 12px 4px; }
  .sig-label { font-size: 10px; color: var(--text-muted); }
  .sig-role { font-size: 10.5px; font-weight: 600; white-space: nowrap; color: var(--accent); }

  /* Всплывающее окно диагноза */
  .rec-popup { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; padding: 22px 26px; max-width: 520px; width: 90%; z-index: 9001; box-shadow: 0 12px 48px rgba(0,0,0,.5); }
  .rec-popup h3 { font-size: 15px; font-weight: 700; color: var(--accent); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
  .rec-popup .rec-type { background: var(--accent-light); border: 1.5px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
  .rec-popup .rec-mode { font-size: 12px; color: var(--text-sec); margin-bottom: 8px; line-height: 1.5; }
  .rec-popup .rec-note { font-size: 11px; color: var(--text-muted); font-style: italic; margin-bottom: 14px; }
  .rec-popup button { padding: 9px 22px; border: none; border-radius: var(--radius); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; margin-right: 8px; transition: all var(--tr); }
  .rec-popup .btn-apply { background: var(--accent); color: var(--on-accent); }
  .rec-popup .btn-apply:hover { background: var(--accent-dark); }
  .rec-popup .btn-skip { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
  .rec-popup-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9000; display: none; }
  .rec-popup-overlay.open { display: block; }

  /* Модальное окно настроек */
  .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9000; display: none; align-items: center; justify-content: center; }
  .modal-overlay.open { display: flex; }
  .modal { background: var(--surface); border-radius: 12px; width: 520px; max-width: 92vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
  .modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); color: var(--text); display: flex; align-items: center; justify-content: space-between; }
  .modal-head h2 { font-size: 16px; font-weight: 700; }
  .modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-sec); transition: color 0.2s; }
  .modal-close:hover { color: var(--danger); }
  .modal-body { padding: 16px 20px 20px; }
  .modal-body label.setting { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--text); }
  .modal-body label.setting:last-child { border-bottom: none; }
  .modal-body label.setting input[type="checkbox"], .modal-body label.setting input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

  .manual-input { font-family: inherit; font-size: 12px; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); width: 100%; outline: none; background: var(--input-bg); color: var(--text); display: none; margin-top: 4px; }
  .manual-input.show { display: block; }
  
  /* #15: Утилитарные классы для замены повторяющихся inline-стилей */
  .u-mt-8 { margin-top: 8px; }
  .u-mt-4 { margin-top: 4px; }
  .u-w-100 { width: 100%; }
  .u-hidden { display: none; }
  .u-section-subhead { font-size: 12px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; margin: 14px 0 8px; }
  .u-bg-alt { background: var(--surface-alt); }
  
  /* Все readonly-поля автоматически получают приглушённый фон */
  input[readonly], textarea[readonly] { background: var(--surface-alt); }
  
  /* #24: Таблица "Измерения и программирование электродов" */
  .meas-prog-wrap { overflow-x: auto; }
  .meas-prog-table { width: 100%; border-collapse: collapse; }
  .meas-prog-table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-sec);
    padding: 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    background: var(--surface-alt);
  }
  .meas-prog-table thead th.col-param { text-align: left; }
  .meas-prog-table thead th.chamber-pp { color: #818cf8; border-bottom: 2px solid #6366f1; }
  .meas-prog-table thead th.chamber-rv { color: #34d399; border-bottom: 2px solid #10b981; }
  .meas-prog-table thead th.chamber-lv { color: #fbbf24; border-bottom: 2px solid #f59e0b; }
  .meas-prog-table thead .subhead th { font-size: 10px; padding: 4px 6px; background: transparent; border-bottom: 1px solid var(--border); }
  .meas-prog-table thead .subhead th.col-meas { color: #60a5fa; }
  .meas-prog-table thead .subhead th.col-prog { color: #c084fc; }
  
  .meas-prog-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(42, 63, 85, 0.4);
    vertical-align: middle;
    font-size: 12px;
  }
  .meas-prog-table tbody td:first-child { color: var(--text); width: 22%; }
  .meas-prog-table tbody td.cell-na {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(0, 0, 0, 0.12);
  }
  .meas-prog-table tbody td.cell-merged {
    text-align: center;
    background: rgba(0, 188, 212, 0.04);
  }
  .meas-prog-table tbody td input,
  .meas-prog-table tbody td select { width: 100%; min-width: 70px; }
  .meas-prog-table tbody td.cell-merged select { max-width: 140px; margin: 0 auto; }
  
  /* Адаптивно для мобильного: стопка по строкам, каждый параметр — карточка по камерам */
  @media (max-width: 768px) {
    .meas-prog-table thead { display: none; }
    .meas-prog-table, .meas-prog-table tbody { display: block; width: 100%; }
    .meas-prog-table tr {
      display: block;
      margin-bottom: 14px;
      padding: 10px 12px;
      background: var(--surface-alt);
      border-radius: var(--radius);
      border-left: 3px solid var(--border);
    }
    .meas-prog-table tbody td {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 6px 0;
      border: none;
      border-bottom: 1px dashed rgba(42, 63, 85, 0.3);
      width: 100%;
    }
    .meas-prog-table tbody td:last-child { border-bottom: none; }
    .meas-prog-table tbody td:first-child {
      width: 100%;
      font-weight: 600;
      color: var(--accent);
      font-size: 13px;
      padding-bottom: 6px;
      margin-bottom: 4px;
      border-bottom: 1px solid var(--border);
    }
    .meas-prog-table tbody td:first-child::before { content: ''; }
    .meas-prog-table tbody td:not(:first-child)::before {
      content: attr(data-label);
      flex: 0 0 110px;
      font-size: 11px;
      color: var(--text-sec);
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }
    .meas-prog-table tbody td.cell-na::before { color: var(--text-muted); }
    .meas-prog-table tbody td input,
    .meas-prog-table tbody td select { flex: 1; }
    
    /* Скрытые камеры в мобильном — скрываем все ячейки этой камеры */
    .meas-prog-table tbody td.col-pp.col-hidden,
    .meas-prog-table tbody td.col-rv.col-hidden,
    .meas-prog-table tbody td.col-lv.col-hidden { display: none !important; }
    
    /* Если в строке скрыты все 6 ячеек данных, скрываем строку целиком — JS пометит */
    .meas-prog-table tr.row-all-hidden { display: none !important; }
  }

  /* Оповещения об ошибках (сверху) */
  .val-warn { position: fixed; bottom: 20px; right: 20px; left: auto; top: auto; transform: none; background: var(--surface); border: 2px solid var(--danger); border-radius: 10px; padding: 12px 36px 12px 16px; max-width: 380px; width: auto; z-index: 8500; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-size: 12px; line-height: 1.45; animation: valSlide .3s ease; }
  .val-warn .vw-title { font-weight: 700; color: var(--danger); font-size: 12.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
  .val-warn .vw-body { color: var(--text); font-size: 11.5px; max-height: 30vh; overflow-y: auto; }
  .val-warn .vw-body b { color: var(--danger); }
  .val-warn .vw-close { position: absolute; top: 6px; right: 8px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 0; line-height: 1; }
  .val-warn .vw-close:hover { color: var(--text); }
  @keyframes valSlide { from{opacity:0; top:0;} to{opacity:1; top:20px;} }

  /* Настройки врачей */
  .doc-group { margin-bottom: 14px; }
  .doc-group-title { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
  .doc-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
  .doc-item { display: grid; grid-template-columns: auto 1fr 1.4fr 130px auto; align-items: center; gap: 6px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
  .doc-item .doc-name { min-width: 0; background: transparent; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 12.5px; padding: 2px 0; }
  .doc-item .doc-role { min-width: 0; background: transparent; border: none; border-left: 1px dashed var(--border); padding: 2px 6px; outline: none; color: var(--text-sec); font-family: inherit; font-size: 11.5px; font-style: italic; }
  .doc-item .doc-role:focus { color: var(--text); font-style: normal; }
  .doc-item .doc-phone { background: transparent; border: none; border-left: 1px dashed var(--border); padding: 2px 6px; outline: none; color: var(--text-sec); font-family: 'Consolas', monospace; font-size: 11.5px; }
  .doc-item .doc-phone:focus { color: var(--text); }
  .doc-item .doc-head { width: 14px; height: 14px; cursor: pointer; opacity: .5; transition: opacity .2s; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--warning); }
  .doc-item .doc-head:hover, .doc-item .doc-head.active { opacity: 1; }
  .doc-item .doc-del { width: 20px; height: 20px; border: none; background: transparent; cursor: pointer; color: var(--danger); font-size: 16px; display: flex; align-items: center; justify-content: center; opacity: .5; }
  .doc-item .doc-del:hover { opacity: 1; }
  /* Если у группы нет звёздочки (хирурги, аритмологи) — первая колонка отсутствует */
  .doc-item:not(:has(.doc-head)) { grid-template-columns: 1fr 1.4fr 130px auto; }
  /* На узких экранах role и phone уезжают на отдельные строки */
  @media (max-width: 720px) {
    .doc-item { grid-template-columns: auto 1fr auto; }
    .doc-item:not(:has(.doc-head)) { grid-template-columns: 1fr auto; }
    .doc-item .doc-role,
    .doc-item .doc-phone { grid-column: 1 / -1; border-left: none; border-top: 1px dashed var(--border); padding: 4px 0 2px; }
  }
  .doc-add { display: flex; gap: 6px; }
  .doc-add input { flex: 1; padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 6px; background: var(--input-bg); color: var(--text); font-family: inherit; font-size: 12px; outline: none; }
  .doc-add input:focus { border-color: var(--accent); }
  .doc-add button { padding: 5px 12px; border: none; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }

  /* Кнопка FAB */
  .fab { position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 60; background: #11202b; color: #cfe0ee; border: 1px solid rgba(255,255,255,.14); border-right: none; border-radius: 8px 0 0 8px; padding: 14px 6px; cursor: pointer; font-family: var(--mono,monospace); font-size: 11px; letter-spacing: .08em; box-shadow: -2px 0 10px rgba(0,0,0,.35); display: flex; flex-direction: column; align-items: center; gap: 7px; transition: background .2s, color .2s; }
  .fab:hover { background: #162a38; color: #fff; }
  .fab span { writing-mode: vertical-rl; text-orientation: mixed; display: inline-block; }
  .fab svg { width: 18px; height: 18px; pointer-events: none; }

  /* Боковое меню */
  .sidebar { position: fixed; top: 0; right: -280px; width: 280px; height: 100vh; background: var(--surface); border-left: 2px solid var(--accent); z-index: 4999; transition: right .3s ease; overflow-y: auto; padding: 16px 14px; box-shadow: -4px 0 30px rgba(0,0,0,.4); }
  .sidebar.open { right: 0; }
  .sidebar-close { position: absolute; top: 10px; right: 10px; background: none; border: none; cursor: pointer; }
  .sidebar-close svg { width: 20px; height: 20px; fill: var(--text-muted); }
  .sidebar h3 { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  
  .sidebar-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); color: var(--text); font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all var(--tr); margin-bottom: 6px; text-align: left; }
  .sidebar-btn:hover { border-color: var(--accent); background: rgba(45,212,212,.08); color: var(--accent); }
  .sidebar-btn svg { width: 18px; height: 18px; flex-shrink: 0; fill: var(--text-muted); transition: fill .2s; }
  .sidebar-btn:hover svg { fill: var(--accent); }
  
  .sidebar-nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
  .sidebar-nav-link { background: none; border: none; color: var(--text-sec); font-size: 12px; text-align: left; padding: 4px 8px; cursor: pointer; transition: color 0.2s; border-radius: 4px; }
  .sidebar-nav-link:hover { color: var(--accent); background: rgba(45,212,212,.05); }

  .sidebar-sep { height: 1px; background: var(--border); margin: 10px 0; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.18); z-index: 4998; display: none; pointer-events: none; }
  .sidebar-overlay.open { display: block; }

  /* Для скрытия ненужных колонок в таблице ЭКС */
  .col-hidden { display: none; }
  .col-span-all { border: inherit; }

  /* CSS ДЛЯ ПЕЧАТИ */
  #printView { display: none; }
  @media print {
    body { background: #fff !important; font-size: 10pt; font-family: Arial, sans-serif; margin: 0; padding: 0; color: #000 !important; }
    .page-header, .container, .fab, .sidebar, .sidebar-overlay, .modal-overlay, .rec-popup, .rec-popup-overlay, .addr-list, .val-warn, #error-toast, #test-results-modal, #save-indicator { display: none !important; }
    #printView { display: block !important; padding: 0 5mm; }
    @page { margin: 10mm 10mm 9mm 10mm; }
    
    #printView.footer-all .pv-footer { display: flex; position: fixed; }
    #printView.footer-first .pv-footer { display: flex; position: fixed; }
    #printView.footer-first-last .pv-footer { display: flex; position: fixed; }
    #printView.footer-last .pv-footer { display: none; }
    #printView.footer-off .pv-footer { display: none; }
    #printView .ft-qr svg { width: 100% !important; height: 100% !important; display: block; }
    
    #printView .pv-footer { position: fixed; bottom: 0; left: 0; right: 0; height: 24mm; display: none; align-items: center; justify-content: space-between; padding: 1mm 5mm; border-top: 0.5pt solid #000; font-size: 7pt; background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #printView .pv-footer .ft-qr { width: 22mm; height: 22mm; flex-shrink: 0; }
    
    #printView h1 { font-size: 13pt; font-weight: 700; text-align: center; margin: 0.5mm 0; letter-spacing: 0.5pt; }
    #printView .pv-org { font-size: 9pt; text-align: center; margin: 0 0 0.3mm; font-weight: 400; }
    #printView .pv-sigs-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 6mm; margin-top: 4mm; }
    #printView .pv-sigs-row .pv-protocol-date { font-size: 10pt; min-width: 35mm; padding-bottom: 1mm; white-space: nowrap; }
    #printView .pv-sigs-row .pv-sigs { flex: 1; }
    /* QR справа от подписей — режимы last / first-last */
    #printView .pv-sigs-row-with-qr .pv-sigs-qr { width: 28mm; height: 28mm; flex-shrink: 0; }
    #printView .pv-sigs-row-with-qr .pv-sigs-qr svg { width: 100% !important; height: 100% !important; display: block; }
    #printView .pv-brand { font-size: 9pt; text-align: center; letter-spacing: 0.5pt; margin: 0 0 1.5mm; font-weight: 700; font-variant: small-caps; }
    #printView .pv-sh { font-size: 11pt; font-weight: 700; border-bottom: 1pt solid #000; padding: 0.5mm 0; margin: 2mm 0 0.5mm; }
    #printView .pv-sh.no-border { border-bottom: none; }
    #printView .pv-field { font-size: 9pt; margin: 0.3mm 0; line-height: 1.45; }
    #printView .pv-field b { font-weight: 700; }
    
    #printView table { border-collapse: collapse; width: 100%; margin: 1mm 0; font-size: 8.5pt; table-layout: fixed; }
    #printView th { border: 1pt solid #000; padding: 1mm 2mm; font-weight: 700; font-size: 7pt; text-transform: uppercase; text-align: center; background: #FFF; border-bottom: 1.5pt solid #000; }
    #printView th:first-child { text-align: left; }
    #printView td { border: 1pt solid #000; padding: 0.8mm 2mm; text-align: center; }
    #printView td:first-child { text-align: left; font-weight: 600; font-size: 7.5pt; }
    
    #printView .pv-comp { font-size: 9pt; margin: 0.3mm 0; font-weight: 600; }
    #printView .pv-textarea { font-size: 9pt; border: none; padding: 0; margin: 0.3mm 0; }
    #printView .pv-memo { border: none; padding: 0; margin: 0.5mm 0; }
    #printView .pv-memo h3 { font-size: 10pt; font-weight: 700; border-bottom: 0.5pt solid #000; padding-bottom: 0.5mm; margin-bottom: 1mm; }
    #printView .pv-memo p { font-size: 7.5pt; margin: 0.3mm 0; line-height: 1.35; }
    #printView .pv-memo .warn { font-weight: 700; }
    
    #printView .pv-sigs { display: flex; justify-content: space-between; margin-top: 1mm; }
    #printView .pv-sig { text-align: center; flex: 1; }
    #printView .pv-sig .name { font-size: 9.5pt; font-weight: 700; margin-bottom: 10mm; }
    /* ЛИНИЯ ПОДПИСИ ИСПРАВЛЕНА: Фиксированная ширина 45мм, выровнена по центру */
    #printView .pv-sig .line { border-top: 0.5pt solid #000; margin: 0 auto; width: 45mm; font-size: 7pt; padding-top: 0.5mm; font-weight: 400; }
  }

/* ============================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ============================================================
   Брейкпоинты:
   - 720px — планшеты (уже частично сделано выше)
   - 600px — крупные телефоны (iPhone 14 Pro Max ~430px, после поворота)
   - 480px — обычные смартфоны
   - 360px — узкие смартфоны (старые Android, iPhone SE)
   ============================================================ */

  /* iOS Safari зумирует страницу если font-size < 16px при фокусе.
     Поднимаем до 16px на мобильных устройствах для всех вводов формы. */
  @media (max-width: 720px) {
    .field input, .field select, .field textarea,
    .mt input, .mt select,
    .doc-name, .doc-role, .doc-phone,
    #diagSearch, #memoEditorTextarea,
    .manual-input,
    .doc-add input {
      font-size: 16px !important;
    }
    /* После поднятия шрифта input'ы становятся крупнее — чуть уменьшим padding */
    .field input, .field select, .field textarea { padding: 9px 10px; }
  }

  /* Адаптивная сетка форм: на телефонах в одну колонку */
  @media (max-width: 600px) {
    .form-grid,
    .form-grid-3,
    .form-grid-addr,
    .signatures {
      grid-template-columns: 1fr !important;
      gap: 8px;
    }
    /* Шапка компактнее */
    .page-header { padding: 10px 12px; margin: 6px auto 4px; border-radius: 8px; }
    .page-header h1 { font-size: 15px; margin: 4px 0 2px; line-height: 1.25; }
    .page-header .org-name { font-size: 12px; }
    .page-header .org-addr { font-size: 10px; }
    .page-header .brand { font-size: 9px; padding: 2px 10px; letter-spacing: 1.5px; }

    .container { padding: 8px 10px 80px; }

    /* Touch-target минимум: чекбоксы и радио в настройках */
    .modal-body label.setting input[type="checkbox"],
    .modal-body label.setting input[type="radio"] { width: 22px; height: 22px; }
    .modal-body label.setting { padding: 10px 0; font-size: 14px; }

    /* Заголовки секций крупнее для тыка пальцем */
    .section-header { padding: 12px 14px; font-size: 14px; min-height: 44px; }
    .section-header .num { width: 26px; height: 26px; font-size: 12px; }

    /* Чипы — больше воздуха для пальца */
    .chip { padding: 8px 12px !important; font-size: 13px !important; min-height: 36px; }

    /* Stepper: кнопки на всю ширину чтобы попадать пальцем */
    .stepper-btn { padding: 12px 16px !important; font-size: 14px !important; min-height: 44px; }

    /* Модалки — на узком экране в полный экран */
    .modal { max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; border-radius: 0; }
    .modal-head { padding: 12px 14px; }
    .modal-body { padding: 12px 14px 20px; }

    /* Onboarding и crypto-offer кнопки — в столбик чтобы не выходили за край */
    #onboardingModal .modal-body > div:last-child,
    #cryptoOfferModal .modal-body > div:last-child {
      flex-direction: column !important;
      align-items: stretch !important;
    }
    #onboardingModal .modal-body button,
    #cryptoOfferModal .modal-body button { width: 100%; padding: 12px 14px !important; font-size: 14px !important; }
    /* v7.1.2 (замер puppeteer): модал был 390px при left:15 → правый край
       срезался на 15px за вьюпортом. Ограничиваем шириной экрана минус поля. */
    #onboardingModal .modal,
    #cryptoOfferModal .modal { max-width: calc(100vw - 24px); }

    /* Sidebar — почти на весь экран */
    .sidebar { width: 88vw; right: -100vw; }
    .sidebar-btn { padding: 14px 12px; font-size: 14px; min-height: 44px; }

    /* FAB → краевая вкладка по правому краю — спец. мобильных правил не нужно */

    /* Val-warn — на всю ширину снизу */
    .val-warn { left: 8px; right: 8px; max-width: none; bottom: 8px; }
  }

  /* Очень узкие экраны (старые телефоны) */
  @media (max-width: 360px) {
    .container { padding: 6px 6px 80px; }
    .page-header h1 { font-size: 13px; }
    .top-nav-btn { min-width: 28px; padding: 5px 6px; }
    .top-nav-btn .nav-num { width: 20px; height: 20px; font-size: 10px; }
    .section-header { padding: 10px 10px; font-size: 13px; }
    /* Таблица измерений на ультра-узком — ещё компактнее */
    .meas-prog-table tbody td:not(:first-child)::before { flex: 0 0 80px; font-size: 10px; }
  }

  /* Печать — ничего из мобильного не должно влиять */
  @media print {
    .field input, .field select, .field textarea { font-size: 10pt !important; padding: 1pt 2pt !important; }
  }

  /* iPhone X+ safe-area: учитываем нотч и home-indicator */
  @supports (padding: env(safe-area-inset-bottom)) {
    .container { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
    .fab { right: env(safe-area-inset-right); }
    .val-warn { bottom: calc(8px + env(safe-area-inset-bottom)); right: calc(8px + env(safe-area-inset-right)); }
    .sidebar { padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  }

  /* === РЕЖИМ ПРОВЕРКИ ЭКС === */
  /*
     Секции с одинаковыми data-sec=6/7/8 существуют для обоих режимов.
     Различение — по классу .checkup-only (есть → только в проверке).
     Секции БЕЗ .checkup-only при mode-checkup скрываются (имплантационные).
     Секции С .checkup-only при mode-implantation скрываются.
  */
  /* По умолчанию (имплантация) — скрываем только checkup-секции */
  .section.checkup-only { display: none; }
  /* В режиме проверки — наоборот: скрываем имплантационные 6/7/8 */
  body.mode-checkup .section[data-sec="6"]:not(.checkup-only),
  body.mode-checkup .section[data-sec="7"]:not(.checkup-only),
  body.mode-checkup .section[data-sec="8"]:not(.checkup-only) { display: none !important; }
  /* И показываем checkup-секции */
  body.mode-checkup .section.checkup-only { display: block; }
  /* Раздел 9 «Рекомендации» — только для имплантации (в проверке свой раздел 8) */
  body.mode-checkup .section.implant-only { display: none !important; }

  /* === РЕЖИМ АНАЛИЗА ВЫГРУЗКИ ПРОГРАММАТОРА === */
  /*
     В этом режиме показывается единственная секция <analysis-section> с классом .analysis-only.
     Все остальные секции (1-11) скрыты, верхняя нав-панель скрыта,
     дата протокола в шапке и подписи — тоже скрыты (анализ — это инструмент, а не протокол с подписями).
  */
  /* По умолчанию (имплантация / проверка) — analysis-секция скрыта */
  .section.analysis-only { display: none; }
  /* В режиме анализа — показываем analysis-секцию, скрываем всё остальное */
  body.mode-analysis .section:not(.analysis-only) { display: none !important; }
  body.mode-analysis .section.analysis-only { display: block; }
  body.mode-analysis .top-nav-bar { display: none !important; }
  body.mode-analysis .header-date-wrap { display: none !important; }
  body.mode-analysis .signatures { display: none !important; }
  body.mode-analysis #statusBanners { display: none !important; }

  /* Подписи: в режиме проверки только аритмолог-программист.
     Хирург и кардиолог-наблюдающий — не показываются. */
  body.mode-checkup #sigBlockSurgeon,
  body.mode-checkup #sigBlockCardio { display: none !important; }
  body.mode-checkup .signatures { grid-template-columns: 1fr !important; }

  /* Чипы симптомов */
  .symptom-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .symptom-chips .chip {
    padding: 6px 12px;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    user-select: none;
  }
  .symptom-chips .chip:hover { border-color: var(--accent); }
  .symptom-chips .chip.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
  }
  .symptom-chips .chip.no-complaints { border-color: var(--success); }
  .symptom-chips .chip.no-complaints.active { background: var(--success-bg); color: var(--success); }
  .symptom-chips .chip-edit {
    padding: 4px 10px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 14px;
    font-size: 11px;
  }

  /* Чекбоксы рекомендаций проверки */
  .checkup-recs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
  .checkup-rec {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    transition: all 0.15s;
    line-height: 1.3;
  }
  .checkup-rec:hover { border-color: var(--accent); }
  .checkup-rec input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
  .checkup-rec input[type="checkbox"]:checked + span { color: var(--accent); font-weight: 600; }
  /* На мобильных — в один столбец чтобы не сжимать текст */
  @media (max-width: 600px) { .checkup-recs { grid-template-columns: 1fr; } }

  /* Выпадающий список совпадений из архива (под полем ФИО) */
  .archive-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    display: none;
  }
  .archive-list.open { display: block; }
  .archive-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
  }
  .archive-item:last-child { border-bottom: none; }
  .archive-item:hover, .archive-item:focus {
    background: var(--accent-light);
    outline: none;
  }
  .archive-fio { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
  .archive-meta { font-size: 11px; color: var(--text-sec); }

  /* Кнопка нав-панели "История" — только в режиме проверки */
  .top-nav-btn.checkup-only-btn,
  .sidebar-btn.checkup-only-btn { display: none; }
  body.mode-checkup .top-nav-btn.checkup-only-btn { display: inline-flex; }
  body.mode-checkup .sidebar-btn.checkup-only-btn { display: flex; }
  /* implant-only — наоборот: видны только в имплантации, скрыты в проверке */
  body.mode-checkup .top-nav-btn.implant-only-btn,
  body.mode-checkup .sidebar-nav-link.implant-only-btn,
  body.mode-checkup .modal-body label.setting.implant-only-setting { display: none !important; }

  /* === ИСТОРИЯ ПРОВЕРОК — графики === */
  .history-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--surface-alt);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-sec);
  }
  .history-new-btn {
    padding: 6px 14px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    flex-shrink: 0;
  }
  .history-new-btn:hover { background: var(--accent-dark); }
  .history-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px dashed var(--border);
    line-height: 1.55;
  }
  .history-charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  @media (max-width: 1024px) { .history-charts-grid { grid-template-columns: 1fr; } }
  .history-charts-grid .history-chart { margin-bottom: 0; }
  /* Внутри узких колонок — SVG должен сжиматься */
  .history-charts-grid .history-chart svg { max-width: 100%; height: auto; }
  .history-chart {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .history-chart-empty { text-align: center; padding: 14px; }
  .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .chart-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
  }
  .chart-unit { font-weight: 400; color: var(--text-sec); font-size: 11px; }
  .chart-legend {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-sec);
  }
  .chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
  }
  .chart-svg {
    width: 100%;
    height: auto;
    max-height: 240px;
    display: block;
  }

  @media print {
    /* Графики истории и сама секция в печать не идут (по требованию пользователя) */
    .section[data-sec="11"], #printView .section[data-sec="11"] { display: none !important; }
  }

  /* === МОДАЛКА «НАЙТИ ПАЦИЕНТА» === */
  .patient-finder-list {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
  }
  .patient-finder-group {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .patient-finder-group:last-child { border-bottom: none; }
  .patient-finder-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
  }
  .patient-finder-fio { font-size: 14px; font-weight: 700; color: var(--text); }
  .patient-finder-meta { font-size: 11.5px; color: var(--text-sec); margin-top: 2px; }
  .patient-finder-records {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--accent);
  }
  .patient-finder-rec {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11.5px;
  }
  .patient-finder-rec .rec-mode { color: var(--accent); font-weight: 600; }
  .patient-finder-rec .rec-date { color: var(--text); }
  .patient-finder-rec .pf-rec-del {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.5;
    transition: opacity 0.15s;
  }
  .patient-finder-rec .pf-rec-del:hover { opacity: 1; }
  .pf-btn {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
  }
  .pf-btn-load { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
  .pf-btn-load:hover { background: var(--accent-dark); }
  .pf-btn-export:hover { border-color: var(--accent); color: var(--accent); }

  /* === ПЛАШКИ СТАТУСА (под шапкой) === */
  .status-banners { max-width: 1250px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 6px; }
  .status-banners:empty { display: none; }
  .status-banner {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid;
  }
  .status-banner.status-info  { background: var(--accent-light); color: var(--accent); border-color: rgba(45,212,212,.3); }
  .status-banner.status-warn  { background: var(--warning-bg, rgba(232,184,75,.15)); color: var(--warning, #e8b84b); border-color: var(--warning, #e8b84b); }
  .status-banner.status-error { background: rgba(240,103,107,.12); color: var(--danger, #f0676b); border-color: var(--danger, #f0676b); font-weight: 600; }
  @media print { .status-banners { display: none !important; } }

  /* === Сравнительная таблица «было ↔ стало» (печать) === */
  #printView .pv-comparison h2 { font-size: 10pt; }
  #printView .pv-comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    margin-bottom: 4mm;
  }
  #printView .pv-comp-table th,
  #printView .pv-comp-table td {
    border: 0.5pt solid #000;
    padding: 1.5mm 2mm;
    text-align: left;
  }
  #printView .pv-comp-table th {
    background: #f0f0f0;
    font-weight: 700;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Блок «Статус пациента» в сайдбаре */
  .sidebar-patient-status:empty { display: none; }
  .side-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    font-size: 12.5px;
    border: 1px solid;
  }
  .side-stat-icon { flex-shrink: 0; font-size: 14px; }
  .side-stat-label { color: var(--text-sec); flex-shrink: 0; }
  .side-stat-value { font-weight: 600; margin-left: auto; }
  .side-stat-info { background: var(--accent-light); color: var(--accent); border-color: rgba(45,212,212,.30); }
  .side-stat-warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
  .side-stat-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 600; }

  body.light-theme .side-stat-info { background: var(--accent-light); color: var(--accent-dark); border-color: var(--accent); }
  body.light-theme .side-stat-warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
  body.light-theme .side-stat-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

  /* Settings: пункт «11. История» виден только в режиме проверки */
  .modal-body label.setting.checkup-only-setting { display: none; }
  body.mode-checkup .modal-body label.setting.checkup-only-setting { display: flex; }

  /* Поля «Медицинская организация» в Настройках */
  .org-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
  .org-field { display: flex; flex-direction: column; gap: 4px; }
  .org-field-label { font-size: 11.5px; color: var(--text-sec); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
  .org-field input {
    padding: 8px 10px;
    background: var(--input-bg);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .org-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,212,.15); }
  .org-reset-btn {
    align-self: flex-start;
    padding: 6px 12px;
    background: var(--surface-alt);
    color: var(--text-sec);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
  }
  .org-reset-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* Светлая тема — переопределение фокуса */
  body.light-theme .org-field input:focus { box-shadow: 0 0 0 2px rgba(43,127,191,.30); }

  /* === АНАЛИЗ ВЫГРУЗКИ ПРОГРАММАТОРА (раздел analysis) === */
  .analysis-placeholder {
    padding: 24px;
    background: var(--card-bg, rgba(255,255,255,.04));
    border: 1px dashed var(--border, rgba(255,255,255,.2));
    border-radius: 8px;
    line-height: 1.6;
  }
  .analysis-placeholder p { margin: 0 0 12px 0; }
  .analysis-placeholder p:last-child { margin-bottom: 0; }
  .analysis-placeholder code {
    font-family: ui-monospace, monospace;
    background: rgba(0,0,0,.25);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 13px;
  }
  body.light-theme .analysis-placeholder code { background: #eee; color: #333; }

  /* === АНАЛИЗ ВЫГРУЗКИ — UI этапа 2 === */
  .analysis-status-bar {
    display: flex; gap: 24px; flex-wrap: wrap;
    padding: 8px 14px; margin-bottom: 12px;
    background: rgba(0, 188, 212, .06);
    border-left: 3px solid var(--accent, #2dd4d4);
    border-radius: 4px;
    font-size: 13px; color: var(--text-sec, #aaa);
  }
  .analysis-status-bar code {
    background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace;
  }
  body.light-theme .analysis-status-bar code { background: #eee; color: #333; }

  .analysis-loader {
    padding: 16px; margin-bottom: 16px;
    background: var(--card-bg, rgba(255,255,255,.04));
    border: 1px dashed var(--border, rgba(255,255,255,.2));
    border-radius: 8px;
  }
  .analysis-loader p { margin: 0 0 12px 0; line-height: 1.5; }
  .analysis-loader code {
    background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 12px;
  }
  body.light-theme .analysis-loader code { background: #eee; color: #333; }
  .analysis-loader-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
  .analysis-loader-btn {
    display: inline-flex; align-items: center;
    padding: 10px 16px; cursor: pointer;
    background: var(--accent, #2dd4d4); color: var(--on-accent, #0d1520);
    border: none; border-radius: 6px;
    font-weight: 500; font-size: 14px;
    transition: opacity .15s;
  }
  .analysis-loader-btn:hover { opacity: .85; }
  .analysis-clear-btn {
    background: transparent;
    color: var(--text-sec, #aaa);
    border: 1px solid var(--border, rgba(255,255,255,.2));
  }
  .analysis-progress {
    margin-top: 12px; padding: 8px 12px;
    background: rgba(0, 188, 212, .1);
    border-radius: 4px;
    font-family: ui-monospace, monospace; font-size: 13px;
  }

  /* v3.4.15: красивый виджет прогресса со спиннером и прогресс-баром.
     Адаптивен: на десктопе компактная карточка, на мобильном — на всю ширину. */
  .analysis-progress-card {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 16px 0;
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.08), rgba(0, 188, 212, 0.02));
    border: 1px solid rgba(0, 188, 212, 0.3);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  }
  /* v3.4.18: явное правило для [hidden] — побеждает .analysis-progress-card,
     потому что специфичность .class[attr] = (0,2,0) > .class = (0,1,0).
     Без него атрибут hidden из JS визуально не действовал, и панель оставалась
     висеть после завершения анализа. */
  .analysis-progress-card[hidden] {
    display: none;
  }
  .ap-spinner-wrap {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
  }
  .ap-spinner {
    width: 100%; height: 100%;
    transform-origin: center;
    animation: ap-rotate 1.4s linear infinite;
  }
  .ap-spinner-track {
    stroke: rgba(0, 188, 212, 0.15);
  }
  .ap-spinner-arc {
    stroke: #2dd4d4;
    stroke-dasharray: 90 150;  /* видимая дуга ~70% круга */
    stroke-dashoffset: 0;
    animation: ap-dash 1.2s ease-in-out infinite;
  }
  @keyframes ap-rotate {
    100% { transform: rotate(360deg); }
  }
  @keyframes ap-dash {
    0%   { stroke-dasharray: 1 150;   stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 90 150;  stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90 150;  stroke-dashoffset: -124; }
  }
  .ap-body {
    flex: 1 1 auto;
    min-width: 0;  /* для корректного truncate в subtitle */
  }
  .ap-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--accent, #2dd4d4);
    margin-bottom: 2px;
  }
  .ap-subtitle {
    font-size: 13px;
    color: var(--text-sec, #aaa);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ap-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
  }
  .ap-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2dd4d4, #5fe8e8);
    border-radius: 3px;
    transition: width 0.25s ease-out;
  }
  .ap-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-sec, #aaa);
  }
  .ap-stat b { color: var(--text); font-weight: 600; }
  .ap-stat-err b { color: #ff9800; }
  .ap-stat-pct {
    margin-left: auto;
    font-weight: 600;
    color: var(--accent, #2dd4d4);
  }

  /* Мобильная адаптация: спиннер уменьшен, карточка плотнее */
  @media (max-width: 600px) {
    .analysis-progress-card {
      gap: 12px;
      padding: 14px;
      flex-wrap: wrap;
    }
    .ap-spinner-wrap { width: 40px; height: 40px; }
    .ap-title { font-size: 14px; }
    .ap-subtitle { font-size: 12px; }
    .ap-stats { font-size: 11px; gap: 10px; }
    .ap-stat-pct { margin-left: 0; }
  }

  /* v3.4.26: padding-х для содержимого анализа. analysis-section не имеет
     .section-body обёртки (она в HTML других секций даёт padding 12/16),
     поэтому контент лепился к левому/правому краю. Здесь — явные отступы. */
  .analysis-summary {
    margin-top: 16px;
    padding: 4px 18px 14px;
  }
  .analysis-progress-card { margin: 4px 18px 14px; }
  .analysis-archive { margin: 4px 18px 14px; }
  .analysis-summary h3 {
    margin: 16px 0 8px 0; font-size: 15px; font-weight: 600;
    color: var(--accent, #2dd4d4);
  }
  .analysis-kinds { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
  .analysis-kinds li {
    padding: 4px 10px; background: rgba(0, 188, 212, .1); border-radius: 4px; font-size: 13px;
  }
  .analysis-summary-tbl {
    width: 100%; border-collapse: collapse; margin-top: 8px;
    font-size: 13px;
  }
  .analysis-summary-tbl td, .analysis-summary-tbl th {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.1));
    text-align: left; vertical-align: top;
  }
  .analysis-summary-tbl th {
    background: rgba(0, 188, 212, .08);
    font-weight: 600; color: var(--text-sec, #aaa);
  }
  .analysis-summary-tbl td:first-child { color: var(--text-sec, #aaa); width: 40%; }
  .analysis-summary-tbl tr.row-arrhythmia td { color: #ff9b6b; font-weight: 500; }

  .analysis-debug { margin-top: 20px; }
  .analysis-debug summary {
    cursor: pointer; padding: 6px 12px;
    background: rgba(255,255,255,.04); border-radius: 4px;
    font-size: 13px; color: var(--text-sec, #aaa);
  }
  .analysis-debug pre {
    max-height: 400px; overflow: auto;
    padding: 12px; margin-top: 8px;
    background: rgba(0,0,0,.3); border-radius: 4px;
    font-family: ui-monospace, monospace; font-size: 11px;
    white-space: pre-wrap; word-break: break-all;
  }
  body.light-theme .analysis-debug pre { background: #f4f4f4; color: #222; }

  /* === Многовизитный дашборд (этап 3) === */
  /* v3.4.52: компактная шапка — уменьшены отступы между stats-bar / линией /
     заголовком пациента / тегами. Раньше margin-top: 24px + padding-top: 12px
     давали 36px пустоты до заголовка. */
  .analysis-patient {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border, rgba(255,255,255,.12));
  }
  .analysis-patient:first-of-type {
    border-top: none;
    margin-top: 4px;
    padding-top: 0;
  }
  .analysis-patient-header {
    margin: 0 0 1px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent, #2dd4d4);
  }
  .analysis-patient-meta {
    color: var(--text-sec, #aaa);
    font-weight: 400;
    font-size: 12px;
  }
  .analysis-patient-tags {
    margin: 1px 0 6px 0;
    color: var(--text-sec, #aaa);
    font-size: 12px;
  }
  /* v3.4.57: старый .analysis-patient h4 удалён — стиль h4 задан общим
     `analysis-section h4` в клиническом блоке. */
  .analysis-trends-wrap {
    overflow-x: auto;
    margin-bottom: 8px;
  }
  .analysis-trends-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 480px;
  }
  .analysis-trends-tbl th, .analysis-trends-tbl td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
    text-align: left;
    white-space: nowrap;
  }
  .analysis-trends-tbl thead th {
    background: rgba(0, 188, 212, .1);
    color: var(--accent, #2dd4d4);
    font-weight: 600;
    text-align: center;
    vertical-align: top;
  }
  .analysis-trends-tbl thead th:first-child { text-align: left; }
  .analysis-th-sub {
    display: block;
    font-weight: 400;
    color: var(--text-sec, #aaa);
    font-size: 10px;
    margin-top: 2px;
  }
  .analysis-trend-label {
    color: var(--text-sec, #aaa);
    font-weight: 500;
  }
  .analysis-trends-tbl tbody td:not(.analysis-trend-label) {
    text-align: center;
    font-family: ui-monospace, monospace;
  }

  /* === Действия по пациенту в режиме analysis (этап 4) === */
  .analysis-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 8px 0 12px 0;
  }
  .analysis-link {
    flex: 1 1 auto;
    margin: 1px 0;
    font-size: 12px;
    color: var(--text-sec, #aaa);
  }
  .analysis-link-found {
    color: #6bd16b;
    font-weight: 500;
  }
  .analysis-link-none {
    color: #ffb86b;
  }
  .analysis-action-btn {
    font-size: 12px;
    padding: 4px 10px;
    white-space: nowrap;
  }


  /* === Группа в архиве: разделитель «Анализы / Протоколы» === */
  .archive-group-header {
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-sec, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--border, #333);
  }
  .archive-group-header:first-child { border-top: none; }
  .archive-item-analysis {
    border-left: 2px solid #6bd16b;
  }

  /* === КРИТИЧЕСКИЕ НАХОДКИ И РЕКОМЕНДАЦИИ (этап В, v3.4.12) === */
  .analysis-critical-banner {
    margin: 12px 0 16px;
    padding: 12px 16px;
    background: rgba(255, 82, 82, 0.08);
    border: 1px solid rgba(255, 82, 82, 0.4);
    border-left: 4px solid #ff5252;
    border-radius: 6px;
  }
  .analysis-critical-title {
    font-weight: 700;
    font-size: 13px;
    color: #ff5252;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .analysis-critical-list {
    margin: 0; padding-left: 18px; list-style: disc;
    font-size: 13px; line-height: 1.5;
  }
  .crit-item-critical { color: #ff5252; }
  .crit-item-warning  { color: #ffb86b; }

  .analysis-recs-block { margin: 16px 0; }
  .analysis-recs-title {
    font-size: 14px; font-weight: 600;
    margin: 0 0 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border, #333);
  }
  .analysis-recs-list {
    display: flex; flex-direction: column; gap: 12px;
  }
  .analysis-rec-card {
    padding: 18px 20px;
    border-radius: var(--radius-lg, 14px);
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-left: 3px solid var(--rec-c, var(--accent, #6bb6ff));
    background: var(--surface, rgba(255,255,255,0.03));
    font-size: 13.5px;
    line-height: 1.5;
  }

  .analysis-rec-head {
    display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
    margin-bottom: 8px;
  }
  .rec-icon { font-size: 14px; flex-shrink: 0; }
  .rec-cat {
    font-family: 'Consolas', ui-monospace, monospace;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--rec-c, var(--accent));
    width: 100%;
  }
  .rec-title {
    font-size: 15.5px; font-weight: 600;
    color: var(--text, #e5e7eb);
  }
  .analysis-rec-desc { color: var(--text-sec, #94a5b4); margin-bottom: 4px; }
  .analysis-rec-action {
    color: var(--text-sec, #94a5b4);
    font-size: 13px;
    padding-top: 12px;
    border-top: 1px dashed var(--border, rgba(255,255,255,0.12));
    margin-top: 12px;
  }
  .analysis-rec-action strong { color: var(--accent-2, var(--accent, #6bb6ff)); }

  /* === АВТОТЕСТЫ ПОРОГОВ (этап Г, v3.4.12) === */
  .analysis-autotests-block { margin: 16px 0; }
  .analysis-autotests-title {
    font-size: 14px; font-weight: 600;
    margin: 0 0 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border, #333);
  }
  .analysis-autotests-sub {
    font-size: 12px; color: var(--text-sec, #aaa);
    margin: 0 0 8px;
  }
  .analysis-autotests-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: rgba(255,255,255,0.02);
    border-radius: 4px;
    overflow: hidden;
  }
  .analysis-autotests-tbl th,
  .analysis-autotests-tbl td {
    padding: 6px 10px;
    border: 1px solid var(--border, #333);
    text-align: left;
  }
  .analysis-autotests-tbl th {
    background: rgba(0, 188, 212, 0.08);
    font-weight: 600;
    color: var(--text, #e5e7eb);
    font-size: 11px;
  }
  .autotest-row-success {
    background: rgba(107, 209, 107, 0.06);
  }
  .autotest-row-failed {
    background: rgba(255, 82, 82, 0.10);
    color: #ff9b6b;
  }
  .autotest-row-empty {
    color: var(--text-muted, #888);
    font-style: italic;
  }
  .autotest-empty { text-align: center; }
  .autotest-status-ok      { color: #6bd16b; font-weight: 600; }
  .autotest-status-failed  { color: #ff5252; font-weight: 700; }
  .autotest-status-unknown { color: var(--text-muted, #888); }

  .analysis-autotests-warning {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(255, 82, 82, 0.10);
    border-left: 3px solid #ff5252;
    border-radius: 4px;
    color: #ff9b6b;
    font-size: 12px;
    font-weight: 500;
  }

  .analysis-autotests-events {
    margin-top: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    overflow: hidden;
  }
  .analysis-autotests-events > summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-sec, #aaa);
    font-weight: 500;
    user-select: none;
  }
  .analysis-autotests-events > summary:hover {
    background: rgba(255,255,255,0.04);
  }
  .analysis-autotests-events[open] > summary {
    border-bottom: 1px solid var(--border, #333);
  }
  .analysis-autotests-events-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
  }
  .analysis-autotests-events-tbl th,
  .analysis-autotests-events-tbl td {
    padding: 4px 10px;
    border-bottom: 1px solid var(--border, #333);
    text-align: left;
  }
  .analysis-autotests-events-tbl th {
    background: rgba(45,212,212,0.05);
    color: var(--text-sec, #aaa);
    font-weight: 500;
  }

  /* === СПАРКЛАЙНЫ ТРЕНДОВ (этап Е, v3.4.12) === */
  .analysis-sparklines-block { margin: 16px 0; }
  .analysis-sparklines-title {
    font-size: 14px; font-weight: 600;
    margin: 0 0 10px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border, #333);
  }
  .analysis-sparklines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
  }
  .analysis-sparkline-card {
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border, #333);
    border-left: 3px solid #6bb6ff;
  }
  .analysis-sparkline-card.sparkline-low,
  .analysis-sparkline-card.sparkline-high {
    border-left-color: #ff5252;
    background: rgba(255,82,82,0.05);
  }
  .analysis-sparkline-card.sparkline-ok {
    border-left-color: #6bd16b;
  }
  .sparkline-label {
    font-size: 11px;
    color: var(--text-sec, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
  }
  .sparkline-row {
    display: flex; align-items: center; gap: 12px;
    justify-content: space-between;
  }
  .sparkline-value {
    font-size: 18px; font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
  }
  .sparkline-value-ok   { color: #6bd16b; }
  .sparkline-value-low,
  .sparkline-value-high { color: #ff5252; }
  .sparkline-unit {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-sec, #aaa);
  }
  .sparkline-svg {
    flex-shrink: 0;
    line-height: 0;
  }
  .sparkline-svg svg { display: block; }
  .sparkline-range {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-sec, #888);
    font-style: italic;
  }

  /* === РИТМ И ПРОВОДИМОСТЬ (этап Л, v3.4.12) === */
  .analysis-rhythm-block {
    margin: 12px 0 16px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border, #333);
    border-left: 4px solid #6bb6ff;
    border-radius: 6px;
  }
  .analysis-rhythm-title {
    font-size: 14px; font-weight: 600;
    margin: 0 0 8px;
    color: var(--text, #e5e7eb);
  }
  .ac-rhythm-meta {
    font-size: 12px; color: var(--text-sec, #aaa);
    margin-bottom: 10px;
  }
  .ac-rhythm-meta div { margin-bottom: 2px; }
  .ac-meta-label { color: var(--text-muted, #888); }
  .ac-rhythm-meta strong { color: var(--text, #e5e7eb); font-weight: 600; }

  .ac-rhythm-warning {
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(255, 155, 107, 0.10);
    border-left: 3px solid #ff9b6b;
    border-radius: 4px;
    color: #ff9b6b;
    font-size: 12px;
  }
  .ac-rhythm-warning-soft {
    margin-bottom: 6px;
    padding: 6px 10px;
    background: rgba(255, 212, 92, 0.08);
    border-left: 3px solid #ffd45c;
    border-radius: 4px;
    color: #ffd45c;
    font-size: 12px;
  }

  .ac-rhythm-section-title {
    font-size: 12px; font-weight: 600;
    margin: 10px 0 6px;
    color: var(--text-sec, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  .ac-rhythm-stats {
    display: flex; flex-direction: column;
    gap: 5px;
    font-size: 12px;
  }
  .ac-stat-row {
    display: grid;
    grid-template-columns: 1fr auto 140px;
    gap: 10px; align-items: center;
  }
  .ac-stat-label strong {
    font-weight: 600; color: var(--text, #e5e7eb);
    margin-right: 6px;
  }
  .ac-stat-desc { color: var(--text-sec, #aaa); font-size: 11px; }
  .ac-stat-value {
    font-family: monospace;
    font-weight: 600;
    color: var(--text, #e5e7eb);
    min-width: 36px; text-align: right;
  }
  .ac-bar {
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    overflow: hidden;
  }
  .ac-bar-fill {
    height: 100%;
    transition: width 0.3s;
    border-radius: 4px;
  }
  .ac-bar-fill-good      { background: #6bd16b; }   /* собственный ритм — хорошо */
  .ac-bar-fill-pace      { background: #6bb6ff; }   /* стимуляция — нейтрально */
  .ac-bar-fill-pace-warn { background: #ff9b6b; }   /* стимуляция при риске PICM */

  .ac-rhythm-tachy {
    display: flex; flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }
  .ac-tachy-row { display: flex; gap: 8px; align-items: baseline; }
  .ac-tachy-label { color: var(--text-sec, #aaa); min-width: 110px; }
  .ac-tachy-value { font-weight: 600; }
  .ac-tachy-good { color: #6bd16b; }
  .ac-tachy-warn { color: #ffb86b; }
  .ac-tachy-bad  { color: #ff5252; }
  .ac-tachy-na   { color: var(--text-muted, #888); font-style: italic; }
  .ac-tachy-note { color: var(--text-sec, #aaa); font-size: 11px; }

  .ac-rhythm-sensor {
    font-size: 12px;
    color: var(--text, #e5e7eb);
    line-height: 1.6;
  }
  .ac-rhythm-sensor strong { font-weight: 600; }
  .ac-sensor-detail { color: var(--text-sec, #aaa); font-size: 11px; }

  .ac-rhythm-changes {
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
  }
  .ac-rhythm-changes-stable {
    background: rgba(107, 209, 107, 0.06);
    color: #6bd16b;
  }
  .ac-rhythm-changes-active {
    background: rgba(255, 212, 92, 0.08);
    color: #ffd45c;
  }

  /* === Развёрнутый блок изменений настроек (v3.4.12) === */
  .ac-settings-changes {
    margin-top: 10px;
    padding: 8px 10px 10px;
    border-radius: 6px;
    background: rgba(255, 212, 92, 0.05);
    border: 1px solid rgba(255, 212, 92, 0.2);
  }
  .ac-settings-changes-header {
    font-size: 12px;
    color: #ffd45c;
    margin-bottom: 6px;
  }
  .ac-settings-changes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .ac-settings-changes-table th {
    text-align: left;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-sec, #aaa);
    font-weight: 500;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .ac-settings-changes-table td {
    padding: 4px 8px;
    color: var(--text, #e5e7eb);
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  .ac-settings-changes-table tr:last-child td { border-bottom: none; }
  .ac-settings-changes-table .ac-settings-old { color: var(--text-sec, #aaa); font-family: monospace; }
  .ac-settings-changes-table .ac-settings-new { color: #ffd45c; font-weight: 500; font-family: monospace; }

  /* === ДАШБОРД "обзор за минуту" (этап М, v3.4.12) === */
  .analysis-dashboard {
    margin: 12px 0 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border, #333);
  }
  .dash-overall {
    padding: 12px 14px;
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border, #333);
  }
  .dash-overall-icon { font-size: 20px; flex-shrink: 0; }
  .dash-overall-text { font-size: 14px; font-weight: 700; }
  .dash-overall-meta {
    flex: 1; min-width: 0;
    font-size: 11px; color: var(--text-sec, #aaa);
    text-overflow: ellipsis; overflow: hidden;
  }

  .dash-overall-ok       { background: rgba(107, 209, 107, 0.10); }
  .dash-overall-ok       .dash-overall-text { color: #6bd16b; }
  .dash-overall-medium   { background: rgba(255, 212, 92, 0.10); }
  .dash-overall-medium   .dash-overall-text { color: #ffd45c; }
  .dash-overall-high     { background: rgba(255, 155, 107, 0.12); }
  .dash-overall-high     .dash-overall-text { color: #ff9b6b; }
  .dash-overall-critical { background: rgba(255, 82, 82, 0.15); }
  .dash-overall-critical .dash-overall-text { color: #ff5252; }

  .dash-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    background: var(--border, #333);
  }
  .dash-cell {
    background: rgba(255,255,255,0.02);
    padding: 10px 12px;
    display: flex; flex-direction: column;
    gap: 6px;
    min-width: 0;
  }
  .dash-cell-head {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600;
    color: var(--text-sec, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .dash-cell-domain-icon { font-size: 13px; }
  .dash-cell-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-cell-status { font-size: 12px; flex-shrink: 0; }
  .dash-cell-value {
    font-size: 13px; font-weight: 500;
    color: var(--text, #e5e7eb);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dash-cell.dash-ok       { background: rgba(107, 209, 107, 0.05); }
  .dash-cell.dash-medium   { background: rgba(255, 212, 92, 0.06); }
  .dash-cell.dash-medium   .dash-cell-value { color: #ffd45c; }
  .dash-cell.dash-high     { background: rgba(255, 155, 107, 0.08); }
  .dash-cell.dash-high     .dash-cell-value { color: #ff9b6b; font-weight: 600; }
  .dash-cell.dash-critical { background: rgba(255, 82, 82, 0.10); }
  .dash-cell.dash-critical .dash-cell-value { color: #ff5252; font-weight: 700; }

  /* Мобильный — 2 колонки */
  @media (max-width: 600px) {
    .dash-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* === ЭГМ VIEWER (этап И.1, v3.4.12) === */
  .episode-egm-btn {
    background: rgba(0, 188, 212, 0.15);
    border: 1px solid #2dd4d4;
    color: #2dd4d4;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
  }
  .episode-egm-btn:hover {
    background: rgba(0, 188, 212, 0.30);
  }
  .episode-egm-na {
    color: var(--text-muted, #888);
    font-style: italic;
  }

  .egm-viewer-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: rgba(15, 25, 35, 0.96);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  }
  .egm-header {
    padding: 10px 16px;
    background: #15202b;
    border-bottom: 1px solid #2a3a48;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
  }
  .egm-title {
    flex: 1; min-width: 0;
    font-size: 14px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .egm-controls {
    padding: 8px 14px;
    background: #15202b;
    border-bottom: 1px solid #2a3a48;
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
  }
  .egm-btn {
    background: #2a3a48;
    border: 1px solid #3a4a58;
    color: #e5e7eb;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
  }
  .egm-btn:hover { background: #3a4a58; }
  .egm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .egm-btn-active {
    background: #2dd4d4;
    border-color: #2dd4d4;
    color: #0d1520;
    font-weight: 600;
  }
  .egm-btn-close {
    margin-left: auto;
    background: transparent;
    font-size: 14px;
  }
  .egm-zoom-label, .egm-page-label, .egm-calib-label {
    font-size: 11px; color: var(--text-sec, #aaa);
    font-family: monospace;
    min-width: 60px; text-align: center;
  }
  .egm-sep {
    width: 1px;
    height: 18px;
    background: #2a3a48;
    margin: 0 4px;
  }
  .egm-canvas-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #0a1218;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }
  .egm-canvas-wrap.egm-cursor-cross {
    cursor: crosshair;
  }
  .egm-canvas {
    display: block;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  }
  .egm-overlay {
    position: absolute;
    pointer-events: auto;
  }
  .egm-canvas-wrap:not(.egm-cursor-cross) .egm-overlay {
    pointer-events: none;
  }
  .egm-status {
    padding: 6px 14px;
    background: #15202b;
    border-top: 1px solid #2a3a48;
    font-size: 11px;
    color: var(--text-sec, #aaa);
    flex-shrink: 0;
  }

  /* === PVC stats (этап И.3, v3.4.12) === */
  .ac-pvc-stats {
    display: flex; flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }
  .ac-pvc-row {
    display: flex; gap: 8px; align-items: baseline;
    flex-wrap: wrap;
  }
  .ac-pvc-value {
    color: var(--text, #e5e7eb);
    font-weight: 500;
  }
  .ac-pvc-note {
    color: var(--text-muted, #888);
    font-size: 11px;
    font-style: italic;
  }

  /* === Sensor diagnostics issues (этап Н, v3.4.12) === */
  .ac-sensor-issues {
    margin-top: 8px;
    display: flex; flex-direction: column;
    gap: 4px;
  }
  .ac-sensor-issue {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
  }
  .ac-sensor-issue-high {
    background: rgba(255, 155, 107, 0.10);
    border-left: 3px solid #ff9b6b;
  }
  .ac-sensor-issue-medium {
    background: rgba(255, 212, 92, 0.08);
    border-left: 3px solid #ffd45c;
  }
  .ac-sensor-issue-info {
    background: rgba(107, 182, 255, 0.06);
    border-left: 3px solid #6bb6ff;
  }
  .ac-sensor-issue-icon { flex-shrink: 0; }
  .ac-sensor-issue-body { color: var(--text, #e5e7eb); }
  .ac-sensor-issue-body em { color: var(--text-sec, #aaa); font-style: italic; }

  /* === Narrative report preview (этап Ж, v3.4.12) === */
  .narrative-preview-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9998;
    background: rgba(15, 25, 35, 0.96);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  }
  .narrative-preview-header {
    padding: 10px 16px;
    background: #15202b;
    border-bottom: 1px solid #2a3a48;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
  }
  .narrative-preview-title {
    flex: 1;
    font-size: 14px; font-weight: 600;
  }
  .narrative-preview-body {
    flex: 1;
    padding: 16px;
    overflow: auto;
    background: #0a1218;
  }
  .narrative-preview-text {
    width: 100%;
    height: 100%;
    min-height: 60vh;
    padding: 14px;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #2a3a48;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    box-sizing: border-box;
  }
  .narrative-preview-status {
    padding: 8px 16px;
    background: #15202b;
    border-top: 1px solid #2a3a48;
    font-size: 11px;
    color: var(--text-sec, #aaa);
    flex-shrink: 0;
  }

  /* === АРХИВ ПАЦИЕНТОВ (этап З, v3.4.12) === */
  .analysis-archive {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border, #333);
    border-radius: 6px;
  }
  .archive-section { display: flex; flex-direction: column; gap: 10px; }
  /* v3.4.21: custom-element archive-section по умолчанию inline — это могло
     визуально схлопывать его содержимое. Делаем явно block. */
  archive-section { display: block; }
  /* v3.4.30: history-section и archive-section — custom-element-ы. Класс
     .checkup-only / .archive-only стоит на их inner div, что скрывает
     ВНУТРЕННЕЕ содержимое, но сам custom-element как контейнер остаётся
     видимым и может занимать место. Скрываем их на уровне tag-а в режимах
     где они не нужны. */
  body:not(.mode-checkup) history-section { display: none !important; }
  body.mode-checkup history-section { display: block; }
  body:not(.mode-archive) archive-section { display: none !important; }
  body.mode-archive archive-section { display: block !important; }
  /* Калькулятор Сгарбосса–Смита — виден только в своём режиме; прочий контент скрыт. */
  sgarbossa-calc { display: block; }
  body:not(.mode-sgarbossa) sgarbossa-calc { display: none !important; }
  body.mode-sgarbossa .section { display: none !important; }
  body.mode-sgarbossa .top-nav-bar,
  body.mode-sgarbossa .header-date-wrap,
  body.mode-sgarbossa .signatures,
  body.mode-sgarbossa #statusBanners,
  body.mode-sgarbossa analysis-section,
  body.mode-sgarbossa archive-section,
  body.mode-sgarbossa history-section { display: none !important; }
  /* Калькулятор VA-времени / PVARP — та же схема видимости. */
  va-pvarp-calc { display: block; }
  body:not(.mode-vapvarp) va-pvarp-calc { display: none !important; }
  body.mode-vapvarp .section { display: none !important; }
  body.mode-vapvarp .top-nav-bar,
  body.mode-vapvarp .header-date-wrap,
  body.mode-vapvarp .signatures,
  body.mode-vapvarp #statusBanners,
  body.mode-vapvarp analysis-section,
  body.mode-vapvarp archive-section,
  body.mode-vapvarp history-section { display: none !important; }
  /* Стили калькулятора Сгарбосса–Смита */
  .sc-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
  .sc-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
  .sc-sub { font-size: 13px; color: var(--text-sec, var(--muted)); margin: 0 0 18px; }
  .sc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
  .sc-card-h { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-sec, var(--muted)); margin-bottom: 12px; }
  .sc-row { display: flex; gap: 16px; flex-wrap: wrap; }
  .sc-field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); flex: 1; min-width: 180px; }
  .sc-field input { flex: 1; min-width: 70px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
  .sc-u { font-size: 13px; color: var(--text-sec, var(--muted)); }
  .sc-chk { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); padding: 7px 0; cursor: pointer; }
  .sc-chk input { margin-top: 3px; flex: none; }
  .sc-result-box { margin: 6px 0 16px; }
  .sc-ecg { margin: 4px 0 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface); overflow: hidden; }
  .sc-ratio { font-size: 14px; color: var(--text); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
  .sc-res { padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
  .sc-res-empty { background: var(--surface); border: 1px dashed var(--border); color: var(--text-sec, var(--muted)); }
  .sc-res-pos { background: var(--danger-bg, rgba(240,103,107,.12)); border: 1px solid var(--danger); color: var(--text); }
  .sc-res-neg { background: rgba(76,175,80,.10); border: 1px solid var(--ok, #4caf50); color: var(--text); }
  .sc-warn { background: rgba(255,179,0,.10); border: 1px solid var(--warn, #ffb300); color: var(--text); padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
  .sc-pos { color: var(--danger); font-weight: 600; }
  .sc-neg { color: var(--ok, #4caf50); font-weight: 600; }
  .sc-note { font-size: 12px; line-height: 1.55; color: var(--text-sec, var(--muted)); border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
  /* Стили калькулятора VA-времени / PVARP */
  .vp-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
  .vp-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
  .vp-sub { font-size: 13px; color: var(--text-sec, var(--muted)); margin: 0 0 18px; }
  .vp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
  .vp-card-h { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-sec, var(--muted)); margin-bottom: 12px; }
  .vp-p { font-size: 14px; line-height: 1.55; color: var(--text); margin: 0; }
  .vp-ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; color: var(--text); }
  .vp-ul li { margin: 4px 0; }
  .vp-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .vp-row:last-child { border-bottom: none; }
  .vp-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-sec, var(--muted)); }
  .vp-field input { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); font-size: 14px; width: 110px; font-variant-numeric: tabular-nums; }
  .vp-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
  .vp-row-status { font-size: 12px; color: var(--text-sec, var(--muted)); flex: 1; min-width: 160px; }
  .vp-rs-valid { color: var(--ok, #4caf50); }
  .vp-rs-farfield, .vp-rs-toolate, .vp-rs-block { color: var(--warn); }
  .vp-del { background: none; border: 1px solid var(--border); color: var(--text-sec, var(--muted)); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; flex: none; }
  .vp-add { margin-top: 8px; background: none; border: 1px dashed var(--border); color: var(--accent, var(--text)); border-radius: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
  .vp-result-box { margin: 6px 0 16px; }
  .vp-res { padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
  .vp-res-empty { background: var(--surface); border: 1px dashed var(--border); color: var(--text-sec, var(--muted)); }
  .vp-res-ok { background: rgba(76,175,80,.10); border: 1px solid var(--ok, #4caf50); color: var(--text); }
  .vp-note { font-size: 12px; line-height: 1.55; color: var(--text-sec, var(--muted)); border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
  .archive-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
  }
  .archive-header h3 { margin: 0; font-size: 14px; }
  .archive-actions { display: flex; gap: 6px; flex-wrap: wrap; }
  .archive-search-wrap {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 4px;
  }
  .archive-search-input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    color: var(--text, #e5e7eb);
    font-size: 12px;
  }
  .archive-search-input:focus {
    outline: none;
    border-color: #2dd4d4;
  }
  .archive-search-count {
    font-size: 11px; color: var(--text-sec, #aaa);
    flex-shrink: 0;
  }
  .archive-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .archive-table th,
  .archive-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border, #333);
  }
  .archive-table thead th {
    background: rgba(255,255,255,0.04);
    font-weight: 600;
    color: var(--text-sec, #aaa);
    user-select: none;
  }
  .archive-table .archive-th {
    cursor: pointer;
  }
  .archive-table .archive-th:hover {
    background: rgba(0, 188, 212, 0.10);
    color: #2dd4d4;
  }
  .archive-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
  }
  .archive-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
  }
  .archive-status.dash-ok       { background: rgba(107, 209, 107, 0.15); color: #6bd16b; }
  .archive-status.dash-medium   { background: rgba(255, 212, 92, 0.15); color: #ffd45c; }
  .archive-status.dash-high     { background: rgba(255, 155, 107, 0.18); color: #ff9b6b; }
  .archive-status.dash-critical { background: rgba(255, 82, 82, 0.20);  color: #ff5252; }

  /* === Сайдбар: три режим-специфичных блока (v3.4.15) === */
  /* По умолчанию все три блока скрыты. Body-класс mode-* открывает свой. */
  /* v3.4.50: ЖЁСТКАЯ защита сайдбаров через html[data-mode="..."].
     data-mode на <html> выставляется в первой же строке app.js, до загрузки
     body, поэтому никакой race-condition не успевает показать чужой сайдбар.
     Использует !important чтобы перебить любые конфликтующие правила. */
  html[data-mode] .sidebar-mode-implant,
  html[data-mode] .sidebar-mode-checkup,
  html[data-mode] .sidebar-mode-analysis,
  html[data-mode] .sidebar-mode-archive { display: none !important; }

  html[data-mode="implantation"] .sidebar-mode-implant { display: block !important; }
  html[data-mode="checkup"]      .sidebar-mode-checkup  { display: block !important; }
  html[data-mode="analysis"]     .sidebar-mode-analysis { display: block !important; }
  html[data-mode="archive"]      .sidebar-mode-archive  { display: block !important; }

  /* Fallback на старые body-классы — оставлены на случай если data-mode не успел встать. */
  .sidebar-mode-implant,
  .sidebar-mode-checkup,
  .sidebar-mode-analysis { display: none; }

  body.mode-implantation .sidebar-mode-implant { display: block; }
  body.mode-checkup      .sidebar-mode-checkup  { display: block; }
  body.mode-analysis     .sidebar-mode-analysis { display: block; }

  /* Defensive: явное скрытие при двойных body-классах. */
  body.mode-analysis     .sidebar-mode-implant,
  body.mode-analysis     .sidebar-mode-checkup,
  body.mode-archive      .sidebar-mode-implant,
  body.mode-archive      .sidebar-mode-checkup,
  body.mode-archive      .sidebar-mode-analysis,
  body.mode-checkup      .sidebar-mode-implant,
  body.mode-checkup      .sidebar-mode-analysis,
  body.mode-implantation .sidebar-mode-checkup,
  body.mode-implantation .sidebar-mode-analysis { display: none !important; }

  /* v3.4.15: при нескольких пациентах в выгрузке скрываем пер-пациентные
     сайдбар-кнопки — они работали только на patients[0] и вводили в заблуждение.
     Юзер вместо них использует кнопки в карточке каждого пациента. */
  body.analysis-multi-patient .sidebar-mode-analysis [data-sidebar-action="analysisSavePat"],
  body.analysis-multi-patient .sidebar-mode-analysis [data-sidebar-action="analysisDownloadDoc"],
  body.analysis-multi-patient .sidebar-mode-analysis [data-sidebar-action="analysisCopyNarrative"],
  body.analysis-multi-patient .sidebar-mode-analysis [data-sidebar-action="analysisPreviewNarrative"],
  body.analysis-multi-patient .sidebar-mode-analysis [data-sidebar-action="analysisPrint"] {
    display: none !important;
  }
  /* Подсказка в самом сайдбаре когда такие кнопки скрыты */
  body.analysis-multi-patient .sidebar-mode-analysis::after {
    content: "В выгрузке несколько пациентов. Действия по каждому — в карточке пациента.";
    display: block;
    margin: 8px 12px;
    padding: 8px 10px;
    background: rgba(255, 200, 0, 0.08);
    border-left: 3px solid #ff9800;
    color: var(--text-sec, #aaa);
    font-size: 12px;
    line-height: 1.4;
    border-radius: 3px;
  }

  /* Баннер-подсказка в самом блоке анализа над списком пациентов */
  .analysis-multi-hint {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: rgba(255, 200, 0, 0.08);
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
  }
  .analysis-multi-hint b { color: #ff9800; }

  /* v3.4.16: блок «Из выгрузки устройства» (.bnk данные) */
  .analysis-bnk-block {
    margin: 10px 0 14px;
    padding: 10px 14px;
    background: rgba(0, 188, 212, 0.04);
    border-left: 3px solid #2dd4d4;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
  }
  /* v3.4.17: Хронологический таймлайн пациента */
  .pt-block {
    margin: 14px 0 18px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
  }
  .pt-header { font-size: 14px; margin-bottom: 8px; color: var(--text, #e1e3e6); }
  .pt-subtitle { font-size: 12px; color: var(--text-sec, #888); margin-left: 8px; }
  .pt-svg { width: 100%; height: auto; display: block; margin: 4px 0; user-select: none; }
  .pt-axis,
  .pt-tick { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
  .pt-yearlabel { fill: var(--text-sec, #888); font-size: 11px; font-family: inherit; }
  .pt-axislabel { fill: var(--text-sec, #666); font-size: 10px; font-family: inherit; }
  .pt-count { fill: var(--text-sec, #aaa); font-size: 10px; font-weight: 600; font-family: inherit; }
  .pt-event { cursor: pointer; transition: transform 0.1s ease; }
  .pt-event:hover { transform: scale(1.4); transform-origin: center; transform-box: fill-box; }
  .pt-event:focus { outline: none; }
  .pt-event:focus circle, .pt-event:focus polygon { stroke: var(--accent, #2dd4d4); stroke-width: 2.5; }
  .pt-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; color: var(--text-sec, #999); margin-top: 6px; }
  .pt-lg { display: inline-flex; align-items: center; gap: 4px; }
  @media print { .pt-svg { max-height: 80mm; } }
  /* v3.4.17: подсветка колонки в таблице трендов при клике по визиту на таймлайне */
  .pt-highlight {
    background: rgba(0, 188, 212, 0.18) !important;
    transition: background 0.3s ease;
    box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.4);
  }
  .pt-event[data-visit-idx] { cursor: pointer; }
  /* v3.4.17: zoom-кнопки таймлайна */
  .pt-zoom-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 4px 0 8px;
  }
  .pt-zoom-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sec, #aaa);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
  }
  .pt-zoom-btn:hover {
    background: rgba(0, 188, 212, 0.12);
    color: var(--accent, #2dd4d4);
  }
  .pt-zoom-btn.pt-zoom-active {
    background: rgba(0, 188, 212, 0.20);
    color: var(--accent, #2dd4d4);
    border-color: rgba(0, 188, 212, 0.5);
  }
  @media print { .pt-zoom-bar { display: none; } }
  .analysis-bnk-title {
    font-weight: 600;
    color: #2dd4d4;
    margin-bottom: 6px;
    font-size: 13px;
  }
  .analysis-bnk-body div {
    padding: 1px 0;
  }
  .analysis-bnk-body b {
    color: var(--text);
    font-weight: 600;
  }
  .analysis-bnk-body ul {
    list-style: none;
  }
  .analysis-bnk-body ul li {
    padding: 1px 0;
  }

  /* v3.4.15: статистика разбора PDF — сколько файлов, пациентов, отброшено */
  /* v3.4.47: компактная шапка analysis-section. Раньше padding/margin
     были рассчитаны на десктоп с обилием воздуха — для медицинской программы
     где экран забит данными это создавало лишний скролл. */
  .analysis-stats-bar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0 0 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    font-size: 12px;
  }
  .analysis-stats-bar b { color: var(--text); margin-right: 4px; }

  /* Старые маркеры (v3.4.13) — для обратной совместимости с другими частями кода. */
  /* hide-in-analysis: скрывается в режиме анализа (используется в шапке/тулбаре). */
  body.mode-analysis .hide-in-analysis { display: none !important; }
  /* sidebar-analysis-actions: совместимость со старым именем класса. */
  .sidebar-analysis-actions { display: none; }
  body.mode-analysis .sidebar-analysis-actions { display: block; }

  /* === Скрытые proxy-кнопки в форме анализа (этап З.UI, v3.4.12) === */
  /* Сами действия в правом сайдбаре, но handleSidebarAction кликает на эти кнопки. */
  .analysis-proxy-btn {
    display: none !important;
  }
  /* Подсказка в форме анализа */
  .analysis-loader-hint {
    color: var(--text-sec, #aaa);
    font-size: 12px;
    margin: 0 0 4px;
  }

  /* События по всем визитам — свернуто по умолчанию */
  .analysis-events-details {
    margin-top: 12px;
  }
  .analysis-events-details > summary {
    cursor: pointer;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    font-size: 13px;
    user-select: none;
  }
  .analysis-events-details > summary:hover {
    background: rgba(255,255,255,0.06);
  }
  .analysis-events-details[open] > summary {
    margin-bottom: 8px;
  }

  /* === Кнопки в строке архива (v3.4.12) === */
  .archive-row-btn {
    padding: 3px 9px;
    font-size: 11px;
    margin: 0 2px;
  }
  .archive-row-btn-danger {
    color: #ff5252 !important;
    border-color: rgba(255,82,82,0.4) !important;
  }
  .archive-row-btn-danger:hover {
    background: rgba(255,82,82,0.10) !important;
  }

  /* === Печать протокола анализа (v3.4.12) === */
  @media print {
    /* v3.4.15: блок «printing-analysis» удалён — печать анализа теперь идёт
       через стандартный #printView (см. analysis-section.js → case 'print').
       Здесь оставляем только специфические правила для .pv-analysis. */
    #printView .pv-analysis {
      color: #000 !important;
      background: #fff !important;
      font-family: Arial, sans-serif;
      font-size: 9.5pt;
      line-height: 1.35;
    }
    /* Принудительно чёрный текст для всех элементов внутри pv-analysis. */
    #printView .pv-analysis,
    #printView .pv-analysis * {
      color: #000 !important;
    }
    /* Заголовки крупнее и жирнее. */
    #printView .pv-analysis h1 {
      font-size: 14pt; font-weight: 700; text-align: center;
      margin: 1mm 0 2mm; letter-spacing: 0.3pt;
    }
    #printView .pv-analysis h2 {
      font-size: 11pt; font-weight: 700;
      border-bottom: 0.75pt solid #000; padding-bottom: 0.5mm;
      margin: 4mm 0 1.5mm; page-break-after: avoid;
    }
    #printView .pv-analysis h3 {
      font-size: 10pt; font-weight: 700;
      margin: 3mm 0 1mm; page-break-after: avoid;
    }
    /* Параграфы — компактные. */
    #printView .pv-analysis p {
      margin: 0.5mm 0;
    }
    /* Таблицы трендов и эпизодов — чёткие линии, без серых заливок. */
    #printView .pv-analysis table {
      width: 100%;
      border-collapse: collapse;
      margin: 1mm 0;
      font-size: 8.5pt;
      page-break-inside: auto;
    }
    #printView .pv-analysis th {
      border: 0.5pt solid #000;
      padding: 0.8mm 1.5mm;
      font-weight: 700;
      text-align: center;
      background: #fff !important;
    }
    #printView .pv-analysis td {
      border: 0.5pt solid #000;
      padding: 0.6mm 1.5mm;
      vertical-align: top;
    }
    #printView .pv-analysis tr { page-break-inside: avoid; }
    /* Шапка пациента — без рамок, но компактно. */
    #printView .pv-analysis table:first-of-type td {
      border: none;
      padding: 0.4mm 2mm 0.4mm 0;
    }
    /* Списки (рекомендации) — компактно. */
    #printView .pv-analysis ol,
    #printView .pv-analysis ul {
      margin: 1mm 0;
      padding-left: 5mm;
    }
    #printView .pv-analysis li {
      margin-bottom: 1.5mm;
      page-break-inside: avoid;
    }
    /* <pre> для narrative-текста: моноширинный шрифт неуместен в печати, переопределяем. */
    #printView .pv-analysis pre {
      font-family: Arial, sans-serif !important;
      font-size: 9.5pt !important;
      white-space: pre-wrap;
      margin: 0;
    }
  }

  /* ===== Блок «Заключение» внизу страницы анализа (v3.4.12) ===== */
  .analysis-final-conclusion {
    margin-top: 24px;
    padding: 16px 18px;
    background: rgba(0, 188, 212, 0.04);
    border: 1px solid rgba(0, 188, 212, 0.25);
    border-radius: 8px;
  }
  /* v7.6.81: врачебное и пациентское заключение рядом, две колонки */
  .analysis-conclusion-cols {
    display: flex; gap: 16px; flex-wrap: wrap; margin-top: 24px;
  }
  .analysis-conclusion-cols > .analysis-final-conclusion {
    flex: 1 1 420px; min-width: 0; margin-top: 0;
  }
  .analysis-conclusion-cols > .analysis-final-conclusion.is-patient {
    background: rgba(66, 207, 144, 0.05);
    border-color: rgba(66, 207, 144, 0.30);
  }
  .analysis-final-conclusion.is-patient .analysis-final-title { color: #42cf90; }
  .analysis-final-conclusion.is-patient .ac-final-btn {
    background: rgba(66, 207, 144, 0.12);
    color: #42cf90;
    border-color: rgba(66, 207, 144, 0.5);
  }
  @media (max-width: 760px) {
    .analysis-conclusion-cols { flex-direction: column; }
  }
  /* v8.0.5: табы заключения (Для врача / Для пациента) */
  analysis-section .nv-tab {
    background: none; border: none; cursor: pointer;
    padding: 10px 18px; font-size: 14px; font-weight: 600;
    color: var(--muted, #8a94a7);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color .15s, border-color .15s; white-space: nowrap;
  }
  analysis-section .nv-tab:hover { color: var(--text, #e6ebf2); }
  analysis-section .nv-tab.active {
    color: var(--accent); border-bottom-color: var(--accent);
  }
  .analysis-final-title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
    color: #2dd4d4;
  }
  .analysis-final-actions {
    display: flex; gap: 10px;
    margin-bottom: 12px; flex-wrap: wrap;
  }
  .ac-final-btn {
    background: rgba(0, 188, 212, 0.12);
    color: #2dd4d4;
    border: 1px solid rgba(0, 188, 212, 0.5);
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
  }
  .ac-final-btn:hover:not(:disabled) {
    background: rgba(0, 188, 212, 0.22);
  }
  .ac-final-btn:disabled {
    opacity: 0.6; cursor: wait;
  }
  /* v3.4.17: памятка пациенту — зелёная (для пациента, не для врача) */
  .ac-final-btn.ac-handout-btn {
    background: rgba(76, 175, 80, 0.12);
    color: #4caf50;
    border-color: rgba(76, 175, 80, 0.5);
  }
  .ac-final-btn.ac-handout-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.22);
  }
  /* v3.4.17: создать протокол проверки — синяя */
  .ac-final-btn.ac-checkup-btn {
    background: rgba(63, 81, 181, 0.15);
    color: #7986cb;
    border-color: rgba(63, 81, 181, 0.5);
  }
  .ac-final-btn.ac-checkup-btn:hover:not(:disabled) {
    background: rgba(63, 81, 181, 0.28);
  }

  /* v3.4.17: баннер «Заполнено из анализа» в режиме проверки */
  .checkup-prefill-banner {
    margin: 16px 0;
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.10), rgba(63, 81, 181, 0.06));
    border: 1px solid rgba(0, 188, 212, 0.35);
    border-radius: 8px;
    overflow: hidden;
  }
  .checkup-prefill-banner .cpb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 188, 212, 0.12);
    border-bottom: 1px solid rgba(0, 188, 212, 0.2);
    font-size: 14px;
  }
  .checkup-prefill-banner .cpb-head-actions {
    display: flex; gap: 8px; align-items: center;
  }
  .checkup-prefill-banner .cpb-retry {
    background: rgba(255, 152, 0, 0.18);
    border: 1px solid rgba(255, 152, 0, 0.55);
    color: #ff9800;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
  }
  .checkup-prefill-banner .cpb-retry:hover {
    background: rgba(255, 152, 0, 0.28);
  }
  .checkup-prefill-banner .cpb-close {
    background: transparent;
    border: none;
    color: var(--text-sec, #aaa);
    font-size: 18px;
    cursor: pointer;
    padding: 0 6px;
  }
  .checkup-prefill-banner .cpb-close:hover { color: var(--text); }
  .checkup-prefill-banner .cpb-body {
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
  }
  .checkup-prefill-banner .cpb-applied {
    margin-bottom: 6px;
    color: var(--text-sec, #ccc);
  }
  .checkup-prefill-banner .cpb-applied b { color: #4caf50; }
  .checkup-prefill-banner .cpb-skipped {
    margin: 6px 0;
    color: var(--text-sec, #888);
    font-size: 12px;
  }
  .checkup-prefill-banner .cpb-skipped summary { cursor: pointer; }
  .checkup-prefill-banner .cpb-skipped ul { margin: 4px 0 0 18px; padding: 0; }
  .checkup-prefill-banner .cpb-recs {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
  }
  .checkup-prefill-banner .cpb-recs b { color: var(--accent, #2dd4d4); }
  .checkup-prefill-banner .cpb-recs ul { margin: 6px 0 0 18px; padding: 0; }
  .checkup-prefill-banner .cpb-recs li { margin-bottom: 4px; }
  /* v3.4.17: кнопка «Применить» рядом с рекомендациями имеющими apply */
  .checkup-prefill-banner .cpb-apply-btn {
    margin-left: 6px;
    background: rgba(0, 188, 212, 0.18);
    border: 1px solid rgba(0, 188, 212, 0.55);
    color: var(--accent, #2dd4d4);
    border-radius: 3px;
    padding: 1px 8px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
  }
  .checkup-prefill-banner .cpb-apply-btn:hover:not(:disabled) {
    background: rgba(0, 188, 212, 0.32);
  }
  .checkup-prefill-banner .cpb-apply-btn:disabled {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    border-color: rgba(76, 175, 80, 0.5);
    cursor: default;
  }
  @media print { .checkup-prefill-banner { display: none !important; } }
  .analysis-final-text {
    margin: 0;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Menlo', monospace;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-prim, #e8e8e8);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 600px;
    overflow-y: auto;
  }

  /* Печать: убрать кнопки и фон, оставить только текст */
  @media print {
    .analysis-final-actions { display: none; }
    .analysis-final-conclusion {
      background: #fff !important;
      border-color: #888 !important;
      page-break-before: auto;
      page-break-inside: avoid;
    }
    .analysis-final-text {
      background: #fff !important;
      color: #000 !important;
      border: 1px solid #888 !important;
      max-height: none !important;
      overflow: visible !important;
    }
  }

  /* v3.4.12: пустая analysis-section не должна рисовать карточку.
     Когда нет загруженной выгрузки и архив скрыт — нет фона, нет рамки. */
  analysis-section.section:has(#analysisSummary[hidden]):has(#analysisArchive[hidden]):has(#analysisProgress[hidden]) {
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 0;
    padding: 0;
  }

  /* M11 v3.4.12: Дата имплантации в шапке пациента (Анализ выгрузки) */
  .analysis-implant-date {
    margin: 8px 0 12px;
    padding: 8px 12px;
    background: rgba(0, 188, 212, 0.04);
    border-left: 3px solid rgba(0, 188, 212, 0.4);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
  }
  .analysis-implant-date-label {
    font-weight: 600;
    color: var(--text-prim, #e8e8e8);
  }
  .analysis-implant-date-value {
    color: var(--text-prim, #e8e8e8);
    font-weight: 500;
  }
  .analysis-implant-date-input {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-prim, #e8e8e8);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: inherit;
  }
  .analysis-implant-date-input:focus {
    outline: none;
    border-color: rgba(0, 188, 212, 0.6);
  }
  .analysis-implant-date-phase {
    color: #2dd4d4;
    font-weight: 500;
  }
  .analysis-implant-date-hint {
    color: var(--text-sec, #aaa);
    font-style: italic;
    font-size: 12px;
  }
  .analysis-implant-date-src {
    color: var(--text-sec, #888);
    font-size: 11px;
    font-style: italic;
    margin-left: 4px;
  }

  /* ============================================================================
     UI-РЕВИЗИЯ ANALYSIS-SECTION v3.4.12
     Цель: усилить контраст и переходы между блоками. Цветовые акценты слева
     каждого блока, zebra-полосы в таблицах, контрастные заголовки.

     Цветовая семантика:
       синий  #2dd4d4  — общая инфа, дашборд, ритм, заключение
       оранж  #ff9b6b  — аритмии, эпизоды, ЖЭ
       жёлтый #ffd45c  — программирование, изменения настроек
       зелён  #6bd16b  — батарея, нормы
       красн  #ff5252  — критика
     ============================================================================ */

  /* ---------- 1. КАРТОЧКИ БЛОКОВ ---------- */

  /* Базовый стиль "карточка раздела" — общий для всех */
  analysis-section .ac-card {
    margin: 14px 0;
    padding: 14px 16px 14px 18px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left-width: 4px;
    border-radius: 6px;
  }
  /* Синий акцент по умолчанию */
  analysis-section .ac-card { border-left-color: #2dd4d4; }

  /* Оборачиваем существующие блоки. Имена классов — те же что есть в HTML. */
  analysis-section .ac-rhythm-meta,
  analysis-section .analysis-rhythm-block,
  analysis-section .analysis-implant-date,
  analysis-section .analysis-final-conclusion {
    background: rgba(0, 188, 212, 0.04);
    border: 1px solid rgba(0, 188, 212, 0.18);
    border-left: 4px solid #2dd4d4;
    border-radius: 6px;
    padding: 14px 16px;
    margin: 14px 0;
  }
  /* Аритмии / эпизоды — оранжевый */
  analysis-section .ac-rhythm-tachy,
  analysis-section .ac-pvc-stats,
  analysis-section .analysis-events-details,
  analysis-section details.analysis-events-details {
    background: rgba(255, 155, 107, 0.04);
    border: 1px solid rgba(255, 155, 107, 0.20);
    border-left: 4px solid #ff9b6b;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 12px 0;
  }
  /* Изменения настроек — жёлтый */
  analysis-section .ac-settings-changes {
    background: rgba(255, 212, 92, 0.04);
    border: 1px solid rgba(255, 212, 92, 0.22);
    border-left: 4px solid #ffd45c;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 12px 0;
  }
  /* Критические находки (внешний баннер) */
  analysis-section .critical-issues-banner {
    border-left: 4px solid #ff5252;
  }

  /* ---------- 2. ЗАГОЛОВКИ РАЗДЕЛОВ ---------- */

  analysis-section .ac-rhythm-section-title,
  analysis-section .analysis-final-title,
  analysis-section .ac-pvc-stats > h4,
  analysis-section .ac-pvc-stats > h5 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #e8e8e8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  /* Цвет заголовка = цвет акцента блока */
  analysis-section .analysis-rhythm-block .ac-rhythm-section-title {
    color: #2dd4d4;
  }
  analysis-section .ac-rhythm-tachy .ac-rhythm-section-title {
    color: #ff9b6b;
  }
  analysis-section .ac-pvc-stats .ac-rhythm-section-title,
  analysis-section .ac-pvc-stats h4,
  analysis-section .ac-pvc-stats h5 {
    color: #ff9b6b;
  }
  analysis-section .ac-settings-changes .ac-settings-changes-header {
    color: #ffd45c;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 212, 92, 0.18);
    margin: 0 0 10px;
  }

  /* ---------- 3. ТАБЛИЦЫ — Z-bra striping + контраст ---------- */

  /* Общее правило для всех таблиц внутри analysis-section */
  analysis-section table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 8px 0;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 4px;
    overflow: hidden;
  }
  analysis-section table thead tr,
  analysis-section table tr.tbl-head,
  analysis-section table tr:first-child {
    background: rgba(0, 188, 212, 0.10);
  }
  analysis-section table thead th,
  analysis-section table th {
    padding: 8px 12px;
    color: #2dd4d4;
    font-weight: 600;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid rgba(0, 188, 212, 0.25);
  }
  analysis-section table tbody td,
  analysis-section table td {
    padding: 7px 12px;
    color: var(--text, #e8e8e8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  /* Zebra striping */
  analysis-section table tbody tr:nth-child(even) td,
  analysis-section table tr:nth-child(even):not(:first-child) td {
    background: rgba(255, 255, 255, 0.025);
  }
  analysis-section table tbody tr:hover td,
  analysis-section table tr:hover:not(:first-child) td {
    background: rgba(0, 188, 212, 0.08);
  }
  /* Первый столбец — ярче (это лейбл параметра) */
  analysis-section table tbody td:first-child,
  analysis-section table tr:not(:first-child) td:first-child {
    color: var(--text-sec, #b0b0b0);
    font-weight: 500;
  }

  /* Цветной акцент таблиц по родителю-блоку */
  analysis-section .ac-rhythm-tachy table tr:first-child,
  analysis-section .ac-rhythm-tachy table thead tr {
    background: rgba(255, 155, 107, 0.10);
  }
  analysis-section .ac-rhythm-tachy table th {
    color: #ff9b6b;
    border-bottom-color: rgba(255, 155, 107, 0.25);
  }
  analysis-section .ac-settings-changes table tr:first-child,
  analysis-section .ac-settings-changes table thead tr {
    background: rgba(255, 212, 92, 0.10);
  }
  analysis-section .ac-settings-changes table th {
    color: #ffd45c;
    border-bottom-color: rgba(255, 212, 92, 0.25);
  }

  /* ---------- 4. ТАБЛИЦА "Динамика по визитам" — заголовки колонок ---------- */
  /* Это та самая большая таблица 30+ строк, которая сливалась */

  analysis-section .analysis-trends-wrap table th,
  analysis-section .analysis-trends-wrap table tr:first-child td {
    background: rgba(0, 188, 212, 0.10);
    color: #2dd4d4;
    font-weight: 600;
  }
  /* Дата отчёта мелкими буквами под датой визита */
  analysis-section .analysis-trends-wrap table tr:first-child td > div:nth-child(2),
  analysis-section .analysis-trends-wrap table tr:first-child td > small {
    color: var(--text-sec, #888);
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
  }

  /* ---------- 5. ЦВЕТНАЯ ПОДСВЕТКА ЗНАЧЕНИЙ ---------- */

  /* Существующие классы ac-tachy-* — усиливаем яркость */
  analysis-section .ac-tachy-good { color: #6bd16b; font-weight: 500; }
  analysis-section .ac-tachy-warn { color: #ffd45c; font-weight: 500; }
  analysis-section .ac-tachy-bad  { color: #ff5252; font-weight: 600; }
  analysis-section .ac-tachy-na   { color: var(--text-muted, #888); font-style: italic; }

  /* "—" дефис делаем тусклее везде */
  analysis-section table td:where(:not([data-value])):empty,
  analysis-section table td {
    /* через CSS не достаём содержимое td — просто ставим базовый цвет;
       пустые "—" будут читаться как обычный серый */
  }

  /* ---------- 6. БЛОК "ЗАКЛЮЧЕНИЕ" — финальный аккорд страницы ---------- */
  analysis-section .analysis-final-conclusion {
    margin-top: 24px;
    background: rgba(0, 188, 212, 0.06);
    border-left-width: 4px;
  }
  analysis-section .analysis-final-title {
    border-bottom-color: rgba(0, 188, 212, 0.25);
    color: #2dd4d4;
  }
  analysis-section .analysis-final-text {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.10);
    color: #e8e8e8;
  }

  /* v3.4.57: шапка пациента и tags-секция переехали в новый клинический блок выше.
     Старые правила удалены чтобы не перебивать новый стиль. */

  /* ---------- 8. SUMMARY-TABLE (старая) — новый контраст ---------- */
  analysis-section .analysis-summary-tbl {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 4px;
    overflow: hidden;
  }
  analysis-section .analysis-summary-tbl th {
    background: rgba(0, 188, 212, 0.10);
    color: #2dd4d4;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.4px;
    padding: 8px 12px;
  }
  analysis-section .analysis-summary-tbl td {
    color: var(--text, #e8e8e8);
    padding: 7px 12px;
  }
  analysis-section .analysis-summary-tbl tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.025);
  }
  analysis-section .analysis-summary-tbl td:first-child {
    color: var(--text-sec, #b0b0b0);
    font-weight: 500;
  }

  /* ---------- 9. PRINT — упрощаем для бумаги ---------- */
  @media print {
    analysis-section .ac-card,
    analysis-section .analysis-rhythm-block,
    analysis-section .ac-rhythm-tachy,
    analysis-section .ac-pvc-stats,
    analysis-section .ac-settings-changes,
    analysis-section .analysis-events-details,
    analysis-section .analysis-final-conclusion,
    analysis-section .analysis-implant-date {
      background: #fff !important;
      border: 1px solid #888 !important;
      border-left: 3px solid #555 !important;
      color: #000 !important;
    }
    analysis-section table {
      background: #fff !important;
      border-color: #888 !important;
    }
    analysis-section table th {
      background: #f0f0f0 !important;
      color: #000 !important;
      border-color: #888 !important;
    }
    analysis-section table td {
      color: #000 !important;
      border-color: #ddd !important;
    }
    analysis-section table tbody tr:nth-child(even) td {
      background: #fafafa !important;
    }
  }

  /* ============================================================================
     UI v3.4.12 — плашка дашборда: переделана. Не серая решётка, а чёткие ячейки
     с тонкими светлыми разделителями. Каждая ячейка имеет свой ясный фон.
     ============================================================================ */

  /* Дашборд: тонкие разделители между 5 ячейками без серой плашки-фона */
  analysis-section .dash-grid {
    gap: 1px !important;
    background: rgba(0, 0, 0, 0.4) !important;  /* тёмный фон между ячейками */
    padding: 0 !important;
  }
  /* Ячейки: чёткий фон, не сливаются */
  analysis-section .dash-cell {
    background: var(--surface, #232931) !important;
  }
  /* Цветные акценты ячеек — чуть ярче для читаемости */
  analysis-section .dash-cell.dash-ok       { background: rgba(107, 209, 107, 0.08) !important; }
  analysis-section .dash-cell.dash-medium   { background: rgba(255, 212, 92, 0.10) !important; }
  analysis-section .dash-cell.dash-high     { background: rgba(255, 155, 107, 0.12) !important; }
  analysis-section .dash-cell.dash-critical { background: rgba(255, 82, 82, 0.14) !important; }

  /* Баннер "Требует внимания" — чёткое отделение от dash-grid */
  analysis-section .dash-overall {
    border-bottom: 1px solid rgba(255, 255, 255, 0.10) !important;
    padding: 14px 16px !important;
  }

  /* Промежутки между крупными карточками — больше воздуха */
  analysis-section .ac-dashboard,
  analysis-section .analysis-rhythm-block,
  analysis-section .ac-rhythm-tachy,
  analysis-section .ac-pvc-stats,
  analysis-section .ac-settings-changes,
  analysis-section .analysis-events-details,
  analysis-section .analysis-final-conclusion,
  analysis-section .analysis-implant-date,
  analysis-section .ac-rhythm-sensor,
  analysis-section .ac-autotests-block,
  analysis-section .critical-issues-banner,
  analysis-section .analysis-recs-block,
  analysis-section .analysis-trends-wrap {
    margin-top: 14px !important;
    margin-bottom: 14px !important;
  }

  /* v3.4.57: старые правила «больше воздуха» (margin-top: 22-32px, padding 24px)
     для h3/h4/.analysis-patient убраны. Они перебивали клинический-плотный
     дизайн нового блока. Текущие отступы заданы в v3.4.57 (стр ~1830). */

  /* Критические находки — баннер становится заметнее */
  analysis-section .critical-issues-banner {
    background: rgba(255, 82, 82, 0.06) !important;
    border: 1px solid rgba(255, 82, 82, 0.30) !important;
    border-left: 4px solid #ff5252 !important;
    padding: 14px 16px !important;
    border-radius: 6px !important;
  }

  /* Блок "Sensor (rate-response)" — синий акцент чтобы был отдельной секцией */
  analysis-section .ac-rhythm-sensor {
    background: rgba(0, 188, 212, 0.04);
    border: 1px solid rgba(0, 188, 212, 0.18);
    border-left: 4px solid #2dd4d4;
    border-radius: 6px;
    padding: 12px 14px;
  }

  /* Блок "Автотесты порогов" — синий */
  analysis-section .ac-autotests-block {
    background: rgba(0, 188, 212, 0.04);
    border: 1px solid rgba(0, 188, 212, 0.18);
    border-left: 4px solid #2dd4d4;
    border-radius: 6px;
    padding: 12px 14px;
  }

  /* Блок клинических рекомендаций — отдельная карточка */
  analysis-section .recommendations-list {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 6px;
    padding: 14px 16px;
  }

/* v3.4.17: Сопутствующая лекарственная терапия (раздел 2) */
.comed-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--head, #2dd4d4);
  margin: 18px 0 4px;
  padding-top: 14px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}
.comed-hint {
  font-size: 12px;
  color: var(--text-sec, #888);
  margin: 0 0 10px;
  line-height: 1.4;
}
.comed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.comed-group {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px 12px 10px;
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}
.comed-group legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sec, #aaa);
  padding: 0 6px;
}
.comed-group label {
  display: block;
  font-size: 13px;
  padding: 2px 0;
  cursor: pointer;
  line-height: 1.4;
}
.comed-group input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}
.comed-subgroup {
  margin-top: 4px;
  padding-left: 4px;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
  padding-left: 8px;
  margin-left: 2px;
}
.comed-subtitle {
  font-size: 11px;
  color: var(--text-sec, #888);
  display: block;
  margin: 4px 0 2px;
  font-style: italic;
}
.comed-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
}
.comed-inline-label {
  color: var(--text-sec, #aaa);
  white-space: nowrap;
  font-weight: normal;
}
.comed-num-inline {
  width: 70px;
  padding: 3px 6px;
  background: var(--input-bg, #1a1d22);
  color: var(--text, #e1e3e6);
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  font-size: 12px;
}
.comed-textarea {
  width: 100%;
  background: var(--input-bg, #1a1d22);
  color: var(--text, #e1e3e6);
  border: 1.5px solid var(--border, #444);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

/* CHA₂DS₂-VASc мини-калькулятор */
.cha2ds2-widget {
  margin-top: 16px;
  background: rgba(255, 152, 0, 0.06);
  border: 1px solid rgba(255, 152, 0, 0.35);
  border-radius: 8px;
  overflow: hidden;
}
.cha2ds2-head {
  padding: 8px 14px;
  background: rgba(255, 152, 0, 0.12);
  border-bottom: 1px solid rgba(255, 152, 0, 0.2);
  font-size: 14px;
}
.cha2ds2-hint {
  font-size: 12px;
  color: var(--text-sec, #888);
  font-style: italic;
  margin-left: 8px;
}
.cha2ds2-body {
  padding: 10px 14px;
  font-size: 13px;
}
.cha2ds2-auto {
  margin: 0 0 8px;
  color: var(--text-sec, #aaa);
  font-size: 12px;
}
.cha2ds2-auto b { color: var(--text, #e1e3e6); }
.cha2ds2-criteria label {
  display: block;
  padding: 3px 0;
  cursor: pointer;
  line-height: 1.4;
}
.cha2ds2-criteria input[type="checkbox"] {
  margin-right: 6px;
}
.cha2ds2-result {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 152, 0, 0.3);
  font-size: 14px;
}
.cha2ds2-total {
  font-size: 22px;
  font-weight: 700;
  color: #ff9800;
  margin: 0 4px;
}
.cha2ds2-verdict {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.cha2ds2-verdict.cha-indicated {
  color: #ff9800;
  font-weight: 600;
}
.cha2ds2-verdict.cha-low {
  color: var(--text-sec, #aaa);
}

@media print {
  .comed-group input[type="checkbox"]:not(:checked) { display: none; }
  .comed-group label:has(input:not(:checked)) { display: none; }
  .cha2ds2-widget { page-break-inside: avoid; }
}

/* ============================================================
   v3.4.17: РЕЖИМ «АРХИВ» — mobile-friendly read-only просмотр
   ============================================================ */

/* Видимость секций: в архив-режиме показываем только .archive-only */
body.mode-archive .section:not(.archive-only) { display: none !important; }
body.mode-archive .section.archive-only { display: block !important; }
body.mode-archive .top-nav-bar { display: none !important; }
body.mode-archive .header-date-wrap { display: none !important; }
body.mode-archive .signatures { display: none !important; }
body.mode-archive #statusBanners { display: none !important; }

/* Toolbar поиска */
.archive-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.archive-search {
  flex: 1 1 240px;
  min-width: 200px;
  padding: 10px 12px;
  background: var(--input-bg, #1a1d22);
  color: var(--text, #e1e3e6);
  border: 1.5px solid var(--border, #444);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.archive-search:focus {
  border-color: var(--accent, #2dd4d4);
  box-shadow: 0 0 0 2px rgba(0, 188, 212, 0.18);
}
.archive-filter-mode {
  padding: 9px 8px;
  background: var(--input-bg, #1a1d22);
  color: var(--text, #e1e3e6);
  border: 1.5px solid var(--border, #444);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.archive-btn {
  background: rgba(0, 188, 212, 0.12);
  color: var(--accent, #2dd4d4);
  border: 1px solid rgba(0, 188, 212, 0.4);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.archive-btn:hover { background: rgba(0, 188, 212, 0.22); }
.archive-btn-danger {
  color: #e57373;
  border-color: rgba(229, 115, 115, 0.4);
  background: rgba(229, 115, 115, 0.08);
}
.archive-btn-danger:hover { background: rgba(229, 115, 115, 0.18); }

/* Stats строка */
.archive-stats {
  font-size: 12px;
  color: var(--text-sec, #888);
  margin-bottom: 8px;
}
.archive-stats b { color: var(--text, #e1e3e6); }

/* Список карточек */
/* v3.4.22: .archive-list уже определён выше (строка 1182) для autocomplete-dropdown
   под полем ФИО — там position:absolute, left:0, right:0. Этот же класс
   используется ВНУТРИ archive-section custom-element-а для списка карточек —
   но там нужен обычный статичный контейнер. Без явного переопределения
   position/left/right карточки растягивались на всю ширину viewport и
   приклеивались к низу страницы. Скоупим под archive-section. */
archive-section .archive-list {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  max-height: none;
  overflow-y: visible;
  z-index: auto;
  box-shadow: none;
  border: none;
  background: transparent;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.archive-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  min-height: 300px;
  text-align: center;
  color: var(--text-sec, #9aa1a9);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.archive-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.archive-card:hover {
  border-color: rgba(0, 188, 212, 0.35);
  background: rgba(0, 188, 212, 0.04);
}
.archive-card-open {
  border-color: rgba(0, 188, 212, 0.5);
  background: rgba(0, 188, 212, 0.06);
}

.archive-card-head {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  align-items: center;
}
.archive-card-main { flex: 1 1 auto; min-width: 0; }
.archive-card-fio {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #e1e3e6);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-sec, #aaa);
  margin-bottom: 3px;
  align-items: center;
}
.archive-card-sub {
  font-size: 11px;
  color: var(--text-sec, #888);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-card-archived {
  font-style: italic;
  opacity: 0.8;
}
.archive-card-date { font-weight: 500; color: var(--text-sec, #c0c0c0); }

.archive-mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}
.archive-mode-implantation { background: rgba(76, 175, 80, 0.2); color: #81c784; }
.archive-mode-checkup      { background: rgba(63, 81, 181, 0.2); color: #7986cb; }
.archive-mode-analysis     { background: rgba(0, 188, 212, 0.2); color: #4dd0e1; }

.archive-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.archive-card-actions .archive-btn {
  padding: 0;
  font-size: 14px;
  min-width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.archive-card-detail {
  padding: 10px 14px 14px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  font-size: 13px;
  line-height: 1.5;
}
.archive-detail-loading,
.archive-detail-error {
  padding: 10px;
  color: var(--text-sec, #888);
  font-style: italic;
}
.archive-detail-error { color: #e57373; }

.archive-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 16px;
}
.archive-kv {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.06);
}
.archive-kv-lbl {
  color: var(--text-sec, #999);
  white-space: nowrap;
}
.archive-kv-val {
  color: var(--text, #e1e3e6);
  word-break: break-word;
}

.archive-detail-recs,
.archive-detail-drugs {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}
.archive-detail-recs ul {
  margin: 6px 0 0 18px;
  padding: 0;
}
.archive-detail-recs li { margin-bottom: 4px; }

.archive-hint {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-sec, #888);
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent, #2dd4d4);
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
}

/* ===== MOBILE / NARROW VIEWPORT ===== */
@media (max-width: 700px) {
  body.mode-archive .container { padding: 8px !important; }
  body.mode-archive .section { margin-bottom: 8px; border-radius: 6px; }
  body.mode-archive .section-header { padding: 10px 12px; font-size: 15px; }
  body.mode-archive .section-body { padding: 10px; }

  /* Toolbar: search на всю ширину, фильтр + кнопка в строке */
  .archive-toolbar { flex-wrap: wrap; }
  .archive-search { flex-basis: 100%; }

  /* Карточка более компактная */
  .archive-card-head {
    flex-wrap: wrap;
    padding: 8px 10px;
  }
  .archive-card-fio { font-size: 14px; white-space: normal; }
  .archive-card-actions {
    flex-basis: 100%;
    justify-content: flex-end;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 6px;
    margin-top: 4px;
  }
  /* Detail: одна колонка */
  .archive-detail-grid { grid-template-columns: 1fr; }
}

/* В режиме archive — header более компактный для маленьких экранов */
body.mode-archive .header {
  padding: 10px 14px !important;
}
body.mode-archive .header h1 {
  font-size: 18px;
}

/* Печать архива не должна показывать кнопки */
@media print {
  body.mode-archive .archive-toolbar,
  body.mode-archive .archive-card-actions,
  body.mode-archive .archive-hint { display: none !important; }
  .archive-card { break-inside: avoid; }
}

/* ============================================================
   v3.4.17: КАЛЬКУЛЯТОР РЕСУРСА БАТАРЕИ (battery slider)
   ============================================================ */
.bs-block {
  margin: 14px 0 18px;
  padding: 12px 14px;
  background: rgba(255, 193, 7, 0.04);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 8px;
}
.bs-header {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text, #e1e3e6);
}
.bs-hint {
  font-size: 11px;
  color: var(--text-sec, #888);
  font-style: italic;
  margin-left: 6px;
}
.bs-body { font-size: 13px; }

.bs-row {
  margin-bottom: 10px;
}
.bs-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text, #e1e3e6);
}
.bs-label b { color: var(--accent, #2dd4d4); font-size: 15px; }
.bs-cur {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-sec, #888);
  font-style: italic;
}
.bs-slider {
  display: block;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    rgba(67, 160, 71, 0.5) 0%,
    rgba(255, 152, 0, 0.5) 60%,
    rgba(229, 57, 53, 0.5) 100%);
  outline: none;
  cursor: pointer;
}
.bs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--accent, #2dd4d4);
  border: 2px solid var(--bg, #1e1e2e);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.bs-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--accent, #2dd4d4);
  border: 2px solid var(--bg, #1e1e2e);
  border-radius: 50%;
  cursor: grab;
}

.bs-result {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border-top: 2px solid rgba(255, 193, 7, 0.2);
}
.bs-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
.bs-result-lbl {
  color: var(--text-sec, #aaa);
}
.bs-current-years,
.bs-new-years {
  font-size: 16px;
  color: var(--text, #e1e3e6);
  font-weight: 600;
}
.bs-new-years { color: var(--accent, #2dd4d4); }
.bs-delta {
  font-size: 13px;
  font-weight: 600;
}
.bs-delta-up   { color: #4caf50; }
.bs-delta-down { color: #e57373; }
.bs-delta-flat { color: var(--text-sec, #888); font-weight: normal; font-style: italic; }
.bs-power {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-sec, #888);
  font-family: monospace;
}

.bs-disclaimer {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-sec, #999);
  background: rgba(255, 152, 0, 0.06);
  border-left: 3px solid rgba(255, 152, 0, 0.5);
  border-radius: 0 4px 4px 0;
}
.bs-disclaimer b { color: #ff9800; }

/* Печать: показываем расчёт без слайдера */
@media print {
  .bs-slider { display: none; }
  .bs-cur, .bs-hint { display: none; }
  .bs-disclaimer { font-size: 9pt; }
  .bs-block { break-inside: avoid; }
}

/* v3.4.17: Секция 10 (Памятка пациенту) при печати ВСЕГДА начинается с новой страницы.
   Соответствует рекомендации клинического фармаколога: врач оставляет технический
   протокол в карте, аккуратный лист с памяткой отрывает и отдаёт пациенту. */
@media print {
  .section[data-sec="10"] {
    page-break-before: always;
    break-before: page;
  }
}

/* ==========================================================================
   v3.4.25 — LIGHT THEME OVERRIDES для analysis-section
   Раньше CSS analysis-section использовал rgba(255,255,255,...) для фонов и
   светлые цвета для текста. На светлой теме это давало белый-на-белом и
   нечитаемые заголовки. Здесь — явные тёмные цвета на светлом фоне.
   ========================================================================== */

/* Основной текст карточек */
body.light-theme analysis-section,
body.light-theme analysis-section p,
body.light-theme analysis-section div,
body.light-theme analysis-section span:not([class*="badge"]):not([class*="status"]) {
  color: #1a1f2e;
}

/* Заголовки секций — тёмно-синие на белом */
body.light-theme analysis-section .ac-rhythm-section-title,
body.light-theme analysis-section .analysis-final-title,
body.light-theme analysis-section h3,
body.light-theme analysis-section h4,
body.light-theme analysis-section h5 {
  color: #0a3d52 !important;
  border-bottom-color: #d5dde5 !important;
}

/* Цветовые акценты заголовков — насыщеннее под светлый фон */
body.light-theme analysis-section .analysis-rhythm-block .ac-rhythm-section-title { color: #006978 !important; }
body.light-theme analysis-section .ac-rhythm-tachy .ac-rhythm-section-title       { color: #c4441e !important; }
body.light-theme analysis-section .ac-pvc-stats h4,
body.light-theme analysis-section .ac-pvc-stats h5,
body.light-theme analysis-section .ac-pvc-stats .ac-rhythm-section-title          { color: #c4441e !important; }
body.light-theme analysis-section .ac-settings-changes .ac-rhythm-section-title   { color: #856200 !important; }

/* Фоны блоков — светло-серые с цветовой акцентной полоской слева */
body.light-theme analysis-section .ac-card,
body.light-theme analysis-section .ac-rhythm-meta,
body.light-theme analysis-section .analysis-rhythm-block,
body.light-theme analysis-section .analysis-final-conclusion {
  background: #eef7fa !important;
  border-color: #b8dde5 !important;
  border-left-color: #006978 !important;
}
/* v3.4.27: .analysis-implant-date — это контейнер inline-полей (ФИО/ДР/Имплантация),
   в светлой теме НЕ должен иметь голубой фон — на нём лейблы и плейсхолдеры
   становились невидимы. Делаем нейтральный фон с лёгкой рамкой. */
body.light-theme analysis-section .analysis-implant-date {
  background: #f7f9fb !important;
  border: 1px solid #d5dde5 !important;
  border-left: 3px solid #006978 !important;
  border-radius: 4px !important;
}
body.light-theme analysis-section .ac-rhythm-tachy,
body.light-theme analysis-section .ac-pvc-stats,
body.light-theme analysis-section .analysis-events-details,
body.light-theme analysis-section details.analysis-events-details {
  background: #fff2eb !important;
  border-color: #ffc9ad !important;
  border-left-color: #c4441e !important;
}
body.light-theme analysis-section .ac-settings-changes {
  background: #fff8e1 !important;
  border-color: #f5d97f !important;
  border-left-color: #856200 !important;
}
body.light-theme analysis-section .critical-issues-banner {
  background: #fdecea !important;
  border-color: #f5b5b0 !important;
  border-left-color: #c62828 !important;
}

/* v3.4.27: лейблы и инпуты inline-полей в светлой теме — явно тёмные. */
body.light-theme analysis-section .analysis-implant-date-label {
  color: #1a1f2e !important;
}
body.light-theme analysis-section .analysis-implant-date-input {
  background: #fff !important;
  color: #1a1f2e !important;
  border: 1px solid #b5c0cc !important;
}
body.light-theme analysis-section .analysis-implant-date-input::placeholder {
  color: #8a96a4 !important;
}
body.light-theme analysis-section .analysis-implant-date-src {
  color: #6a7585 !important;
}
body.light-theme analysis-section .analysis-implant-date-phase {
  color: #006978 !important;
}
body.light-theme analysis-section .analysis-implant-date-hint {
  color: #4a5260 !important;
}

/* Dashboard «Требует внимания» — фоны и текст */
body.light-theme analysis-section .dash-overall {
  background: #fff8e1 !important;
  border-bottom-color: #e0c060 !important;
  color: #5a4500 !important;
}
body.light-theme analysis-section .dash-cell {
  background: #f7f9fb !important;
  border-color: #d5dde5 !important;
  color: #1a1f2e !important;
}
body.light-theme analysis-section .dash-cell.dash-medium   { background: #fff8e1 !important; border-color: #e0c060 !important; }
body.light-theme analysis-section .dash-cell.dash-high     { background: #fff2eb !important; border-color: #ffaa80 !important; }
body.light-theme analysis-section .dash-cell.dash-critical { background: #fdecea !important; border-color: #f5a098 !important; }
/* v3.4.27: ВАЖНО — правильные имена классов из HTML: .dash-cell-label / .dash-cell-value
   (а не .dash-label / .dash-value как было ошибочно). Метрика «72% A» жёлтый
   текст на жёлтом фоне получалась именно из-за того что override не срабатывал. */
body.light-theme analysis-section .dash-cell .dash-cell-label  { color: #4a5260 !important; }
body.light-theme analysis-section .dash-cell .dash-cell-value  { color: #1a1f2e !important; }
body.light-theme analysis-section .dash-cell.dash-medium   .dash-cell-value { color: #6a4a00 !important; }
body.light-theme analysis-section .dash-cell.dash-high     .dash-cell-value { color: #8a2c00 !important; }
body.light-theme analysis-section .dash-cell.dash-critical .dash-cell-value { color: #8a0e0e !important; }

/* Шапка пациента и метаданные */
body.light-theme analysis-section .analysis-patient-header,
body.light-theme analysis-section .analysis-patient h4 {
  color: #006978 !important;
}
body.light-theme analysis-section .analysis-patient-meta,
body.light-theme analysis-section .analysis-patient-tags {
  color: #4a5260 !important;
}

/* Inline-поля «ФИО / ДР / Имплантация» — нормальные input-цвета */
body.light-theme analysis-section .analysis-inline-input {
  background: #fff !important;
  color: #1a1f2e !important;
  border-color: #c5d0db !important;
}
body.light-theme analysis-section .analysis-from-export {
  color: #6a7585 !important;
}

/* Заголовки секций (h3/h4) — общая граница снизу */
body.light-theme analysis-section h3:not(.analysis-final-title):not(.analysis-patient-header),
body.light-theme analysis-section h4 {
  border-bottom-color: #d5dde5 !important;
}

/* Привязка к архиву — зелёный текст ярче */
body.light-theme analysis-section .analysis-link-found    { color: #1b6e2a !important; }
body.light-theme analysis-section .analysis-link-notfound { color: #856200 !important; }

/* Заголовок «АНАЛИЗ ВЫГРУЗКИ ПРОГРАММАТОРА» в шапке (mode-switcher) */
body.light-theme #modeSwitcherLabel { color: #0a3d52 !important; }

/* ============================================================================
 * v3.4.59: КЛИНИЧЕСКИЙ РЕДИЗАЙН analysis-section (CSS variables + базовая типографика)
 * ============================================================================ */

analysis-section,
analysis-section.analysis-section {
  --ans-bg:        #0e1419;
  --ans-panel:     #161c23;
  --ans-panel-2:   #1a212a;
  --ans-border:    rgba(255,255,255,.06);
  --ans-border-2:  rgba(255,255,255,.10);
  --ans-text:      #d6dde4;
  --ans-text-dim:  #8b9aa7;
  --ans-text-mute: #5d6d7a;
  --ans-accent:    #ffb74d;
  --ans-link:      #4fc3f7;
  --ans-ok:        #66bb6a;
  --ans-warn:      #ffa726;
  --ans-crit:      #ef5350;
  --ans-info:      #42a5f5;
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

analysis-section h3,
analysis-section h4 {
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  color: var(--ans-accent) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  margin: 14px 0 6px 0 !important;
  padding: 0 0 4px 0 !important;
  border-bottom: 1px solid var(--ans-border) !important;
}

analysis-section .analysis-patient-header,
analysis-section h3.analysis-patient-header {
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--ans-link) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  border-bottom: none !important;
  padding: 0 !important;
  margin: 0 0 2px 0 !important;
}

analysis-section h2,
analysis-section .analysis-final-title {
  color: var(--ans-link) !important;
  font-size: 13px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.8px !important;
  font-weight: 600 !important;
  margin: 18px 0 8px 0 !important;
  padding-bottom: 4px !important;
  border-bottom: 1px solid var(--ans-border-2) !important;
}

analysis-section .analysis-stats-bar {
  background: var(--ans-panel) !important;
  border: 1px solid var(--ans-border) !important;
  border-radius: 2px !important;
  padding: 5px 12px !important;
  margin: 0 0 8px 0 !important;
  font-size: 11px !important;
  color: var(--ans-text-dim) !important;
  gap: 16px !important;
  font-family: ui-monospace, "SF Mono", Consolas, monospace !important;
}
analysis-section .analysis-stats-bar b {
  color: var(--ans-text) !important;
  font-weight: 600 !important;
  margin-right: 4px !important;
}

analysis-section .analysis-patient {
  background: transparent !important;
  margin-top: 14px !important;
  padding: 12px 14px !important;
  border: 1px solid var(--ans-border) !important;
  border-left: 3px solid var(--ans-link) !important;
  border-top-color: var(--ans-border) !important;
  border-radius: 2px !important;
}
analysis-section .analysis-patient:first-of-type { margin-top: 0 !important; }

analysis-section .analysis-patient-meta {
  color: var(--ans-text-mute) !important;
  font-size: 12px !important;
}
analysis-section .analysis-patient-tags {
  color: var(--ans-text-dim) !important;
  font-size: 11px !important;
  margin: 4px 0 8px 0 !important;
  font-family: ui-monospace, "SF Mono", Consolas, monospace !important;
}

analysis-section .analysis-action-btn,
analysis-section .pt-zoom-btn {
  background: var(--ans-panel-2) !important;
  color: var(--ans-text) !important;
  border: 1px solid var(--ans-border-2) !important;
  border-radius: 2px !important;
  padding: 4px 12px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  letter-spacing: 0.3px !important;
  cursor: pointer;
}
analysis-section .pt-zoom-active {
  background: rgba(79,195,247,.15) !important;
  border-color: var(--ans-link) !important;
  color: var(--ans-link) !important;
}

analysis-section .critical-issues-banner {
  background: linear-gradient(90deg, rgba(239,83,80,.14), rgba(239,83,80,.04)) !important;
  border: 1px solid rgba(239,83,80,.3) !important;
  border-left: 4px solid var(--ans-crit) !important;
  border-radius: 2px !important;
  padding: 10px 14px !important;
}

analysis-section .pt-block,
analysis-section .ac-block,
analysis-section .analysis-card,
analysis-section .ac-rhythm-sensor,
analysis-section .ac-autotests-block,
analysis-section .analysis-rhythm-block,
analysis-section .ac-rhythm-tachy,
analysis-section .ac-pvc-stats,
analysis-section .ac-settings-changes,
analysis-section .analysis-events-details,
analysis-section .analysis-final-conclusion,
analysis-section .analysis-implant-date {
  background: var(--ans-panel) !important;
  border: 1px solid var(--ans-border) !important;
  border-radius: 2px !important;
  padding: 12px 14px !important;
}

analysis-section .analysis-link {
  font-size: 11px !important;
  color: var(--ans-text-dim) !important;
  font-family: ui-monospace, "SF Mono", Consolas, monospace !important;
}
analysis-section .analysis-link-found  { color: var(--ans-ok) !important; }
analysis-section .analysis-link-none   { color: var(--ans-warn) !important; }

analysis-section .analysis-trends-tbl thead th {
  background: rgba(79,195,247,.08) !important;
  color: var(--ans-link) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.4px !important;
}

/* ============================================================================
 * v4.0.0: PATIENT-PANEL — горизонтальная клиническая шапка пациента
 * ============================================================================ */

analysis-section .patient-panel-v4 {
  background: linear-gradient(180deg, var(--ans-panel-2) 0%, var(--ans-panel) 100%);
  border: 1px solid var(--ans-border) !important;
  border-top: 1px solid var(--ans-border) !important;
  border-radius: 14px !important;
  padding: 22px 24px !important;
  margin: 0 0 18px 0 !important;
  overflow: hidden;
  display: flex !important;
  flex-direction: column !important;
}
analysis-section .pp-row-primary {
  order: 1;
  padding: 0 !important;
  background: transparent !important;
  border-bottom: none !important;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
analysis-section .pp-name {
  font-size: 24px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  color: var(--ans-text);
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}
analysis-section .pp-name-missing {
  color: var(--ans-text-mute);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
}
analysis-section .pp-id {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--ans-text-dim);
  flex-shrink: 0;
}
analysis-section .pp-id-label {
  color: var(--ans-text-mute);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}
analysis-section .pp-row-meta {
  order: 3;
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--ans-border);
  border: 1px solid var(--ans-border);
  border-radius: 10px;
  overflow: hidden;
}
analysis-section .pp-meta-item {
  padding: 14px 16px;
  border-right: none !important;
  background: var(--ans-panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
analysis-section .pp-meta-item:last-child { border-right: none; }
analysis-section .pp-meta-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ans-text-mute);
  font-weight: 600;
}
analysis-section .pp-meta-value {
  font-size: 14px;
  color: var(--ans-text);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}
analysis-section .pp-row-badges {
  order: 2;
  padding: 14px 0 0 0 !important;
  background: transparent !important;
  border-top: none !important;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
analysis-section .pp-badge {
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0.2px;
  font-weight: 600;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
analysis-section .pp-badge-ok    { color: var(--ans-ok);   border-color: rgba(102,187,106,.35); background: rgba(102,187,106,.08); }
analysis-section .pp-badge-warn  { color: var(--ans-warn); border-color: rgba(255,167,38,.35); background: rgba(255,167,38,.08); }
analysis-section .pp-badge-crit  { color: var(--ans-crit); border-color: rgba(239,83,80,.35); background: rgba(239,83,80,.08); }
analysis-section .pp-badge-info  { color: var(--ans-link); border-color: rgba(79,195,247,.35); background: rgba(79,195,247,.08); }
analysis-section .pp-badge-archive {
  color: var(--ans-text-dim);
  border-color: var(--ans-border-2);
  background: var(--ans-panel);
}
analysis-section .pp-badge-spinner {
  animation: pp-spinner-pulse 1.2s ease-in-out infinite;
  font-weight: 700;
}
@keyframes pp-spinner-pulse { 0%, 100% { opacity: 0.3 } 50% { opacity: 1 } }

/* ============================================================================
 * v4.0.2: STICKY SECTION NAVIGATION
 * ============================================================================ */

analysis-section .pp-section-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 20, 25, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-bottom: 1px solid var(--ans-border);
  border-radius: 0;
  padding: 0;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  margin: 0 0 18px 0;
  box-shadow: none;
}
analysis-section .pp-section-nav-link {
  flex-shrink: 0;
  padding: 12px 14px;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0.2px;
  color: var(--ans-text-dim);
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  transition: color .15s, border-color .15s;
}
analysis-section .pp-section-nav-link:hover {
  color: var(--ans-text);
  background: transparent;
  border-bottom-color: var(--ans-border);
}
analysis-section .pp-section-nav-link.active {
  background: transparent;
  color: var(--ans-link);
  border-bottom: 2px solid var(--ans-link);
  font-weight: 600;
  box-shadow: none;
}
analysis-section h3[id],
analysis-section h4[id] { scroll-margin-top: 60px; }

/* ============================================================================
 * v4.0.3: KPI-TILE редизайн dash-grid
 * ============================================================================ */

analysis-section .dash-grid {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 14px !important;
  background: transparent !important;
}
/* v4.0.16: ЧИСТЫЕ ячейки. Раньше rgba-tinted фоны (rgba(255,167,38,.03)
 * и т.д.) накладывались на panel — получался мутный коричнево-серый.
 * Теперь: один чистый panel-цвет на все ячейки + цветной левый бордер
 * показывает статус. Главное значение — цветной текст по статусу. */
analysis-section .dash-cell {
  background: var(--ans-panel) !important;
  padding: 16px 18px 16px 20px !important;
  min-height: 92px;
  display: flex !important;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--ans-border) !important;
  border-left: 4px solid var(--ans-text-mute) !important;
  border-radius: 14px !important;
}
analysis-section .dash-cell.dash-ok       { border-left-color: var(--ans-ok) !important; }
analysis-section .dash-cell.dash-medium   { border-left-color: #ffd54f !important; }
analysis-section .dash-cell.dash-high     { border-left-color: var(--ans-warn) !important; }
analysis-section .dash-cell.dash-critical { border-left-color: var(--ans-crit) !important; }

/* Перебиваем СТАРЫЕ tinted-фоны из блока 2237+ и 3432+ (rgba-наложения
 * давали мутность). Принудительно один чистый panel-цвет. */
analysis-section .dash-cell,
analysis-section .dash-cell.dash-ok,
analysis-section .dash-cell.dash-medium,
analysis-section .dash-cell.dash-high,
analysis-section .dash-cell.dash-critical {
  background: var(--ans-panel) !important;
}

analysis-section .dash-cell-head {
  display: flex !important;
  align-items: center;
  gap: 6px;
}
analysis-section .dash-cell-label {
  font-size: 10px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.8px !important;
  color: var(--ans-text-dim) !important;
  flex: 1;
}
analysis-section .dash-cell-domain-icon { font-size: 14px; }
analysis-section .dash-cell-status { font-size: 13px; flex-shrink: 0; }

analysis-section .dash-kpi-main {
  font-size: 22px;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--ans-text);
  line-height: 1.2;
  letter-spacing: -0.2px;
}
analysis-section .dash-cell.dash-ok       .dash-kpi-main { color: var(--ans-ok); }
analysis-section .dash-cell.dash-medium   .dash-kpi-main { color: #ffd54f; }
analysis-section .dash-cell.dash-high     .dash-kpi-main { color: var(--ans-warn); }
analysis-section .dash-cell.dash-critical .dash-kpi-main { color: var(--ans-crit); }

/* Для случая когда нет split на main+subs (старый рендер с одной строкой) */
analysis-section .dash-cell-value {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--ans-text) !important;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
analysis-section .dash-cell.dash-ok       .dash-cell-value { color: var(--ans-ok) !important; }
analysis-section .dash-cell.dash-medium   .dash-cell-value { color: #ffd54f !important; }
analysis-section .dash-cell.dash-high     .dash-cell-value { color: var(--ans-warn) !important; }
analysis-section .dash-cell.dash-critical .dash-cell-value { color: var(--ans-crit) !important; }

analysis-section .dash-kpi-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}
analysis-section .dash-kpi-sub {
  font-size: 10px;
  font-weight: 500;
  font-family: ui-monospace, monospace;
  color: var(--ans-text-dim);
  padding: 2px 7px;
  background: var(--ans-panel-2);
  border-radius: 6px;
  border: 1px solid var(--ans-border-2);
  white-space: nowrap;
}

/* ============================================================================
 * v4.0.1: МОБИЛЬНАЯ АДАПТАЦИЯ ТАБЛИЦ + v4.0.5 padding compression
 * ============================================================================ */

@media (max-width: 768px) {
  .container { padding: 8px 0 30px !important; }
  .section-body { padding: 8px 6px 10px !important; }
  .section-body.hidden { padding: 0 6px !important; }

  analysis-section .analysis-patient { padding: 8px 4px !important; border-left-width: 2px !important; }
  analysis-section .pt-block,
  analysis-section .ac-block,
  analysis-section .analysis-card,
  analysis-section .ac-rhythm-sensor,
  analysis-section .ac-autotests-block,
  analysis-section .analysis-rhythm-block,
  analysis-section .ac-rhythm-tachy,
  analysis-section .ac-pvc-stats,
  analysis-section .ac-settings-changes,
  analysis-section .analysis-events-details,
  analysis-section .analysis-final-conclusion,
  analysis-section .analysis-implant-date,
  analysis-section .critical-issues-banner {
    padding: 8px 8px !important;
  }

  analysis-section .ac-settings-changes-table { display: block; border: none !important; }
  analysis-section .ac-settings-changes-table thead { display: none; }
  analysis-section .ac-settings-changes-table tbody,
  analysis-section .ac-settings-changes-table tr { display: block; }
  analysis-section .ac-settings-changes-table tr {
    background: var(--ans-panel) !important;
    border: 1px solid var(--ans-border) !important;
    border-radius: 2px;
    margin-bottom: 6px;
    padding: 8px 10px;
  }
  analysis-section .ac-settings-changes-table td { display: block; border: none !important; padding: 0 !important; font-size: 11px !important; }
  analysis-section .ac-settings-changes-table td:nth-child(1) { font-size: 12px !important; font-weight: 600; color: var(--ans-text) !important; margin-bottom: 4px; }
  analysis-section .ac-settings-changes-table td:nth-child(2),
  analysis-section .ac-settings-changes-table td:nth-child(3) { display: inline-block; padding: 3px 8px !important; border: 1px solid var(--ans-border-2) !important; border-radius: 2px; margin-right: 6px; font-family: ui-monospace, monospace !important; }
  analysis-section .ac-settings-changes-table td:nth-child(2)::before { content: 'было: '; color: var(--ans-text-mute); font-size: 9px; text-transform: uppercase; margin-right: 4px; }
  analysis-section .ac-settings-changes-table td:nth-child(3) { color: var(--ans-warn) !important; border-color: rgba(255,167,38,.3) !important; background: rgba(255,167,38,.06) !important; }
  analysis-section .ac-settings-changes-table td:nth-child(3)::before { content: '→ стало: '; color: var(--ans-text-mute); font-size: 9px; text-transform: uppercase; margin-right: 4px; }

  analysis-section .analysis-autotests-tbl,
  analysis-section .analysis-autotests-events-tbl {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap;
    width: 100%;
  }
  analysis-section .analysis-autotests-tbl thead,
  analysis-section .analysis-autotests-tbl tbody,
  analysis-section .analysis-autotests-events-tbl thead,
  analysis-section .analysis-autotests-events-tbl tbody { display: table; width: max-content; min-width: 100%; }
  analysis-section .analysis-autotests-tbl th,
  analysis-section .analysis-autotests-tbl td,
  analysis-section .analysis-autotests-events-tbl th,
  analysis-section .analysis-autotests-events-tbl td {
    display: table-cell !important;
    white-space: nowrap !important;
    padding: 4px 8px !important;
    font-size: 10px !important;
  }

  analysis-section .pp-row-primary { flex-direction: column; gap: 4px; padding: 8px 12px; }
  analysis-section .pp-name { font-size: 15px; }
  analysis-section .pp-row-meta { grid-template-columns: 1fr 1fr; }
  analysis-section .pp-meta-item { padding: 6px 10px; }
  analysis-section .pp-section-nav { padding: 3px 6px; }
  analysis-section .pp-section-nav-link { padding: 4px 8px; font-size: 9px; }
  analysis-section .dash-grid { grid-template-columns: repeat(2, 1fr) !important; }
  analysis-section .dash-cell { padding: 8px 10px !important; min-height: 78px; }
  analysis-section .dash-kpi-main { font-size: 14px; }
  analysis-section .dash-kpi-sub { font-size: 9px; padding: 1px 5px; }
}

@media (max-width: 420px) {
  .container { padding: 6px 0 24px !important; }
  .section-body { padding: 6px 4px 8px !important; }
  analysis-section .analysis-patient { padding: 6px 3px !important; }
  analysis-section .pp-row-meta { grid-template-columns: 1fr; }
  analysis-section .dash-grid { grid-template-columns: 1fr !important; }
}

@media print {
  analysis-section .pp-section-nav { display: none !important; }
  analysis-section .patient-panel-v4 { background: #fff !important; border-color: #888 !important; }
  analysis-section .pp-row-primary,
  analysis-section .pp-row-meta,
  analysis-section .pp-row-badges { background: #fff !important; }
  analysis-section .pp-meta-value { color: #000 !important; }
}

body.light-theme analysis-section {
  --ans-bg: #ffffff;
  --ans-panel: #f5f7fa;
  --ans-panel-2: #ebeff5;
  --ans-border: rgba(0,0,0,.08);
  --ans-border-2: rgba(0,0,0,.14);
  --ans-text: #1a242e;
  --ans-text-dim: #4a5868;
  --ans-text-mute: #7b8a98;
  --ans-accent: #e0750a;
  --ans-link: #0288d1;
}

/* ============================================================================
   v4.0.21: HERO пустого состояния анализатора выгрузки (режим analysis).
   Тёмный фон, тонкая типографика, синий акцент, кардио-ретикул. Токены --ans-*.
   ============================================================================ */
analysis-section .ans-hero{position:relative;max-width:680px;margin:0 auto;
  padding:clamp(26px,5vw,52px) 22px 40px;text-align:center;
  animation:ansHeroFade .55s cubic-bezier(.2,.7,.2,1) both}
@keyframes ansHeroFade{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}

analysis-section .ans-reticle{width:180px;margin:0 auto 22px;line-height:0}
analysis-section .ans-reticle svg{width:100%;height:auto;display:block}
analysis-section .ans-dev{fill:none;stroke:var(--ans-link);stroke-width:2;stroke-linejoin:round;stroke-linecap:round;
  filter:drop-shadow(0 0 4px rgba(79,195,247,.45))}
analysis-section .ans-dev-tip{fill:var(--ans-link)}

analysis-section .ans-eyebrow{font-size:10.5px;letter-spacing:4px;text-transform:uppercase;
  color:var(--ans-text-mute);font-weight:500;margin-bottom:18px}
analysis-section .ans-lede{font-size:clamp(17px,3.4vw,22px);font-weight:300;line-height:1.45;
  color:var(--ans-text);max-width:520px;margin:0 auto;letter-spacing:.1px}
analysis-section .ans-lede b{font-weight:500;color:var(--ans-link)}
analysis-section .ans-meta{margin:14px auto 0;max-width:500px;font-size:12.5px;color:var(--ans-text-dim);line-height:1.6}
analysis-section .ans-meta code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;
  color:var(--ans-link);background:rgba(79,195,247,.08);padding:1px 6px;border-radius:5px}

analysis-section .ans-dz{margin:32px auto 0;max-width:520px;border:1px dashed var(--ans-border-2);border-radius:20px;
  background:linear-gradient(180deg,rgba(255,255,255,.018),rgba(255,255,255,0));padding:40px 28px;cursor:pointer;
  transition:.2s cubic-bezier(.2,.7,.2,1);position:relative}
analysis-section .ans-dz:hover{border-color:rgba(79,195,247,.45);background:rgba(79,195,247,.03)}
analysis-section .ans-dz.drag{border-color:var(--ans-link);background:rgba(79,195,247,.06);
  box-shadow:0 0 0 5px rgba(79,195,247,.10),0 18px 50px rgba(0,0,0,.45);transform:translateY(-2px)}
analysis-section .ans-dz-ic{width:54px;height:54px;margin:0 auto 16px;border-radius:50%;display:grid;place-items:center;
  background:rgba(79,195,247,.14);border:1px solid rgba(79,195,247,.22);transition:.2s}
analysis-section .ans-dz.drag .ans-dz-ic{transform:translateY(-3px) scale(1.06)}
analysis-section .ans-dz-ic svg{width:24px;height:24px;stroke:var(--ans-link);fill:none;stroke-width:1.6}
analysis-section .ans-dz-t{font-size:15px;font-weight:500;color:var(--ans-text);letter-spacing:.1px}
analysis-section .ans-dz-s{font-size:12.5px;color:var(--ans-text-dim);margin-top:5px}
analysis-section .ans-dz-alt{margin-top:16px;display:inline-block;padding:6px 15px;border-radius:8px;background:transparent;
  border:1px solid var(--ans-border-2);color:var(--ans-text-dim);font-size:12px;cursor:pointer;transition:.15s;font-family:inherit}
analysis-section .ans-dz-alt:hover{border-color:var(--ans-link);color:var(--ans-link)}
analysis-section .ans-dz-fmt{margin-top:18px;display:flex;gap:7px;justify-content:center;flex-wrap:wrap}
analysis-section .ans-dz-fmt span{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;letter-spacing:1px;
  color:var(--ans-text-mute);border:1px solid var(--ans-border);border-radius:6px;padding:3px 9px}

/* ============================================================
   v5-port: анализ динамики (rb-tan-*) + уточнение модели (rb-fda-*).
   Палитра — переменные темы v4, корректно в тёмной и светлой теме.
   ============================================================ */
.rb-tan { margin-top: 16px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.rb-tan-h { font-weight: 600; color: var(--text); margin-bottom: 10px; }
.rb-tan-cap { font-weight: 400; font-size: 12px; color: var(--text-sec); margin-left: 6px; }
.rb-tan-banner { padding: 8px 11px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.rb-tan-banner.st-ok { background: var(--success-bg); color: var(--success); }
.rb-tan-banner.st-info { background: rgba(95,170,232,.12); color: #5faae8; }
.rb-tan-banner.st-warn { background: var(--warning-bg); color: var(--warning); }
.rb-tan-banner.st-crit { background: var(--danger-bg); color: var(--danger); }
.rb-tan-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 7px 10px; border-left: 3px solid var(--border); border-radius: 6px; background: var(--surface); margin-bottom: 6px; }
.rb-tan-row.st-warn { border-left-color: var(--warning); }
.rb-tan-row.st-crit { border-left-color: var(--danger); }
.rb-tan-row.st-info { border-left-color: #5faae8; }
.rb-tan-ico { font-size: 13px; line-height: 1.2; }
.rb-tan-row.st-warn .rb-tan-ico { color: var(--warning); }
.rb-tan-row.st-crit .rb-tan-ico { color: var(--danger); }
.rb-tan-lbl { font-weight: 600; color: var(--text); }
.rb-tan-val { color: var(--text); }
.rb-tan-delta { font-size: 12px; color: var(--text-sec); background: var(--surface-alt); padding: 1px 7px; border-radius: 999px; }
.rb-tan-note { flex-basis: 100%; font-size: 12px; color: var(--text-sec); }
.rb-tan-line { display: flex; gap: 9px; align-items: flex-start; padding: 9px 10px; border-radius: 6px; background: var(--surface); margin-top: 6px; border-left: 3px solid var(--border); font-size: 13px; color: var(--text); }
.rb-tan-line.st-warn { border-left-color: var(--warning); }
.rb-tan-line.st-crit { border-left-color: var(--danger); }
.rb-tan-line.st-info { border-left-color: #5faae8; }
.rb-tan-flag { font-size: 12px; color: var(--danger); background: var(--danger-bg); padding: 1px 7px; border-radius: 999px; margin-left: 8px; }

.rb-fda { margin-top: 12px; }
.rb-fda-btn { background: transparent; border: 1px solid var(--accent-dark); color: var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.rb-fda-btn:hover { background: var(--surface-alt); }
.rb-fda-btn:disabled { opacity: .6; cursor: default; }
.rb-fda-result { margin-top: 8px; }
.rb-fda-load, .rb-fda-empty { font-size: 13px; color: var(--text-sec); }
.rb-fda-card { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-width: 560px; margin-top: 8px; }
.rb-fda-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 8px; }
.rb-fda-row { display: flex; gap: 12px; padding: 3px 0; font-size: 13px; }
.rb-fda-k { color: var(--text-sec); flex: 0 0 42%; }
.rb-fda-v { color: var(--text); flex: 1; }
.rb-fda-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; }

/* v5-port: уточнение модели в шапке пациента + модалка FDA */
.pp-mri-badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-light); color: var(--accent); margin-left: 4px; vertical-align: middle; }
.pp-fda-link { display: inline-block; margin-left: 6px; padding: 1px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-sec); cursor: pointer; vertical-align: middle; }
.pp-fda-link:hover { border-color: var(--accent); color: var(--accent); }
.rb-fda-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(620px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.rb-fda-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text); }
.rb-fda-close { background: transparent; border: none; color: var(--text-sec); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.rb-fda-close:hover { background: var(--surface-alt); color: var(--text); }
.rb-fda-modal-body { padding: 16px; }
.rb-fda-online-btn { margin-top: 12px; background: transparent; border: 1px solid var(--accent-dark); color: var(--accent); border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.rb-fda-online-btn:hover { background: var(--surface-alt); }
.rb-fda-online-btn:disabled { opacity: .6; cursor: default; }
.rb-fda-online-result { margin-top: 8px; }

/* v5-port: анимация карточки обработки файлов (beam-рамка + bob-иконка + шиммер) */
.analysis-progress-card.rb-prog-card { position: relative; isolation: isolate; --rb-glow-a: rgba(45,212,212,.45); --rb-glow-b: rgba(167,139,250,.40); animation: rb-halo 4.6s ease-in-out infinite, rb-fade-in .25s ease; }
@property --rb-ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.rb-prog-card::before, .rb-prog-card::after { content:''; position:absolute; border-radius: inherit; pointer-events:none; z-index:2; -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.rb-prog-card::before { inset:0; padding:2px; background: conic-gradient(from var(--rb-ang), transparent 0turn, transparent .58turn, #5fe8e8 .76turn, #fff .80turn, #5fe8e8 .84turn, transparent .98turn, transparent 1turn); filter: drop-shadow(0 0 5px #5fe8e8); animation: rb-beam 3s linear infinite; }
.rb-prog-card::after { inset:6px; padding:2px; background: conic-gradient(from var(--rb-ang), transparent 0turn, transparent .55turn, #b794f6 .72turn, #fff .76turn, #b794f6 .80turn, transparent .96turn, transparent 1turn); filter: drop-shadow(0 0 5px #b794f6); animation: rb-beam 4.4s linear infinite reverse; }
@keyframes rb-beam { to { --rb-ang: 360deg; } }
@keyframes rb-halo { 0%,100% { box-shadow: 0 12px 38px rgba(0,0,0,.42), 0 0 20px -6px var(--rb-glow-a), 0 0 26px -4px var(--rb-glow-b); } 50% { box-shadow: 0 14px 44px rgba(0,0,0,.46), 0 0 34px -3px var(--rb-glow-a), 0 0 44px -1px var(--rb-glow-b); } }
.rb-prog-spin { font-size: 30px; line-height: 1; text-align: center; color: #5fe8e8; animation: rb-prog-bob 1.1s ease-in-out infinite, rb-prog-glow 2.4s ease-in-out infinite; }
@keyframes rb-prog-glow { 0%,100% { text-shadow: 0 0 6px rgba(45,212,212,.35); } 50% { text-shadow: 0 0 16px rgba(95,232,232,.85), 0 0 26px rgba(167,139,250,.45); } }
@keyframes rb-prog-bob { 0%,100% { transform: translateY(0); opacity:.85; } 50% { transform: translateY(-7px); opacity:1; } }
.ap-bar-fill.rb-prog-fill { background: linear-gradient(90deg, var(--accent), #5fe8e8, var(--accent)); background-size: 220% 100%; animation: rb-prog-shimmer 1.4s linear infinite; transition: width .35s cubic-bezier(.4,0,.2,1); }
@keyframes rb-prog-shimmer { 0% { background-position: 220% 0; } 100% { background-position: -220% 0; } }
@keyframes rb-fade-in { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .rb-prog-card, .rb-prog-card::before, .rb-prog-card::after, .rb-prog-spin, .ap-bar-fill.rb-prog-fill { animation: none; } }

/* v5-port: баннер диагностики разбора (parse-log) */
.rb-parselog-box { margin: 0 0 16px; text-align: left; background: var(--warning-bg); border: 1px solid var(--warning); border-radius: 10px; padding: 12px 14px; }
.rb-parselog-title { font-size: 12px; color: var(--warning); margin-bottom: 6px; font-weight: 600; }
.rb-parselog { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 42vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; color: var(--text-sec); }
.rb-parselog-clear { background: transparent; border: 1px solid var(--border); color: var(--text-sec); border-radius: 8px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.rb-parselog-clear:hover { border-color: var(--warning); color: var(--warning); }

/* v5-port: акционируемое напоминание о резервной копии */
.backup-reminder { position: fixed; right: 20px; bottom: 20px; z-index: 99999; display: flex; align-items: center; gap: 12px; max-width: 420px; background: var(--surface-alt); border: 1px solid var(--accent-dark); border-left: 3px solid var(--accent); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.4); animation: rb-fade-in .25s ease; }
.backup-reminder .br-ico { font-size: 22px; }
.backup-reminder .br-text { flex: 1; color: var(--text); font-size: 13px; }
.backup-reminder .br-sub { font-size: 11px; color: var(--text-sec); margin-top: 2px; }
.backup-reminder .br-do { background: var(--accent); color: #06222a; border: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.backup-reminder .br-do:hover { background: var(--accent-dark); color: #fff; }
.backup-reminder .br-close { background: transparent; border: none; color: var(--text-sec); font-size: 16px; cursor: pointer; padding: 2px 4px; }
.backup-reminder .br-close:hover { color: var(--text); }
@media print { .backup-reminder { display: none !important; } }

/* v5-port (#1): поле, заполненное из выгрузки PDF (подсветка снимается при ручном вводе) */
input.field-from-pdf, select.field-from-pdf, textarea.field-from-pdf { background-color: var(--accent-light); box-shadow: inset 3px 0 0 0 var(--accent); }

/* v5-port (#6/#7): кратковременная подсветка незаполненного ключевого поля при отмене печати */
input.field-missing-flash, select.field-missing-flash, textarea.field-missing-flash { box-shadow: 0 0 0 2px var(--danger); background-color: var(--danger-bg); transition: box-shadow .2s, background-color .2s; }

/* v4.0.26: редактируемые поля в шапке пациента (ФИО / дата рождения / дата имплантации) */
.pp-name-input { font-family: inherit; color: var(--text); background: transparent; border: none; border-bottom: 1px dashed transparent; padding: 1px 3px; min-width: 260px; max-width: 100%; border-radius: 4px; }
.pp-name-input:hover { border-bottom-color: var(--border); }
.pp-name-input:focus { outline: none; border-bottom-color: var(--accent); background: var(--surface); }
.pp-name-input::placeholder { color: var(--text-muted); font-weight: 400; }
.pp-date-input { font-family: inherit; font-size: 13px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 2px 6px; border-radius: 6px; color-scheme: dark; }
body.light-theme .pp-date-input { color-scheme: light; }
.pp-date-input:hover { border-color: var(--accent-dark); }
.pp-date-input:focus { outline: none; border-color: var(--accent); }
.pp-impl-days { color: var(--text-sec); font-size: 12px; margin-left: 6px; white-space: nowrap; }

/* v4.0.26: прогресс обработки в цветовом режиме — красный слева → зелёный справа.
   Градиент привязан к ширине дорожки (container query), а не к ширине заливки,
   поэтому при малом проценте видна только «красная» часть, при 100% — до зелёного. */
.ap-bar-track.rb-prog-track { position: relative; container-type: inline-size; }
.ap-bar-fill.rb-prog-fill { position: relative; overflow: hidden; background: linear-gradient(90deg, #e74c3c, #f1c40f, #2ecc71); background-size: 100% 100%; animation: none; }
.ap-bar-fill.rb-prog-fill::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 100cqi; background: linear-gradient(90deg, #e74c3c 0%, #e67e22 22%, #f1c40f 48%, #a3d65b 74%, #2ecc71 100%); }

/* v4.0.31: сегментированный переключатель удалён — вернули кнопку .mode-switcher (стили выше) */

/* v4.0.33: первый запуск — разовая подсветка переключателя (пульс холодных цветов, без красного/жёлтого)
 * + подсказка-бабл. Гаснет при первом клике (флаг eks_switcher_hint_seen в localStorage).
 * Авто-пульса при каждой загрузке больше нет — только один раз. */
@keyframes modeSwitchAttn {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(45,212,212,.55); }
  16%  { border-color: #2dd4d4;       box-shadow: 0 0 0 7px rgba(45,212,212,0); }
  33%  { border-color: #4fc3f7;       box-shadow: 0 0 0 0 rgba(79,195,247,.55); }
  50%  { border-color: #4fc3f7;       box-shadow: 0 0 0 7px rgba(79,195,247,0); }
  66%  { border-color: #2ecc71;       box-shadow: 0 0 0 0 rgba(46,204,113,.55); }
  83%  { border-color: #2ecc71;       box-shadow: 0 0 0 7px rgba(46,204,113,0); }
  100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(45,212,212,0); }
}
.page-header h1 .mode-switcher.mode-attn { animation: modeSwitchAttn 2.3s ease-in-out 3; }
.mode-switch-coach {
  position: fixed; transform: translateX(-50%); z-index: 999998;
  background: var(--accent); color: #06222a;
  font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); pointer-events: none; white-space: nowrap;
  animation: coachIn .35s ease both;
}
.mode-switch-coach::before {
  content: ""; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-color: var(--accent);
}
@keyframes coachIn { from { opacity: 0; transform: translateX(-50%) translateY(-5px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .page-header h1 .mode-switcher.mode-attn { animation: none; }
  .mode-switch-coach { animation: none; }
}

/* v4.0.36: на мобильном прячем описательный hero-блок (заголовок BOSTON SCIENTIFIC LATITUDE,
   абзац-описание и строку про отчёты) — оставляем только зону загрузки. Экономия места на телефоне. */
@media (max-width: 600px) {
  analysis-section .ans-eyebrow,
  analysis-section .ans-lede,
  analysis-section .ans-meta { display: none; }
}

/* ============================================================
 * v4.0.37: визуальная полировка — архив (пустое состояние + карточки)
 *          и страница анализа (живая иллюстрация, появление, dropzone).
 *          Сдержанно: глубина за счёт мягких теней и воздуха, без ярких эффектов.
 * ============================================================ */

/* — Архив: пустое состояние — */
.archive-empty-ic { color: var(--accent, #2dd4d4); opacity: .5; line-height: 0; }
.archive-empty-ic svg { width: 60px; height: 60px; }
.archive-empty-title { font-size: 18px; font-weight: 600; color: var(--text, #e1e3e6); letter-spacing: .2px; }
.archive-empty-sub { font-size: 13.5px; line-height: 1.55; max-width: 360px; color: var(--text-sec, #9aa1a9); }

/* — Архив: карточки чуть «дороже» (мягкая тень, подъём при наведении, цветной корешок по типу) — */
.archive-card { box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.archive-card:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.24); }
.archive-card[data-mode="implantation"] { border-left: 3px solid rgba(76,175,80,.55); }
.archive-card[data-mode="checkup"]      { border-left: 3px solid rgba(63,81,181,.55); }
.archive-card[data-mode="analysis"]     { border-left: 3px solid rgba(0,188,212,.55); }

/* — Анализ: «живая» иллюстрация (спокойное сердцебиение + пульс сигнала на кончике электрода) — */
@keyframes ansHeartbeat { 0%, 55%, 100% { transform: scale(1); } 22% { transform: scale(1.07); } 38% { transform: scale(1.015); } }
@keyframes ansTipPulse { 0%, 100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(1.7); } }
analysis-section .ans-heart   { transform-box: fill-box; transform-origin: center; animation: ansHeartbeat 1.25s ease-in-out infinite; }
analysis-section .ans-dev-tip { transform-box: fill-box; transform-origin: center; animation: ansTipPulse 1.25s ease-in-out infinite; }

/* — Анализ: плавное появление hero (разово при показе) — */
@keyframes ansHeroIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
analysis-section .ans-hero > * { animation: ansHeroIn .5s ease both; }
analysis-section .ans-hero > *:nth-child(1) { animation-delay: .05s; }
analysis-section .ans-hero > *:nth-child(2) { animation-delay: .13s; }
analysis-section .ans-hero > *:nth-child(3) { animation-delay: .21s; }
analysis-section .ans-hero > *:nth-child(4) { animation-delay: .29s; }
analysis-section .ans-hero > *:nth-child(5) { animation-delay: .37s; }

/* — Анализ: микро-взаимодействия зоны загрузки — */
@keyframes ansFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
analysis-section .ans-dz-ic { animation: ansFloat 3s ease-in-out infinite; }
analysis-section .ans-dz.drag .ans-dz-ic { animation: none; }
analysis-section .ans-dz:hover { box-shadow: 0 10px 34px rgba(79,195,247,.10); }
analysis-section .ans-dz-fmt span { transition: transform .15s, border-color .15s, color .15s; }
analysis-section .ans-dz-fmt span:hover { transform: translateY(-2px); border-color: var(--ans-link); color: var(--ans-link); }

/* — Уважение к prefers-reduced-motion: всё движение отключаем — */
@media (prefers-reduced-motion: reduce) {
  analysis-section .ans-heart,
  analysis-section .ans-dev-tip,
  analysis-section .ans-dz-ic,
  analysis-section .ans-hero > * { animation: none; }
}

/* v4.0.40: массовое выделение/удаление в архиве */
.archive-bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 10px; background: rgba(255,255,255,.02); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; }
.archive-bulk-spacer { flex: 1 1 auto; }
.archive-bulk-all { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-sec, #aaa); cursor: pointer; user-select: none; }
.archive-bulk-all input, .archive-card-pick input { width: 17px; height: 17px; accent-color: var(--accent, #2dd4d4); cursor: pointer; flex-shrink: 0; }
.archive-bulk-count { font-size: 12px; color: var(--text-sec, #9aa1a9); }
.archive-bulk-count b { color: var(--text, #e1e3e6); }
.archive-card-pick { display: flex; align-items: center; }
.archive-card:has(.archive-card-check:checked) { border-color: rgba(0,188,212,.5); background: rgba(0,188,212,.06); }

/* v4.0.42: на десктопе зону загрузки замещает живой симулятор (iframe). Только десктоп — на мобиле hero и dropzone как прежде, iframe не грузится */
analysis-section .ans-simframe { display: none; width: 100%; border: 0; }
analysis-section .ans-hero.sim-on { max-width: 1250px; padding: 0; }
analysis-section .ans-hero.sim-on > *:not(.ans-simframe):not(.ans-sim-hint) { display: none; }
analysis-section .ans-hero.sim-on .ans-simframe { display: block; width: 100%; aspect-ratio: 1180 / 960; border: 1px solid var(--ans-border-2); border-radius: 14px; background: #0b0f14; box-shadow: 0 14px 40px rgba(0,0,0,.4); }
analysis-section .ans-sim-hint { display: none; }
analysis-section .ans-hero.sim-on .ans-sim-hint { position: absolute; top: 9px; left: 85px; width: 177px; height: 56px; z-index: 6; display: flex; align-items: center; justify-content: center; color: #e60000; font-size: 11px; line-height: 1.2; font-weight: 800; white-space: nowrap; pointer-events: none; }

/* ===================================================================
   v6.1.1 — НОВЫЙ ВИД ОТЧЁТА (по утверждённому макету)
   Слой представления для всей формы протокола выгрузки.
   Шапка (.page-header / .org-* / .header-date-input) НЕ изменяется.
   Цвета — через переменные → обе темы сохранены.
   =================================================================== */

/* ---- общая база: моноцифры, тёмные поля, акцентные чекбоксы ---- */
.mt, .meas-prog-table, .ac-settings-changes-table, .pv-comp-table, .archive-table,
.sparkline-value, .bs-label b, .bs-cur, .ac-tachy-value, .ac-pvc-value, .ap-stat,
.rb-tan-val, .rb-tan-delta, .dash-cell, .acf-inp {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not(.header-date-input),
select, textarea { background: var(--input-bg); color: var(--text); border:1.5px solid var(--border); border-radius: var(--radius); outline:none; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not(.header-date-input):focus,
select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width:15px; height:15px; cursor:pointer; }

/* ---- КЛИНИЧЕСКАЯ ФОРМА: группы-карточки + чипы-тумблеры ---- */
.acf-block { margin: 10px 0 4px; }
.acf-maintitle { font-size: 13px; font-weight: 700; color: var(--text-sec); margin-bottom: 12px; letter-spacing:.2px; }
.acf-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acf-group-wide { grid-column: 1 / -1; }
@media (max-width: 980px) { .acf-wrap { grid-template-columns: 1fr; } }
.acf-group { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-lg, 14px); padding: 18px; }
.acf-group-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.acf-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; }
.acf-fields:last-child { margin-bottom: 0; }
.acf-field { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-sec); }
.acf-unit { color: var(--text-muted); font-size: 11.5px; }
.acf-inp { background: var(--input-bg); color: var(--text); border: 1.5px solid var(--border); border-radius: 8px; padding: 8px 11px; font-size: 13px; width: 84px; outline: none; transition: all var(--tr); }
.acf-inp-sm { width: 62px; }
.acf-sel { width: auto; min-width: 120px; }
.acf-inp:hover { border-color: rgba(45,212,212,.4); }
.acf-inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.acf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.acf-chips:not(:last-child) { margin-bottom: 14px; }
.acf-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-sec); background: var(--input-bg); border: 1.5px solid var(--border); border-radius: 100px; padding: 7px 13px; cursor: pointer; user-select: none; transition: all .18s ease; }
.acf-chip:hover { border-color: var(--accent); color: var(--text); }
.acf-chip input { margin: 0; width: 14px; height: 14px; }
.acf-chip:has(input:checked) { color: var(--accent); background: var(--accent-light); border-color: var(--accent); font-weight: 600; }
.acf-note { font-size: 12.5px; color: var(--text); margin-top: 12px; line-height: 1.5; }
.acf-note-mut { color: var(--text-sec); }

/* ---- ПОДСВЕТКА ДЕЛЬТ по ячейкам таблицы динамики (рост значимых параметров) ---- */
analysis-section .analysis-trends-tbl td.atrend-up-strong { color: var(--danger) !important; font-weight: 700 !important; }
analysis-section .analysis-trends-tbl td.atrend-up        { color: var(--warning) !important; font-weight: 600 !important; }
analysis-section .analysis-trends-tbl td.atrend-down      { color: var(--ans-link, #4fc3f7) !important; }

/* ---- ТАБЛИЦА «ДИНАМИКА ПО ВИЗИТАМ» — стиль макета.
        ВАЖНО: в коде эта таблица стилизуется правилами `analysis-section .analysis-trends-tbl ... !important`
        (выше по файлу), поэтому здесь нужна ТА ЖЕ специфичность + !important, иначе не применится.
        Раскладку не трогаем (collapse + overflow-x), table-layout НЕ задаём. ---- */
analysis-section .analysis-trends-wrap {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  overflow: auto !important;
  max-height: 560px !important;
}
analysis-section .analysis-trends-tbl { font-variant-numeric: tabular-nums !important; }
analysis-section .analysis-trends-tbl th,
analysis-section .analysis-trends-tbl td { padding: 11px 14px !important; }
/* липкая шапка */
analysis-section .analysis-trends-tbl thead th { position: sticky !important; top: 0 !important; z-index: 3 !important; }
/* липкий первый столбец (название параметра) */
analysis-section .analysis-trends-tbl tbody td.analysis-trend-label,
analysis-section .analysis-trends-tbl thead th:first-child {
  position: sticky !important; left: 0 !important; z-index: 2 !important; background: var(--surface) !important;
}
analysis-section .analysis-trends-tbl thead th:first-child { z-index: 4 !important; }
/* зебра + hover */
analysis-section .analysis-trends-tbl tbody tr:nth-child(even) td { background: rgba(255,255,255,.025) !important; }
analysis-section .analysis-trends-tbl tbody tr:nth-child(even) td.analysis-trend-label { background: #15212b !important; }
analysis-section .analysis-trends-tbl tbody tr:hover td { background: var(--accent-light) !important; }
body.light-theme analysis-section .analysis-trends-tbl tbody td.analysis-trend-label,
body.light-theme analysis-section .analysis-trends-tbl thead th:first-child { background: #FFFFFF !important; }
body.light-theme analysis-section .analysis-trends-tbl tbody tr:nth-child(even) td { background: rgba(0,0,0,.03) !important; }
body.light-theme analysis-section .analysis-trends-tbl tbody tr:nth-child(even) td.analysis-trend-label { background: #F0F0F0 !important; }

/* ---- ТАБЛИЦА «ИЗМЕНЕНИЯ НАСТРОЕК» — просторнее (она НЕ fixed) ---- */
.ac-settings-changes-table th, .ac-settings-changes-table td { padding: 11px 14px; }

/* ---- ТАБЛИЦЫ: только безопасные штрихи (зебра/hover), без вмешательства в раскладку ---- */
.ac-settings-changes-table tbody tr:nth-child(even) { background: rgba(255,255,255,.022); }
body.light-theme .ac-settings-changes-table tbody tr:nth-child(even) { background: rgba(0,0,0,.03); }

/* ---- ТРЕНДЫ (спарклайны): карточки с цветной кромкой ---- */
.analysis-sparkline-card { border-radius: var(--radius); border: 1px solid var(--border); border-top: 2px solid var(--accent); padding: 16px; }
.analysis-sparkline-card.sparkline-high { border-top-color: var(--danger); }
.analysis-sparkline-card.sparkline-ok { border-top-color: var(--success); }
.sparkline-value-ok { color: var(--success); }
.sparkline-value-high { color: var(--danger); }

/* ---- РЕКОМЕНДАЦИИ: бейдж категории ---- */
.rec-cat { display: block; width: 100%; font-family: 'Consolas', ui-monospace, monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--rec-c, var(--accent)); margin-bottom: 8px; }

/* ---- КНОПКИ ---- */
.btn { padding: 8px 14px; border-radius: var(--radius); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ---- ЗАГОЛОВКИ СЕКЦИЙ: чуть мягче ---- */
.section-header { border-radius: var(--radius) var(--radius) 0 0; }


/* ====================================================================== */
/* v6.2.0: РЕЖИМ «АНАЛИЗ ВЫГРУЗКИ» — стили нового интерфейса (макет          */
/* protokol-novy). Все правила скоуплены под analysis-section. Переменные   */
/* темы макета вынесены на корень компонента (НЕ в глобальный :root, чтобы  */
/* не менять боевую тему). Классы btn/chip/field/line/warn переименованы в  */
/* nv-* во избежание коллизий с app.css. keyframes → nv_*.                  */
/* ====================================================================== */
analysis-section {
--bg:#0a0f14; --bg-2:#0c131a;
    --surface:#111b24; --surface-2:#16242f; --surface-3:#1d2e3c;
    --line:rgba(255,255,255,.07); --line-2:rgba(255,255,255,.13);
    --text:#e9eff4; --muted:#94a5b4; --faint:#637482;
    --accent:#35c7d6; --accent-2:#7adfe8;
    --ok:#42cf90; --warn:#e9b44c; --crit:#f0616d; --info:#5d9ff5; --violet:#ab8ce2;
    --ok-bg:rgba(66,207,144,.12); --warn-bg:rgba(233,180,76,.12); --crit-bg:rgba(240,97,109,.12); --info-bg:rgba(93,159,245,.12); --accent-bg:rgba(53,199,214,.12);
    --font:system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
    --mono:ui-monospace,'SF Mono',Consolas,'JetBrains Mono',monospace;
    --r:14px; --r-sm:10px;
    /* v6.2.0: свойства body/.app макета — враппер .app в разметке удалён, держим на компоненте */
    display:block; position:relative; z-index:1; max-width:1240px; margin:0 auto;
    padding:0 24px 80px; background:var(--bg); color:var(--text);
    font-family:var(--font); font-size:15px; line-height:1.55; -webkit-font-smoothing:antialiased;
    scroll-padding-top:128px;
}

  
  analysis-section .mono, analysis-section .num{font-family:var(--mono); font-variant-numeric:tabular-nums}


  /* header */
  analysis-section header.top{position:sticky; top:0; z-index:30; background:rgba(10,15,20,.82); backdrop-filter:blur(12px); border-bottom:1px solid var(--line); margin:0 -24px; padding:16px 24px}

  analysis-section .top-row{display:flex; align-items:center; justify-content:space-between; gap:16px; max-width:1240px; margin:0 auto; flex-wrap:wrap}

  analysis-section .clinic{font-size:13px; color:var(--muted)}
 analysis-section .clinic b{color:var(--text); font-weight:600}

  analysis-section .clinic .addr{font-size:11.5px; color:var(--faint); margin-top:2px}

  analysis-section .title-pill{display:flex; align-items:center; gap:10px; font-family:var(--mono); font-size:12.5px; letter-spacing:.06em; text-transform:uppercase; color:var(--accent); border:1px solid var(--accent); border-radius:100px; padding:8px 16px}

  analysis-section .title-pill .dot{width:8px; height:8px; border-radius:50%; background:var(--accent); box-shadow:0 0 10px var(--accent)}

  analysis-section .meta-chips{display:flex; gap:8px; flex-wrap:wrap}

  analysis-section .mchip{font-family:var(--mono); font-size:11.5px; color:var(--muted); background:var(--surface); border:1px solid var(--line); border-radius:8px; padding:5px 11px}

  analysis-section .mchip b{color:var(--accent-2); font-weight:600}


  /* dropzone */
  analysis-section .dz{margin:30px 0; border:1.5px dashed var(--line-2); border-radius:var(--r); background:var(--surface); padding:48px 24px; text-align:center; cursor:pointer; transition:.2s}

  analysis-section .dz:hover, analysis-section .dz.drag{border-color:var(--accent); background:var(--surface-2)}

  analysis-section .dz-ic{width:46px; height:46px; margin:0 auto 14px; color:var(--accent)}

  analysis-section .dz-t{font-size:16px; font-weight:600}

  analysis-section .dz-s{font-size:13px; color:var(--muted); margin-top:6px}

  analysis-section .dz-fmt{display:flex; gap:8px; justify-content:center; margin-top:16px}

  analysis-section .dz-fmt span{font-family:var(--mono); font-size:11px; color:var(--faint); border:1px solid var(--line); border-radius:6px; padding:3px 9px}

  analysis-section .progress{margin:24px 0; display:none}

  analysis-section .progress.on{display:block}

  analysis-section .pbar{flex:1 1 auto; height:10px; background:#16222e; border-radius:6px; overflow:hidden}

  /* v7.6.30: заливка прогресса — рельс красный→жёлтый→зелёный, привязанный к полной ширине трека
     (background-size = 10000/pct%, ставится в _progSet), поэтому при 30% видна красная зона, при 100% — зелёная. */
  analysis-section .pbar i{display:block; height:100%; width:0; border-radius:6px; background-image:linear-gradient(90deg,#f0616d,#e9b44c 52%,#42cf90); background-repeat:no-repeat; background-position:left center; background-size:100% 100%; transition:width .25s ease, background-size .25s ease}

  analysis-section .perr{color:var(--crit); font-size:13px; margin-top:10px}

  /* v7.6.29: терминальный вывод анализа выгрузки (см. analysis-section.js handle()).
     Палитра фиксированно-тёмная и привязана к #aTerm — id перебивает light-theme div/span. */
  analysis-section #aTerm{font-family:var(--mono); font-size:13px; line-height:1.7; background:#0b1117; border:1px solid rgba(255,255,255,.08); border-radius:10px; padding:0 18px 16px; color:#c9d4e0; max-height:340px; overflow-y:auto; overflow-x:hidden}
  /* v7.6.30: прогресс-бар + процент закреплены в верхней части терминала (sticky), строки прокручиваются под ними. */
  analysis-section #aTerm .ans-prog{position:sticky; top:0; z-index:2; display:flex; align-items:center; gap:12px; background:#0b1117; padding:14px 0 11px; margin-bottom:6px; border-bottom:1px solid rgba(255,255,255,.07)}
  analysis-section #aTerm .ans-pct{flex:0 0 auto; min-width:3.4em; text-align:right; font-size:12px; color:#9fb2c8; font-variant-numeric:tabular-nums}
  analysis-section #aTerm .at-line{display:flex; align-items:baseline; gap:.5em; white-space:nowrap}
  analysis-section #aTerm .at-prompt{display:block; color:#e9eff4; margin-bottom:6px; white-space:nowrap}
  analysis-section #aTerm .at-mark{flex:0 0 1em; text-align:center; color:#637482}
  analysis-section #aTerm .at-name{flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; color:#c9d4e0}
  analysis-section #aTerm .at-dots{flex:1 1 auto; min-width:1.5em; align-self:center; height:1px; background-image:radial-gradient(circle, rgba(255,255,255,.28) .9px, transparent 1.2px); background-size:6px 2px; background-repeat:repeat-x; background-position:0 center}
  analysis-section #aTerm .at-val{flex:0 0 auto; color:#7adfe8; white-space:nowrap}
  analysis-section #aTerm .at-txt{flex:1 1 auto; color:#9fb2c8; white-space:normal}
  analysis-section #aTerm .at-ok .at-mark, analysis-section #aTerm .at-sum .at-mark{color:#42cf90}
  analysis-section #aTerm .at-warn .at-mark, analysis-section #aTerm .at-warn .at-val{color:#e9b44c}
  analysis-section #aTerm .at-err .at-mark, analysis-section #aTerm .at-err .at-val{color:#f0616d}
  analysis-section #aTerm .at-skip{opacity:.55}
  analysis-section #aTerm .at-env{display:block; color:#637482; margin-bottom:4px}
  analysis-section #aTerm .at-suberr{display:block; color:#c98b91; padding-left:1.6em; white-space:normal; word-break:break-word; font-size:12px; opacity:.9}

  /* v7.6.31/.32: вкладки выбора пациента, окрашены по клиническому статусу (см. _patStatus):
     crit→красный, warn→оранжевый, ok→зелёный. Активная — бирюзовое кольцо ПОВЕРХ цвета статуса.
     Палитра фиксированная (под «novy»-дашборд), привязана к #ptSwitch — id перебивает light-theme div/span. */
  analysis-section #ptSwitch{display:flex; flex-wrap:wrap; gap:8px; margin:0 0 18px}
  analysis-section #ptSwitch .pt-tab{display:inline-flex; align-items:center; gap:8px; font-family:var(--font); font-size:13px; color:#cdd7e2; background:#16242f; border:1px solid rgba(255,255,255,.12); border-radius:999px; padding:7px 14px 7px 11px; cursor:pointer; transition:filter .15s, box-shadow .15s, border-color .15s}
  analysis-section #ptSwitch .pt-tab .pt-dot{flex:none; width:8px; height:8px; border-radius:50%; background:#637482}
  analysis-section #ptSwitch .pt-tab .pt-tab-nm{color:inherit}
  analysis-section #ptSwitch .pt-tab .pt-tab-n{font-family:var(--mono); font-size:11px; min-width:1.5em; height:1.5em; line-height:1.5em; text-align:center; border-radius:999px; background:rgba(255,255,255,.12); color:inherit}
  analysis-section #ptSwitch .pt-tab.pt-st-crit{background:rgba(240,97,109,.16); border-color:rgba(240,97,109,.5); color:#ffd6d9}
  analysis-section #ptSwitch .pt-tab.pt-st-crit .pt-dot{background:#f0616d}
  analysis-section #ptSwitch .pt-tab.pt-st-warn{background:rgba(233,180,76,.16); border-color:rgba(233,180,76,.5); color:#f6e6c2}
  analysis-section #ptSwitch .pt-tab.pt-st-warn .pt-dot{background:#e9b44c}
  analysis-section #ptSwitch .pt-tab.pt-st-ok{background:rgba(66,207,144,.14); border-color:rgba(66,207,144,.45); color:#cdeede}
  analysis-section #ptSwitch .pt-tab.pt-st-ok .pt-dot{background:#42cf90}
  analysis-section #ptSwitch .pt-tab:hover{filter:brightness(1.12)}
  analysis-section #ptSwitch .pt-tab.active{box-shadow:0 0 0 2px #35c7d6, 0 0 0 4px rgba(53,199,214,.25); border-color:#35c7d6}

  /* v7.6.33: технический футер (диагностика разбора выгрузки). Палитра фиксированная, привязан
     к #techFooter (id перебивает light-theme div/span). Скрыт в печати — см. @media print ниже. */
  analysis-section #techFooter.tech-footer{margin:28px 0 8px; padding:14px 16px; background:#0c131a; border:1px dashed rgba(255,255,255,.14); border-radius:10px; font-family:var(--mono); font-size:12px; color:#9fb2c8}
  analysis-section #techFooter .tf-head{font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:#637482; margin-bottom:10px}
  analysis-section #techFooter .tf-row{display:flex; flex-wrap:wrap; gap:7px 18px}
  analysis-section #techFooter .tf-row-2{margin-top:8px; padding-top:8px; border-top:1px solid rgba(255,255,255,.07)}
  analysis-section #techFooter .tf-sub{color:#637482; font-size:10.5px; text-transform:uppercase; letter-spacing:.04em; align-self:center}
  analysis-section #techFooter .tf-item{white-space:nowrap}
  analysis-section #techFooter .tf-k{color:#8a9bab}
  analysis-section #techFooter .tf-v{font-weight:600; color:#e9eff4}
  analysis-section #techFooter .tf-v.tf-ok{color:#42cf90}
  analysis-section #techFooter .tf-v.tf-warn{color:#e9b44c}
  analysis-section #techFooter .tf-v.tf-err{color:#f0616d}
  analysis-section #techFooter .tf-det{margin-top:10px}
  analysis-section #techFooter .tf-det summary{cursor:pointer; color:#8a9bab; outline:none}
  analysis-section #techFooter .tf-det summary:hover{color:#cdd7e2}
  analysis-section #techFooter .tf-list{margin-top:6px; padding-left:12px; max-height:170px; overflow:auto; color:#7e8f9f; line-height:1.65; word-break:break-all}
  @media print { analysis-section #techFooter{display:none !important} }

  /* section nav */
  analysis-section nav.sections{position:sticky; top:0; z-index:25; background:rgba(10,15,20,.8); backdrop-filter:blur(12px); border-bottom:1px solid var(--line); margin:0 -24px 28px; padding:0 24px; display:none}
  /* v6.2.0 (скрин 3): навигация прокручивается по горизонтали (11 пунктов).
     Скроллбар скрыт — добавляем градиент-затухание справа как намёк на продолжение. */
  analysis-section nav.sections.on{display:block; position:sticky}

  analysis-section .nav-row{display:flex; gap:4px; overflow-x:auto; max-width:1240px; margin:0 auto; scrollbar-width:none}

  analysis-section .nav-row::-webkit-scrollbar{height:0}

  analysis-section nav.sections a{flex:1 1 auto; text-align:center; font-size:12.5px; color:var(--muted); padding:13px 8px; border-bottom:2px solid transparent; white-space:nowrap; text-decoration:none; transition:.2s; cursor:pointer}

  analysis-section nav.sections a:hover{color:var(--text)}

  analysis-section nav.sections a.active{color:var(--accent); border-bottom-color:var(--accent)}


  analysis-section section{padding-top:18px; margin-bottom:34px}

  analysis-section .sec-head{display:flex; align-items:center; gap:12px; margin-bottom:16px}

  analysis-section .sec-head h2{font-size:13px; font-weight:600; letter-spacing:.12em; text-transform:uppercase; color:var(--muted)}

  analysis-section .sec-head .nv-line{display:none}

  analysis-section .sec-head .cnt{font-family:var(--mono); font-size:13px}


  analysis-section .card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:22px}

  analysis-section .card-h{font-size:14px; font-weight:600; margin-bottom:14px; display:flex; align-items:center; gap:8px}

  analysis-section .card-h .ic{width:7px; height:7px; border-radius:50%; background:var(--accent)}


  /* patient */
  analysis-section .patient{background:linear-gradient(180deg,var(--surface-2),var(--surface)); border:1px solid var(--line-2); border-radius:var(--r); padding:24px; margin-bottom:20px}

  analysis-section .pt-top{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap}

  analysis-section .pt-name{font-size:24px; font-weight:700; letter-spacing:-.01em; color:var(--text); background:transparent; border:1px solid transparent; border-radius:8px; padding:2px 8px; margin:-2px -8px; width:100%; max-width:520px; font-family:var(--font)}

  analysis-section .pt-name:hover{border-color:var(--line-2)}

  analysis-section .pt-name:focus{outline:none; border-color:var(--accent); background:var(--bg-2); box-shadow:0 0 0 3px var(--accent-bg)}

  analysis-section .pt-name::placeholder{color:var(--faint); font-weight:400; font-size:16px}

  /* v8.0.58: уведомление об авто-транслитерации ФИО + галочка подтверждения */
  analysis-section .pt-translit{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:8px; padding:6px 10px; border:1px dashed var(--accent); border-radius:8px; background:var(--accent-bg); font-size:12px; color:var(--muted); max-width:520px}
  analysis-section .pt-translit-ic{color:var(--accent); flex:0 0 auto}
  analysis-section .pt-translit-txt{flex:1 1 200px}
  analysis-section .pt-translit-cf{display:inline-flex; align-items:center; gap:6px; cursor:pointer; color:var(--text); white-space:nowrap; font-weight:600}
  analysis-section .pt-translit-cf input{width:auto; margin:0}

  analysis-section .fv-date{font-family:var(--mono); font-size:13px; background:var(--bg-2); border:1px solid var(--line-2); border-radius:7px; color:var(--text); padding:5px 8px; width:100%}

  analysis-section .fv-date:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-bg)}

  analysis-section .pt-sn{font-family:var(--mono); font-size:13px; color:var(--muted)}
 analysis-section .pt-sn b{color:var(--accent-2)}

  analysis-section .pt-badges{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:14px}

  analysis-section .badge{font-size:12px; font-weight:500; border-radius:8px; padding:5px 11px; display:inline-flex; align-items:center; gap:6px}

  analysis-section .b-accent{color:var(--accent); background:var(--accent-bg); border:1px solid rgba(53,199,214,.3)}

  analysis-section .b-ok{color:var(--ok); background:var(--ok-bg); border:1px solid rgba(66,207,144,.3)}

  analysis-section .b-info{color:var(--info); background:var(--info-bg); border:1px solid rgba(93,159,245,.3)}

  /* v6.2.0 (п.5): счётчики выгрузки в строке бейджей — нейтральный чип + тонкий разделитель.
     Моноширинный, приглушённый, чтобы не спорить с клиническими бейджами. */
  analysis-section .b-meta{color:var(--muted); background:var(--surface); border:1px solid var(--line); font-family:var(--mono); font-size:11.5px; font-weight:600}
  analysis-section .badge-sep{width:1px; align-self:stretch; min-height:18px; background:var(--line-2); margin:0 2px}

  analysis-section .pt-fields{display:grid; grid-template-columns:repeat(6,1fr); gap:1px; background:var(--line); border:1px solid var(--line); border-radius:var(--r-sm); overflow:hidden; margin-top:20px}

  analysis-section .pt-fields .f{background:var(--surface); padding:14px 16px}

  analysis-section .pt-fields .fl{font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--faint); margin-bottom:6px}

  analysis-section .pt-fields .fv{font-family:var(--mono); font-size:14px; color:var(--text)}

  @media(max-width:860px){
analysis-section .pt-fields{grid-template-columns:repeat(2,1fr)}
}


  /* tiles */
  analysis-section .tiles{display:grid; grid-template-columns:repeat(5,1fr); gap:14px}

  @media(max-width:980px){
analysis-section .tiles{grid-template-columns:repeat(2,1fr)}
}

  @media(max-width:520px){
analysis-section .tiles{grid-template-columns:1fr}
}

  analysis-section .tile{position:relative; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:18px 18px 18px 22px; overflow:hidden}

  analysis-section .tile::before{content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--c,var(--faint))}

  analysis-section .tile.ok{--c:var(--ok)}
 analysis-section .tile.nv-warn{--c:var(--warn)}
 analysis-section .tile.crit{--c:var(--crit)}
 analysis-section .tile.info{--c:var(--info)}

  analysis-section .tile .tl{font-size:10.5px; letter-spacing:.1em; text-transform:uppercase; color:var(--faint)}

  analysis-section .tile .tv{font-family:var(--mono); font-size:24px; font-weight:600; margin:8px 0 4px; color:var(--text)}

  analysis-section .tile .tv.c{color:var(--c)}

  analysis-section .tile .ts{font-family:var(--mono); font-size:11.5px; color:var(--muted); display:inline-block; background:var(--bg-2); border:1px solid var(--line); border-radius:6px; padding:2px 8px}


  analysis-section .placeholder{color:var(--faint); font-size:13px; padding:14px 0}


  /* rhythm */
  analysis-section .twocol{display:grid; grid-template-columns:1fr 1fr; gap:14px}
 @media(max-width:860px){
analysis-section .twocol{grid-template-columns:1fr}
}
  /* v7.1.0: mobile-guard — контент карточек ритма/сенсора не должен уезжать за край.
     Best-effort: переносим длинные строки, разрешаем flex-элементам сжиматься. */
 @media(max-width:600px){
  analysis-section .ac-tachy-row,
  analysis-section .ac-pvc-row { flex-wrap:wrap; }
  analysis-section .ac-tachy-label { min-width:0; }
  analysis-section #rhythmTachy,
  analysis-section #rhythmSensor { min-width:0; overflow-wrap:anywhere; word-break:break-word; }
}

  analysis-section .barrow{display:grid; grid-template-columns:34px 1fr 160px 56px; align-items:center; gap:14px; padding:11px 0; border-top:1px solid var(--line)}

  analysis-section .barrow:first-of-type{border-top:none}

  analysis-section .barrow .code{font-family:var(--mono); font-weight:600; font-size:13px; color:var(--accent-2)}

  analysis-section .barrow .lbl{font-size:14px; color:var(--muted)}

  analysis-section .barrow .track{display:block; width:100%; height:8px; border-radius:6px; background:var(--bg-2); overflow:hidden}

  analysis-section .barrow .fill{display:block; height:8px; border-radius:6px; min-width:2px}

  analysis-section .barrow .pct{font-family:var(--mono); font-size:14px; text-align:right; font-weight:600}

  /* v7.1.2 (замер puppeteer: .barrow давал docWidth 448px при vw 390 —
     жёсткая колонка трека 160px не влезает). На мобильном бар переезжает
     на отдельную строку во всю ширину; подпись и % остаются сверху.
     Блок стоит ПОСЛЕ базовых правил .barrow — иначе перебивается каскадом. */
 @media(max-width:600px){
  analysis-section .barrow{grid-template-columns:34px minmax(0,1fr) 52px; gap:4px 10px; padding:9px 0}
  analysis-section .barrow .code{grid-column:1; grid-row:1}
  analysis-section .barrow .lbl{grid-column:2; grid-row:1; font-size:12.5px}
  analysis-section .barrow .pct{grid-column:3; grid-row:1; font-size:13px}
  analysis-section .barrow .track{grid-column:1 / -1; grid-row:2}
}

  analysis-section .mrow{display:flex; align-items:baseline; justify-content:space-between; gap:14px; padding:11px 0; border-top:1px solid var(--line)}

  analysis-section .mrow:first-child{border-top:none}

  analysis-section .mrow .ml{font-size:14px; color:var(--muted)}

  analysis-section .mrow .mv{font-family:var(--mono); font-size:15px; font-weight:600}

  analysis-section .mrow .mv small{font-family:var(--font); font-weight:400; color:var(--faint); font-size:12.5px; margin-left:8px}

  analysis-section .v-ok{color:var(--ok)}
 analysis-section .v-warn{color:var(--warn)}
 analysis-section .v-crit{color:var(--crit)}
 analysis-section .v-mut{color:var(--muted)}

  analysis-section .callout{display:flex; gap:12px; padding:14px 16px; border-radius:var(--r-sm); font-size:13.5px; line-height:1.5; border:1px solid var(--line)}

  analysis-section .callout .ci{flex-shrink:0; width:20px; height:20px; margin-top:1px}

  analysis-section .callout.nv-warn{background:var(--warn-bg); border-color:rgba(233,180,76,.28)}
 analysis-section .callout.nv-warn .ci{color:var(--warn)}

  analysis-section .callout.info{background:var(--info-bg); border-color:rgba(93,159,245,.28)}
 analysis-section .callout.info .ci{color:var(--info)}

  analysis-section .callout.crit{background:var(--crit-bg); border-color:rgba(240,97,109,.28)}
 analysis-section .callout.crit .ci{color:var(--crit)}
  analysis-section .callout.warn{background:rgba(217,138,58,.12); border-color:rgba(217,138,58,.30)}
  analysis-section .callout.warn .ci{color:var(--warn)}

  analysis-section .callout + .callout{margin-top:10px}

  analysis-section .callout b{color:var(--text)}
 analysis-section .callout .em{font-style:italic; color:var(--muted)}

  analysis-section .cf-summary{margin-top:10px; padding:10px 14px; border-radius:var(--r-sm); background:var(--accent-bg); border:1px solid rgba(53,199,214,.28); font-size:13px; line-height:1.7; color:var(--muted)}
 analysis-section .cf-summary b{color:var(--text); font-weight:600}
 analysis-section .cf-warn .act b{color:var(--crit)}


  /* tables */
  analysis-section .tablewrap{border:1px solid var(--line); border-radius:var(--r); overflow-x:auto}

  analysis-section table{width:100%; border-collapse:collapse; font-size:13.5px}

  analysis-section thead th{position:sticky; top:0; background:var(--surface-2); text-align:left; font-weight:600; font-size:11.5px; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); padding:13px 16px; border-bottom:1px solid var(--line-2); z-index:2}

  analysis-section #changesWrap table{table-layout:fixed}

  analysis-section #changesWrap thead th:nth-child(1){width:50%}
 analysis-section #changesWrap thead th:nth-child(2), analysis-section #changesWrap thead th:nth-child(3){width:25%}

  analysis-section tbody td{padding:11px 16px; border-bottom:1px solid var(--line); vertical-align:top; overflow-wrap:anywhere}

  analysis-section tbody tr:last-child td{border-bottom:none}

  analysis-section tbody tr:nth-child(even){background:rgba(255,255,255,.018)}

  analysis-section tbody tr:hover{background:var(--accent-bg)}

  analysis-section td.k{color:var(--muted); font-weight:500; background:var(--surface)}

  analysis-section tbody tr:nth-child(even) td.k{background:#131e27}

  analysis-section .num-cell{font-family:var(--mono); font-variant-numeric:tabular-nums}

  analysis-section .was{color:var(--faint)}
 analysis-section .now{color:var(--accent-2); font-weight:600}

  analysis-section .delta-up{color:var(--crit); font-weight:600}
 analysis-section .delta-down{color:var(--info); font-weight:600}

  analysis-section .pill-ok{font-family:var(--mono); font-size:11.5px; color:var(--ok); background:var(--ok-bg); border-radius:6px; padding:2px 9px}

  analysis-section .tbl-foot{padding:12px 16px; font-size:12.5px; color:var(--faint); background:var(--surface-2); border-top:1px solid var(--line)}


  /* recommendations */
  analysis-section .recs{display:grid; gap:12px}

  analysis-section .rec{background:var(--surface); border:1px solid var(--line); border-left:3px solid var(--c,var(--accent)); border-radius:var(--r-sm); padding:18px 20px}

  analysis-section .rec .cat{font-family:var(--mono); font-size:10.5px; letter-spacing:.1em; text-transform:uppercase; color:var(--c,var(--accent)); margin-bottom:8px; display:inline-block}

  analysis-section .rec h4{font-size:15.5px; font-weight:600; margin-bottom:8px; color:var(--text)}

  analysis-section .rec p{font-size:13.5px; color:var(--muted); line-height:1.55}

  analysis-section .rec .act{margin-top:12px; padding-top:12px; border-top:1px dashed var(--line-2); font-size:13px; color:var(--muted)}

  analysis-section .rec .act b{color:var(--accent-2); font-weight:600}


  /* trends sparklines — как в мокапе */
  analysis-section .trends{display:grid; grid-template-columns:repeat(4,1fr); gap:14px}

  @media(max-width:900px){
analysis-section .trends{grid-template-columns:repeat(2,1fr)}
}

  @media(max-width:520px){
analysis-section .trends{grid-template-columns:1fr}
}

  analysis-section .trend{background:var(--surface); border:1px solid var(--line); border-top:2px solid var(--tc); border-radius:var(--r-sm); padding:16px}

  analysis-section .trend.ok{--tc:var(--ok)}
 analysis-section .trend.high{--tc:var(--crit)}
 analysis-section .trend.low{--tc:var(--warn)}

  analysis-section .trend .tt{font-size:11px; letter-spacing:.05em; text-transform:uppercase; color:var(--faint)}

  analysis-section .trend .tv{font-family:var(--mono); font-size:24px; font-weight:600; margin:6px 0; color:var(--tc)}

  analysis-section .trend .tv small{font-size:13px; color:var(--muted)}

  analysis-section .trend svg{width:100%; height:34px; display:block; margin:8px 0 6px}

  analysis-section .trend .tn{font-family:var(--mono); font-size:10.5px; color:var(--faint)}


  /* visit-table: закреплённый первый столбец */
  analysis-section #vtWrap td:first-child, analysis-section #vtWrap th:first-child{position:sticky; left:0; z-index:1; background:var(--surface); text-align:left}

  analysis-section #vtWrap thead th:first-child{z-index:3; background:var(--surface-2)}

  analysis-section #vtWrap tbody tr:nth-child(even) td:first-child{background:#131e27}

  analysis-section #vtWrap td, analysis-section #vtWrap th{white-space:nowrap; text-align:right}

  analysis-section #vtWrap td:first-child, analysis-section #vtWrap th:first-child{text-align:left; min-width:240px}

  analysis-section #vtWrap .vchg{color:var(--warn); font-weight:600}


  /* battery calculator */
  analysis-section .slider{margin:10px 0 22px}

  analysis-section .slider .sh{display:flex; justify-content:space-between; font-size:13.5px; margin-bottom:8px}

  analysis-section .slider .sh b{font-family:var(--mono); color:var(--accent)}

  analysis-section .slider .sh .cur{font-size:11.5px; color:var(--faint)}

  analysis-section input[type=range]{-webkit-appearance:none; width:100%; height:8px; border-radius:6px; background:linear-gradient(90deg,var(--ok),var(--warn),var(--crit)); outline:none}

  analysis-section input[type=range]::-webkit-slider-thumb{-webkit-appearance:none; width:20px; height:20px; border-radius:50%; background:var(--accent-2); border:3px solid var(--bg); box-shadow:0 0 10px rgba(53,199,214,.6); cursor:pointer}

  analysis-section input[type=range]::-moz-range-thumb{width:18px; height:18px; border-radius:50%; background:var(--accent-2); border:3px solid var(--bg); cursor:pointer}

  analysis-section .calc-out{display:flex; gap:30px; flex-wrap:wrap; padding:16px; background:var(--bg-2); border:1px solid var(--line); border-radius:var(--r-sm); margin-top:6px}

  analysis-section .calc-out .co{font-size:12.5px; color:var(--muted)}
 analysis-section .calc-out .co b{display:block; font-family:var(--mono); font-size:22px; color:var(--accent-2); margin-top:4px}


  /* clinical form */
  analysis-section .form-cols{display:grid; grid-template-columns:repeat(3,1fr); gap:14px}
 @media(max-width:980px){
analysis-section .form-cols{grid-template-columns:1fr}
}

  analysis-section .grp-title{font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--accent-2); margin:4px 0 10px}

  analysis-section .nv-field{margin-bottom:14px}

  analysis-section .nv-field label{display:block; font-size:11.5px; letter-spacing:.04em; text-transform:uppercase; color:var(--faint); margin-bottom:6px}

  analysis-section .inp{display:flex; align-items:center; gap:8px}

  analysis-section .inp input, analysis-section .inp select{font-family:var(--mono); background:var(--bg-2); border:1px solid var(--line-2); border-radius:8px; color:var(--text); padding:9px 12px; font-size:13.5px; width:100%; transition:.2s}

  analysis-section .inp input:focus, analysis-section .inp select:focus{border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-bg); outline:none}

  analysis-section .inp .unit{font-family:var(--mono); font-size:12px; color:var(--faint); flex-shrink:0}

  analysis-section .chips{display:flex; flex-wrap:wrap; gap:8px}

  analysis-section .nv-chip{font-size:12.5px; color:var(--muted); background:var(--bg-2); border:1px solid var(--line-2); border-radius:100px; padding:7px 13px; cursor:pointer; user-select:none; transition:.18s; display:inline-flex; align-items:center; gap:7px}

  analysis-section .nv-chip::before{content:""; width:13px; height:13px; border-radius:4px; border:1.5px solid var(--faint); transition:.18s}

  analysis-section .nv-chip:hover{border-color:var(--muted); color:var(--text)}

  analysis-section .nv-chip.on{color:var(--accent); background:var(--accent-bg); border-color:var(--accent)}

  analysis-section .nv-chip.on::before{background:var(--accent); border-color:var(--accent); box-shadow:inset 0 0 0 2px var(--bg-2)}


  /* conclusion */
  analysis-section .conclusion{background:var(--bg-2); border:1px solid var(--line); border-radius:var(--r-sm); padding:22px 24px; font-family:var(--font); font-size:14px; line-height:1.6; color:var(--text); min-width:0; overflow-wrap:anywhere; word-break:break-word}
  analysis-section .conclusion .cb-title{font-size:13px; font-weight:700; letter-spacing:.04em; color:var(--accent); text-transform:uppercase; margin-bottom:14px}
  analysis-section .conclusion .cb-h{font-size:12px; font-weight:700; letter-spacing:.03em; text-transform:uppercase; color:var(--text); margin:16px 0 6px; padding-bottom:4px; border-bottom:1px solid var(--line)}
  analysis-section .conclusion .cb-line{color:var(--muted); margin:2px 0}
  analysis-section .conclusion .cb-line b{color:var(--text); font-weight:600}
  analysis-section .conclusion .cb-gap{height:6px}
  analysis-section .conclusion .cb-rec{color:var(--muted); margin:7px 0; padding:8px 12px; background:var(--surface-2); border-left:3px solid var(--line-2); border-radius:6px}
  analysis-section .conclusion .cb-callout{margin:4px 0 10px; padding:9px 13px; border-radius:8px; border-left:3px solid; font-size:13.5px}
  analysis-section .conclusion .cb-callout.ok{background:rgba(46,160,120,.10); border-left-color:var(--ok); color:var(--text)}
  analysis-section .conclusion .cb-callout.warn{background:rgba(217,138,58,.12); border-left-color:#d98a3a; color:var(--text)}
  analysis-section .conclusion .cb-callout.danger{background:rgba(200,60,60,.12); border-left-color:var(--danger); color:var(--text)}
  analysis-section .conclusion .cb-next{margin:12px 0 0; padding:8px 13px; border-radius:8px; background:var(--surface-2); border:1px dashed var(--line-2); display:inline-block; font-size:13.5px; color:var(--text)}
  analysis-section .conclusion-edit{width:100%; min-height:360px; background:var(--bg-2); border:1px solid var(--accent); border-radius:var(--r-sm); padding:20px 22px; font-family:var(--mono); font-size:13px; line-height:1.7; color:var(--text); resize:vertical; box-sizing:border-box}

  analysis-section .conclusion b{color:var(--text); font-weight:600}

  analysis-section .actions{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px}

  analysis-section .nv-btn{font-size:13.5px; font-weight:500; border-radius:9px; padding:11px 18px; border:1px solid var(--line-2); background:var(--surface-2); color:var(--text); cursor:pointer; display:inline-flex; align-items:center; gap:8px; transition:.2s; font-family:var(--font)}

  analysis-section .nv-btn:hover{border-color:var(--accent); color:var(--accent)}

  analysis-section .nv-btn.primary{background:var(--accent); border-color:var(--accent); color:#04181b; font-weight:600}

  analysis-section .nv-btn.primary:hover{background:var(--accent-2); color:#04181b}

  analysis-section .nv-btn.ghost{background:transparent}

  analysis-section .nv-btn svg{width:16px; height:16px}

  analysis-section .nv-btn:disabled{opacity:.5; cursor:not-allowed}

  analysis-section .build-note{margin:30px -24px 0; padding:14px 24px; background:var(--accent-bg); border-top:1px solid rgba(53,199,214,.25); font-size:13px; color:var(--muted); text-align:center}

  analysis-section .build-note b{color:var(--accent-2)}



/* v6.2.0: компонент несёт классы .section .analysis-only (контракт режима),
   из-за чего боевые свойства .section (фон/рамка/overflow/тень) накладываются
   поверх макета. В режиме анализа их нейтрализуем — макет рисует фон сам. */
/* v6.2.0 (п.3): в режиме анализа фон всей страницы — как в эталоне (#0a0f14),
   темнее боевого #0d1520. Выше контраст и читабельность; другие режимы не трогаем. */
body.mode-analysis { background: #0a0f14 !important; }

body.mode-analysis analysis-section.section {
  background: transparent; border: 0; border-radius: 0;
  box-shadow: none; overflow: visible; margin-bottom: 0;
}
body.mode-analysis analysis-section.section:hover {
  box-shadow: none; border-color: transparent;
}

/* v6.2.0 (п.4): мобильная адаптация нового интерфейса анализа.
   Боковой padding компонента (24px) на телефоне сужаем; шапку и навигацию
   страхуем от переполнения по ширине. Сетки уже схлопнуты медиазапросами макета. */
@media (max-width: 600px) {
  analysis-section { padding-left: 12px; padding-right: 12px; scroll-padding-top: 96px; }
  analysis-section nav.sections { margin: 0 -12px 20px; padding: 0 12px; }
  analysis-section .nav-row { gap: 6px; }
  analysis-section .nav-row a { font-size: 12.5px; }
  /* на десктопе пункты распределены (flex:1 1 auto) и влезают; на телефоне это сжало бы
     их нечитаемо — естественная ширина + горизонтальный скролл нав-строки. */
  analysis-section nav.sections a { flex: 0 0 auto; padding: 12px 11px; }
  analysis-section .top-row { gap: 10px; }
  analysis-section .title-pill { font-size: 11px; padding: 6px 12px; }
  analysis-section .pt-name { font-size: 18px; }
  analysis-section .actions { flex-wrap: wrap; }

  /* v6.2.3 (п.2): на телефоне широкие таблицы (8 колонок) сжимались, и длинный текст в
     ячейках рвался посимвольно («R V A u t o…»). Даём таблицам min-width и неразрывные
     ячейки — таблица скроллится по горизонтали внутри .tablewrap целиком, текст читаем. */
  analysis-section .tablewrap { -webkit-overflow-scrolling: touch; }
  analysis-section .tablewrap table { min-width: 720px; }
  analysis-section table th,
  analysis-section table td { white-space: nowrap; }
}
@media (max-width: 380px) {
  analysis-section .pt-fields { grid-template-columns: 1fr; }
}

/* ====================================================================== */
/* v6.2.0 (факт 1): светлая тема ломала новый интерфейс анализа.           */
/* Старое правило body.light-theme analysis-section div{color:#1a1f2e}    */
/* (app.css:~4111) красило тёмным ЛЮБОЙ div/span внутри компонента, а     */
/* карточки эталона всегда тёмные (--surface:#111b24) и light-варианта не  */
/* имеют → тёмный текст на тёмном фоне. Решение: новый интерфейс — это     */
/* самодостаточный тёмный макет; в светлой теме сохраняем его палитру.     */
/* Эти правила идут ПОСЛЕ всех light-правил → перекрывают их.              */
/* ====================================================================== */
body.light-theme analysis-section,
body.light-theme analysis-section p,
body.light-theme analysis-section div,
body.light-theme analysis-section span:not([class*="badge"]):not([class*="status"]) {
  color: var(--text);   /* тёмная палитра компонента (#e9eff4), не #1a1f2e */
}
/* поле ввода ФИО: в light-теме фон делался белым где-то выше — возвращаем тёмный */
body.light-theme analysis-section .pt-name {
  background: var(--surface-2); color: var(--text);
}
/* приглушённые подписи и моно-значения — как в dark */
body.light-theme analysis-section .card-h,
body.light-theme analysis-section .fl,
body.light-theme analysis-section .muted,
body.light-theme analysis-section .pt-fields .fl { color: var(--muted); }
body.light-theme analysis-section .fv,
body.light-theme analysis-section .mono { color: var(--text); }

/* ============================================================
   v7.6.10: Ч/Б КОНТРАСТНАЯ ПЕЧАТЬ.
   На чёрно-белом принтере цвет (акценты, серый --muted, бледные
   rgba-подложки плиток/callout'ов/бейджей, цветные границы) выходит
   бледно-серым и неконтрастным. В печати приводим ВЕСЬ печатаемый
   контент аналитики к ЧЁРНОМУ тексту на БЕЛОМ фоне с ЧЁРНЫМИ
   границами. Тяжесть (severity) сохраняем толщиной рамки, не цветом.
   SVG-графики не трогаем (данные кодируются формой, не цветом).
   Селекторы совпадают по специфичности с исходными и идут ПОЗЖЕ —
   поэтому перебивают ранние print-правила.
   ============================================================ */
@media print {
  /* --- Заключение: десктоп (cb-*) и мобильный (final) --- */
  analysis-section .conclusion, analysis-section .conclusion *,
  analysis-section .analysis-final-conclusion, analysis-section .analysis-final-conclusion * {
    color: #000 !important;
    background: #fff !important;
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  analysis-section .conclusion { border: 1px solid #000 !important; }
  analysis-section .conclusion .cb-h { border-bottom: 1px solid #000 !important; }
  analysis-section .conclusion .cb-callout,
  analysis-section .conclusion .cb-rec { border-left: 3px solid #000 !important; }
  analysis-section .conclusion .cb-next { border: 1px dashed #000 !important; }

  /* --- Дашборд-плитки: бледные цветные подложки → белый + чёрная рамка.
         Тяжесть сохраняем толщиной ЛЕВОЙ рамки (high/critical — жирная). --- */
  analysis-section .dash-cell.dash-ok,
  analysis-section .dash-cell.dash-medium,
  analysis-section .dash-cell.dash-high,
  analysis-section .dash-cell.dash-critical {
    background: #fff !important;
    border: 1px solid #000 !important;
  }
  analysis-section .dash-cell.dash-high,
  analysis-section .dash-cell.dash-critical { border-left: 4px solid #000 !important; }
  analysis-section .dash-kpi-main,
  analysis-section .dash-kpi-sub { color: #000 !important; background: #fff !important; }

  /* --- Бейджи пациента: цвет → чёрный текст / белый фон / чёрная рамка --- */
  analysis-section .pp-badge-ok,
  analysis-section .pp-badge-warn,
  analysis-section .pp-badge-crit,
  analysis-section .pp-badge-info {
    color: #000 !important;
    background: #fff !important;
    border-color: #000 !important;
  }

  /* --- Таблица изменений: ячейка «стало» без оранжевой подложки --- */
  analysis-section .ac-settings-changes-table td:nth-child(3) {
    color: #000 !important;
    background: #fff !important;
    border-color: #000 !important;
  }

  /* --- Критическая плашка: контрастная рамка вместо цветного фона --- */
  analysis-section .critical-issues-banner {
    color: #000 !important;
    background: #fff !important;
    border: 2px solid #000 !important;
  }

  /* --- Светлая тема (печать идёт в ней): её бледные подложки плиток
         (#fdecea/#fff2eb/#fff8e1) и цветной текст значений имеют выше
         специфичность — кроем на ней же. Тяжесть — толщиной левой рамки. --- */
  body.light-theme analysis-section .dash-cell.dash-ok,
  body.light-theme analysis-section .dash-cell.dash-medium,
  body.light-theme analysis-section .dash-cell.dash-high,
  body.light-theme analysis-section .dash-cell.dash-critical {
    background: #fff !important;
    border-color: #000 !important;
  }
  body.light-theme analysis-section .dash-cell.dash-high,
  body.light-theme analysis-section .dash-cell.dash-critical {
    border-left: 4px solid #000 !important;
  }
  body.light-theme analysis-section .dash-cell .dash-cell-value,
  body.light-theme analysis-section .dash-cell.dash-medium .dash-cell-value,
  body.light-theme analysis-section .dash-cell.dash-high .dash-cell-value,
  body.light-theme analysis-section .dash-cell.dash-critical .dash-cell-value {
    color: #000 !important;
  }
}

/* ============================================================
   v7.6.13: ТРАССИРУЕМОСТЬ — источник клинического правила (КР РКО).
   Показывается на ЭКРАНЕ рядом с рекомендацией (врач может проверить/
   защитить логику), но в ПЕЧАТЬ и экспорт НЕ попадает — печатный документ
   пациента не должен нести цитаты-источники.
   ============================================================ */
.rec-source {
  display: inline-block;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-sec);
  opacity: .8;
  margin-left: 4px;
}
.rec-source::before { content: ""; }
@media print {
  .rec-source { display: none !important; }
}

  /* ═══ v7.6.40: левый сайдбар «Справочник препаратов» (вне analysis-section, фикс. тёмная палитра) ═══ */
  .drugref-toggle{position:fixed; left:0; top:50%; transform:translateY(-50%); z-index:60; background:#11202b; color:#cfe0ee; border:1px solid rgba(255,255,255,.14); border-left:none; border-radius:0 8px 8px 0; padding:14px 6px; cursor:pointer; font-family:var(--mono,monospace); font-size:11px; letter-spacing:.08em; box-shadow:2px 0 10px rgba(0,0,0,.35); display:flex; flex-direction:column; align-items:center; gap:7px}
  .drugref-toggle span{writing-mode:vertical-rl; text-orientation:mixed; display:inline-block}
  .drugref-toggle svg{width:18px; height:18px; pointer-events:none}
  .drugref-toggle:hover{background:#162a38; color:#fff}
  /* Рецепт (Форма 107-1/у) — панель под заключением */
  .rx-panel{margin-top:14px; border:1px solid rgba(45,212,212,.35); border-radius:10px; padding:12px 14px; background:rgba(45,212,212,.05)}
  .rx-panel .rx-head{display:flex; align-items:center; gap:8px; font-weight:600; font-size:13px; color:var(--accent); margin-bottom:10px}
  .rx-panel .rx-head svg{width:16px; height:16px; flex:0 0 auto}
  .rx-panel .rx-list{display:flex; flex-direction:column; gap:7px; margin-bottom:10px}
  .rx-panel .rx-item{display:flex; align-items:center; gap:8px; cursor:pointer; font-weight:400; font-size:13px}
  .rx-panel .rx-item input{width:auto; margin:0; flex:0 0 auto}
  .rx-panel .rx-item input:disabled + span{opacity:.4}
  .rx-panel .rx-actions{display:flex; align-items:center; gap:12px; flex-wrap:wrap}
  .rx-panel .rx-hint{font-size:12px; opacity:.7}
  .rx-panel .rx-nm{flex:1 1 auto}
  .rx-panel .rx-why{font-size:11px; color:var(--danger,#e2504a); white-space:nowrap}
  .rx-panel .rx-warn{font-size:12px; line-height:1.45; color:var(--warn,#d8902a); margin-bottom:8px}
  .rx-panel .rx-warn:empty{display:none; margin:0}
  @media print{ .rx-panel{display:none !important} }
  .drugref-overlay{position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:69; opacity:0; pointer-events:none; transition:opacity .2s}
  .drugref-overlay.on{opacity:1; pointer-events:auto}
  .drugref-drawer{position:fixed; left:0; top:0; bottom:0; width:min(440px,92vw); z-index:70; background:#0c131a; color:#cfd8e2; border-right:1px solid rgba(255,255,255,.12); box-shadow:4px 0 24px rgba(0,0,0,.5); transform:translateX(-105%); transition:transform .22s ease; display:flex; flex-direction:column; font-size:13px}
  .drugref-drawer.on{transform:translateX(0)}
  .drugref-head{display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid rgba(255,255,255,.1)}
  .drugref-title{font-weight:600; color:#eaf1f7; font-size:15px}
  .drugref-close{background:none; border:none; color:#8a9bab; font-size:18px; cursor:pointer; line-height:1; padding:4px}
  .drugref-close:hover{color:#fff}
  .drugref-controls{display:flex; align-items:center; gap:8px; padding:12px 16px; flex-wrap:wrap}
  .drugref-search{flex:1; min-width:0; background:#0a1219; border:1px solid rgba(255,255,255,.16); border-radius:7px; color:#eaf1f7; padding:8px 10px; font-size:13px}
  .drugref-search::placeholder{color:#5c6c7a}
  .drugref-family{background:#0a1219; border:1px solid rgba(255,255,255,.16); border-radius:7px; color:#cfd8e2; padding:8px 6px; font-size:12px; max-width:46%}
  .drugref-count{padding:0 16px 8px; color:#637482; font-size:11px}
  .drugref-list{flex:1; overflow-y:auto; padding:0 10px 16px}
  .drugref-group{position:sticky; top:0; background:#0c131a; color:#637482; font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; padding:8px 6px 4px; z-index:1}
  .drugref-item{display:flex; flex-direction:column; gap:2px; width:100%; min-width:0; text-align:left; background:none; border:none; border-bottom:1px solid rgba(255,255,255,.05); color:#cfd8e2; padding:9px 8px; cursor:pointer}
  .drugref-item:hover{background:rgba(255,255,255,.04)}
  .drugref-item-name{font-weight:600; color:#eaf1f7; overflow-wrap:break-word; word-break:break-word}
  .drugref-item-sub{font-size:11px; color:#7e8f9f}
  .drugref-empty{padding:16px; color:#7e8f9f}
  .drugref-mono{flex:1; overflow-y:auto; padding:16px}
  .drugref-back{background:none; border:1px solid rgba(255,255,255,.16); color:#9fb2c8; border-radius:6px; padding:5px 10px; font-size:12px; cursor:pointer; margin-bottom:12px}
  .drugref-back:hover{color:#fff; border-color:rgba(255,255,255,.3)}
  .drugref-mono-head{margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid rgba(255,255,255,.1)}
  .drugref-mono-name{font-size:18px; font-weight:700; color:#eaf1f7}
  .drugref-mono-class{font-size:12px; color:#7e8f9f; margin-top:2px}
  .drugref-row{display:flex; gap:10px; padding:8px 0; border-bottom:1px solid rgba(255,255,255,.05); align-items:flex-start}
  .drugref-k{flex:0 0 34%; color:#7e8f9f; font-size:11.5px; text-transform:uppercase; letter-spacing:.03em}
  .drugref-v{flex:1; color:#dbe4ec; line-height:1.5; white-space:pre-wrap}
  .drugref-renal-line{margin-bottom:3px}
  @media print { .drugref-toggle,.drugref-overlay,.drugref-drawer{display:none !important} }

  /* ═══ v7.6.41: вкладки + чекер взаимодействий в справочнике ═══ */
  .drugref-tabs{display:flex; gap:4px; padding:8px 12px 0}
  .drugref-tab{flex:1; background:#0a1219; border:1px solid rgba(255,255,255,.12); border-bottom:none; border-radius:7px 7px 0 0; color:#8a9bab; padding:8px 6px; font-size:12px; cursor:pointer}
  .drugref-tab.on{background:#13212c; color:#eaf1f7; border-color:rgba(255,255,255,.18)}
  .drugref-panel{display:flex; flex-direction:column; flex:1; min-height:0}
  .drugref-ic-sugg{padding:0 16px; display:flex; flex-direction:column}
  .drugref-ic-suggest{display:flex; flex-direction:column; gap:1px; text-align:left; background:#0a1219; border:1px solid rgba(255,255,255,.1); border-radius:6px; color:#dbe4ec; padding:7px 9px; margin-bottom:4px; cursor:pointer; font-size:13px}
  .drugref-ic-suggest:hover{background:#13212c}
  .drugref-ic-sel{display:flex; flex-wrap:wrap; gap:6px; padding:10px 16px}
  .drugref-ic-chip{display:inline-flex; align-items:center; gap:6px; background:#173042; color:#cfe6f2; border:1px solid rgba(53,199,214,.4); border-radius:14px; padding:4px 6px 4px 11px; font-size:12px}
  .drugref-ic-x{background:none; border:none; color:#9fb2c8; cursor:pointer; font-size:12px; line-height:1; padding:0 2px}
  .drugref-ic-x:hover{color:#fff}
  .drugref-ic-result{padding:4px 16px 16px; overflow-y:auto; flex:1}
  .drugref-ic-ok{color:#42cf90; padding:10px 0; font-size:13px}
  .drugref-ic-alert{display:flex; gap:9px; align-items:flex-start; padding:9px 10px; border-radius:8px; margin-bottom:7px; font-size:12.5px; line-height:1.45}
  .drugref-ic-sev{flex:0 0 auto; font-weight:700; font-size:10.5px; text-transform:uppercase; letter-spacing:.03em; padding-top:1px}
  .drugref-ic-text{flex:1; color:#e7eef4}
  .drugref-sev-high{background:rgba(240,97,109,.13); border:1px solid rgba(240,97,109,.4)}
  .drugref-sev-high .drugref-ic-sev{color:#f0616d}
  .drugref-sev-mod{background:rgba(233,180,76,.12); border:1px solid rgba(233,180,76,.38)}
  .drugref-sev-mod .drugref-ic-sev{color:#e9b44c}
  .drugref-sev-low{background:rgba(120,160,190,.1); border:1px solid rgba(120,160,190,.3)}
  .drugref-sev-low .drugref-ic-sev{color:#9fc0d8}

  /* ═══ v7.6.42: связь справочника с текущим пациентом ═══ */
  .drugref-ic-load{flex:0 0 auto; background:#173042; color:#cfe6f2; border:1px solid rgba(53,199,214,.4); border-radius:7px; padding:8px 10px; font-size:11.5px; cursor:pointer; white-space:nowrap}
  .drugref-ic-load:hover{background:#1d3c50; color:#fff}
  .drugref-item-badge{display:inline-block; margin-left:7px; font-size:9.5px; text-transform:uppercase; letter-spacing:.03em; color:#7fd4c1; border:1px solid rgba(66,207,144,.4); border-radius:9px; padding:1px 6px; vertical-align:middle}
  .drugref-item-pt{background:rgba(66,207,144,.06)}
  .drugref-item-pt .drugref-item-name{color:#eaf7f1}
  .drugref-badge-concl{color:#67b5e8; border-color:rgba(70,150,230,.45)}
  .drugref-item-concl{box-shadow:inset 3px 0 0 rgba(70,150,230,.55)}

  /* ═══ v7.6.43: подсветка противопоказаний для текущего пациента (1b) ═══ */
  .drugref-item-ci{display:inline-block; margin-left:7px; font-size:9.5px; text-transform:uppercase; letter-spacing:.03em; border-radius:9px; padding:1px 6px; vertical-align:middle}
  .drugref-item-ci.ci-high{color:#f0616d; border:1px solid rgba(240,97,109,.5)}
  .drugref-item-ci.ci-mod{color:#e9b44c; border:1px solid rgba(233,180,76,.5)}
  .drugref-item-ci-high .drugref-item-name{color:#f4c4c9}
  .drugref-mono-warn{padding:10px 12px; border-radius:8px; margin-bottom:12px}
  .drugref-mono-warn-h{font-weight:700; font-size:12.5px; margin-bottom:5px}
  .drugref-sev-high .drugref-mono-warn-h{color:#f0616d}
  .drugref-sev-mod .drugref-mono-warn-h{color:#e9b44c}
  .drugref-mono-warn-r{font-size:12px; line-height:1.5; color:#e7eef4}
