* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 0% 0%, #eff6ff 0%, transparent 35%),
    radial-gradient(circle at 100% 20%, #fae8ff 0%, transparent 30%),
    #f8fafc;
  color: #0f172a;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
  background: rgba(248, 250, 252, 0.8);
  border-bottom: 1px solid #e2e8f0;
}

.topbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 1;
  min-width: 0;
}

.topbar-actions-dropdown {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  margin: 0;
}

.topbar-actions-dropdown > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 38px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  list-style: none;
}

.topbar-actions-dropdown > summary::-webkit-details-marker {
  display: none;
}

.topbar-actions-collapsible {
  display: none;
}

.topbar-actions-dropdown[open] .topbar-actions-collapsible {
  display: flex;
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 210px;
  width: max-content;
  max-width: calc(100vw - 1rem);
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  padding: 0.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.topbar-actions-collapsible .btn,
.topbar-actions-collapsible a.btn {
  width: 100%;
  justify-content: center;
  min-height: 34px;
  padding: 0.4rem 0.58rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.topbar-menu-toggle .topbar-menu-label {
  display: none;
}

.topbar-menu-toggle::before {
  content: "☰";
  font-size: 1.05rem;
  line-height: 1;
  color: #0f172a;
}

.topbar-menu-toggle.topbar-menu-toggle--login {
  min-width: 108px;
}

.topbar-menu-toggle.topbar-menu-toggle--login .topbar-menu-label {
  display: inline;
  font-size: 0.9rem;
  color: #0f172a;
}

.topbar-menu-toggle.topbar-menu-toggle--login::before {
  content: "";
  display: none;
}

.topbar-actions-dropdown.topbar-actions-dropdown--fade-in {
  animation: topbarActionsFadeIn 220ms ease-out 1;
}

@keyframes topbarActionsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Единый размер подписей кнопок/ссылок в шапке (главная, профиль, тарифы, админка) */
.topbar-actions .btn,
.topbar-actions a.btn {
  font-size: 0.9rem;
}

#userProfileBtn {
  max-width: clamp(140px, 30vw, 280px);
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 960px) {
  #userProfileBtn {
    max-width: min(48vw, 220px);
  }
}

.topbar-plan-upsell {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.55rem;
  font-size: 12px;
  line-height: 1.35;
}

.topbar-plan-upsell.hidden {
  display: none;
}

.topbar-plan-upsell-current {
  width: 100%;
  text-align: center;
  font-weight: 600;
  color: #334155;
}

.topbar-plan-upsell-higher {
  color: #64748b;
}

.topbar-plan-upsell-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn.btn-topbar-upsell {
  padding: 0.2rem 0.5rem;
  font-size: 11px;
  border-radius: 8px;
  font-weight: 600;
}

.btn.btn-topbar-upsell-toggle {
  display: none;
  padding: 0.2rem 0.5rem;
  font-size: 11px;
  border-radius: 8px;
  font-weight: 600;
}

.cabinet-hero-section {
  margin-top: 1.5rem;
}

.cabinet-hero-card {
  width: 100%;
}

@media (max-width: 960px) {
  .topbar-plan-upsell {
    flex: 1 1 100%;
    order: 3;
    padding-top: 0.28rem;
    margin-top: 0.12rem;
    border-top: 1px solid #e2e8f0;
    justify-content: flex-start;
    gap: 0.25rem 0.45rem;
  }

  .topbar-plan-upsell-current {
    width: auto;
    max-width: calc(100% - 100px);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn.btn-topbar-upsell-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-plan-upsell:not(.is-expanded) .topbar-plan-upsell-higher,
  .topbar-plan-upsell:not(.is-expanded) .topbar-plan-upsell-actions {
    display: none;
  }

  .topbar-plan-upsell.is-expanded .topbar-plan-upsell-current {
    max-width: 100%;
    white-space: normal;
  }

  .topbar-plan-upsell.is-expanded .topbar-plan-upsell-higher {
    width: 100%;
    text-align: left;
  }

  .topbar-plan-upsell.is-expanded .topbar-plan-upsell-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Логотип кликабелен на всех страницах и должен одинаково масштабироваться. */
.logo {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.premium {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #f8fafc;
}

.premium p,
.muted {
  color: #94a3b8;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.cabinet-overview-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cabinet-overview-stats .stat {
  text-align: center;
}

.cabinet-overview-stats .muted {
  font-size: 0.82rem;
  line-height: 1.2;
}

.stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.8rem;
}

.value {
  font-size: 1.35rem;
  font-weight: 700;
}

.timeline-item {
  padding: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  background: #fff;
}

.timeline-list {
  margin-top: 0.8rem;
  max-height: 380px;
  overflow: auto;
}

.timeline-docs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.doc-link {
  display: inline-block;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
  text-decoration: none;
  color: #1d4ed8;
  background: #eff6ff;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.report-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.8rem;
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

/* AI-отчёты: HTML из Markdown (не pre-wrap — типографика заголовков/списков). */
.report-box.report-md {
  white-space: normal;
  font-size: 0.95rem;
  color: #334155;
}

.report-md h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.5rem 0 0.45rem;
  line-height: 1.25;
  color: #0f172a;
}

.report-md h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0.85rem 0 0.4rem;
  line-height: 1.3;
  color: #0f172a;
}

.report-md h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.65rem 0 0.35rem;
  color: #1e293b;
}

