/**
 * Общая доводка UI зоотех-страниц (consumption, components, feed_dispensers, reports).
 * Подключать после page-inline <style>, до </head>.
 */

.page-content,
.zootech-app-body .wesp-page-main {
  flex: 1 0 auto;
  width: 100%;
}

/* Панели (отчёты): компактная шапка, скругление на контейнере */
.zootech-panel {
  background: var(--surface, var(--bg-white));
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--zt-space-4, 1.5rem);
  overflow: hidden;
  padding: 0;
}

.zootech-panel > .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.875rem 0.375rem;
  margin: 0;
  min-height: 0;
  line-height: 1.25;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, var(--text-dark));
  background: var(--surface, var(--bg-white)) !important;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
}

.zootech-panel > .card-header i {
  font-size: 0.8125rem;
  color: var(--primary-color);
}

.zootech-panel > .card-header .btn-sm,
.zootech-panel > .card-header .btn {
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1.2;
  min-height: auto;
}

.zootech-panel > .card-body {
  padding: 0.875rem 1rem 1rem;
}

/* Секции components / consumption / reports */
.zootech-app-body .form-section.zt-section,
.zootech-app-body .consumption-block.zt-section {
  border-radius: 16px;
  overflow: hidden;
  padding: var(--zt-space-4, 1.5rem);
  margin-bottom: var(--zt-space-4, 1.5rem);
}

/* /reports: выпадающий календарь не должен обрезаться карточкой */
.zootech-app-body.reports-page .form-section.zt-section.reports-controls {
  overflow: visible;
}

.zootech-app-body .form-section .form-title,
.zootech-app-body .consumption-block .section-title {
  font-size: var(--zt-font-section, 1.125rem);
  font-weight: 600;
  margin: 0 0 var(--zt-space-3, 1rem);
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.25;
}

.zootech-app-body .consumption-section {
  margin: 1.25rem 0 0;
}

/* Карточки: без поднятия, подсветка как на dashboard рецептов */
.zootech-app-body .report-card,
.zootech-app-body .component-card,
.zootech-app-body .dispenser-card.list-item,
.zootech-app-body .zt-card,
.zootech-app-body .zt-section,
.zootech-app-body .list-item,
.zootech-app-body .role-card {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.zootech-app-body .report-card:hover,
.zootech-app-body .component-card.zt-card--interactive:hover,
.zootech-app-body .component-card.component-card--clickable:hover,
.zootech-app-body .dispenser-card.list-item:hover,
.zootech-app-body .zt-card--interactive:hover,
.zootech-app-body .zt-card:hover,
.zootech-app-body .zt-section:hover,
.zootech-app-body .list-item:hover,
.zootech-app-body .role-card:hover {
  transform: none !important;
}

.zootech-app-body .report-card:hover {
  box-shadow: var(--shadow-soft);
  background-color: rgba(var(--primary-rgb), 0.04);
  border-color: rgba(var(--primary-rgb), 0.35);
}

html[data-theme="dark"] .zootech-app-body .report-card:hover {
  background-color: rgba(var(--primary-rgb), 0.08);
  border-color: rgba(var(--primary-rgb), 0.4);
  box-shadow: none;
}

.zootech-app-body .component-card.zt-card--interactive:hover,
.zootech-app-body .component-card.component-card--clickable:hover {
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(var(--primary-rgb, 33, 150, 243), 0.2);
  border-color: var(--primary-color);
  background-color: rgba(var(--primary-rgb), 0.04);
}

.zootech-app-body .dispenser-card.list-item:hover {
  box-shadow: none !important;
  border-color: var(--primary-color);
  background-color: rgba(var(--primary-rgb), 0.05);
}

/* Кнопки: без translateY на hover */
.zootech-app-body .btn-secondary:hover,
.zootech-app-body .btn-danger:hover,
.zootech-app-body .btn-success:hover,
.zootech-app-body .magic-button:hover,
.zootech-app-body .modern-btn:hover,
.zootech-app-body .nav-link:hover {
  transform: none !important;
}

.zootech-app-body .magic-button:hover,
.zootech-app-body .modern-btn.btn-primary-modern:hover {
  filter: brightness(1.06);
}

/* Не дублировать page-enter и fade-in / content-reveal */
html.wesp-page-enter-pending .fade-in,
html.wesp-page-enter-ready .fade-in,
html.wesp-page-enter-pending .wesp-content-reveal,
html.wesp-page-enter-ready .wesp-content-reveal {
  animation: none !important;
  opacity: inherit;
  transform: none !important;
}

html.wesp-page-enter-done .fade-in {
  animation: zt-reveal 0.45s var(--wesp-enter-ease, ease) both;
}

@media (prefers-reduced-motion: reduce) {
  html.wesp-page-enter-done .fade-in {
    animation: none !important;
  }
}

/* Loading на странице оборудования */
.zootech-app-body .loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zt-space-2, 12px);
  min-height: 8rem;
  padding: var(--zt-space-4, 24px);
  color: var(--text-muted);
  font-size: var(--zt-font-body, 0.9375rem);
}

