/**
 * Общая оболочка: фон, шапка, кнопки. Палитра: #FFA742 #318230 #79CE4B #EFF9E3
 */

:root {
  --color-pale: #eff9e3;
  --color-green-dark: #318230;
  --color-green-mid: #79ce4b;
  --color-accent: #ffa742;

  --shell-bg: var(--color-pale);
  --shell-text: #1a3018;
  --shell-muted: #3d5537;
  --shell-card: #ffffff;
  --shell-border: #c4dfb2;
  --table-header-bg: #dff3d4;
  --row-highlight-bg: #e8f8dc;

  --btn-primary-bg: var(--color-accent);
  --btn-primary-border: #e08620;
  --btn-secondary-bg: var(--color-green-dark);
  --btn-secondary-border: #246622;
  --btn-muted-bg: #d8f0cb;
  --btn-muted-border: #98d078;
  --nav-bg: var(--color-green-dark);
  --danger-bg: #b3261e;
  --danger-border: #8c1f19;
  --site-brand-logo-text-gap: 16px;
}

body.site-body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: var(--shell-bg);
  color: var(--shell-text);
  line-height: 1.35;
}

html.ui-locale-pending:not(.uzi-locale-ready) .site-shell,
html.ui-locale-pending:not(.uzi-locale-ready) .login-page {
  visibility: hidden;
}

/* Первая загрузка языка на устройстве (пока нет localStorage-кэша бандла) */
.uzi-locale-first-load {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 48, 24, 0.45);
  box-sizing: border-box;
}

.uzi-locale-first-load[hidden] {
  display: none !important;
}

.uzi-locale-first-load-card {
  width: min(420px, 100%);
  background: var(--shell-card, #fff);
  color: var(--shell-text, #1a3018);
  border: 1px solid var(--shell-border, #c4dfb2);
  border-radius: 10px;
  padding: 22px 24px 20px;
  box-shadow: 0 12px 40px rgba(26, 48, 24, 0.18);
}

.uzi-locale-first-load-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.uzi-locale-first-load-body {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--shell-muted, #3d5537);
}

.uzi-locale-first-load-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--btn-muted-bg, #d8f0cb);
  overflow: hidden;
}

.uzi-locale-first-load-bar > span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: var(--color-green-dark, #318230);
  animation: uzi-locale-first-load-slide 1.1s ease-in-out infinite;
}

@keyframes uzi-locale-first-load-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.site-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

.site-header-wrap {
  background: var(--nav-bg);
  color: #fff;
  box-shadow: 0 1px 4px rgba(49, 130, 48, 0.2);
}

.site-header {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  box-sizing: border-box;
}

.site-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: 100%;
}

.site-brand {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--site-brand-logo-text-gap);
  font-weight: 700;
  font-size: clamp(14px, 2.2vw, 16px);
  color: #fff;
  text-decoration: none;
  margin-right: 4px;
}

.site-brand-logo {
  display: block;
  flex-shrink: 0;
  height: 32px;
  width: auto;
  border-radius: 6px;
  background: #fff;
  padding: 3px 8px;
  box-sizing: content-box;
}

.site-brand-text {
  min-width: 0;
  padding-left: 2px;
}

.site-header-temporary-access {
  flex: 0 0 auto;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #1a3018;
  border: 1px solid rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.site-header-temporary-access-note {
  margin: 6px 0 0;
  padding: 0;
  font-size: 10px;
  line-height: 1.4;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
}

.site-header-temporary-access-mail {
  color: #ffe8c4;
  text-decoration: underline;
}

.site-header-temporary-access-mail:hover {
  color: #fff;
}

.site-brand:hover {
  text-decoration: underline;
}

/* Пункты меню скрыты до /api/me (site-header.js → html.site-nav-ready). */
html:not(.site-nav-ready) .site-nav {
  visibility: hidden;
  pointer-events: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
  min-width: 0;
  justify-content: flex-end;
}

.site-nav .nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px clamp(10px, 1.4vw, 14px);
  border-radius: 10px;
  background: rgba(239, 249, 227, 0.15);
  border: 1px solid rgba(239, 249, 227, 0.35);
  color: #fff !important;
  font-size: clamp(12px, 1.6vw, 14px);
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
  max-width: min(280px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.site-nav .nav-link:hover {
  background: rgba(255, 167, 66, 0.35);
  border-color: rgba(255, 167, 66, 0.55);
}

.site-nav-feed-link {
  position: relative;
  padding-right: clamp(12px, 1.8vw, 18px);
}

.site-nav-feed-bell {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.45));
}