.report-md p {
  margin: 0.5rem 0;
  line-height: 1.55;
}

.report-md ul,
.report-md ol {
  margin: 0.45rem 0 0.45rem 1.35rem;
}

.report-md li {
  margin: 0.2rem 0;
}

.report-md blockquote {
  margin: 0.5rem 0;
  padding: 0.35rem 0.75rem;
  border-left: 4px solid #cbd5e1;
  background: #f1f5f9;
  color: #475569;
}

.report-md pre {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.report-md :not(pre) > code {
  background: #f1f5f9;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}

.report-md hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 1rem 0;
}

.report-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.65rem 0;
}

.report-md th,
.report-md td {
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.report-md th {
  background: #f8fafc;
  font-weight: 600;
}

.report-md a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.report-md a:hover {
  color: #1d4ed8;
}

.table-wrap {
  margin-top: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: auto;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.app-table th,
.app-table td {
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.app-table th {
  background: #f8fafc;
  color: #334155;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ============================================================ */
/* Сортировка таблиц истории: кнопки в заголовках колонок       */
/* ============================================================ */
.table-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.table-sort-btn__icon {
  color: #94a3b8;
  font-size: 0.84em;
  line-height: 1;
}

.table-sort-btn.is-active {
  color: #0f172a;
}

.table-sort-btn.is-active .table-sort-btn__icon {
  color: #2563eb;
}

/* Админка — очередь фоновых задач: кнопки в одной строке без «разъезда» */
.admin-bg-job-actions-td {
  white-space: nowrap;
  vertical-align: middle;
}
.admin-bg-job-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
}

.app-table-admin-jobs .admin-bg-job-created-th,
.app-table-admin-jobs .admin-bg-job-created-td {
  width: 1%;
  max-width: 5.75rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  vertical-align: middle;
  font-size: 0.78rem;
  line-height: 1.15;
}
.app-table-admin-jobs .admin-bg-job-created-th {
  white-space: nowrap;
}
.admin-bg-job-created {
  display: block;
}
.admin-bg-job-created__date {
  display: block;
  font-weight: 600;
  color: #334155;
}
.admin-bg-job-created__time {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

/* Отладочный промпт к Ollama в ЛК: только при классе mhh-user-is-admin на html (ставит updateAuthUi). */
html:not(.mhh-user-is-admin) .admin-ollama-debug-spoiler {
  display: none !important;
}
.admin-ollama-debug-spoiler {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.55rem 0.5rem;
  background: #f8fafc;
}
.admin-ollama-debug-spoiler__summary {
  cursor: pointer;
  font-size: 12px;
  color: #64748b;
  user-select: none;
}
.admin-ollama-debug-spoiler__pre {
  margin: 0.45rem 0 0;
  max-height: 220px;
  overflow: auto;
  font-size: 11px;
  white-space: pre-wrap;
}

.lab-result-row-high td {
  background: #fef2f2;
}

.lab-result-row-low td {
  background: #fffbeb;
}

.lab-result-row-abnormal td {
  background: #fff7ed;
}

.lab-result-row-unknown td {
  background: #f8fafc;
}

.lab-result-row-normal td {
  background: #f0fdf4;
}

.pagination {
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

a.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: #0f172a;
  box-sizing: border-box;
}

a.btn:visited {
  color: #0f172a;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14);
  filter: brightness(0.98);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.section-action-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accordion-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.36s ease-in-out,
    opacity 0.28s ease-in-out;
  will-change: max-height, opacity;
}

.accordion-body.is-expanded {
  opacity: 1;
}

.accordion-chevron {
  transition: transform 0.28s ease-in-out;
}

.section-action-btn[data-expanded="false"] .accordion-chevron {
  transform: rotate(-90deg);
}

.btn-light {
  background: #f8fafc;
  color: #0f172a;
}

.btn-outline {
  border: 1px solid #cbd5e1;
  background: #fff;
}

.btn-success {
  background: #16a34a;
  color: #fff;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-success-soft {
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.btn-danger-soft {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.btn-info {
  background: #0ea5e9;
  color: #fff;
}

.btn-users-outline {
  border: 1px solid #5eead4;
  background: #f0fdfa;
  color: #115e59;
}

.btn-visits-outline {
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1e40af;
}

.btn-labs-outline {
  border: 1px solid #c4b5fd;
  background: #f5f3ff;
  color: #6d28d9;
}

.action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.action-buttons .btn {
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.btn-with-icon::before {
  font-size: 0.92em;
  line-height: 1;
}

.doc-uniform-btn {
  width: 280px;
  justify-content: flex-start;
  gap: 0.35rem;
}

.doc-uniform-btn-text {
  display: inline-block;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.doc-uniform-btn-size {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: #1e3a8a;
  opacity: 0.9;
  white-space: nowrap;
}

.btn-loading {
  position: relative;
}

.btn-loading::after {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  margin-left: 0.3rem;
  animation: btn-spin 0.75s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-login::before { content: "🔐"; }
.icon-logout::before { content: "↩"; }
.icon-admin::before { content: "🛠"; }
.icon-profile::before { content: "👤"; }
.icon-premium::before { content: "⭐"; }
.icon-upload::before { content: "⬆"; }
.icon-analyze::before { content: "🧠"; }
.icon-add::before { content: "＋"; }
.icon-register::before { content: "📝"; }
.icon-refresh::before { content: "↻"; }
.icon-search-ai::before { content: "🔎"; }
.icon-close::before { content: "✕"; }
.icon-check::before { content: "✓"; }
.icon-save::before { content: "💾"; }
.icon-delete::before { content: "🗑"; }
.icon-open::before { content: "📄"; }
.icon-restore::before { content: "↺"; }
.icon-back::before { content: "←"; }
.icon-plans::before { content: "📋"; }
.icon-prev::before { content: "←"; }
.icon-next::before { content: "→"; }

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  margin-bottom: 0.6rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.status {
  font-size: 0.92rem;
  margin-top: 0.5rem;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.status-row .status {
  margin-top: 0;
}

.profile-readonly-stack {
  display: grid;
  gap: 0.85rem;
}

.profile-hero-card {
  border-left: 4px solid #93c5fd;
}

.health-connect-filters-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.health-connect-presets-row {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: wrap;
}

.health-connect-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.health-connect-actions-row .btn {
  width: auto;
}

.health-connect-preset-btn {
  width: auto;
  min-height: 32px;
  padding: 0.32rem 0.55rem;
  font-size: 0.8rem;
}

.health-kit-preset-btn {
  width: auto;
  min-height: 32px;
  padding: 0.32rem 0.55rem;
  font-size: 0.8rem;
}

.health-connect-filters-row select,
.health-connect-filters-row input {
  margin-bottom: 0;
}

.health-connect-filters-row #healthConnectMetricTypeFilter,
.health-connect-filters-row #diaryHealthConnectMetricTypeFilter {
  flex: 1 1 220px;
}

.health-connect-filters-row #diaryHealthKitMetricTypeFilter {
  flex: 1 1 220px;
}

.health-connect-filters-row #healthConnectFromDate,
.health-connect-filters-row #healthConnectToDate,
.health-connect-filters-row #diaryHealthConnectFromDate,
.health-connect-filters-row #diaryHealthConnectToDate {
  flex: 0 0 170px;
}

.health-connect-filters-row #diaryHealthKitFromDate,
.health-connect-filters-row #diaryHealthKitToDate {
  flex: 0 0 170px;
}

.health-connect-metrics-btn {
  flex: 0 0 auto;
  width: auto;
  min-height: 36px;
  padding: 0.42rem 0.7rem;
  font-size: 0.84rem;
  white-space: nowrap;
}

/* Состояния строки статуса над кнопкой AI-анализа (без inline color в JS) */
.status-ai-ready {
  color: #0f766e;
}

.status-ai-error {
  color: #dc2626;
}

.parse-mode-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  color: #334155;
  background: #f8fafc;
  white-space: nowrap;
}

.parse-mode-badge.mode-llm {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1e40af;
}

.parse-mode-badge.mode-fallback {
  border-color: #fcd34d;
  background: #fef3c7;
  color: #92400e;
}

.parse-mode-badge.mode-debug {
  border-color: #94a3b8;
  background: #e2e8f0;
  color: #334155;
}

.parse-mode-badge.mode-pending {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #475569;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

#labPanelResultsModal .modal {
  width: min(980px, 100%);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

#labPanelResultsModal {
  align-items: flex-start;
  padding-top: 5.5rem;
  z-index: 1200;
}

#aiReportViewModal .modal {
  width: min(900px, 100%);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

#aiReportViewModal {
  align-items: flex-start;
  padding-top: 5.5rem;
  z-index: 1200;
}

#aiReportViewModalBody.report-box {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: calc(100vh - 220px);
}

#labPanelResultsTableWrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  max-height: calc(100vh - 220px);
}

#documentViewerModal {
  z-index: 1200;
  align-items: flex-start;
  padding-top: 3rem;
}

.document-viewer-modal {
  width: min(96vw, 1200px);
  max-width: 100%;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.document-viewer-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.document-viewer-toolbar h3 {
  margin: 0;
  flex: 1 1 160px;
  min-width: 0;
  word-break: break-word;
}

.document-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  justify-content: flex-end;
}

.document-viewer-zoom-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.document-viewer-zoom-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  min-width: 3rem;
  text-align: center;
}

