.activity-filter-panel > .activity-context {
  grid-column: 1 / -1;
  margin: 0;
}

.animal-ux {
  min-width: 0;
}

.field-group {
  min-width: 0;
}

.field-group input,
.field-group select,
.field-group textarea {
  min-width: 0;
  max-width: 100%;
}

.herd-search-period {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.herd-search-period legend {
  margin-bottom: 8px;
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 720;
}

.herd-search-period legend .muted {
  font-weight: 400;
}

.animal-ux .herd-search-period,
.herd-search-help {
  grid-column: 1 / -1;
}

.herd-search-help {
  margin: 0;
  font-size: 0.82rem;
}

.herd-selection-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 24px;
  min-width: 0;
  margin: 0 0 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.herd-selection-controls legend {
  padding: 0 6px;
  color: var(--navy);
  font-weight: 750;
}

.selection-choice,
.selection-buttons,
.herd-batch-actions > div,
.batch-confirm-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.selection-choice {
  flex-wrap: nowrap;
}

.selection-choice label,
.selection-row-label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.selection-choice input,
.herd-selection-cell input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  accent-color: var(--green-dark);
}

.herd-batch-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--green-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.herd-batch-actions p {
  margin: 0;
  color: var(--navy);
  font-weight: 750;
}

.herd-batch-actions button,
.batch-confirm-actions button {
  min-height: 44px;
}

.herd-batch-actions button:disabled {
  cursor: default;
  opacity: 0.55;
}

.batch-sample {
  margin: 0 0 24px;
  border-bottom: 1px solid var(--border);
}

.batch-sample summary {
  min-height: 44px;
  padding: 10px 0;
  color: var(--green-dark);
  cursor: pointer;
}

.batch-animal-list {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.batch-animal-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.batch-payload dd,
.activity-table td {
  overflow-wrap: anywhere;
}

.activity-table td[data-label="Resumo"] > span {
  display: block;
}

.activity-filter-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 761px) {
  .selection-row-label {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .herd-selection-cell {
    width: 70px;
    text-align: center;
  }

  .activity-filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .animal-ux .animal-table .herd-selection-cell {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-bottom: 12px;
  }

  .animal-ux .animal-table .herd-selection-cell::before {
    display: none;
  }

  .herd-batch-actions > div > *,
  .batch-confirm-actions > *,
  .batch-confirm-actions form button {
    width: 100%;
  }

  .activity-filter-panel > .field-group:last-of-type {
    grid-column: 1 / -1;
  }
}

.animal-ux .animal-filter-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.animal-ux .animal-filter-panel > .field-group:first-child,
.animal-ux .animal-filter-panel > .field-group:nth-child(4) {
  grid-column: 1 / -1;
}

.animal-ux .animal-more-filter-grid {
  grid-template-columns: 1fr;
}

.animal-ux .animal-filter-actions > * {
  flex: 1 1 auto;
  min-height: 44px;
  text-align: center;
}

.animal-ux .animal-identity-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--green-dark);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  overflow-wrap: anywhere;
}

.animal-ux .animal-identity-link:hover {
  color: var(--navy);
}

.animal-ux .animal-list-name {
  display: block;
  font-size: 0.8rem;
}

.animal-ux .animal-table td[data-label="Identificação"] .status-badge {
  display: inline-flex;
  margin-top: 4px;
}

.animal-ux a:focus-visible,
.animal-ux summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.animal-ux .animal-detail-header {
  display: grid;
  gap: 18px;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.animal-ux .animal-detail-header > div:first-child {
  order: 0;
  min-width: 0;
}

.animal-ux .animal-detail-header h1 {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.animal-secondary-name {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.animal-ux .animal-detail-header > .form-actions {
  order: 2;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.animal-ux .animal-detail-header > .form-actions > * {
  flex: 1 1 auto;
  min-height: 44px;
}

.animal-ux .animal-detail-header #resumo {
  order: 1;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.animal-ux .animal-detail-header #resumo > .compact-section-heading {
  display: none;
}

.animal-ux .animal-detail-header .detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.animal-ux .animal-detail-header .detail-list > div {
  padding: 0;
  background: transparent;
  border: 0;
}

.animal-ux .animal-detail-header .detail-list dt {
  font-size: 0.68rem;
}

.animal-ux .animal-detail-header .detail-list dd {
  font-size: 0.9rem;
}

.animal-ux .animal-detail-nav {
  margin-bottom: 16px;
}

.animal-detail-group {
  min-width: 0;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 24px;
}

.animal-detail-group > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  gap: 3px 16px;
  min-height: 66px;
  padding: 16px 20px;
  color: var(--navy);
  cursor: pointer;
  list-style: none;
}

.animal-detail-group > summary::-webkit-details-marker {
  display: none;
}

.animal-detail-group > summary > span {
  font-size: 1rem;
  font-weight: 800;
}

.animal-detail-group > summary > small {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.76rem;
}

.animal-detail-group > summary::after {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: '';
  transform: rotate(45deg);
}

.animal-detail-group[open] > summary {
  border-bottom: 1px solid var(--border);
}

.animal-detail-group[open] > summary::after {
  transform: rotate(225deg);
}

.animal-ux .animal-detail-group > .detail-section,
.animal-ux .animal-initial-load > .detail-section {
  margin: 0;
  padding: 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.animal-ux .animal-detail-group > .detail-section + .detail-section {
  border-top: 1px solid var(--border);
}

.animal-ux .animal-detail-group h2 {
  font-size: 1.1rem;
}

.animal-initial-load {
  margin: 0 20px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8faf7;
}

.animal-initial-load > summary {
  min-height: 48px;
  padding: 14px;
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 750;
  cursor: pointer;
}

.animal-ux .animal-initial-load > .detail-section {
  background: transparent;
}

.animal-progeny-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.animal-progeny-list > li {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.animal-progeny-list p {
  margin: 5px 0 0;
}

@media (min-width: 700px) {
  .animal-ux .animal-filter-panel > .field-group:nth-child(4) {
    grid-column: auto;
  }

  .animal-ux .animal-more-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .animal-ux .animal-filter-actions > * {
    flex: 0 1 auto;
    width: auto;
  }

  .animal-ux .animal-detail-header .detail-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .animal-ux .animal-detail-header > .form-actions > * {
    flex: 0 1 auto;
  }

  .animal-progeny-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .animal-ux .animal-filter-panel {
    grid-template-columns: minmax(220px, 2fr) minmax(140px, 1fr) minmax(260px, 2fr);
  }

  .animal-ux .animal-filter-panel > .herd-search-period {
    grid-column: auto;
  }

  .animal-ux .animal-filter-panel > .field-group:first-child {
    grid-column: auto;
  }

  .animal-ux .animal-more-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .animal-ux .animal-detail-header {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 24px;
  }

  .animal-ux .animal-detail-header > .form-actions {
    order: 0;
    justify-content: flex-end;
    max-width: 600px;
  }

  .animal-ux .animal-detail-header #resumo {
    grid-column: 1 / -1;
  }
}