.site-nav .nav-link[aria-current="page"] {
  background: var(--color-accent);
  color: #1a1408 !important;
  border-color: #f5c06a;
  font-weight: 700;
}

/* inline-flex выше перебивает [hidden] на десктопе — «Активность» и «ПЖ» только для админа (site-header.js) */
.site-nav-uni-templates {
  display: contents;
}

.site-nav .nav-link[hidden] {
  display: none !important;
}

.site-header-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  flex: 0 0 auto;
  margin-left: auto;
  font-size: clamp(12px, 1.6vw, 14px);
  font-weight: 600;
  color: #eff9e3;
  max-width: 100%;
}

.site-header-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(260px, 42vw);
}

.site-header-locale {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: clamp(11px, 1.5vw, 13px);
  font-weight: 600;
  color: #eff9e3;
}

.site-header-locale-label {
  display: none;
}

.site-header-locale-select {
  font: inherit;
  font-weight: 600;
  color: #1a3d12;
  background: #eff9e3;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 2px 6px;
  max-width: 9rem;
  cursor: pointer;
}

.site-header-group-name {
  font-size: 12px;
  font-weight: 500;
  color: #d8f0c4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(200px, 38vw);
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  line-height: 1.35;
}

.site-header-device-warn {
  margin: 0;
  padding: 3px 10px 5px;
  font-size: 10px;
  line-height: 1.35;
  font-weight: 500;
  text-align: center;
  color: #6b4a12;
  background: #fff6df;
  border-bottom: 1px solid #e8d4a8;
}

.feature-dev-notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #b00020;
  background: #ffebee;
  border: 1px solid #ef9a9a;
  border-radius: 8px;
}

.feature-dev-notice-dialog {
  max-width: min(420px, calc(100vw - 32px));
  padding: 20px 22px;
  border: 1px solid #ef9a9a;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.feature-dev-notice-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.feature-dev-notice-dialog-text {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: #b00020;
  text-align: center;
}

.feature-dev-notice-dialog-actions {
  display: flex;
  justify-content: center;
}

.feature-dev-notice-dialog-actions button {
  min-height: 40px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #b00020;
  background: #b00020;
  color: #fff;
}

.site-header-logout {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: #eff9e3;
  text-decoration: underline;
  cursor: pointer;
}

.site-header-logout:hover {
  color: var(--color-accent);
}

.settings-snapshots-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: min(50vh, 360px);
  overflow-y: auto;
  border: 1px solid #dde4ec;
  border-radius: 6px;
}

.settings-snapshots-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f6;
  font-size: 13px;
}

.settings-snapshots-item:last-child {
  border-bottom: none;
}

.settings-snapshots-meta {
  flex: 1;
  min-width: 12em;
  line-height: 1.4;
}

.settings-snapshots-tag {
  font-size: 11px;
  color: #6b7280;
  font-weight: normal;
}

.session-bar.site-session {
  margin: 14px 0 12px;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  justify-content: flex-end;
}

.session-bar.site-session .who {
  margin-right: auto;
  color: var(--shell-muted);
}

/* Кнопки */
.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: #1a1408;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.04);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: #fff;
}

.btn-secondary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-muted {
  background: var(--btn-muted-bg);
  border-color: var(--btn-muted-border);
  color: var(--shell-text);
}

.btn-muted:hover:not(:disabled) {
  background: #cae8b8;
}

.btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.shell-field {
  flex: 1 1 200px;
  min-width: 140px;
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}

.shell-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.shell-hint {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  color: var(--shell-muted);
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 768px) {
  :root {
    --site-brand-logo-text-gap: 12px;
  }

  .site-header-wrap {
    position: relative;
    z-index: 1003;
  }

  .site-header-row {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px 10px;
  }

  .site-brand {
    flex: 1;
    min-width: 0;
    margin-right: 0;
    font-size: 14px;
  }

  .site-brand-logo {
    height: 22px;
    width: auto;
    max-width: 80px;
    padding: 2px 4px;
    object-fit: contain;
  }

  .site-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .site-nav-toggle {
    display: inline-flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 5px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 11px;
    border: 1px solid rgba(239, 249, 227, 0.45);
    border-radius: 10px;
    background: rgba(239, 249, 227, 0.12);
    cursor: pointer;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  .site-nav-toggle:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  .site-nav-toggle-bar {
    display: block;
    height: 3px;
    width: 100%;
    background: #eff9e3;
    border-radius: 1px;
    transition:
      transform 0.18s ease,
      opacity 0.18s ease;
  }

  body.site-nav-drawer-open .site-nav-toggle-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  body.site-nav-drawer-open .site-nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  body.site-nav-drawer-open .site-nav-toggle-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  .site-header-user {
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 6px 10px;
    max-width: min(220px, 52vw);
  }

  .site-header-user-name {
    max-width: min(100px, 28vw);
  }

  .site-header-group-name {
    max-width: min(88px, 24vw);
    font-size: 11px;
    padding: 1px 7px;
  }

  .site-nav {
    position: fixed;
    z-index: 1002;
    left: 0;
    right: 0;
    top: var(--site-header-h, 52px);
    max-height: min(70dvh, calc(100dvh - var(--site-header-h, 52px)));
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 10px 14px 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    margin: 0;
    flex: none !important;
    min-width: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform-origin: top center;
    transform: scaleY(0.92);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 0.16s ease,
      transform 0.16s ease,
      visibility 0.16s;
  }

  body.site-nav-drawer-open .site-nav {
    transform: scaleY(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .site-nav .nav-link {
    flex: none;
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
    box-sizing: border-box;
  }

  body.site-nav-drawer-open {
    overflow: hidden;
  }
}

@media (max-width: 400px) {
  :root {
    --site-brand-logo-text-gap: 10px;
  }

  .site-brand-logo {
    height: 20px;
    max-width: 64px;
    padding: 2px 3px;
  }

  .site-brand {
    font-size: 13px;
  }
}

.site-nav-toggle {
  display: none;
}

.site-nav-backdrop {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  right: 0;
  top: var(--site-header-h, 52px);
  bottom: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(20, 35, 18, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.site-nav-drawer-open .site-nav-backdrop {
  display: block;
}

@media (min-width: 769px) {
  body.site-nav-drawer-open {
    overflow: auto;
  }

  body.site-nav-drawer-open .site-nav-backdrop {
    display: none !important;
  }
}

.site-shell .actions button,
.site-shell .norms-save-row button,
.site-shell .presets-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  border: 1px solid var(--btn-muted-border);
  background: var(--btn-muted-bg);
  color: var(--shell-text);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Клинические страницы на .site-main без .site-shell (МЖ, универсальный протокол) */
.site-main .actions button,
.site-main .norms-save-row button,
.site-main .presets-row button,
.site-main #protocolEquipmentPanel button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  border: 1px solid var(--btn-muted-border);
  background: var(--btn-muted-bg);
  color: var(--shell-text);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.site-main .actions input,
.site-main .actions select,
.site-main .mamma-protocol-toolbar input,
.site-main .mamma-protocol-toolbar select,
.site-main #protocolEquipmentPanel select {
  padding: 7px 10px;
  font: 14px Arial, sans-serif;
  border: 1px solid #767676;
  border-radius: 4px;
  max-width: 100%;
  box-sizing: border-box;
  background: #fff;
  color: var(--shell-text);
}

.site-main .actions select,
.site-main .mamma-protocol-toolbar select,
.site-main #protocolEquipmentPanel select {
  width: auto;
  min-width: 6em;
}

.site-main .actions button.primary,
.site-main button.primary,
.site-main #protocolEquipmentPanel button.primary {
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #1a1408;
}

.site-main .actions button.secondary,
.site-main button.secondary,
.site-main #uniPathologyList button.secondary:not(.path-list-btn-delete),
.site-main #protocolEquipmentPanel button.secondary {
  border: 1px solid var(--btn-secondary-border);
  border-color: var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: #fff;
}

.site-main .actions button.secondary:hover:not(:disabled),
.site-main button.secondary:hover:not(:disabled),
.site-main #uniPathologyList button.secondary:hover:not(:disabled):not(.path-list-btn-delete),
.site-main #protocolEquipmentPanel button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.site-main .actions button.primary:hover:not(:disabled),
.site-main button.primary:hover:not(:disabled),
.site-main #protocolEquipmentPanel button.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.site-main .actions button:disabled,
.site-main button:disabled,
.site-main #protocolEquipmentPanel button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.site-main #uniPathologyList button.secondary:not(.path-list-btn-delete) {
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.2;
}

