.lab-sandbox-page {
  position: relative;
  min-height: 100vh;
  background-color: transparent;
}

/* Прозрачный body — иначе --bg-page перекрывает фон Heisenberg (::before) */
body.zootech-app-body.lab-sandbox-page {
  background-color: transparent !important;
}

html:has(body.lab-sandbox-page) {
  background-color: transparent;
}

.lab-sandbox-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("/static/img/lab-heisenberg-bg.jpg") center center / cover no-repeat;
  background-attachment: fixed;
}

.lab-sandbox-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.35) 0%,
    rgba(0, 0, 0, 0.08) 40%,
    rgba(0, 0, 0, 0.2) 100%
  );
}

.lab-sandbox-page .wesp-page-main {
  background: transparent;
}

.lab-sandbox-page .lab-sandbox-header {
  margin-bottom: 1.25rem;
}

.lab-sandbox-page .lab-sandbox-header h1,
.lab-sandbox-page .lab-sandbox-header h2,
.lab-sandbox-page .lab-sandbox-header p,
.lab-sandbox-page .lab-sandbox-header a {
  color: #f8fafc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.lab-sandbox-page .lab-sandbox-header a:hover {
  color: #fde047;
}

.lab-sandbox-page .lab-sandbox-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.lab-sandbox-page .lab-sandbox-header p {
  margin: 0;
  color: var(--text-muted, #64748b);
  font-size: 0.9rem;
}

.lab-sandbox-flow {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr minmax(280px, 360px);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1200px) {
  .lab-sandbox-flow {
    grid-template-columns: 1fr;
  }
}

.lab-sandbox-panel {
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 12px;
  padding: 1rem;
}

html[data-theme="dark"] .lab-sandbox-panel {
  background: var(--bg-white, #1e2428);
  border-color: rgba(255, 255, 255, 0.12);
}

.lab-sandbox-panel__title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.75rem;
}

.lab-sandbox-field {
  margin-bottom: 0.65rem;
}

.lab-sandbox-field label {
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.lab-sandbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.lab-sandbox-table {
  width: 100%;
  font-size: 0.875rem;
}

.lab-sandbox-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}

.lab-sandbox-table td {
  vertical-align: middle;
}

.lab-sandbox-table .form-control,
.lab-sandbox-table .form-select {
  min-width: 0;
}

.lab-sandbox-results table {
  width: 100%;
  font-size: 0.8125rem;
}

.lab-sandbox-results th,
.lab-sandbox-results td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border-light, #e2e8f0);
}

.lab-sandbox-diff--ok {
  color: #15803d;
  font-weight: 600;
}

.lab-sandbox-diff--bad {
  color: #b91c1c;
  font-weight: 600;
}