.document-viewer-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  max-height: calc(100vh - 11rem);
  overflow: auto;
  margin-top: 0.75rem;
  background: #e2e8f0;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  -webkit-overflow-scrolling: touch;
}

.document-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #64748b;
  background: rgba(241, 245, 249, 0.92);
  z-index: 2;
}

.document-viewer-loading.hidden {
  display: none;
}

.document-viewer-fallback {
  padding: 1.5rem;
  color: #475569;
  line-height: 1.5;
}

.document-viewer-zoom-wrap {
  padding: 0.5rem;
  min-height: 100%;
}

.document-viewer-zoom-inner {
  transform-origin: 0 0;
  display: inline-block;
  vertical-align: top;
}

.document-viewer-iframe {
  display: block;
  width: min(900px, 92vw);
  min-height: 72vh;
  border: 0;
  background: #fff;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.12);
}

.document-viewer-img {
  display: block;
  max-width: none;
  height: auto;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.12);
}

.user-name-btn {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-tab-btn {
  transition: all 0.2s ease;
}

.auth-tab-btn.btn-primary {
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.lab-confidence-badge {
  display: inline-block;
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  margin-bottom: 0.45rem;
  border: 1px solid transparent;
}

.lab-confidence-high {
  color: #065f46;
  background: #d1fae5;
  border-color: #6ee7b7;
}

.lab-confidence-medium {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

.lab-confidence-low {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}

.lab-confidence-manual {
  color: #334155;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: #fff;
  font-size: 0.9rem;
}

.inline-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.quick-filters {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.2rem 0 0.4rem;
}

.quick-filter-btn {
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}

.flow-section {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 0.9rem;
  display: grid;
  gap: 0.9rem;
}

.flow-section-header {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.flow-section-header h3 {
  margin: 0;
  font-size: 1rem;
}

.flow-section-header p {
  margin: 0.2rem 0 0;
  color: #64748b;
  font-size: 0.88rem;
}

.flow-section-icon {
  font-size: 1.05rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.flow-section-visits {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 22%);
}

.flow-section-labs {
  background: linear-gradient(180deg, #f9f7ff 0%, #ffffff 22%);
}

.flow-section-cabinet {
  background: linear-gradient(180deg, #f1f5f9 0%, #ffffff 24%);
}

.flow-section-diagnostics {
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 22%);
}

.flow-section-diary {
  background: linear-gradient(180deg, #fff7f5 0%, #ffffff 22%);
}

.diary-chart-block {
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fafafa;
}

.diary-vitals-chart-tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  max-width: min(300px, calc(100% - 1rem));
  padding: 0.4rem 0.55rem;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  color: #f8fafc;
  background: #0f172a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.diary-chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  justify-content: space-between;
}

.diary-chart-period {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.diary-chart-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.diary-chart-range-label {
  font-size: 12px;
  max-width: min(300px, 100%);
  text-align: center;
}

.diary-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: 0.5rem 0 0.25rem;
  font-size: 13px;
  color: #475569;
}

.diary-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.diary-chart-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.diary-vitals-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 0.25rem;
}

.menstrual-chart-block {
  background: #fffafc;
  border-color: #fce7f3;
}

.diary-menstrual-svg {
  width: 100%;
  max-width: 920px;
  height: auto;
  display: block;
  margin-top: 0.35rem;
}

.menstrual-chart-legend .diary-chart-legend-item {
  font-size: 12px;
}

.diary-vitals-metrics-row {
  display: grid;
  grid-template-columns: minmax(11rem, 1.4fr) repeat(3, 1fr);
  gap: 0.6rem;
  align-items: end;
}

.diary-vitals-metrics-row input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .diary-vitals-metrics-row {
    grid-template-columns: 1fr 1fr;
  }

  .diary-vitals-metrics-row input#diaryVitalsMeasuredAt {
    grid-column: 1 / -1;
  }
}

.cabinet-main-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.cabinet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.35rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
}

.cabinet-tab {
  flex: 1 1 auto;
  min-width: 5.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.cabinet-tab:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.75);
}