.site-main .path-list-btn-edit,
.site-main .edit-path-inline {
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #1a1408;
}

.site-main .protocol-panel-build-btn {
  font-weight: 700;
}

/* Патологии: единые кнопки в цветах сайта */
.site-shell #pathologyPanelRoot .actions > button.secondary,
.site-shell #thyroidPathologyPanelRoot .actions > button.secondary,
.site-shell #uniPathologyActions > button.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: #fff;
}

.site-shell #pathologyPanelRoot .path-checkbox-list button.secondary,
.site-shell #pathologyPanelRoot .template-path-col-actions button.secondary,
.site-shell #thyroidPathologyPanelRoot .path-checkbox-list button.secondary,
.site-shell #uniPathologyList button.secondary:not(.path-list-btn-delete) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: #fff;
}

.site-shell .path-list-btn-edit,
.site-shell .edit-path-inline {
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #1a1408;
}

.site-shell .path-list-btn-reorder,
.site-shell .path-list-btn-add-path,
.site-shell .path-list-btn-subgroup,
.site-shell .adult-obp-path-group-toggle,
.site-shell .thyroid-path-group-toggle {
  min-width: 1.75rem;
  padding: 2px 8px !important;
  font-size: 11px !important;
  border-color: var(--btn-muted-border);
  background: var(--btn-muted-bg);
  color: var(--shell-text);
}

.site-shell .path-list-btn-duplicate {
  min-height: 28px !important;
  padding: 3px 10px !important;
  font-size: 11px !important;
  border-color: var(--color-green-mid);
  background: var(--color-pale);
  color: var(--color-green-dark);
}

.site-shell .path-list-btn-delete {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  border-radius: 8px !important;
  border: 1px solid #e8a8a8 !important;
  background: #fff5f5 !important;
  color: var(--danger-bg) !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.site-shell .path-list-btn-delete:hover:not(:disabled) {
  background: #fde8e8 !important;
  border-color: #d88888 !important;
  filter: none;
}

#pathologyEditOverlay .kidney-ref-head button.primary,
#thyroidPathologyEditOverlay .kidney-ref-head button.primary,
#pathologyEditOverlay .kidney-ref-head #btnPathologyModalSave,
.site-shell #pathologyEditOverlay .kidney-ref-head button.primary,
.site-shell #thyroidPathologyEditOverlay .kidney-ref-head button.primary,
.site-shell #pathologyEditOverlay .kidney-ref-head #btnPathologyModalSave {
  min-height: 32px !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  border: 1px solid var(--btn-primary-border) !important;
  background: var(--btn-primary-bg) !important;
  color: #1a1408 !important;
  box-shadow: none !important;
  filter: none !important;
}

