@layer modules {
  /* Full-height flex layout for the weaning list page
  /* ======================================================================== */

  .weaning-list {
    display: flex;
    flex-direction: column;
    min-block-size: 0;
  }

  /* Under the page-menu mechanism the body lives in .page__content. The
     weaning-list manages its own scroll (pinned header + scrolling table +
     pinned action bar), so its column is a flex column with overflow:hidden —
     not the usual scrolling .page__content. */
  .page__content:has(> .weaning-list) {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-block-size: 0;
    overflow: hidden;
    padding-block-end: calc(var(--footer-height) + env(safe-area-inset-bottom));
  }

  @media (max-width: 639px) {
    /* No sidebar on mobile and .page isn't a flex row there, so make it a flex
       column to pass the contained-scrolling viewport height to .page__content. */
    .page:has(.weaning-list) {
      display: flex;
      flex-direction: column;
      min-block-size: 0;
      overflow: hidden;
    }

    .page__content:has(> .weaning-list) {
      padding-block-end: 0;
    }
  }

  .page__content > .weaning-list {
    flex: 1;
    min-block-size: 0;
  }

  /* Header: stats + search (pinned at top, never scrolls)
  /* ------------------------------------------------------------------------ */

  .weaning-list__header {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: var(--block-space-half);
    margin-block-end: var(--block-space);
  }

  /* Stats table — borderless, full-width, tabular nums */

  .weaning-list__stats {
    border-radius: 0;
    box-shadow: none;
    font-variant-numeric: tabular-nums;
  }

  .weaning-list__stats td {
    font-weight: 700;
    text-align: center;
  }

  .weaning-list__stats th {
    text-align: center;
  }

  /* Scrollable table area
  /* ------------------------------------------------------------------------ */

  .weaning-list__scroll {
    -webkit-overflow-scrolling: touch;
    flex: 1;
    margin-block-start: var(--block-space-half);
    min-block-size: 0;
    overflow-y: auto;
  }

  .weaning-list__scroll thead {
    background: var(--color-canvas);
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
  }

  /* Booking action bar (bottom)
  /* ------------------------------------------------------------------------ */

  .weaning-list__action {
    background: var(--color-canvas);
    border-block-start: 1px solid var(--color-ink-lighter);
    flex-shrink: 0;
    padding-block: var(--block-space-half);
  }

  .weaning-list__action-buttons {
    display: flex;
    gap: var(--block-space-half);
  }

  .weaning-list__action-buttons > *,
  .weaning-list__action-buttons > form {
    flex: 1;
  }

  .weaning-list__action-buttons .btn {
    inline-size: 100%;
  }

  /* Claimed-by badge (shown when another user has selected the sow)
  /* ------------------------------------------------------------------------ */

  .weaning-list__claimed {
    color: var(--color-ink-light);
    display: block;
    font-size: 0.75em;
  }

  /* Vertically center every cell against the tallest column (the qty stepper),
     so the toggle button, tag and switch line up centered rather than sitting
     on the baseline. */
  .weaning-list__scroll tbody td {
    vertical-align: middle;
  }

  /* .switch is inline-flex; left as default `baseline` it drops to the cell's text
     baseline and sits low. Center it on the line so it aligns with the toggle/number. */
  .weaning-list .switch {
    vertical-align: middle;
  }
}
