/* Явные цвета для читаемости в тёмной теме: белый фон + тёмный текст */
.lab-user-report {
  background: #ffffff;
  border: 1px solid #e7ebf0;
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  color: #0f172a;
}

.lab-user-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lab-user-report-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  color: #0f172a;
}

.lab-user-report-source {
  margin: 0 0 12px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #475569;
  background: #f1f5f9;
  border-radius: 8px;
  border-left: 3px solid #0f766e;
}

.lab-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #dfe4ea;
}

.lab-badge-normal {
  background: #f1f8f3;
  color: #1d5d2d;
}

.lab-badge-mild {
  background: #f5f7fb;
  color: #334155;
}

.lab-badge-moderate {
  background: #fff7e8;
  color: #9a6700;
}

.lab-badge-urgent {
  background: #fff1f1;
  color: #b42318;
}

.lab-user-report--structured .lab-user-report-block {
  margin-top: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #e7ebf0;
  background: #fafbfc;
}

.lab-user-report--structured .lab-user-report-block + .lab-user-report-block {
  margin-top: 12px;
  padding-top: 14px;
  border-top: none;
}

.lab-user-report-block--document {
  border-left: 4px solid #0f766e !important;
  background: #f8faf9 !important;
}

.lab-user-report-block--summary {
  background: #f0f9ff !important;
  border-color: #bae6fd !important;
}

.lab-user-report-block--actions {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
}

.lab-user-report-block--urgent {
  background: #fff7ed !important;
  border-color: #fdba74 !important;
}

.lab-user-report-body {
  margin: 0;
}

.lab-user-report-p {
  margin: 0 0 0.65rem;
  font-size: 14px;
  line-height: 1.55;
  color: #0f172a;
}

.lab-user-report-p:last-child {
  margin-bottom: 0;
}

.lab-user-report-block--document .lab-user-report-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}

.lab-user-report-block--summary .lab-user-report-title,
.lab-user-report-block--actions .lab-user-report-title,
.lab-user-report-block--urgent .lab-user-report-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #0f766e;
  margin: 0 0 8px;
}

.lab-user-report-block--urgent .lab-user-report-title {
  color: #c2410c;
}

.lab-user-report-block--default .lab-user-report-title {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin: 0 0 8px;
}

/* Старый вид без --structured (если подключат без обёртки) */
.lab-user-report:not(.lab-user-report--structured) .lab-user-report-block + .lab-user-report-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf1f5;
}

.lab-user-report:not(.lab-user-report--structured) .lab-user-report-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #334155;
}

.lab-user-report-list {
  margin: 0;
  padding-left: 18px;
}

.lab-user-report-list li {
  line-height: 1.5;
  margin-bottom: 6px;
  color: #0f172a;
}

.doctor-details {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid #e7ebf0;
  border-radius: 8px;
  background: #f8f9fb;
}

.doctor-details summary {
  cursor: pointer;
  font-weight: 600;
}

.doctor-details pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  font-size: 12px;
  background: #fff;
  border-radius: 4px;
  color: #0f172a;
}

/* Структурированный отчёт для врача — удобочитаемый вид */
.report-doctor-structured {
  margin-top: 0.5rem;
}
.report-doctor-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e7ebf0;
}
.report-doctor-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.report-doctor-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f766e;
}
.report-structured-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.report-structured-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.45;
}
.report-label {
  font-weight: 600;
  color: #334155;
  flex-shrink: 0;
}
.report-value {
  color: #0f172a;
}
.report-doctor-paragraph {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #0f172a;
}
.report-doctor-main {
  margin-bottom: 0.75rem;
}
.report-contract-table-wrap {
  overflow-x: auto;
}
.report-contract-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.report-contract-table th,
.report-contract-table td {
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.45rem;
  vertical-align: top;
  text-align: left;
}
.report-contract-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}
.doctor-details--collapsed summary {
  font-size: 0.85rem;
  color: #64748b;
}

/* Отчёт на тёмном фоне — светлый блок, тёмный текст для читаемости */
body.theme-dark .report-section,
body.theme-dark .report-content,
body.theme-dark .report-doctor-block,
body.theme-dark .report-doctor-main {
  background: #ffffff;
  color: #1e293b;
}
body.theme-dark .report-doctor-block {
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1rem;
  border: 1px solid #e2e8f0;
}
body.theme-dark .report-doctor-section-title {
  color: #0f766e;
}
body.theme-dark .report-doctor-paragraph,
body.theme-dark .report-value,
body.theme-dark .report-label {
  color: #1e293b;
}
body.theme-dark .report-structured-line {
  color: #1e293b;
}

/* Развёрнутый отчёт / полноэкранный просмотр — структура и воздух */
.report-expand-root {
  max-width: 52rem;
  margin: 0 auto;
}
.report-expand-banner {
  margin-bottom: 1rem;
  padding: 1rem 1rem 0.9rem;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}