.zootech-app-body .loading-state i {
  color: var(--primary-color);
}

/* Dashed add-cards — единая min-height */
.zootech-app-body .add-devices-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--zt-space-3, 16px);
  margin-bottom: 1rem;
}

@media (max-width: 992px) {
  .zootech-app-body .add-devices-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .zootech-app-body .add-devices-container {
    grid-template-columns: 1fr;
  }
}

/* Analytics: итоги и сравнение на /reports */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .analytics-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-kpi-card {
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1rem 1.125rem;
}

.analytics-kpi-card__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.analytics-kpi-card__value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-dark);
}

.analytics-kpi-card__value--warn {
  color: #dc3545;
}

.analytics-kpi-card__value--loss {
  color: #dc3545;
  font-weight: 700;
}

.analytics-kpi-card__value--risk {
  color: #d97706;
  font-weight: 700;
}

html[data-theme="dark"] .analytics-kpi-card__value--risk {
  color: #fbbf24;
}

.analytics-kpi-card__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.analytics-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.analytics-top-list {
  display: grid;
  grid-template-columns: minmax(8.5rem, 12rem) minmax(5rem, 1fr) minmax(7.5rem, max-content);
  column-gap: 1rem;
  row-gap: 0.55rem;
  align-items: center;
}

.analytics-top-row {
  display: contents;
}