.cabinet-tab--active {
  color: #0f172a;
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.cabinet-tab-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.cabinet-tab-panel {
  display: block;
}

.cabinet-tab-panel.hidden {
  display: none;
}

#adminMainTabsWrap .admin-cabinet-tabs .cabinet-tab {
  flex: 1 1 9rem;
  min-width: 4.75rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.55rem;
}

#adminMainTabsWrap .admin-cabinet-tabs .cabinet-tab-label {
  text-align: center;
  line-height: 1.2;
}

.flow-section-users {
  background: linear-gradient(180deg, #f6fdfb 0%, #ffffff 22%);
}

.admin-hero-section {
  margin-top: 1.5rem;
}

.admin-hero-grid {
  margin-top: 0;
}

.admin-hero-card {
  min-height: 190px;
}

.admin-compact-form .row {
  gap: 0.5rem;
}

.admin-compact-form input {
  margin-bottom: 0.5rem;
}

.flow-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #64748b;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0.15rem 0;
}

.flow-divider::before,
.flow-divider::after {
  content: "";
  height: 1px;
  background: #cbd5e1;
  flex: 1;
}

.lab-flow-step {
  border-left: 4px solid #bfdbfe;
  background: #fff;
}

.flow-step-visits {
  border-left-color: #93c5fd;
}