#pathologyEditOverlay .kidney-ref-head button.secondary,
#thyroidPathologyEditOverlay .kidney-ref-head button.secondary,
#pathologyEditOverlay .kidney-ref-head #btnPathologyModalClose,
.site-shell #pathologyEditOverlay .kidney-ref-head button.secondary,
.site-shell #thyroidPathologyEditOverlay .kidney-ref-head button.secondary,
.site-shell #pathologyEditOverlay .kidney-ref-head #btnPathologyModalClose {
  min-height: 32px !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  border: 1px solid var(--btn-muted-border) !important;
  background: var(--btn-muted-bg) !important;
  color: var(--shell-text) !important;
  box-shadow: none !important;
  filter: none !important;
}

.site-shell .actions button.primary,
.site-shell button.primary {
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #1a1408;
}

.site-shell .actions button.secondary,
.site-shell button.secondary {
  border: 1px solid var(--btn-secondary-border);
  border-color: var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: #fff;
}

.site-shell .actions button.secondary:hover:not(:disabled),
.site-shell button.secondary:hover:not(:disabled),
.site-shell #pathologyPanelRoot .actions > button.secondary:hover:not(:disabled),
.site-shell #thyroidPathologyPanelRoot .actions > button.secondary:hover:not(:disabled),
.site-shell #uniPathologyActions > button.secondary:hover:not(:disabled),
.site-shell #pathologyPanelRoot .path-checkbox-list button.secondary:hover:not(:disabled),
.site-shell #thyroidPathologyPanelRoot .path-checkbox-list button.secondary:hover:not(:disabled),
.site-shell #uniPathologyList button.secondary:hover:not(:disabled):not(.path-list-btn-delete),
.site-shell .path-list-btn-edit:hover:not(:disabled),
.site-shell .edit-path-inline:hover:not(:disabled) {
  filter: brightness(1.06);
}

#pathologyEditOverlay .kidney-ref-head button.primary:hover:not(:disabled),
#thyroidPathologyEditOverlay .kidney-ref-head button.primary:hover:not(:disabled),
#pathologyEditOverlay .kidney-ref-head #btnPathologyModalSave:hover:not(:disabled),
.site-shell #pathologyEditOverlay .kidney-ref-head button.primary:hover:not(:disabled),
.site-shell #thyroidPathologyEditOverlay .kidney-ref-head button.primary:hover:not(:disabled),
.site-shell #pathologyEditOverlay .kidney-ref-head #btnPathologyModalSave:hover:not(:disabled) {
  filter: brightness(1.05);
}

#pathologyEditOverlay .kidney-ref-head button.secondary:hover:not(:disabled),
#thyroidPathologyEditOverlay .kidney-ref-head button.secondary:hover:not(:disabled),
#pathologyEditOverlay .kidney-ref-head #btnPathologyModalClose:hover:not(:disabled),
.site-shell #pathologyEditOverlay .kidney-ref-head button.secondary:hover:not(:disabled),
.site-shell #thyroidPathologyEditOverlay .kidney-ref-head button.secondary:hover:not(:disabled),
.site-shell #pathologyEditOverlay .kidney-ref-head #btnPathologyModalClose:hover:not(:disabled) {
  filter: brightness(0.97);
}

.site-shell .norms-save-row button {
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #1a1408;
}

.site-shell button.btn-muted {
  border-color: var(--btn-muted-border);
  background: var(--btn-muted-bg);
  color: var(--shell-text);
}

.site-shell .plaque-chip button,
.site-shell .chip button {
  display: inline;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-weight: 700;
  color: #a00;
}

