/* Producción de leche: layout only, scoped to the existing screen and forms. */
#production { min-width: 0; }
#production .milk-production-panel { min-width: 0; container: milk-panel / inline-size; }
#production .milk-panel-head { flex-direction: row; flex-wrap: wrap; align-items: end; }
#production .milk-panel-head > div:first-child { flex: 1 1 240px; min-width: 0; }
#production .milk-panel-actions { flex: 1 1 350px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
#production .milk-month-picker { min-width: 0; }
#production .milk-month-button { width: 100%; min-width: 0; min-height: 44px; }
#production .milk-month-button span { overflow-wrap: anywhere; text-align: left; }
#production .milk-month-button svg { flex: 0 0 18px; }
#production #milk-new-record { min-height: 44px; white-space: normal; }
#production .milk-month-popover { max-width: 100%; }
#production .milk-month-grid button,
#production .milk-month-yearbar button,
#production .milk-month-current { min-height: 44px; }
#production .milk-production-summary > div { min-width: 0; padding: 10px 12px; }
#production .milk-production-summary strong { overflow-wrap: anywhere; }
/* Use actual panel width, not device width: the tablet sidebar takes space. */
#production .milk-trend-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
#production .milk-trend-main,
#production .milk-alert-center { min-width: 0; }
#production .milk-trend-filters { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(112px, .8fr) minmax(155px, 1fr); max-width: none; gap: 10px; }
#production .milk-trend-filters label { min-width: 0; }
#production .milk-trend-filters input,
#production .milk-trend-filters select,
#production .milk-trend-filters .st-select-button { min-height: 44px; height: auto; }
#production .milk-trend-filters .st-select-button,
#production .milk-trend-filters .st-select-option { white-space: normal; overflow-wrap: anywhere; }
/* Four shared metrics in BASIC and PRO; narrow screens retain two columns. */
#production .milk-trend-summary { max-width: none; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
#production .milk-trend-summary > div { min-width: 0; padding: 11px 12px; }
#production .milk-trend-summary strong { font-size: clamp(1.08rem, 2.2vw, 1.3rem); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#production .milk-trend-summary small { display: block; margin-top: 5px; color: #68746f; font-size: .7rem; line-height: 1.35; }
#production .milk-trend-summary .milk-summary-noncommercial { background: #fbf8ef; border-color: #e9e2ce; }
@media (max-width: 950px) {
  #production .milk-trend-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#production #milk-production-trend-chart svg { height: auto; }
#production .milk-chart-stage,
#production #milk-production-trend-chart { min-height: 0; }
#production .milk-chart-legend { gap: 7px 16px; line-height: 1.5; }
#production .milk-chart-legend span { min-width: 0; }
#production .milk-chart-legend i { flex-shrink: 0; }
#production .st-milk-tooltip { min-width: 0; max-width: min(210px, 100%); overflow-wrap: anywhere; }
#production .milk-alert-row strong,
#production .milk-alert-row p { overflow-wrap: anywhere; }
#production .milk-alert-view,
#production .milk-alert-rules summary { min-height: 44px; }
#production .milk-production-panel > .table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
#production .milk-event-continue { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 0; min-width: 44px; padding: 4px 7px; border-radius: 999px; font-size: .66rem; line-height: 1.45; text-decoration: none; white-space: nowrap; }
/* Match the status pill visually while keeping a 44px activation area. */
#production .milk-event-continue::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); border-radius: inherit; }
@media (pointer: coarse) {
  #production .milk-event-continue { margin-block: 11px; }
}
@container milk-panel (min-width: 960px) {
  #production .milk-trend-layout { grid-template-columns: minmax(0, 1.9fr) minmax(290px, 1fr); gap: 24px; }
}
@container milk-panel (max-width: 560px) {
  #production .milk-trend-filters { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  #production .milk-trend-filters label:first-child { grid-column: 1 / -1; }
  #production .milk-production-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #production .milk-production-summary > div:first-child { grid-column: 1 / -1; }
}
@container milk-panel (max-width: 350px) {
  #production .milk-panel-actions,
  #production .milk-trend-filters { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  #production .milk-production-panel { padding: 14px; }
  #production .production-intro h2 { font-size: 1.25rem; line-height: 1.3; }
  #production .milk-panel-actions { flex-basis: auto; width: 100%; }
  #production .milk-month-popover { left: 0; right: auto; }
  #production .milk-trend-filters input,
  #production .milk-trend-filters select { font-size: 16px; }
}

/* Both create and correction forms share one scroll surface. A visual-viewport
   enhancement keeps these bounds above the software keyboard where available. */
:is(#milk-record-modal, #milk-correction-modal) {
  top: var(--milk-viewport-top, 0px); bottom: auto;
  height: 100vh; height: var(--milk-viewport-height, 100dvh);
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
:is(#milk-record-modal, #milk-correction-modal) .milk-record-card {
  width: min(980px, 100%); max-width: 100%; max-height: 100%; min-height: 0;
  overflow: auto; overscroll-behavior: contain; padding: 18px;
  scroll-padding-top: 58px; scroll-padding-bottom: 86px;
}
:is(#milk-record-modal, #milk-correction-modal) .close {
  position: sticky; top: 0; right: auto; z-index: 5; display: block;
  width: 44px; height: 44px; margin: -8px -8px -36px auto;
  border-radius: 9px; background: #fff;
}
:is(#milk-record-modal, #milk-correction-modal) h2 { padding-right: 40px; overflow-wrap: anywhere; }
:is(#milk-record-modal, #milk-correction-modal) .eyebrow { padding-right: 44px; }
:is(#milk-record-modal, #milk-correction-modal) form,
:is(#milk-record-modal, #milk-correction-modal) label,
:is(#milk-record-modal, #milk-correction-modal) .st-select-wrap { min-width: 0; }
:is(#milk-record-modal, #milk-correction-modal) .milk-record-card :is(input, select, textarea, .st-select-button) { min-width: 0; max-width: 100%; min-height: 44px; scroll-margin-block: 64px 88px; }
:is(#milk-record-modal, #milk-correction-modal) .st-select-button { white-space: normal; overflow-wrap: anywhere; }
:is(#milk-record-modal, #milk-correction-modal) .modal-actions { position: sticky; bottom: -18px; z-index: 4; background: #fff; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); gap: 8px; flex-wrap: wrap; }
:is(#milk-record-modal, #milk-correction-modal) .modal-actions button { min-height: 44px; flex: 1 1 130px; }
#milk-record-modal .milk-cow-list,
#milk-correction-modal #milk-edit-values { max-height: none; overflow: visible; }
#milk-record-modal .milk-cow-name,
#milk-correction-modal .milk-edit-row > div { min-width: 0; overflow-wrap: anywhere; }
#milk-record-modal .milk-record-card { container: milk-capture / inline-size; }
#milk-record-modal .milk-cow-row { grid-template-columns: minmax(0, 1fr) 150px 120px 82px; }
#milk-record-modal .milk-cow-head { flex-wrap: wrap; gap: 8px; }
#milk-record-modal .milk-cow-head > div { min-width: 0; }
#milk-correction-modal .milk-edit-row { grid-template-columns: minmax(0, 1fr) minmax(90px, 120px); gap: 12px; }
@media (max-width: 720px) {
  :is(#milk-record-modal, #milk-correction-modal) .milk-form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  :is(#milk-record-modal, #milk-correction-modal) .milk-record-card :is(input, select, textarea, .st-select-button) { font-size: 16px; }
  #milk-record-modal #milk-record-source-wrap { max-width: none; }
  #milk-record-modal .milk-cow-row { grid-template-columns: minmax(0, 1fr) minmax(80px, 110px); gap: 8px; padding: 12px; }
  #milk-record-modal .milk-cow-name,
  #milk-record-modal .milk-cow-save-state,
  #milk-record-modal .milk-cow-reason-wrap { grid-column: 1 / -1; }
  #milk-record-modal .milk-cow-reason-wrap { grid-template-columns: minmax(0, 1fr); }
  #milk-record-modal .milk-cow-save-state { text-align: left; }
  #milk-record-modal .milk-cow-progress { text-align: left; }
}
@media (max-height: 500px) and (orientation: landscape) {
  :is(#milk-record-modal, #milk-correction-modal) .milk-record-card { padding-top: 10px; }
  :is(#milk-record-modal, #milk-correction-modal) .modal-actions { margin-top: 10px; padding-top: 8px; }
}

/* The reason follows outcome and liters when the capture card has room.
   Hidden reasons keep their reserved column, so all cows remain aligned. */
@container milk-capture (min-width: 760px) {
  #milk-record-modal .milk-cow-row { grid-template-columns: minmax(140px, 180px) 180px 90px minmax(160px, 1fr) 74px; }
  #milk-record-modal .milk-cow-row > .milk-cow-name { grid-column: 1; grid-row: 1; }
  #milk-record-modal .milk-cow-row > .milk-cow-outcome,
  #milk-record-modal .milk-cow-row > .st-select-wrap:has(> .milk-cow-outcome) { grid-column: 2; grid-row: 1; min-width: 0; }
  #milk-record-modal .milk-cow-row > .milk-cow-liters { grid-column: 3; grid-row: 1; }
  #milk-record-modal .milk-cow-row > .milk-cow-reason-wrap { grid-column: 4; grid-row: 1; grid-template-columns: minmax(0, 1fr); min-width: 0; }
  #milk-record-modal .milk-cow-row > .milk-cow-save-state { grid-column: 5; grid-row: 1; }
}

/* Phone simplification requested from the marked production screenshots. */
@media (max-width: 720px) {
  #production .milk-panel-head > div:first-child,
  #production .milk-production-summary { display: none; }
  #production .milk-trend-summary { gap: 8px; margin: 10px 0; }
  #production .milk-trend-summary > div { padding: 8px 10px; }
  #production .milk-trend-summary span { font-size: .72rem; line-height: 1.3; }
  #production .milk-trend-summary strong { font-size: 1rem; line-height: 1.2; margin-top: 4px; }
}


/* Keep the full seven-column presentation outside the phone breakpoint. */
#production .milk-events-table .milk-table-phone { display: none; }
/* Keep totals aligned and place the production credit below the report. */
#production .milk-events-table tfoot :is(th, td) { background: #eef5ee; border-top: 2px solid #d5e3d5; font-weight: 750; }
#production .milk-events-table tfoot small { font-weight: 600; }
#production .milk-events-table tfoot[hidden] { display: none; }
body.authenticated:has(#production.active)::after { position: static; display: block; margin: 0 22px 14px; }
@media (max-width: 720px) {
  #production .milk-events-table { min-width: 300px; width: 100%; }
  #production .milk-events-table :is(.milk-events-session, .milk-events-source, .milk-events-noncommercial, .milk-table-wide) { display: none; }
  #production .milk-events-table .milk-table-phone { display: inline; }
  #production .milk-events-table .milk-event-noncommercial-phone { display: block; margin-top: 4px; font-size: .65rem; color: #7b693d; white-space: normal; }
  #production .milk-events-table :is(th, td) { padding: 9px 6px; }
  #production .milk-events-table th { font-size: .66rem; letter-spacing: .02em; }
  #production .milk-events-table td { font-size: .78rem; }
  #production .milk-events-table :is(th, td):nth-child(1):not([colspan]) { width: 25%; white-space: nowrap; }
  #production .milk-events-table :is(th, td):nth-child(4) { width: 14%; }
  #production .milk-events-table :is(th, td):nth-child(5) { width: 25%; white-space: nowrap; }
  #production .milk-events-table .milk-event-status { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
  #production .milk-events-table .milk-event-status > span { white-space: nowrap; }
  #production .milk-events-table .milk-event-continue { margin-block: 11px; }
}


@media (max-width: 720px) {
  #production .milk-production-trend.milk-after-capture { margin: 18px 0 0; border-bottom: 0; padding-bottom: 0; }
}


/* Reserved feedback space keeps loading from collapsing the table/chart. */
#production .milk-events-load-status { min-height: 2.7em; margin: 4px 0 0; font-size: .7rem; line-height: 1.35; color: #68746f; }
#production #milk-trend-loading { position: static; min-height: 2.7em; margin: 4px 0 0; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: .7rem; line-height: 1.35; }
#production #milk-trend-loading[hidden] { display: block; visibility: hidden; }
#production .milk-alert-cutoff-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: .72rem; color: #526058; }
#production .milk-alert-cutoff-controls[hidden],
#production #milk-alert-date-host[hidden] { display: none; }
#production #milk-alert-change-cutoff { min-height: 44px; min-width: 44px; border: 0; background: transparent; color: #245c49; font: inherit; text-decoration: underline; cursor: pointer; }
#production #milk-alert-date-host label { display: grid; gap: 6px; margin: 8px 0; font-size: .72rem; font-weight: 650; color: #526058; }
#production #milk-alert-date-host input { min-width: 0; max-width: 100%; min-height: 44px; border: 1px solid #dfe5df; border-radius: 9px; padding: 10px; background: #fff; color: #24312c; font: inherit; }
@media (max-width: 720px) {
  #production .milk-month-phone .milk-trend-filters { grid-template-columns: minmax(0, 1fr); }
  #production #milk-alert-date-host input { font-size: 16px; }
  #production #milk-alert-date-host .st-date-button { min-height: 44px; }
}