.flow-step-labs {
  border-left-color: #c4b5fd;
}

.flow-step-users {
  border-left-color: #5eead4;
}

.flow-step-diagnostics {
  border-left-color: #2dd4bf;
}

.flow-step-diary {
  border-left-color: #fb923c;
}

.flow-step-service {
  border-left-color: #f59e0b;
}

/* Делаем акцент на карточках в тоне родительской секции (чуть ярче фона). */
/* ============================================================ */
/* Цветовые акценты карточек по вкладкам главной страницы       */
/* ============================================================ */
#cabinetOverviewSection .lab-flow-step {
  border-left-color: #94a3b8;
}

#privateVisitsSection .lab-flow-step {
  border-left-color: #60a5fa;
}

#privateLabsSection .lab-flow-step {
  border-left-color: #a78bfa;
}

#diagnosticsSection .lab-flow-step {
  border-left-color: #2dd4bf;
}

#privateDiarySection .lab-flow-step {
  border-left-color: #fb923c;
}

.lab-flow-step .toolbar {
  margin-bottom: 0.3rem;
}

.lab-flow-step .section-action-btn {
  margin-bottom: 0.15rem;
}

.flow-step-badge {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.45rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #93c5fd;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 0.76rem;
  font-weight: 700;
}

.flow-step-badge-visits {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1e3a8a;
}

.flow-step-badge-labs {
  border-color: #c4b5fd;
  background: #ede9fe;
  color: #5b21b6;
}