.group-offers-banner {
  margin-bottom: 14px;
  border: 1px solid #c9d4e8;
  border-radius: 10px;
  background: #f3f7ff;
  padding: 12px 14px;
}
.group-offers-banner-inner > strong {
  display: block;
  margin-bottom: 10px;
}
.group-offers-item {
  border-top: 1px solid #dbe4f2;
  padding-top: 10px;
  margin-top: 10px;
}
.group-offers-item:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.group-offers-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  justify-content: space-between;
  margin-bottom: 6px;
}
.group-offers-meta {
  color: #555;
  font-size: 13px;
}
.group-offers-msg {
  font-size: 13px;
  color: #333;
  margin-bottom: 8px;
}
.group-offers-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.group-offers-actions button {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--btn-primary-border, #2d6a4f);
  background: var(--btn-primary-bg, #2d6a4f);
  color: #fff;
}
.group-offers-actions button.ghost {
  background: #fff;
  color: #333;
  border-color: #a0a0a0;
}
.group-offers-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Плавающая кнопка «Сформировать протокол» на страницах шаблонов */
.protocol-floating-build-btn {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  /* Выше модалки первой загрузки языка (10050), иначе кнопка «пропадает» под оверлеем */
  z-index: 10110;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 4px 16px rgba(49, 130, 48, 0.35);
  border: 1px solid var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.protocol-floating-build-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(49, 130, 48, 0.42);
}

.protocol-floating-build-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.protocol-floating-build-btn.is-busy {
  opacity: 0.72;
  cursor: wait;
}

/* Резервная кнопка в блоке «Итоговый протокол» — всегда доступна */
.protocol-panel-build-btn {
  font-weight: 700;
}

.protocol-panel-build-btn.is-busy {
  opacity: 0.72;
  cursor: wait;
}

/* Модальное окно патологий — единый стиль (оверлей вне .site-shell) */
.kidney-ref-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(26, 48, 24, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: auto;
}

.kidney-ref-overlay[hidden] {
  display: none !important;
}

.kidney-ref-sheet {
  background: var(--shell-card, #fff);
  border: 1px solid var(--shell-border, #c4dfb2);
  border-radius: 12px;
  max-width: min(960px, 100%);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(49, 130, 48, 0.18);
}

.kidney-ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--shell-border, #c4dfb2);
  background: linear-gradient(180deg, var(--color-pale, #eff9e3) 0%, #fff 100%);
  border-radius: 12px 12px 0 0;
}

.kidney-ref-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--color-green-dark, #318230);
}

.kidney-ref-scroll {
  overflow: auto;
  padding: 14px 16px;
  flex: 1 1 auto;
  max-height: calc(92vh - 60px);
  background: #fff;
}

.pathology-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pathology-modal-sticky-name {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--shell-border, #c4dfb2);
  box-shadow: 0 4px 12px rgba(49, 130, 48, 0.08);
}

.pathology-modal-name-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--shell-text, #1a3018);
}

.pathology-modal-name-label input,
.pathology-modal-name-label select,
#pathologyEditOverlay select,
#thyroidPathologyEditOverlay select {
  font-weight: normal;
  padding: 8px 10px;
  border: 1px solid var(--shell-border, #c4dfb2);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--shell-text, #1a3018);
  background: #fff;
}

.pathology-modal-placeholder-scroll {
  max-height: min(52vh, 560px);
  overflow-y: auto;
  border: 1px solid var(--shell-border, #c4dfb2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
  background: var(--color-pale, #eff9e3);
}

.pathology-protocol-fields input[type="text"],
.pathology-protocol-fields textarea {
  font: 14px Arial, Helvetica, sans-serif;
  border: 1px solid var(--shell-border, #c4dfb2);
  border-radius: 8px;
  box-sizing: border-box;
  color: var(--shell-text, #1a3018);
  background: #fff;
  padding: 7px 10px;
}

/* Шаблон / без отличия — серый; при focus или отличии — полноценный цвет */
.pathology-protocol-fields input[type="text"]:not(.pathology-ph-edited):not(:focus):not(.pathology-ph-active),
.pathology-protocol-fields textarea:not(.pathology-ph-edited):not(:focus):not(.pathology-ph-active) {
  color: var(--shell-muted, #3d5537);
  opacity: 0.72;
}

.pathology-protocol-fields input[type="text"]:focus,
.pathology-protocol-fields textarea:focus,
.pathology-protocol-fields input[type="text"].pathology-ph-active,
.pathology-protocol-fields textarea.pathology-ph-active,
.pathology-protocol-fields input[type="text"].pathology-ph-edited,
.pathology-protocol-fields textarea.pathology-ph-edited {
  color: var(--shell-text, #1a3018);
  opacity: 1;
}

.pathology-protocol-fields input[type="text"]:not(.pathology-ph-edited)::placeholder,
.pathology-protocol-fields textarea:not(.pathology-ph-edited)::placeholder {
  color: var(--shell-muted, #3d5537);
  opacity: 0.65;
}

.pathology-protocol-fields input[type="text"].pathology-ph-edited,
.pathology-protocol-fields textarea.pathology-ph-edited {
  background: #e8f8dc;
  border-color: var(--color-green-mid, #79ce4b) !important;
  box-shadow: none;
}

#pathologyEditOverlay .pathology-modal-head-actions .primary,
#thyroidPathologyEditOverlay .pathology-modal-head-actions .primary,
#pathologyEditOverlay #btnPathologyModalSave,
#thyroidPathologyEditOverlay #btnThyroidPathologyModalSave {
  min-height: 34px;
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--btn-primary-border) !important;
  background: var(--btn-primary-bg) !important;
  color: #1a1408 !important;
  box-shadow: none !important;
  cursor: pointer;
}

#pathologyEditOverlay .pathology-modal-head-actions .secondary,
#thyroidPathologyEditOverlay .pathology-modal-head-actions .secondary,
#pathologyEditOverlay #btnPathologyModalClose,
#thyroidPathologyEditOverlay #btnThyroidPathologyModalClose {
  min-height: 34px;
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--btn-muted-border) !important;
  background: var(--btn-muted-bg) !important;
  color: var(--shell-text) !important;
  box-shadow: none !important;
  cursor: pointer;
}

.pathology-protocol-fields .modal-path-section-title {
  margin-top: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-green-dark, #318230);
}

.pathology-protocol-fields .modal-path-section-title strong {
  color: var(--color-green-dark, #318230);
}

/* Блок «Датчики» — одна строка, перед итоговым протоколом */
.protocol-equipment-panel {
  margin-bottom: 14px;
}

#protocolEquipmentPanel .protocol-equipment-title {
  margin: 0 0 8px;
  font-size: 14px;
}

#protocolEquipmentPanel .protocol-equipment-settings-hint {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
}

#protocolEquipmentPanel .protocol-equipment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

#protocolEquipmentPanel .protocol-equipment-apparatus {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex: 0 0 auto;
}

#protocolEquipmentPanel .protocol-equipment-apparatus-label {
  white-space: nowrap;
  font-size: 13px;
}

#protocolEquipmentPanel .protocol-equipment-apparatus-select {
  width: auto;
  min-width: 16ch;
  max-width: none;
  padding: 6px 36px 6px 8px;
  font-size: 13px;
  box-sizing: border-box;
  flex-shrink: 0;
}

#protocolEquipmentPanel .protocol-equipment-sensors {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 13px;
  flex: 1 1 auto;
  min-width: 0;
}

#protocolEquipmentPanel .protocol-equipment-sensor-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

#protocolEquipmentPanel .protocol-equipment-mode {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.equipment-catalog-editor {
  max-width: 720px;
}

.equipment-apparatus-block {
  border: 1px solid var(--color-border, #d8d8d8);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: #fff;
}

.equipment-apparatus-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.equipment-apparatus-summary::-webkit-details-marker {
  display: none;
}

.equipment-apparatus-name {
  flex: 1;
  min-width: 12em;
  font-weight: 600;
}

.equipment-sensors-list {
  margin: 10px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.equipment-sensor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.equipment-sensor-model {
  flex: 1;
  min-width: 10em;
}

.equipment-sensor-type {
  min-width: 12em;
}

.equipment-catalog-actions {
  margin-top: 12px;
}

.protocol-recommended-equipment {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.35;
}