.report-expand-banner__title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.report-expand-banner__meta {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: #64748b;
}
.report-expand-toc {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #334155;
}
.report-expand-toc li {
  margin-bottom: 0.25rem;
  word-break: break-word;
}
.report-expand-section--docs {
  padding-top: 0.25rem;
  border-top: 1px solid #e2e8f0;
  margin-top: 0.5rem;
}
.aggregate-doc-card__long {
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fafafa;
}
.aggregate-doc-card__long summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: #0f766e;
}
.aggregate-doc-card__long[open] summary {
  margin-bottom: 0.5rem;
}
.report-expand-lead {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #475569;
  background: #f1f5f9;
  border-radius: 10px;
  border-left: 4px solid #0f766e;
}
.report-expand-section {
  margin-bottom: 1.35rem;
}
.report-expand-h {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.report-expand-section--docs .report-expand-h {
  color: #0f766e;
}

.aggregate-doc-card {
  margin-bottom: 1rem;
  padding: 1rem 1rem 1rem 0.85rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
.aggregate-doc-card--structured {
  padding-bottom: 0.75rem;
}
.aggregate-doc-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.aggregate-doc-card__titlestack {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}
.aggregate-doc-card__type {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f766e;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
}
.aggregate-doc-card__summary-wrap {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #0f766e;
}
.aggregate-doc-card__num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  background: #0f766e;
  border-radius: 8px;
}
.aggregate-doc-card__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  color: #0f172a;
  word-break: break-word;
}
.aggregate-doc-card__summary {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #334155;
}
.aggregate-doc-card__detail {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #e2e8f0;
}
.aggregate-doc-card__detail-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.35rem;
}
.aggregate-doc-card__detail-body {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #475569;
}

.aggregate-doc-details {
  margin-top: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fafafa;
  overflow: hidden;
}
.aggregate-doc-details__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
}
.aggregate-doc-details__summary::-webkit-details-marker {
  display: none;
}
.aggregate-doc-details__title {
  color: #0f766e;
}
.aggregate-doc-details__hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.aggregate-doc-details[open] .aggregate-doc-details__summary {
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.aggregate-doc-prose {
  padding: 0.65rem 0.85rem 0.85rem;
  max-height: min(55vh, 22rem);
  overflow: auto;
  font-size: 0.84rem;
  line-height: 1.55;
  color: #334155;
  -webkit-overflow-scrolling: touch;
}
.aggregate-doc-prose .aggregate-doc-p {
  margin: 0 0 0.55rem;
}
.aggregate-doc-prose .aggregate-doc-p:last-child {
  margin-bottom: 0;
}
.aggregate-doc-ul {
  margin: 0 0 0.55rem;
  padding-left: 1.15rem;
}
.aggregate-doc-ul li {
  margin-bottom: 0.35rem;
}
.report-expand-details--merged .aggregate-doc-prose {
  max-height: min(60vh, 28rem);
}

.report-expand-details {
  margin-bottom: 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.report-expand-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: #334155;
  padding: 0.35rem 0;
}
.report-expand-details[open] summary {
  margin-bottom: 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
}
.report-doctor-main--aggregate-raw {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #334155;
  max-height: min(70vh, 28rem);
  overflow: auto;
  padding: 0.25rem;
}

.report-callout {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.report-callout--next {
  background: #f0fdf4;
  border-color: #86efac;
}
.report-callout--urgent {
  background: #fff7ed;
  border-color: #fdba74;
}
.report-callout .report-expand-h {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #047857;
  margin-bottom: 0.5rem;
}
.report-callout--urgent .report-expand-h {
  color: #c2410c;
}
.report-callout__p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #1e293b;
}

.report-doctor-structured--aggregate {
  margin-top: 0.25rem;
}
.report-doctor-section--aggregate-file {
  padding: 0.75rem 0;
  border-bottom: 1px solid #e7ebf0;
}
.report-doctor-section--aggregate-file:last-child {
  border-bottom: none;
}
.report-doctor-aggregate-body {
  font-size: 0.9rem;
}
.report-doctor-aggregate-lead {
  margin: 0 0 0.5rem !important;
  font-weight: 600;
  color: #334155 !important;
}
.report-doctor-aggregate-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid #e2e8f0;
}

body.theme-dark .report-expand-lead {
  background: #1e293b;
  color: #e2e8f0;
  border-left-color: #2dd4bf;
}
body.theme-dark .aggregate-doc-card {
  background: #fff;
}
body.theme-dark .report-expand-details {
  background: #1e293b;
  border-color: #334155;
}
body.theme-dark .report-expand-details summary {
  color: #e2e8f0;
}