.flow-step-badge-users {
  border-color: #5eead4;
  background: #ccfbf1;
  color: #115e59;
}

.flow-step-badge-diagnostics {
  border-color: #2dd4bf;
  background: #ccfbf1;
  color: #115e59;
}

.flow-step-badge-diary {
  border-color: #fb923c;
  background: #ffedd5;
  color: #9a3412;
}

.flow-step-badge-service {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #92400e;
}

.storage-progress {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 0.35rem;
}

.storage-progress-fill {
  height: 100%;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #0d9488);
  transition: width 0.25s ease;
}

.storage-progress.is-warning .storage-progress-fill {
  background: linear-gradient(90deg, #f59e0b, #ea580c);
}

.storage-progress.is-full .storage-progress-fill {
  background: linear-gradient(90deg, #dc2626, #b91c1c);
}

.profile-billing-focus-pulse {
  animation: profileBillingPulse 3.6s ease-out 1;
}

@keyframes profileBillingPulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(15, 118, 110, 0.34),
      0 10px 28px rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 118, 110, 0.42);
  }
  35% {
    box-shadow:
      0 0 0 10px rgba(15, 118, 110, 0.14),
      0 12px 30px rgba(15, 23, 42, 0.08);
    border-color: rgba(15, 118, 110, 0.58);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(15, 118, 110, 0),
      0 10px 28px rgba(15, 23, 42, 0.06);
    border-color: #e2e8f0;
  }
}

.admin-storage-cell {
  min-width: 160px;
}

.admin-user-actions-stack {
  display: grid;
  gap: 0.35rem;
  min-width: 240px;
}

.admin-user-plan-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-user-plan-controls .admin-user-plan-select,
.admin-user-plan-controls .admin-user-plan-period {
  width: auto;
  min-width: 96px;
  margin-bottom: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
}

.admin-user-action-btn {
  margin-bottom: 0;
  padding: 0.33rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

@media (max-width: 980px) {
  .grid,
  .stats,
  .row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    width: calc(100% - 1rem);
  }

  .topbar-inner {
    min-height: auto;
    padding: 0.5rem 0;
    gap: 0.5rem;
  }

  .brand h2 {
    font-size: 1rem;
  }

  .topbar-actions-dropdown {
    width: auto;
    flex: 0 0 auto;
    margin-left: auto;
  }

  #userProfileBtn {
    max-width: 100%;
  }

  .card {
    padding: 0.8rem;
    border-radius: 14px;
  }

  .flow-section {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .flow-section-header {
    gap: 0.5rem;
  }

  .flow-section-header h3 {
    font-size: 0.95rem;
  }

  .flow-section-header p {
    font-size: 0.82rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .toolbar > * {
    width: 100%;
  }

  .health-connect-filters-row {
    flex-wrap: wrap;
  }

  .health-connect-presets-row {
    gap: 0.35rem;
  }

  .health-connect-actions-row {
    gap: 0.4rem;
  }

  .health-connect-actions-row .btn {
    width: auto;
  }

  .health-connect-filters-row #healthConnectMetricTypeFilter,
  .health-connect-filters-row #healthConnectFromDate,
  .health-connect-filters-row #healthConnectToDate,
  .health-connect-filters-row #diaryHealthConnectMetricTypeFilter,
  .health-connect-filters-row #diaryHealthConnectFromDate,
  .health-connect-filters-row #diaryHealthConnectToDate,
  .health-connect-filters-row #diaryHealthKitMetricTypeFilter,
  .health-connect-filters-row #diaryHealthKitFromDate,
  .health-connect-filters-row #diaryHealthKitToDate {
    flex: 1 1 100%;
  }

  .health-connect-metrics-btn {
    width: auto;
  }

  .status-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-table {
    font-size: 0.84rem;
  }

  .app-table th,
  .app-table td {
    padding: 0.5rem 0.45rem;
  }

  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    white-space: normal;
  }

  .action-buttons .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }

  .doc-uniform-btn {
    width: 100%;
  }

  .pagination {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .modal-overlay {
    padding: 0.5rem;
  }

  .modal {
    width: 100%;
    padding: 0.75rem;
    border-radius: 14px;
    max-height: calc(100vh - 1rem);
    overflow: auto;
  }

  #labPanelResultsModal {
    padding-top: 0.75rem;
  }

  #labPanelResultsTableWrap {
    max-height: calc(100vh - 180px);
  }

  #aiReportViewModal {
    padding-top: 0.75rem;
  }

  #aiReportViewModalBody.report-box {
    max-height: calc(100vh - 180px);
  }

  #documentViewerModal {
    padding-top: 0.75rem;
  }

  .document-viewer-modal {
    max-height: calc(100vh - 1rem);
  }

  .document-viewer-iframe {
    width: 100%;
    min-height: 62vh;
  }
}