.analytics-top-row__name {
  font-size: 0.875rem;
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-top-row__bar {
  height: 8px;
  min-width: 0;
  width: 100%;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.analytics-top-row__bar span {
  display: block;
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
}

.analytics-pf-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.analytics-pf-card {
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1rem 1.125rem;
  cursor: pointer;
}

.analytics-pf-card__head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.analytics-pf-section + .analytics-pf-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.analytics-pf-section__title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.analytics-pf-mixer-line {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-light);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.analytics-pf-mixer-line strong {
  color: var(--text-primary, inherit);
  font-weight: 600;
}

.analytics-pf-mixer-line--negative strong {
  color: #dc3545;
}

.analytics-pf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.analytics-pf-legend__dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.analytics-pf-legend__dot--base { background: #94a3b8; }
.analytics-pf-legend__dot--plan { background: #3b82f6; }
.analytics-pf-legend__dot--actual { background: #10b981; }

.analytics-pf-bars {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}

.analytics-pf-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.analytics-pf-bar span {
  display: block;
  height: 8px;
  border-radius: 4px;
  min-width: 2px;
}

.analytics-pf-bar--base span { background: #94a3b8; }
.analytics-pf-bar--plan span { background: #3b82f6; }
.analytics-pf-bar--actual span { background: #10b981; }

.analytics-pf-bar em {
  font-style: normal;
  min-width: 3rem;
  text-align: right;
  color: var(--text-muted);
}

.analytics-top-row__value {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  justify-self: end;
}

.analytics-top-row__value--loss {
  color: #dc3545;
}

.analytics-top-row__value--risk {
  color: #d97706;
}

.analytics-top-row__bar--loss span {
  background: #dc3545;
}

.analytics-top-row__bar--risk span {
  background: #d97706;
}

.analytics-pf-comp--excluded {
  opacity: 0.82;
}

.analytics-pf-comp--excluded .analytics-pf-comp__name {
  color: #6b7280;
}

html[data-theme="dark"] .analytics-pf-comp--excluded .analytics-pf-comp__name {
  color: #9ca3af;
}

.analytics-pf-comp__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.analytics-pf-fault {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.analytics-pf-fault--execution {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.1);
}

.analytics-pf-fault--zootech,
.analytics-pf-fault--excluded {
  color: #4b5563;
  background: rgba(107, 114, 128, 0.12);
}

.analytics-pf-fault--adjusted {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
}

html[data-theme="dark"] .analytics-pf-fault--zootech,
html[data-theme="dark"] .analytics-pf-fault--excluded {
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .analytics-pf-fault--adjusted {
  color: #93c5fd;
  background: rgba(147, 197, 253, 0.12);
}

.analytics-pf-note--execution {
  color: #dc3545;
}

.analytics-pf-note--zootech {
  color: #6b7280;
}

html[data-theme="dark"] .analytics-pf-note--zootech {
  color: #d1d5db;
}

html[data-theme="dark"] .analytics-pf-note--execution {
  color: #f87171;
}

.analytics-pf-notes {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  list-style: disc;
}

.stock-forecast-banner {
  margin: 0 0 1rem;
  padding: 0.65rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(220, 53, 69, 0.35);
  background: rgba(220, 53, 69, 0.08);
  font-size: 0.875rem;
}

.info-item--warn .info-value {
  color: #dc3545;
  font-weight: 700;
}

.stock-card-explanation {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

/* Оборудование: отступ от navbar как на /recipes (только margin-bottom у navbar) */
.zootech-app-body.feed-dispensers-page .page-content > .container {
  padding-top: 0;
}

.zootech-app-body.components-page .page-content > .container {
  padding-top: 0;
}

.zootech-app-body.reports-page .page-content > .container {
  padding-top: 0;
}

.zootech-app-body.feed-dispensers-page .add-devices-container {
  margin-bottom: 1rem;
}

/* Унифицированный чекбокс (фильтры /reports, настройки и др.) */
.zt-checkbox {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.zt-checkbox__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.zt-checkbox__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--border-light, #cbd5e1);
  border-radius: 4px;
  background: var(--surface, var(--bg-white, #fff));
  color: #fff;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  pointer-events: none;
}

.zt-checkbox__box::after {
  content: "";
  display: block;
  width: 0.28rem;
  height: 0.5rem;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  margin-top: -0.12rem;
  transition: transform 0.12s ease;
}

.zt-checkbox__input:checked + .zt-checkbox__box {
  background: var(--primary-color, #2196f3);
  border-color: var(--primary-color, #2196f3);
}

.zt-checkbox__input:checked + .zt-checkbox__box::after {
  transform: rotate(45deg) scale(1);
}

.zt-checkbox__input:focus-visible + .zt-checkbox__box {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 33, 150, 243), 0.22);
}

.zt-checkbox__input:disabled + .zt-checkbox__box {
  opacity: 0.45;
  cursor: not-allowed;
}

html[data-theme="dark"] .zt-checkbox__box {
  background: var(--dm-field, #2c3338);
  border-color: rgba(255, 255, 255, 0.22);
}

html[data-theme="dark"] .zt-checkbox__input:checked + .zt-checkbox__box {
  background: var(--primary-color);
  border-color: var(--primary-color);
}