/* GOLD STANDARD — единый «клинико-справочный» вид */
.lab-user-report--gold.lr-gold {
  padding: 0;
  overflow: hidden;
  border: 1px solid #c7d2fe;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}
.lr-gold-hero {
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #f0fdfa 0%, #eef2ff 50%, #faf5ff 100%);
  border-bottom: 1px solid #e2e8f0;
}
.lr-gold-hero-head {
  margin-bottom: 10px;
}
.lr-gold-hero-head h3 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.lr-gold-hero-lead {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
  color: #0f172a;
}
.lr-gold-hero-meta {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.4;
}
.lr-gold-meta-label {
  font-weight: 700;
  color: #334155;
}
.lr-gold-hero-disclaimer {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #64748b;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.lr-gold-section {
  padding: 14px 16px;
  border-bottom: 1px solid #edf1f5;
  background: #fff;
}
.lr-gold-section:last-child {
  border-bottom: none;
}
.lr-gold-section-title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f766e;
}
.lr-gold-section-body .lab-user-report-p {
  font-size: 0.9rem;
}
.lr-gold-section--emphasis {
  background: #f8fafc;
  border-left: 4px solid #0f766e;
}
.lr-gold-section--emphasis .lr-gold-section-title {
  color: #0f766e;
}
.lr-gold-section--warning {
  background: #fffbeb;
  border-left: 4px solid #d97706;
}
.lr-gold-section--warning .lr-gold-section-title {
  color: #b45309;
}
.lr-gold-section--danger {
  background: #fff7ed;
  border-left: 4px solid #ea580c;
}
.lr-gold-section--danger .lr-gold-section-title {
  color: #c2410c;
}
.lr-gold-section--legal {
  background: #f8fafc;
  border-left: 4px solid #64748b;
}
.lr-gold-section--legal .lr-gold-section-title {
  color: #475569;
  font-size: 0.72rem;
}
.lr-gold-section--neutral .lr-gold-section-title {
  color: #334155;
}
body.theme-dark .lab-user-report--gold.lr-gold {
  background: #fff;
  border-color: #334155;
}
body.theme-dark .lr-gold-hero {
  background: linear-gradient(135deg, #1e293b 0%, #312e81 100%);
  border-bottom-color: #334155;
}
body.theme-dark .lr-gold-hero-lead {
  color: #f1f5f9;
}
body.theme-dark .lr-gold-hero-meta {
  color: #cbd5e1;
}
body.theme-dark .lr-gold-hero-disclaimer {
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.5);
  border-color: #475569;
}
body.theme-dark .lr-gold-section {
  background: #fff;
  border-bottom-color: #e2e8f0;
}
body.theme-dark .lr-gold-section-title {
  color: #0f766e;
}

/* Aggregate summary dashboard (web + fullscreen) */
:root {
  --agg-bg: #f5f7fb;
  --agg-card: #ffffff;
  --agg-text: #1f2937;
  --agg-muted: #6b7280;
  --agg-green: #059669;
  --agg-yellow: #d97706;
  --agg-red: #dc2626;
  --agg-border: #e5e7eb;
}

.aggregate-dashboard-card {
  background: var(--agg-card);
  border: 1px solid var(--agg-border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.aggregate-dashboard-card--main {
  border-left: 4px solid var(--agg-red);
}

.aggregate-dashboard-risk {
  margin-top: 8px;
}

.risk-bar {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
}

.risk-bar.red { background: #fee2e2; color: #991b1b; }
.risk-bar.yellow { background: #fef3c7; color: #92400e; }
.risk-bar.green { background: #d1fae5; color: #065f46; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.green { background: #d1fae5; color: #065f46; }

.aggregate-analysis-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  border-top: 1px solid var(--agg-border);
  padding: 8px 0;
}

.aggregate-analysis-row:first-of-type {
  border-top: none;
  padding-top: 2px;
}

.aggregate-analysis-row__left {
  min-width: 0;
}

.aggregate-analysis-row__title {
  font-weight: 700;
  color: var(--agg-text);
  margin-bottom: 2px;
}

.aggregate-analysis-row__sub {
  color: var(--agg-muted);
}

.aggregate-dashboard-typo {
  line-height: 1.52;
  letter-spacing: 0.01em;
}

.aggregate-dashboard-typo .report-expand-h {
  margin-bottom: 10px;
}

.aggregate-dashboard-typo li {
  margin: 6px 0;
}

.aggregate-sticky-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--agg-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
}

.aggregate-sticky-nav__btn {
  border: 1px solid var(--agg-border);
  background: #fff;
  color: var(--agg-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.aggregate-sticky-nav__btn.is-active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.summary-dashboard-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-dashboard-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
}

.summary-dashboard-modal-content {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 24px));
  height: min(88vh, 920px);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(2, 6, 23, 0.3);
  border: 1px solid #e2e8f0;
}

.summary-dashboard-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.summary-dashboard-modal-head h3 {
  margin: 0;
  font-size: 15px;
}

.summary-dashboard-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#summaryDashboardFrame {
  width: 100%;
  height: calc(100% - 56px);
  border: none;
}

.labs-fallback-banner {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #facc15;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 600;
}

@media (max-width: 720px) {
  .aggregate-analysis-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .aggregate-dashboard-card {
    padding: 12px;
  }
  .summary-dashboard-modal-content {
    width: calc(100vw - 10px);
    height: calc(100vh - 10px);
    border-radius: 10px;
  }
}