@media (max-width: 520px) {
  .btn {
    width: 100%;
    justify-content: center;
  }

  .section-action-btn {
    justify-content: space-between;
  }

  .topbar-actions .btn {
    width: auto;
  }

  .topbar-actions-dropdown[open] .topbar-actions-collapsible {
    min-width: calc(100vw - 1rem);
    right: -0.2rem;
    padding: 0.45rem;
  }

  .brand {
    gap: 0.55rem;
  }

  .logo {
    width: 30px;
    height: 30px;
  }

  .stats .value {
    font-size: 1.2rem;
  }

  .app-table {
    font-size: 0.8rem;
  }
}

@media (max-width: 1100px) {
  .cabinet-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .cabinet-overview-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .table-wrap {
    overflow: visible;
  }

  .app-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .app-table thead {
    display: none;
  }

  .app-table tbody,
  .app-table tr,
  .app-table td {
    display: block;
    width: 100%;
  }

  .app-table tr {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.55rem;
    background: #fff;
    overflow: hidden;
  }

  .app-table td {
    border-bottom: 1px dashed #e2e8f0;
    padding: 0.5rem 0.55rem;
  }

  .app-table td:last-child {
    border-bottom: 0;
  }

  .admin-bg-job-actions-td {
    white-space: normal;
  }
  .admin-bg-job-actions {
    flex-wrap: wrap;
  }

  .app-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
}

@media (max-width: 380px) {
  .container {
    width: calc(100% - 0.75rem);
  }

  .card {
    padding: 0.65rem;
    border-radius: 12px;
  }

  .flow-section {
    padding: 0.6rem;
    gap: 0.6rem;
  }

  .app-table tr {
    margin-bottom: 0.45rem;
    border-radius: 9px;
  }

  .app-table td {
    padding: 0.42rem 0.45rem;
  }

  .app-table td::before {
    font-size: 0.68rem;
    margin-bottom: 0.12rem;
  }

  .btn {
    padding: 0.52rem 0.62rem;
    font-size: 0.84rem;
    border-radius: 9px;
  }

  /* Та же база, что у `.btn`, иначе более специфичное правило шапки перебивает ужатие */
  .topbar-actions .btn,
  .topbar-actions a.btn {
    font-size: 0.84rem;
  }

  .action-buttons .btn {
    min-width: 100px;
    padding: 0.38rem 0.5rem;
    font-size: 0.78rem;
  }

  .parse-mode-badge {
    font-size: 0.7rem;
    padding: 0.12rem 0.4rem;
  }

  .status {
    font-size: 0.84rem;
  }

  .modal {
    padding: 0.6rem;
    border-radius: 12px;
  }
}

/* ============================================================
   Всплывающие уведомления (notify.js — showAppNotify)
   ============================================================ */

/* Баннеры подписки / хранилища под шапкой кабинета */
.subscription-banner-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subscription-banner-stack .subscription-banner {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.9rem;
}

.subscription-banner-stack .subscription-banner p {
  margin: 0;
}

.app-notify-stack {
  position: fixed;
  top: 88px;
  right: 16px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.app-notify-stack .app-notify {
  pointer-events: auto;
}

.app-notify {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
  border: 1px solid #e2e8f0;
  background: #fff;
  opacity: 0;
  transform: translateX(14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-notify--in {
  opacity: 1;
  transform: translateX(0);
}

.app-notify--out {
  opacity: 0;
  transform: translateX(14px);
}

.app-notify--success {
  border-color: #5eead4;
  background: #f0fdfa;
}

.app-notify--error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.app-notify__text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
  color: #0f172a;
  word-break: break-word;
}

.app-notify--error .app-notify__text {
  color: #991b1b;
}

.app-notify__close {
  flex-shrink: 0;
  margin: -4px -6px -4px 0;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.app-notify__close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
}

@media (max-width: 600px) {
  .app-notify-stack {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}