.lab-sandbox-diff--na {
  color: var(--text-muted, #94a3b8);
}

.lab-sandbox-norm--empty {
  color: var(--text-muted, #94a3b8);
  font-style: italic;
  font-size: 0.78rem;
}

.lab-sandbox-norms {
  font-size: 0.78rem;
  max-height: 220px;
  overflow: auto;
}

.lab-sandbox-norms dt {
  font-weight: 600;
  margin-top: 0.35rem;
}

.lab-sandbox-norms dd {
  margin: 0 0 0.25rem;
  color: var(--text-muted, #64748b);
}

.lab-sandbox-empty {
  color: var(--text-muted, #94a3b8);
  font-size: 0.875rem;
  text-align: center;
  padding: 1.5rem 0.5rem;
}

.lab-sandbox-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  margin-bottom: 0.75rem;
}

html[data-theme="dark"] .lab-sandbox-step {
  background: rgba(3, 105, 161, 0.25);
  color: #7dd3fc;
}

.lab-formulate-section {
  border-top: 1px solid var(--border-light, #e2e8f0);
  padding-top: 1.5rem;
}

.lab-agrostar-section {
  border-top: 1px solid var(--border-light, #e2e8f0);
  padding-top: 1.5rem;
}

.lab-agrostar-drop {
  border: 2px dashed var(--border-light, #cbd5e1);
  border-radius: 0.75rem;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(248, 250, 252, 0.6);
}

html[data-theme="dark"] .lab-agrostar-drop {
  background: rgba(15, 23, 42, 0.35);
}

.lab-agrostar-drop:hover,
.lab-agrostar-drop:focus-visible {
  border-color: #38bdf8;
  outline: none;
}

.lab-agrostar-drop--active {
  border-color: #0ea5e9;
  background: rgba(224, 242, 254, 0.45);
}

html[data-theme="dark"] .lab-agrostar-drop--active {
  background: rgba(3, 105, 161, 0.2);
}

.lab-agrostar-drop__icon {
  font-size: 2rem;
  color: #0ea5e9;
  margin-bottom: 0.5rem;
}

.lab-agrostar-drop__title {
  font-weight: 600;
  margin: 0;
}

.lab-agrostar-drop__file {
  color: #0369a1;
  font-weight: 500;
}

.lab-agrostar-warn {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  background: #fef3c7;
  color: #92400e;
  margin: 0.1rem 0.15rem 0.1rem 0;
}

html[data-theme="dark"] .lab-agrostar-warn {
  background: rgba(146, 64, 14, 0.25);
  color: #fcd34d;
}

.lab-agrostar-result--ok {
  color: #15803d;
}

.lab-agrostar-result--err {
  color: #b91c1c;
}

.lab-agrostar-sniff {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.lab-agrostar-sniff-card {
  background: rgba(248, 250, 252, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.5rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

html[data-theme="dark"] .lab-agrostar-sniff-card {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(71, 85, 105, 0.6);
}

.lab-agrostar-sniff-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.lab-agrostar-sniff__target--warn {
  color: #92400e;
  font-size: 0.875rem;
}

html[data-theme="dark"] .lab-agrostar-sniff__target--warn {
  color: #fcd34d;
}

.lab-agrostar-sniff-meta th {
  width: 38%;
  font-weight: 500;
  color: #64748b;
  vertical-align: top;
}

.lab-agrostar-sniff-nutrients td:first-child {
  max-width: 14rem;
}

.lab-agrostar-sniff__skip {
  color: var(--bs-secondary-color);
  line-height: 1.45;
}

.lab-agrostar-sniff__notes ul {
  padding-left: 1.1rem;
  color: #92400e;
}

html[data-theme="dark"] .lab-agrostar-sniff__notes ul {
  color: #fcd34d;
}

/* —— Heisenberg prime (ошибка на /lab) —— */
.lab-heisenberg-prime-overlay {
  position: fixed;
  inset: 0;
  z-index: 6500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  --lab-prime-eye-y: 26.5vh;
  --lab-prime-eye-gap: 78px;
}

.lab-heisenberg-prime-active .lab-heisenberg-prime-overlay {
  opacity: 1;
}

.lab-heisenberg-prime-active.lab-sandbox-page::before {
  filter: saturate(0.45) contrast(1.2) brightness(0.62) sepia(0.15);
  transform: scale(1.06);
  background-position: center 28%;
  transition: filter 0.4s ease, transform 0.6s ease, background-position 0.5s ease;
}

.lab-heisenberg-prime-active.lab-sandbox-page::after {
  background: linear-gradient(
    180deg,
    rgba(40, 0, 0, 0.35) 0%,
    rgba(10, 0, 0, 0.08) 38%,
    rgba(50, 0, 0, 0.55) 100%
  );
}

/* UI убираем — остаётся Walter и баннер prime */
.lab-heisenberg-prime-active #wespZootechNavMount,
.lab-heisenberg-prime-active .lab-sandbox-header,
.lab-heisenberg-prime-active .lab-sandbox-flow,
.lab-heisenberg-prime-active .lab-agrostar-section,
.lab-heisenberg-prime-active .lab-formulate-section {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s ease;
}

.lab-heisenberg-prime-active .wesp-page-main {
  filter: none;
}

.lab-heisenberg-prime__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% var(--lab-prime-eye-y),
    transparent 0%,
    rgba(0, 0, 0, 0.12) 38%,
    rgba(80, 0, 0, 0.78) 100%
  );
  animation: labPrimeVignette 0.9s ease-in-out infinite alternate;
}

.lab-heisenberg-prime__glow {
  position: absolute;
  left: 50%;
  top: var(--lab-prime-eye-y);
  width: min(36vw, 280px);
  height: min(28vw, 200px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 38, 38, 0.42) 0%, transparent 68%);
  animation: labPrimeGlow 1.1s ease-in-out infinite alternate;
}

.lab-heisenberg-prime__eyes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.lab-heisenberg-prime__eye {
  position: absolute;
  top: var(--lab-prime-eye-y);
  width: 102px;
  height: 58px;
  margin: 0;
  border-radius: 50%;
  background: #ef4444;
  box-shadow:
    0 0 10px 3px rgba(239, 98, 98, 0.95),
    0 0 22px 8px rgba(185, 28, 28, 0.6),
    0 0 40px 16px rgba(127, 29, 29, 0.35);
  animation: labPrimeEyePulse 0.55s ease-in-out infinite alternate;
}

.lab-heisenberg-prime__eye--left {
  left: calc(50% - var(--lab-prime-eye-gap));
  transform: translate(-50%, -50%);
}

.lab-heisenberg-prime__eye--right {
  left: calc(50% + var(--lab-prime-eye-gap));
  transform: translate(-50%, -50%);
}

.lab-heisenberg-prime__scanlines {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.04) 2px,
    rgba(255, 255, 255, 0.04) 4px
  );
}

.lab-heisenberg-prime__banner {
  position: absolute;
  left: 50%;
  bottom: clamp(1.5rem, 8vh, 4rem);
  transform: translateX(-50%);
  width: min(92vw, 520px);
  padding: 0.85rem 1.1rem;
  border-radius: 0.75rem;
  text-align: center;
  background: rgba(15, 0, 0, 0.82);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color: #fecaca;
  backdrop-filter: blur(6px);
}

.lab-heisenberg-prime__title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 18px rgba(239, 68, 68, 0.8);
}

.lab-heisenberg-prime__subtitle {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #f87171;
  margin-top: 0.15rem;
}

.lab-heisenberg-prime__reason {
  margin-top: 0.55rem;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #fee2e2;
}

.lab-heisenberg-prime__source {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: #fca5a5;
  opacity: 0.9;
}

@keyframes labPrimeEyePulse {
  from {
    opacity: 0.75;
    filter: brightness(0.92);
  }
  to {
    opacity: 1;
    filter: brightness(1.15);
  }
}

@keyframes labPrimeVignette {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

@keyframes labPrimeGlow {
  from {
    opacity: 0.45;
    transform: translate(-50%, -50%) scale(0.96);
  }
  to {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@media (max-width: 768px) {
  .lab-heisenberg-prime-overlay {
    --lab-prime-eye-y: 24.5vh;
    --lab-prime-eye-gap: 1198px;
  }
}

@media (min-width: 1400px) {
  .lab-heisenberg-prime-overlay {
    --lab-prime-eye-y: 27vh;
    --lab-prime-eye-gap: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-heisenberg-prime__eye,
  .lab-heisenberg-prime__vignette,
  .lab-heisenberg-prime__glow {
    animation: none;
  }

  .lab-heisenberg-prime-overlay {
    transition: none;
  }
}

.lab-formulate-steps {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.lab-formulate-step {
  border: 1px solid var(--border-light, #e2e8f0);
  background: transparent;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
}

.lab-formulate-step--active {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

.lab-formulate-step-panel--calc.d-none {
  display: none !important;
}

.lab-formulate-pool-wrap {
  max-height: 320px;
  overflow: auto;
}

.lab-formulate-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.lab-formulate-badge--ok {
  background: #dcfce7;
  color: #166534;
}

.lab-formulate-badge--bad {
  background: #fee2e2;
  color: #991b1b;
}

.lab-formulate-row--ineligible {
  opacity: 0.55;
}

.lab-formulate-opt-keys {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
  font-size: 0.8rem;
}

.lab-formulate-opt-key {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.5rem;
  align-items: start;
  cursor: pointer;
}

.lab-formulate-opt-key small {
  grid-column: 2;
}

.lab-formulate-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.5rem;
}

.lab-formulate-row--target td {
  background: rgba(14, 165, 233, 0.08);
  font-weight: 600;
}

.lab-formulate-row--target td.lab-sandbox-diff--bad,
.lab-formulate-row--target td.lab-sandbox-diff--ok {
  font-size: 0.95rem;
}
