.animal-welfare-frame { display: grid; gap: 0; min-width: 0; }
.welfare-index, .welfare-workbench { min-width: 0; padding: 14px; }
.welfare-index-toolbar { display: flex; gap: 12px; align-items: start; justify-content: space-between; margin-bottom: 14px; }
.welfare-index-toolbar .ac-index-query { flex: 1; max-width: 720px; }

.welfare-workbench { display: grid; gap: 12px; align-content: start; background: var(--surface-2); }
.welfare-phase-nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; min-width: 0; }
.welfare-phase-nav button {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: center;
  min-width: 0; min-height: 62px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer;
}
.welfare-phase-nav button > span:last-child { display: grid; gap: 2px; min-width: 0; }
.welfare-phase-nav button strong, .welfare-phase-nav button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.welfare-phase-nav button small { color: var(--ink-muted); font-size: var(--font-xs); font-weight: 500; }
.welfare-phase-nav button.active { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.welfare-phase-nav button.complete .welfare-phase-number { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.welfare-phase-number { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 50%; font-weight: 700; }

.welfare-progress-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.welfare-progress-strip > span { display: grid; gap: 3px; padding: 10px 12px; background: var(--surface); }
.welfare-progress-strip small { color: var(--ink-muted); font-size: var(--font-xs); }
.welfare-progress-strip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.welfare-phase-body { min-width: 0; }
.welfare-card { display: grid; gap: 16px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.welfare-section-head { display: flex; gap: 16px; align-items: start; justify-content: space-between; }
.welfare-section-head h3, .welfare-card h4 { margin: 2px 0 0; }
.welfare-section-intro { max-width: 760px; margin: 6px 0 0; color: var(--ink-muted); }
.welfare-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.welfare-card label { display: grid; gap: 6px; min-width: 0; font-weight: 700; }
.welfare-card label small { font-weight: 400; color: var(--ink-muted); }
.welfare-card input, .welfare-card select, .welfare-card textarea { width: 100%; min-width: 0; min-height: 44px; box-sizing: border-box; }
.welfare-card textarea { resize: vertical; }
.welfare-inline-field { max-width: 360px; }
.welfare-honesty { display: grid; grid-template-columns: 1fr auto; gap: 5px 16px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.welfare-honesty span { font-size: 1.3rem; font-weight: 700; }
.welfare-honesty p { grid-column: 1 / -1; margin: 0; color: var(--ink-muted); }

.welfare-entry-list { display: grid; gap: 8px; }
.welfare-entry-row { display: grid; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.welfare-lot-row { grid-template-columns: minmax(210px, 2fr) minmax(110px, .7fr) minmax(110px, .7fr) auto; }
.welfare-observation-row { grid-template-columns: minmax(160px, .8fr) minmax(150px, .7fr) minmax(260px, 2fr) auto; }
.welfare-row-remove { min-height: 44px; color: var(--danger); }
.welfare-add-row { justify-self: start; min-height: 44px; }

.welfare-prereq-summary { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(100px, .55fr)); gap: 8px; }
.welfare-prereq-summary > span, .welfare-prereq-progress { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.welfare-prereq-summary > span small { color: var(--ink-muted); }
.welfare-prereq-summary > span strong { font-size: 1.15rem; }
.welfare-prereq-summary > span.success strong { color: var(--success); }
.welfare-prereq-summary > span.danger strong { color: var(--danger); }
.welfare-prereq-progress > span { display: flex; justify-content: space-between; gap: 10px; }
.welfare-prereq-progress > div { height: 7px; overflow: hidden; border-radius: 999px; background: var(--line); }
.welfare-prereq-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .18s ease; }
.welfare-prereq-toolbar { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(170px, .8fr) minmax(150px, .7fr); gap: 10px; align-items: end; }
.welfare-prereq-result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.welfare-prereq-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: min(560px, calc(100vh - 410px)); min-height: 240px; overflow: auto; padding: 2px 5px 2px 2px; }
.welfare-prereq { display: grid; gap: 9px; align-content: start; padding: 13px; border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.welfare-prereq.conformant { border-left-color: var(--success); }
.welfare-prereq.non_conformant { border-left-color: var(--danger); }
.welfare-prereq.not_applicable { opacity: .78; }
.welfare-prereq[hidden], .welfare-prereq-empty[hidden] { display: none; }
.welfare-prereq header, .welfare-prereq > div, .welfare-import-preview header, .welfare-nc-list article > div { display: flex; gap: 12px; align-items: start; justify-content: space-between; }
.welfare-prereq p, .welfare-nc-list p { margin: 0; }
.welfare-prereq > div label { flex: 1; }
.welfare-severity { padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); font-size: var(--font-xs); }
.welfare-severity.knockout, .welfare-severity.major { color: var(--danger); }
.welfare-prereq-empty { grid-column: 1 / -1; place-self: center; max-width: 420px; padding: 32px; text-align: center; }
.welfare-prereq-empty p { margin: 7px 0 14px; color: var(--ink-muted); }

.welfare-result-sources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.welfare-result-sources article { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.welfare-result-sources p { margin: 8px 0; font-size: 1.25rem; font-weight: 700; }
.welfare-result-sources small { color: var(--ink-muted); }
.welfare-import-box { display: flex; gap: 10px; align-items: end; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.welfare-import-box label { flex: 1; }
.welfare-import-box .btn { min-height: 44px; }
.welfare-import-preview { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--accent); border-radius: 12px; }
.welfare-import-preview header div { display: grid; gap: 4px; }
.welfare-import-preview dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.welfare-import-preview dl div { padding: 8px; background: var(--surface-2); border-radius: 8px; }
.welfare-import-preview dd { margin: 4px 0 0; font-weight: 700; }
.welfare-import-warning { margin: 0; padding: 10px; border-radius: 8px; background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
.welfare-advisory, .welfare-nc-editor { padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.welfare-advisory > summary, .welfare-nc-editor > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; }
.welfare-criterion-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.welfare-score-block { display: grid; gap: 10px; }
.welfare-score-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.welfare-score-grid span { display: grid; gap: 5px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.welfare-score-grid strong { font-size: 1.15rem; }
.welfare-disclaimer { margin: 0; color: var(--ink-muted); }
.welfare-nc-list { display: grid; gap: 10px; }
.welfare-nc-list article { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.welfare-nc-editor .welfare-form-grid { margin: 14px 0; }
.wide-field { grid-column: 1 / -1; }

.welfare-phase-actions { position: sticky; z-index: 8; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 -4px 14px rgba(28, 38, 31, .08); backdrop-filter: blur(8px); }
.welfare-phase-actions-main { display: flex; gap: 8px; justify-content: end; }
.welfare-phase-actions .btn { min-height: 44px; }

@media (max-width: 1350px) {
  .welfare-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welfare-prereq-list { grid-template-columns: 1fr; }
  .welfare-prereq-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .welfare-prereq-progress { grid-column: 1 / -1; }
  .welfare-criterion-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .welfare-index, .welfare-workbench { padding: 12px; }
  .welfare-phase-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .welfare-phase-nav button { min-height: 58px; }
  .welfare-progress-strip { grid-template-columns: 1fr; }
  .welfare-lot-row, .welfare-observation-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welfare-entry-notes { grid-column: 1 / -1; }
  .welfare-row-remove { justify-self: end; }
  .welfare-prereq-toolbar { grid-template-columns: 1fr 1fr; }
  .welfare-prereq-toolbar label:first-child { grid-column: 1 / -1; }
  .welfare-result-sources, .welfare-criterion-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welfare-score-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .welfare-prereq-list { max-height: 620px; }
}

@media (max-width: 760px) {
  .welfare-form-grid, .welfare-result-sources, .welfare-criterion-inputs, .welfare-score-grid { grid-template-columns: 1fr; }
  .welfare-index-toolbar, .welfare-import-box, .welfare-prereq > div { flex-direction: column; align-items: stretch; }
  .welfare-import-preview dl { grid-template-columns: 1fr; }
  .welfare-phase-actions { align-items: stretch; }
  .welfare-phase-actions-main { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .welfare-prereq-progress i { transition: none; }
}

.welfare-sampling-summary { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.welfare-sampling-summary label { display:grid; gap:8px; font-weight:600; }
.welfare-sampling-summary output,.welfare-sampling-summary input { display:block; min-height:44px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--surface-2); font-size:var(--font-lg); box-sizing:border-box; }
.welfare-sampling-actions { display:flex; flex-wrap:wrap; gap:12px; }
.welfare-sampling-table summary { cursor:pointer; min-height:44px; font-weight:600; }
.welfare-sampling-table table { width:100%; max-width:560px; margin:16px 0; border-collapse:collapse; }
.welfare-sampling-table th,.welfare-sampling-table td { text-align:left; padding:8px 12px; border-bottom:1px solid var(--line); }
.welfare-lot-row input[readonly] { background:var(--surface-2); }
@media(max-width:680px) { .welfare-sampling-summary { grid-template-columns:minmax(0,1fr); } }

.welfare-protocol-criterion { border:1px solid var(--line); border-radius:10px; padding:10px 14px; margin:8px 0; min-width:0; }
.welfare-protocol-criterion > summary { display:flex; gap:12px; align-items:center; justify-content:space-between; min-height:44px; cursor:pointer; font-weight:600; }
.welfare-protocol-criterion > summary small { color:var(--ink-muted); flex-shrink:0; }
.welfare-protocol-inputs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; padding:12px 0; }
.welfare-protocol-inputs label,.welfare-water-row label { display:grid; gap:7px; min-width:0; }
.welfare-protocol-inputs input,.welfare-protocol-inputs select,.welfare-water-row input,.welfare-water-row select { min-height:44px; width:100%; min-width:0; box-sizing:border-box; }
.welfare-water-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; padding:14px 0; border-bottom:1px solid var(--line); }
.welfare-protocol-result-actions { display:flex; flex-wrap:wrap; gap:10px; }
.welfare-protocol-breakdown pre { max-width:100%; max-height:320px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font-size:.85rem; }
.welfare-protocol-result { overflow-wrap:anywhere; }
.welfare-import-preview table { width:100%; border-collapse:collapse; table-layout:fixed; }
.welfare-import-preview th,.welfare-import-preview td { text-align:left; padding:8px; border-bottom:1px solid var(--line); overflow-wrap:anywhere; }
@media(max-width:1100px) { .welfare-protocol-inputs,.welfare-water-row { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:760px) { .welfare-protocol-inputs,.welfare-water-row { grid-template-columns:minmax(0,1fr); } }
.welfare-protocol-criterion > summary::before { content:"▸"; color:var(--ink-muted); }
.welfare-protocol-criterion[open] > summary::before { content:"▾"; }
.welfare-protocol-criterion > summary > span { flex:1; min-width:0; }
