:root {
  --vf-primary: #42675a;
  --vf-primary-hover: #345348;
  --vf-primary-soft: #e6eee9;
  --vf-background: #f4f2ec;
  --vf-surface: #fffefa;
  --vf-surface-muted: #efeee8;
  --vf-border: #d8d9d2;
  --vf-border-strong: #bec4bd;
  --vf-text: #27332f;
  --vf-text-muted: #68736e;
  --vf-success: #287347;
  --vf-success-soft: #e7f3eb;
  --vf-warning: #956414;
  --vf-warning-soft: #f8efdc;
  --vf-danger: #a13c3c;
  --vf-danger-soft: #f8e8e6;
  --vf-info: #426d83;
  --vf-info-soft: #e7f0f4;
  --vf-focus: rgba(66, 103, 90, .22);
  --vf-shadow: 0 3px 14px rgba(38, 50, 44, .06);
  --vf-radius: 8px;
  --vf-space-1: 4px;
  --vf-space-2: 8px;
  --vf-space-3: 12px;
  --vf-space-4: 16px;
  --vf-space-5: 24px;
  --vf-space-6: 32px;
  --vf-list-max-height: 380px;
  --vf-content-max: 1260px;
  --vf-content-wide-max: 1800px;
  --vf-page-gutter: clamp(16px, 1.5vw, 24px);
  --vf-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--vf-text);
  background: var(--vf-background);
  font: 15px/1.5 var(--vf-font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--vf-primary); text-underline-offset: 2px; }
a:hover { color: var(--vf-primary-hover); }
h1, h2, h3 { margin: 0 0 var(--vf-space-3); line-height: 1.25; letter-spacing: -.018em; }
h1 { font-size: clamp(1.65rem, 2.3vw, 2.1rem); }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--vf-space-3); }
[hidden], .hidden { display: none; }

.wrap, .vf-page {
  width: min(100%, var(--vf-content-max));
  margin-inline: auto;
  padding: var(--vf-page-gutter);
}
.vf-page-wide { width: min(100%, var(--vf-content-wide-max)); }
.vf-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--vf-space-4);
  margin-bottom: var(--vf-space-5);
}
.vf-page-header h1 { margin-block: var(--vf-space-1); }
.actions, .filters, .tabs, .vf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--vf-space-2);
  flex-wrap: wrap;
}
.groups, .grid, form.grid, .summary-grid, .cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--vf-space-3);
}
.groups { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.vf-nav, .vf-admin-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--vf-space-3);
  min-height: 58px;
  padding: 9px max(var(--vf-page-gutter), calc((100vw - var(--vf-content-max)) / 2 + var(--vf-page-gutter)));
  color: #fff;
  background: #29473e;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.vf-wide-page :is(.vf-nav, .vf-admin-nav) {
  padding-inline: max(var(--vf-page-gutter), calc((100vw - var(--vf-content-wide-max)) / 2 + var(--vf-page-gutter)));
}
.vf-nav strong, .vf-admin-nav strong { font-size: 1.12rem; letter-spacing: -.03em; white-space: nowrap; }
.vf-nav a { color: #fff; text-decoration: none; }
.vf-nav a:hover { color: #fff; text-decoration: underline; }
.vf-nav button, .vf-admin-nav button {
  min-height: 36px;
  padding: 6px 10px;
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, .28);
}
.vf-nav button:hover, .vf-admin-nav button:hover,
.vf-admin-nav .tab.active { color: var(--vf-text); background: #fff; border-color: #fff; }
.nav-user { margin-left: auto; white-space: nowrap; }
.vf-search { position: relative; flex: 1; max-width: 440px; min-width: 0; }
.vf-search-controls { display: flex; gap: var(--vf-space-2); }
.vf-search-controls input { flex: 1; min-width: 0; }
.vf-search-controls .vf-search-submit { white-space: nowrap; }
.vf-search input, .vf-admin-nav > input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--vf-text);
  background: #fff;
}
.vf-admin-nav > input { max-width: 340px; }
.vf-results, .vf-search-results {
  position: absolute;
  z-index: 30;
  width: 100%;
  max-height: 320px;
  overflow: auto;
  color: var(--vf-text);
  background: var(--vf-surface);
  border: 1px solid var(--vf-border);
  border-radius: 0 0 var(--vf-radius) var(--vf-radius);
  box-shadow: var(--vf-shadow);
}
.vf-results:empty, .vf-search-results:empty { display: none; }
.vf-results a, .vf-search-results a { display: block; padding: 8px 10px; border-bottom: 1px solid var(--vf-border); }
.vf-search-results { position: fixed; top: 58px; left: 50%; width: min(720px, calc(100% - 32px)); transform: translateX(-50%); }
.farm-search-results {
  position: fixed;
  top: 58px;
  left: 50%;
  width: min(1260px, calc(100vw - 32px));
  max-height: calc(100dvh - 74px);
  padding: var(--vf-space-3);
  border-radius: var(--vf-radius);
  transform: translateX(-50%);
}
.farm-search-header { display: flex; align-items: center; justify-content: space-between; gap: var(--vf-space-3); margin-bottom: var(--vf-space-3); }
.farm-search-header strong { color: var(--vf-text); font-size: 1.05rem; font-weight: 760; }
.farm-search-results .farm-search-header a {
  display: inline-flex;
  padding: 7px 11px;
  color: var(--vf-primary);
  background: var(--vf-primary-soft);
  border: 1px solid var(--vf-primary);
}
.farm-search-results .farm-search-header a:hover { color: #fff; background: var(--vf-primary); }
.farm-search-status { margin: 0 0 var(--vf-space-2); color: var(--vf-success); font-weight: 650; }
.farm-search-status:empty { display: none; }
.farm-name-results { max-height: 220px; margin-top: var(--vf-space-2); overflow-y: auto; scrollbar-width: thin; }
.farm-search-results .farm-name-result { display: block; width: 100%; min-height: 44px; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--vf-border); border-radius: 0; color: var(--vf-text); background: var(--vf-surface); text-align: left; }
.farm-search-results .farm-name-result:hover,
.farm-search-results .farm-name-result:focus-visible,
.farm-search-results .farm-name-result:active,
.farm-search-results .farm-name-result[aria-selected="true"] { color: var(--vf-primary); background: var(--vf-primary-soft); }
.farm-search-hint { margin: var(--vf-space-2) 0 0; color: var(--vf-text-muted); }
.farm-search-table-scroll { max-height: 282px; overflow: auto; scrollbar-width: thin; }
.farm-search-table-scroll table { width: 970px; min-width: 100%; margin: 0; table-layout: fixed; }
.farm-search-table-scroll thead { position: sticky; top: 0; z-index: 2; }
.farm-search-table-scroll th { color: var(--vf-text); background: var(--vf-surface-muted); vertical-align: middle; }
.farm-search-table-scroll td > a { display: inline; padding: 0; border: 0; white-space: nowrap; }
.farm-search-table-scroll th,
.farm-search-table-scroll td { padding: 6px 4px; white-space: normal; vertical-align: middle; }
.farm-search-table-scroll .sort-button { white-space: normal; line-height: 1.2; }
.farm-search-table-scroll .farm-search-column-barn { width: 52px; text-align: center; }
.farm-search-table-scroll .farm-search-column-litter { width: 42px; }
.farm-search-table-scroll :is(.farm-search-column-entry_date, .farm-search-column-sale_date) { width: 74px; }
.farm-search-table-scroll .farm-search-column-status { width: 84px; text-align: center; }
.farm-search-table-scroll .farm-search-column-age { width: 58px; text-align: center; }
.farm-search-table-scroll .farm-search-column-source { width: 90px; overflow: hidden; text-overflow: ellipsis; }
.farm-search-table-scroll td.farm-search-column-source { white-space: nowrap; }
.farm-search-table-scroll .farm-search-column-group { width: 42px; }
.farm-search-table-scroll :is(.farm-search-column-entered, .farm-search-column-total_deaths, .farm-search-column-weekly_deaths, .farm-search-column-remaining) { width: 52px; text-align: center; }
.farm-search-table-scroll .farm-search-column-mortality { width: 58px; text-align: center; font-weight: 650; }
.farm-search-table-scroll .farm-search-column-vet { width: 110px; }
.farm-search-results .sort-button { color: var(--vf-text); font: inherit; }
.farm-search-results .sort-button span { color: var(--vf-text-muted); }
.farm-search-results .sort-button:hover { color: var(--vf-text); background: transparent; }
.farm-search-action-cell { width: 96px; min-width: 96px; text-align: center; vertical-align: middle; }
.farm-search-cancel { min-width: max-content; white-space: nowrap; }
.farm-search-cancel-dialog { width: min(520px, calc(100vw - 32px)); color: var(--vf-text); text-align: left; }
.farm-search-cancel-dialog button { color: var(--vf-text); background: var(--vf-surface); border-color: var(--vf-border-strong); }
.farm-search-cancel-dialog .danger-action { color: #fff; background: var(--vf-danger); border-color: var(--vf-danger); }
.sort-button { min-height: auto; padding: 2px; border: 0; background: transparent; }
.search-result-row { display: flex; align-items: center; gap: var(--vf-space-3); padding: var(--vf-space-2); border-bottom: 1px solid var(--vf-border); }
.search-result-row:last-child { border-bottom: 0; }
.search-result-row > a { flex: 1; padding: 4px 2px; border: 0; }

section, .card, .panel-block, .feed-plan-card, .fmd-plan-card {
  margin-bottom: var(--vf-space-4);
  padding: var(--vf-space-4);
  background: var(--vf-surface);
  border: 1px solid var(--vf-border);
  border-radius: var(--vf-radius);
  box-shadow: var(--vf-shadow);
}
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: var(--vf-space-3);
  margin-bottom: var(--vf-space-4);
}
.kpis :is(.card, .feed-plan-card, .fmd-plan-card) { margin: 0; box-shadow: none; }
.dashboard-kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr)); }
.dashboard-kpis :is(.card, .feed-plan-card, .fmd-plan-card) { min-height: 88px; }
.value { font-size: 1.45rem; font-weight: 720; line-height: 1.25; font-variant-numeric: tabular-nums; }
.muted, .helper, .admin-note { color: var(--vf-text-muted); }

button, .button {
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--vf-border-strong);
  border-radius: 6px;
  color: var(--vf-text);
  background: var(--vf-surface);
  cursor: pointer;
  text-decoration: none;
  font-weight: 620;
}
button:hover, .button:hover { color: var(--vf-text); background: var(--vf-surface-muted); }
button:disabled { cursor: not-allowed; opacity: .58; }
button[type="submit"], #create, #show-create, #export, #load-week, #export-all-week, .module-link {
  color: #fff;
  background: var(--vf-primary);
  border-color: var(--vf-primary);
}
button[type="submit"]:hover, #create:hover, #show-create:hover, #export:hover,
#load-week:hover, #export-all-week:hover, .module-link:hover { color: #fff; background: var(--vf-primary-hover); }
#load-week:disabled { color: #fff; background: var(--vf-primary); }
#delete, #close, #confirm-cleanup { color: var(--vf-danger); border-color: #d8a6a1; background: var(--vf-danger-soft); }
.danger-action { color: #fff; border-color: var(--vf-danger); background: var(--vf-danger); }
.danger-action:hover { color: #fff; background: #843131; }
.danger-outline { color: var(--vf-danger); border-color: #d8a6a1; background: transparent; font-size: .82rem; }

label { display: grid; gap: var(--vf-space-1); color: var(--vf-text); font-size: .9rem; font-weight: 640; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--vf-text);
  background: #fff;
  border: 1px solid var(--vf-border-strong);
  border-radius: 6px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--vf-focus);
  outline-offset: 2px;
  border-color: var(--vf-primary);
}
input:disabled, select:disabled, textarea:disabled { color: var(--vf-text-muted); background: var(--vf-surface-muted); }
fieldset { margin: var(--vf-space-4) 0; padding: var(--vf-space-4); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
legend { padding-inline: var(--vf-space-2); font-weight: 700; }
.choice { display: flex; align-items: center; gap: var(--vf-space-2); font-weight: 500; }
.choice input { width: 18px; min-height: 18px; }
.form-span { grid-column: 1 / -1; }
.source-search { display: flex; align-items: center; gap: var(--vf-space-2); }
.source-search input, .source-search select { flex: 1; min-width: 0; }
.source-search button { white-space: nowrap; }
.source-result, .field-error { min-height: 1.4em; margin: var(--vf-space-1) 0 0; font-size: .86rem; }
.source-result:not(:empty) { color: var(--vf-success); }
.field-error:not(:empty) { color: var(--vf-danger); }
.form-actions { align-self: end; }
.form-actions button { width: 100%; }

.report-toolbar { display: flex; align-items: end; gap: var(--vf-space-2); flex-wrap: wrap; }
.report-toolbar label { flex: 1 1 360px; }
.weekly-status { min-height: 1.5em; margin: var(--vf-space-3) 0 var(--vf-space-1); }
.weekly-status.is-applied { color: var(--vf-success); font-weight: 650; }
.weekly-status.is-pending { color: var(--vf-warning); }
.weekly-heading { margin: var(--vf-space-4) 0 var(--vf-space-3); }
.weekly-heading span { display: block; color: var(--vf-text-muted); font-size: .9rem; font-weight: 500; }
.weekly-report-list { display: grid; gap: var(--vf-space-2); }
.weekly-report-row { display: flex; align-items: center; justify-content: space-between; gap: var(--vf-space-3); padding: var(--vf-space-3); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
.weekly-report-row > button:first-child { flex: 1; border: 0; text-align: left; background: transparent; }
.weekly-preview { width: min(1180px, calc(100vw - 32px)); max-width: none; color: var(--vf-text); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
.weekly-preview::backdrop { background: rgba(25, 36, 32, .45); }
.weekly-preview-header { display: flex; align-items: start; justify-content: space-between; gap: var(--vf-space-3); }
.weekly-table-scroll { max-height: min(520px, 65vh); overflow: auto; }
.weekly-table-scroll table { width: max-content; min-width: 100%; margin: 0; }
.weekly-table-scroll thead { position: sticky; top: 0; z-index: 1; }
.weekly-table-scroll th { background: var(--vf-surface-muted); white-space: nowrap; }
.weekly-table-scroll td { white-space: nowrap; }
.system-export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--vf-space-3); }
.system-export-card { padding: var(--vf-space-4); background: var(--vf-surface-muted); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
.system-export-card h3 { min-height: 2.5em; }
.system-export-actions { display: flex; gap: var(--vf-space-2); margin-top: var(--vf-space-3); }
.system-export-status { min-height: 1.5em; margin: var(--vf-space-2) 0 0; }
.system-export-status.is-success { color: var(--vf-success); font-weight: 650; }
.system-export-status.is-empty { color: var(--vf-text-muted); }
.positive-preview { width: min(620px, calc(100vw - 32px)); }
.positive-preview-primary { color: var(--vf-success); font-size: 1.2rem; font-weight: 700; }
.positive-preview .actions { justify-content: flex-end; }

.vf-list-scroll {
  max-height: var(--vf-list-max-height);
  overflow: auto;
  scrollbar-width: thin;
}
.vf-list-scroll table {
  display: table;
  width: max-content;
  min-width: 100%;
  margin: 0;
  overflow: visible;
}
.vf-list-scroll thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.diagnostic-exam-scroll { max-height: min(62vh, 620px); }
.diagnostic-exam-scroll table { min-width: 1320px; table-layout: fixed; }
.diagnostic-exam-scroll th, .diagnostic-exam-scroll td { padding: 8px; white-space: normal; vertical-align: top; }
.diagnostic-exam-scroll th:nth-child(1), .diagnostic-exam-scroll th:nth-child(2) { width: 108px; }
.diagnostic-exam-scroll th:nth-child(3) { width: 76px; }
.diagnostic-exam-scroll th:nth-child(4) { width: 130px; }
.diagnostic-exam-scroll th:nth-child(5) { width: 245px; }
.diagnostic-exam-scroll th:nth-child(6) { width: 150px; }
.diagnostic-exam-scroll th:nth-child(7) { width: 210px; }
.diagnostic-exam-scroll th:nth-child(8) { width: 130px; }
.diagnostic-exam-scroll th:nth-child(9) { width: 104px; }
.diagnostic-exam-scroll td > div + div { margin-top: 4px; }
.exam-required-invalid { border-color: var(--vf-danger); background: var(--vf-danger-soft); }
.exam-required-invalid legend { color: var(--vf-danger); }
.vet-activity-scroll {
  width: 100%;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.vet-activity-scroll table {
  display: table;
  width: 100%;
  table-layout: fixed;
  margin: 0;
  overflow: visible;
}
.vet-activity-scroll th, .vet-activity-scroll td { padding: 7px 8px; white-space: normal; vertical-align: middle; }
.vet-activity-scroll th:nth-child(1) { width: 12%; }
.vet-activity-scroll th:nth-child(2), .vet-activity-scroll th:nth-child(3) { width: 14%; }
.vet-activity-scroll th:nth-child(4) { width: 7%; }
.vet-activity-scroll th:nth-child(5) { width: 18%; }
.vet-activity-scroll th:nth-child(n+6) { width: 8.75%; }
.activity-status { font-weight: 650; }
.activity-status-recent { color: var(--vf-success); }
.activity-status-two-days { color: var(--vf-warning); }
.activity-status-three-days { color: var(--vf-danger); }
.activity-status-none { color: var(--vf-text-muted); }
.vet-activity-scroll thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.litter-table-scroll {
  width: 100%;
  max-height: clamp(360px, calc(100dvh - 230px), 720px);
  overflow: auto;
  scrollbar-width: thin;
}
.litter-table-scroll table { display: table; width: max-content; min-width: 100%; margin: 0; overflow: visible; }
.litter-table-scroll tbody tr { height: 52px; }
.litter-table-scroll thead { position: sticky; top: 0; z-index: 1; }
.quick-deaths-mode { display: flex; align-items: center; gap: var(--vf-space-2); }
.quick-deaths-mode input { width: 18px; min-height: 18px; }
.barn-management-page .litter-table-scroll table { min-width: 1380px; }
.barn-management-page .litter-table-scroll :is(th, td) { padding: 8px 9px; }
.barn-management-page .litter-table-scroll tr > :nth-child(6) { width: 76px; min-width: 76px; max-width: 76px; }
.barn-management-page .litter-table-scroll tbody tr.clickable-row { cursor: pointer; }
.barn-management-page .litter-table-scroll tbody tr.clickable-row:focus-visible {
  outline: 3px solid var(--vf-focus);
  outline-offset: -3px;
}
.quick-deaths-table table { width: 100%; min-width: 2112px; table-layout: auto; }
.quick-entry-toolbar { align-items: end; flex-wrap: wrap; }
.quick-report-date { display: flex; flex-direction: column; gap: var(--vf-space-1); }
.quick-report-date input { min-height: 42px; }
.quick-entry-toolbar #save-all { min-height: 42px; white-space: nowrap; }
.save-all-area { position: relative; display: inline-flex; }
#quick-toast:not(:empty) {
  position: absolute; inset: calc(100% + var(--vf-space-2)) 0 auto auto;
  z-index: 19; width: max-content; max-width: min(420px, calc(100vw - 32px));
  margin: 0; white-space: normal;
}
.quick-entry-dialog { width: min(620px, calc(100vw - 32px)); }
.quick-entry-dialog ul:empty { display: none; }
.quick-entry-dialog li { margin-bottom: var(--vf-space-2); }
.quick-tests-toolbar { align-items: end; }
.quick-tests-table table { min-width: 1450px; }
.quick-tests-table th:first-child, .quick-tests-table td:first-child { min-width: 145px; }
.quick-tests-table input, .quick-tests-table select { min-width: 130px; width: 100%; }
.quick-tests-table input[maxlength="50"] { min-width: 190px; }
.quick-tests-actions { display: flex; justify-content: flex-end; margin-top: var(--vf-space-4); }
.quick-tests-section { margin-top: var(--vf-space-4); padding: var(--vf-space-4); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); background: var(--vf-surface); }
.quick-tests-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--vf-space-3); margin-bottom: var(--vf-space-3); }
.quick-tests-section-heading h2, .quick-tests-section-heading p { margin: 0; }
.quick-tests-section-heading p { color: var(--vf-muted); }
.quick-tests-history-section { background: color-mix(in srgb, var(--vf-surface) 96%, var(--vf-primary)); }
.quick-test-history-group + .quick-test-history-group { margin-top: var(--vf-space-4); padding-top: var(--vf-space-4); border-top: 1px solid var(--vf-border); }
.quick-test-history-group h3 { margin: 0 0 var(--vf-space-2); }
.quick-test-history-scroll { max-height: 360px; overflow: auto; }
.quick-test-history-table { min-width: 1040px; }
.quick-test-history-table td { vertical-align: top; white-space: normal; }
.quick-test-history-table ul { margin: 0; padding-left: 18px; }
@media (max-width: 900px) { .quick-tests-section-heading { align-items: flex-start; flex-direction: column; } }
.quick-test-toast {
  position: fixed; z-index: 40; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: min(430px, calc(100vw - 32px)); padding: var(--vf-space-4);
  border: 1px solid var(--vf-border); border-radius: var(--vf-radius);
  background: var(--vf-surface); box-shadow: var(--vf-shadow);
}
.quick-test-toast[hidden] { display: none; }
.quick-test-toast.is-success { border-color: var(--vf-success); }
.quick-test-toast.is-success #quick-test-result-icon,
.quick-test-toast.is-success #quick-test-result-title { color: var(--vf-success); }
.quick-test-toast.is-error { border-color: var(--vf-danger); }
.quick-test-toast.is-error #quick-test-result-icon,
.quick-test-toast.is-error #quick-test-result-title { color: var(--vf-danger); }
.quick-test-toast .save-result-heading { padding-right: 28px; }
.quick-test-toast p { margin-bottom: 0; }
.save-result-dialog[open] {
  position: fixed; inset: auto; z-index: 20; margin: 0; overflow: auto;
  max-height: var(--save-result-max-height, calc(100dvh - 32px));
  border-color: var(--vf-success); box-shadow: var(--vf-shadow);
}
.save-result-dialog.is-error { border-color: var(--vf-danger); }
.save-result-heading { display: flex; align-items: center; gap: var(--vf-space-2); padding-right: 28px; }
.save-result-heading h2 { margin: 0; }
#save-result-icon { color: var(--vf-success); font-size: 1.5rem; font-weight: 800; }
.save-result-dialog.is-error #save-result-icon { color: var(--vf-danger); }
.save-result-dialog.is-success :is(.dialog-close, .actions) { display: none; }
.quick-deaths-table th { white-space: normal; line-height: 1.25; }
.quick-entry-sort { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 100%; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-weight: inherit; cursor: pointer; }
.quick-entry-sort:hover { color: var(--vf-primary); }
.quick-entry-sort:focus-visible { outline: 3px solid var(--vf-focus); outline-offset: 2px; border-radius: 3px; }
.quick-entry-sort span { min-width: 1em; font-weight: 800; }
.quick-deaths-table td { white-space: nowrap; vertical-align: middle; }
.quick-deaths-table .quick-deaths-number {
  width: 7ch;
  min-width: 72px;
  max-width: 88px;
  min-height: 36px;
  padding: 6px 8px;
}
.quick-number-error { position: absolute; top: calc(100% - 2px); left: 4px; z-index: 7; width: 220px; padding: 4px 6px; color: var(--vf-danger); background: var(--vf-surface); border-radius: 4px; white-space: normal; font-size: .75rem; box-shadow: var(--vf-shadow); }
.quick-number-error:empty { display: none; }
.quick-entry-quantity[aria-invalid="true"] { border-color: var(--vf-danger); }
.quick-deaths-table :is(.quick-number-cell, .quick-vaccine-cell, .quick-feed-cell, .quick-close-cell, .quick-save-cell) { width: 1%; }
.quick-date-control { position: relative; display: grid; grid-template-columns: 104px 42px; gap: 4px; align-items: start; }
.quick-date-shortcut { width: 104px; min-height: 36px; padding: 6px 8px; }
.quick-deaths-table :is(.quick-vaccine-date, .quick-feed-date, .quick-sale-date) { width: 42px; min-height: 36px; padding: 4px; color: transparent; }
.quick-date-error { position: absolute; top: 100%; left: 0; z-index: 6; width: 190px; padding: 4px 6px; color: var(--vf-danger); background: var(--vf-surface); border-radius: 4px; white-space: normal; font-size: .75rem; box-shadow: var(--vf-shadow); }
.quick-date-error:empty { display: none; }
.quick-vaccine-entry { display: flex; align-items: center; gap: 4px; }
.quick-vaccine-entry.no-status { display: block; }
.quick-vaccine-status { position: relative; flex: 0 0 auto; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.quick-vaccine-status summary { display: grid; place-items: center; width: 34px; min-height: 36px; padding: 0; border: 1px solid var(--vf-border); border-radius: 6px; color: var(--vf-text-muted); background: var(--vf-surface); cursor: pointer; list-style: none; font-weight: 700; }
.quick-vaccine-status summary::-webkit-details-marker { display: none; }
.quick-vaccine-status summary:focus-visible { outline: 3px solid var(--vf-focus); outline-offset: 2px; border-color: var(--vf-primary); }
.quick-vaccine-status summary[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
.quick-vaccine-status.status-DA_THUC_HIEN summary { color: var(--vf-success); }
.quick-vaccine-status:is(.status-KHONG_THUC_HIEN, .status-BO_QUA) summary { color: var(--vf-danger); }
.quick-vaccine-status-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 8; display: grid; min-width: 160px; padding: 4px; border: 1px solid var(--vf-border); border-radius: 8px; background: var(--vf-surface); box-shadow: var(--vf-shadow); }
.quick-vaccine-status-menu button { width: 100%; padding: 7px 9px; border: 0; color: var(--vf-text); background: transparent; text-align: left; white-space: nowrap; }
.quick-vaccine-status-menu button:hover:not(:disabled) { background: var(--vf-primary-soft); }
.quick-deaths-table .quick-sticky { position: sticky; z-index: 2; background: var(--vf-surface); }
.quick-deaths-table thead .quick-sticky { z-index: 4; background: var(--vf-surface-muted); }
.quick-deaths-table tbody tr:hover .quick-sticky { background: var(--vf-primary-soft); }
.quick-deaths-table .quick-sticky-1 { left: 0; width: 76px; min-width: 76px; max-width: 76px; }
.quick-deaths-table .quick-sticky-2 { left: 76px; width: 70px; min-width: 70px; max-width: 70px; }
.quick-deaths-table .quick-sticky-3 { left: 146px; width: 82px; min-width: 82px; max-width: 82px; }
.quick-deaths-table .quick-sticky-4 { left: 228px; width: 104px; min-width: 104px; max-width: 104px; }
.quick-deaths-table .quick-sticky-5 { left: 332px; width: 88px; min-width: 88px; max-width: 88px; }
.quick-deaths-table .quick-sticky-6 { left: 420px; width: 112px; min-width: 112px; max-width: 112px; }
.quick-deaths-table .quick-sticky-7 { left: 532px; width: 104px; min-width: 104px; max-width: 104px; box-shadow: 3px 0 5px rgb(15 23 42 / 12%); }
.dashboard-litter-scroll { width: 100%; max-height: 265px; overflow: auto; scrollbar-width: thin; }
.dashboard-litter-scroll table { display: table; width: max-content; min-width: 100%; margin: 0; overflow: visible; }
.dashboard-litter-scroll thead { position: sticky; top: 0; z-index: 1; }
/* Freeze identification columns only in the two litter/barn overview tables. */
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) thead { z-index: 3; }
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) tr > :nth-child(-n+2) {
  position: sticky;
  left: 0;
  z-index: 1;
}
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) tr > :nth-child(2) {
  left: var(--vf-farm-width, 0px);
  box-shadow: inset -1px 0 var(--vf-border);
}
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) tr > :first-child {
  max-width: min(240px, 40vw);
  overflow: hidden;
  text-overflow: ellipsis;
}
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) tbody tr > :nth-child(-n+2) {
  background: var(--vf-surface);
}
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) tbody tr:hover > :nth-child(-n+2) {
  background: #f8f8f4;
}
:is(.dashboard-litter-scroll, .barn-management-page .litter-table-scroll) thead tr > :nth-child(-n+2) {
  z-index: 4;
  background: var(--vf-surface-muted);
}
.sort-button { min-height: auto; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; white-space: nowrap; }
.sort-button:hover { color: var(--vf-text); background: transparent; text-decoration: underline; }
.sort-button span { display: inline-block; min-width: 1em; color: var(--vf-text-muted); }

table {
  display: block;
  width: 100%;
  margin: var(--vf-space-3) 0;
  overflow-x: auto;
  border-collapse: collapse;
  background: var(--vf-surface);
  scrollbar-width: thin;
}
thead, tbody { white-space: nowrap; }
th, td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--vf-border);
  font-variant-numeric: tabular-nums;
}
th { color: #46534e; background: var(--vf-surface-muted); font-size: .82rem; letter-spacing: .015em; }
tbody tr:hover { background: #f8f8f4; }
td button { min-height: 32px; padding: 5px 9px; }

.badge, .status-success, .status-warning, .status-danger, .status-info, .status-neutral {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.status-success { color: var(--vf-success); background: var(--vf-success-soft); }
.status-warning { color: var(--vf-warning); background: var(--vf-warning-soft); }
.status-danger { color: var(--vf-danger); background: var(--vf-danger-soft); }
.status-info { color: var(--vf-info); background: var(--vf-info-soft); }
.status-neutral { color: var(--vf-text-muted); background: var(--vf-surface-muted); }
.error, .success, .alert { min-height: 1.4em; padding: 8px 10px; border-radius: 6px; }
.error:not(:empty) { color: var(--vf-danger); background: var(--vf-danger-soft); }
.success:not(:empty) { color: var(--vf-success); background: var(--vf-success-soft); }

.task { padding: 10px 12px; border-bottom: 1px solid var(--vf-border); border-left: 3px solid var(--vf-border-strong); }
.task:last-child { border-bottom: 0; }
.task.overdue { border-left-color: var(--vf-danger); background: var(--vf-danger-soft); }
.task.due { border-left-color: var(--vf-warning); background: var(--vf-warning-soft); }
.task.upcoming { border-left-color: var(--vf-info); background: var(--vf-info-soft); }
.task-alert-trigger { min-height: auto; padding: 0; border: 0; color: var(--vf-primary); background: transparent; text-align: left; }
.task-alert-trigger:hover { color: var(--vf-primary-hover); background: transparent; text-decoration: underline; }
#epidemiology-alert { width: min(520px, calc(100vw - 32px)); }
#epidemiology-alert .actions { justify-content: flex-end; }
#change-group, #acknowledge-alert { color: #fff; background: var(--vf-primary); border-color: var(--vf-primary); }
#change-group:hover, #acknowledge-alert:hover { color: #fff; background: var(--vf-primary-hover); }

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(86vh, 820px);
  padding: var(--vf-space-5);
  overflow: auto;
  color: var(--vf-text);
  background: var(--vf-surface);
  border: 1px solid var(--vf-border);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(27, 39, 33, .2);
}
dialog::backdrop { background: rgba(28, 37, 33, .42); }
.dialog-close { float: right; min-width: 38px; padding: 4px; font-size: 1.2rem; }
dialog pre { max-width: 100%; overflow: auto; padding: var(--vf-space-3); background: var(--vf-surface-muted); }
.vf-spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -.15em; animation: vf-spin .7s linear infinite; }
.vf-save-success { max-width: min(420px, calc(100vw - 32px)); padding: var(--vf-space-5); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); color: var(--vf-success); font-weight: 700; text-align: center; }
.vf-save-success::backdrop { background: rgba(30, 38, 33, .28); }
.litter-create-success { width: min(580px, calc(100vw - 32px)); }
.litter-create-success h2 { margin-top: 0; color: var(--vf-success); }
.litter-create-summary { grid-template-columns: minmax(140px, .7fr) minmax(220px, 1.3fr); margin: var(--vf-space-4) 0; padding: var(--vf-space-4); background: var(--vf-surface-muted); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
.litter-create-summary-row { display: contents; }
.litter-create-summary dd { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.litter-created-id { color: var(--vf-primary); font-size: 1.1rem; }
.litter-create-actions { justify-content: flex-end; }
.litter-create-actions #view-created-litter { color: #fff; background: var(--vf-primary); border-color: var(--vf-primary); }
@keyframes vf-spin { to { transform: rotate(360deg); } }
dl { display: grid; grid-template-columns: 180px 1fr; gap: var(--vf-space-2); }
dt { color: var(--vf-text-muted); }
dd { margin: 0; font-weight: 620; }

.summary { display: flex; align-items: center; gap: var(--vf-space-4); flex-wrap: wrap; }
.summary strong { display: block; font-size: 1.2rem; }
.litter-summary {
  position: sticky;
  top: 58px;
  z-index: 10;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  padding: 12px max(var(--vf-space-4), calc((100vw - 1200px) / 2 + var(--vf-space-5)));
  background: var(--vf-surface);
  border-bottom: 1px solid var(--vf-border);
  box-shadow: var(--vf-shadow);
}
.litter-summary-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--vf-space-3); flex-wrap: wrap; }
.litter-summary h1 { margin: var(--vf-space-2) 0 var(--vf-space-3); overflow-wrap: anywhere; }
.litter-summary-scroll { width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.litter-summary-row { display: flex; width: max-content; min-width: 100%; align-items: center; white-space: nowrap; }
.litter-summary-item { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px var(--vf-space-3); font-size: .94rem; font-weight: 520; font-variant-numeric: tabular-nums; }
.litter-summary-item:first-child { padding-left: 0; }
.litter-summary-item + .litter-summary-item { border-left: 1px solid var(--vf-border); }
.litter-summary-item strong { font-size: inherit; font-weight: 650; }
.summary-grid, .cards { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
section[id] { scroll-margin-top: 180px; }
.result-row { display: grid; grid-template-columns: minmax(210px, 1fr) 160px minmax(180px, 1fr); gap: var(--vf-space-2); align-items: center; margin: 8px 0; }

.vf-admin-nav .tab { border-color: transparent; }
.panel[hidden] { display: none; }
.account-heading { margin: 0 0 var(--vf-space-4); }
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--vf-space-4); }
.account-card { min-width: 0; }
.account-form { display: grid; gap: var(--vf-space-3); }
.account-form .password-control { display: block; }
.account-form > button { width: 100%; margin-top: auto; }
.account-status { min-height: 1.5em; margin: 0; font-size: .9rem; }
.account-status.is-success { color: var(--vf-success); font-weight: 700; }
.account-status.is-error { color: var(--vf-danger); }
.account-separator { margin-top: var(--vf-space-1); border-top: 1px solid var(--vf-border); }
.deactivate-action { color: var(--vf-danger); border-color: #d8a6a1; background: var(--vf-danger-soft); }
.deactivate-action:hover { color: #fff; border-color: var(--vf-danger); background: var(--vf-danger); }
.deactivate-dialog { width: min(480px, calc(100vw - 32px)); }
.deactivate-dialog .actions { justify-content: flex-end; }
.deactivate-dialog #confirm-deactivate-vet { color: #fff; background: var(--vf-danger); }
.farm-management-heading { margin: var(--vf-space-6) 0 var(--vf-space-4); }
.farm-management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--vf-space-4); }
.farm-search-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: var(--vf-space-2); }
.farm-master-table { margin-bottom: var(--vf-space-3); }
.farm-location-card { margin-top: var(--vf-space-5); }
#farm-location-result { margin-top: var(--vf-space-3); }
#edit-farm-location { max-width: 560px; margin-top: var(--vf-space-4); }
.master-toolbar { display: flex; align-items: center; gap: var(--vf-space-3); margin-bottom: var(--vf-space-3); }
.master-editor { max-width: 620px; margin-bottom: var(--vf-space-4); padding: var(--vf-space-4); background: var(--vf-surface-muted); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); }
.master-editor .actions { justify-content: flex-end; }
.master-delete-dialog { width: min(520px, calc(100vw - 32px)); }
.master-delete-dialog .actions { justify-content: flex-end; margin-top: var(--vf-space-4); }
.master-delete-dialog .field-error { margin-top: var(--vf-space-3); }
.diagnostic-master-dialog { width: min(620px, calc(100vw - 32px)); }
#diagnostic-indicators, #sample-types { overflow-x: auto; }
#diagnostic-indicators td:last-child, #sample-types td:last-child { white-space: nowrap; }
details { margin: var(--vf-space-2) 0; padding: 10px 12px; border: 1px solid var(--vf-border); border-radius: 6px; }
summary { cursor: pointer; font-weight: 650; }
.report-toolbar, .report-summary {
  display: flex;
  align-items: flex-end;
  gap: var(--vf-space-3);
  flex-wrap: wrap;
}
.report-toolbar { margin-bottom: var(--vf-space-3); }
.report-summary { align-items: center; }
.report-summary > span { flex: 1; min-width: 180px; }
.report-summary > a { white-space: nowrap; }
#export { margin-top: var(--vf-space-3); }
.litter-toolbar { align-items: flex-end; }
.litter-toolbar button { min-height: 40px; }

.admin-barn-management-panel {
  position: relative;
  left: 50%;
  width: min(calc(100vw - 2 * var(--vf-page-gutter)), var(--vf-content-wide-max));
  transform: translateX(-50%);
}
.admin-barn-management-panel .litter-toolbar {
  flex-wrap: nowrap;
  gap: var(--vf-space-3);
}
.admin-barn-management-panel .litter-toolbar label { flex: 1 1 220px; min-width: 150px; }
.admin-barn-management-panel .litter-toolbar label:first-child { flex-basis: 280px; }
.admin-barn-management-panel .litter-toolbar button { flex: 0 0 auto; white-space: nowrap; }
.admin-barn-management-panel .litter-table-scroll { width: 100%; max-width: 100%; }
.admin-barn-management-panel .litter-table-scroll table { min-width: 1420px; table-layout: auto; }
.admin-barn-management-panel .litter-table-scroll :is(th, td) {
  padding: 7px 6px;
  white-space: nowrap;
}
.admin-barn-management-panel .litter-table-scroll th:first-child,
.admin-barn-management-panel .litter-table-scroll td:first-child { min-width: 150px; white-space: normal; }
.admin-barn-management-panel .litter-table-scroll .sort-button { padding-inline: 5px; white-space: nowrap; }
.admin-barn-management-panel .litter-table-scroll tbody tr.clickable-row { cursor: pointer; }
.admin-barn-management-panel .litter-table-scroll tbody tr.clickable-row:hover > td {
  background: var(--vf-surface-muted);
}
.admin-barn-management-panel .litter-table-scroll tbody tr.clickable-row:focus-visible {
  outline: 3px solid var(--vf-focus);
  outline-offset: -3px;
}

@media (max-width: 900px) {
  .admin-barn-management-panel {
    width: calc(100vw - 2 * var(--vf-space-4));
  }
  .admin-barn-management-panel .litter-toolbar { flex-wrap: wrap; }
}

.vf-login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  overflow-x: hidden;
  background: #f3f0e8;
  font-size: 16px;
}
.farm-sketch { position: fixed; inset: auto 0 0; width: 100%; height: min(56vh, 520px); color: #68786e; opacity: .13; pointer-events: none; }
.login-shell { position: relative; z-index: 1; width: min(420px, calc(100vw - 40px)); min-width: 0; }
.login-card { padding: 38px; border: 1px solid var(--vf-border); border-radius: 14px; background: rgba(255,255,252,.95); box-shadow: 0 18px 45px rgba(46,57,50,.08); }
.brand { margin-bottom: 30px; text-align: center; }
.wordmark { margin: 0; font-size: 2rem; letter-spacing: -.055em; line-height: 1; }
.wordmark span { color: var(--vf-primary); font-weight: 760; }
.tagline { margin: 10px 0 0; color: var(--vf-text-muted); font-size: .94rem; }
.mode { margin: 0 0 22px; color: var(--vf-text-muted); text-align: center; font-size: .88rem; }
.field { display: grid; gap: 7px; margin-bottom: 18px; }
.vf-login-page input { min-height: 46px; }
.password-control { position: relative; }
.password-control input { width: 100%; padding-right: 48px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 42px;
  min-width: 42px;
  min-height: 38px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--vf-text-muted);
}
.password-toggle:hover { background: var(--vf-surface-muted); color: var(--vf-text); }
.password-toggle svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.password-toggle[aria-pressed="false"] .password-toggle-slash { display: none; }
.submit { width: 100%; min-height: 46px; margin-top: 4px; }
.submit:disabled { cursor: wait; }
.vf-login-page .error { min-height: 24px; margin: 14px 0 0; font-size: .9rem; }
.admin-entry { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--vf-border); text-align: center; }
.admin-entry button { min-height: auto; padding: 3px; border: 0; color: var(--vf-primary); background: none; }
.admin-note { margin: 5px 0 0; font-size: .8rem; }

@media (max-width: 1100px) {
  :root { --vf-list-max-height: 340px; }
  .vf-wide-page :is(.vf-nav, .vf-admin-nav) { position: relative; padding-inline: var(--vf-space-4); flex-wrap: wrap; }
  .vf-wide-page .vf-search { order: 3; flex-basis: 100%; max-width: none; }
  .vf-wide-page .farm-search-results { position: absolute; top: calc(100% + 8px); left: 0; width: 100%; max-height: calc(100dvh - 150px); transform: none; }
}
@media (max-width: 900px) {
  .vf-nav, .vf-admin-nav { position: relative; padding-inline: var(--vf-space-4); flex-wrap: wrap; }
  .vf-search { order: 3; flex-basis: 100%; max-width: none; }
  .farm-search-results { position: absolute; top: calc(100% + 8px); left: 0; width: 100%; max-height: calc(100dvh - 150px); transform: none; }
  .vf-admin-nav > input { order: 3; max-width: none; }
  .litter-summary { top: 0; }
  .wrap, .vf-page { padding: var(--vf-space-4); }
  .result-row { grid-template-columns: 1fr; padding: var(--vf-space-2) 0; border-bottom: 1px solid var(--vf-border); }
  .account-grid { grid-template-columns: 1fr; }
  .farm-management-grid { grid-template-columns: 1fr; }
  .quick-deaths-table th, .quick-deaths-table td { padding: 7px 6px; }
  .quick-deaths-table .quick-deaths-number { width: 6ch; min-width: 64px; padding-inline: 6px; }
}
@media (max-width: 560px) {
  :root { --vf-list-max-height: 290px; }
  body { font-size: 14px; }
  .wrap, .vf-page { padding: var(--vf-space-3); }
  .vf-nav, .vf-admin-nav { gap: var(--vf-space-2); }
  .vf-nav strong, .vf-admin-nav strong { width: 100%; }
  .vf-search-controls { align-items: stretch; }
  .vf-search-controls .vf-search-submit { flex: 0 0 auto; }
  .nav-user { margin-left: 0; }
  .groups, .grid, form.grid { grid-template-columns: 1fr; }
  .litter-toolbar, .report-toolbar { align-items: stretch; flex-direction: column; }
  .litter-toolbar > *, .report-toolbar > * { width: 100%; }
  .source-search, .search-result-row { align-items: stretch; flex-direction: column; }
  .source-search > *, .search-result-row > * { width: 100%; }
  section, .card, .feed-plan-card, .fmd-plan-card { padding: var(--vf-space-3); }
  dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: var(--vf-space-4); }
  dl { grid-template-columns: 1fr; }
  dd { margin-bottom: var(--vf-space-2); }
  .vf-login-page { padding: 20px 16px; }
  .login-shell { width: calc(100vw - 32px); }
  .login-card { padding: 30px 24px; border-radius: 12px; }
  .farm-sketch { height: 42vh; opacity: .08; transform: scale(1.35); transform-origin: bottom center; }
  .litter-summary { padding-inline: var(--vf-space-3); }
  .litter-summary-actions { align-items: flex-start; }
  .litter-summary h1 { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* Dashboard export actions and a single replaceable notification. */
.report-export-actions { display: flex; flex-wrap: wrap; gap: var(--vf-space-2); margin-top: var(--vf-space-3); }
.source-farm-picker { position: relative; }
.source-farm-picker > label { display: block; }
.source-farm-search-row { display: flex; gap: var(--vf-space-2); align-items: stretch; }
.source-farm-input { flex: 1; min-width: 0; }
.source-farm-search { white-space: nowrap; }
.source-farm-status, .source-farm-selected { min-height: 1.4em; margin: var(--vf-space-1) 0 0; font-size: .88rem; }
.source-farm-options { position: absolute; z-index: 12; top: calc(100% - 1.4em); width: 100%; max-height: 280px; overflow-y: auto; background: var(--vf-surface); border: 1px solid var(--vf-border); border-radius: var(--vf-radius); box-shadow: var(--vf-shadow); }
.source-farm-option { display: grid; width: 100%; min-height: 48px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--vf-border); border-radius: 0; color: var(--vf-text); background: var(--vf-surface); text-align: left; }
.source-farm-option:last-child { border-bottom: 0; }
.source-farm-option span { color: var(--vf-text-muted); font-size: .82rem; }
.source-farm-option:hover, .source-farm-option:focus-visible, .source-farm-option[aria-selected="true"] { color: var(--vf-primary); background: var(--vf-primary-soft); }
.source-farm-empty { margin: 0; padding: 10px; color: var(--vf-text-muted); }
.report-result-count { color: var(--vf-success); font-size: 1.2rem; font-weight: 700; }
.export-toast:empty { display: none; }
.export-toast:not(:empty) {
  position: fixed; bottom: var(--vf-space-4); right: var(--vf-space-4);
  z-index: 100; max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--vf-border); box-shadow: var(--vf-shadow);
}

.kpi-drill-trigger { text-align: left; color: var(--vf-text); font: inherit; }
.kpi-drill-trigger:hover { background: var(--vf-success-soft); }
:is(.feed-plan-card, .fmd-plan-card) { display: block; width: 100%; text-align: left; color: var(--vf-text); }
:is(.feed-plan-card, .fmd-plan-card):hover { color: var(--vf-text); background: var(--vf-success-soft); }
#kpi-drilldown { width: min(1100px, calc(100vw - 32px)); }
.kpi-drill-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--vf-space-3); }
.kpi-drill-summary p { margin: 0; }
.kpi-drill-scroll { max-height: 60vh; overflow: auto; }
.kpi-drill-scroll table { min-width: 760px; }
.kpi-drill-scroll th { position: sticky; top: 0; z-index: 1; background: var(--vf-surface, #fff); }
#feed-plan-dialog { width: min(1100px, calc(100vw - 32px)); overflow-x: hidden; }
#feed-plan-table {
  width: 100%;
  max-width: 100%;
  max-height: calc(42px + 10 * 52px);
  overflow-x: hidden;
  overflow-y: auto;
}
#feed-plan-table table {
  display: table;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: visible;
  table-layout: fixed;
}
#feed-plan-table :is(thead, tbody) { white-space: normal; }
#feed-plan-table :is(th, td) { padding: 8px 7px; line-height: 1.35; }
#feed-plan-table th { overflow-wrap: normal; }
#feed-plan-table th .sort-button { white-space: normal; }
#feed-plan-table td:first-child { overflow-wrap: anywhere; }
#feed-plan-table td:is(:nth-child(2), :nth-child(3), :nth-child(4), :nth-child(6)) { white-space: nowrap; }
#feed-plan-table .feed-col-farm { width: 31%; }
#feed-plan-table .feed-col-barn { width: 8%; }
#feed-plan-table .feed-col-litter { width: 7%; }
#feed-plan-table .feed-col-entry { width: 12%; }
#feed-plan-table .feed-col-age { width: 22%; }
#feed-plan-table .feed-col-code { width: 20%; }
#fmd-plan-dialog { width: min(1180px, calc(100vw - 32px)); overflow-x: hidden; }
#fmd-plan-table {
  width: 100%;
  max-width: 100%;
  max-height: calc(42px + 10 * 52px);
  overflow-x: hidden;
  overflow-y: auto;
}
#fmd-plan-table table {
  display: table;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: visible;
  table-layout: fixed;
}
#fmd-plan-table :is(thead, tbody) { white-space: normal; }
#fmd-plan-table :is(th, td) { padding: 8px 7px; line-height: 1.35; }
#fmd-plan-table th { overflow-wrap: normal; }
#fmd-plan-table th .sort-button { white-space: normal; }
#fmd-plan-table td:first-child { overflow-wrap: anywhere; }
#fmd-plan-table td:is(:nth-child(2), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7)) { white-space: nowrap; }
#fmd-plan-table .fmd-col-farm { width: 27%; }
#fmd-plan-table .fmd-col-barn { width: 8%; }
#fmd-plan-table .fmd-col-litter { width: 7%; }
#fmd-plan-table .fmd-col-entry { width: 11%; }
#fmd-plan-table .fmd-col-age { width: 18%; }
#fmd-plan-table .fmd-col-vaccine { width: 12%; }
#fmd-plan-table .fmd-col-elapsed { width: 17%; }
.kpi-drill-row { cursor: pointer; }
.kpi-drill-row:hover { background: var(--vf-success-soft); }

@media (max-width: 600px) {
  #feed-plan-dialog { width: calc(100vw - 20px); }
  #feed-plan-table :is(th, td) { padding: 5px 2px; font-size: .68rem; }
  #feed-plan-table td:is(:nth-child(4), :nth-child(6)) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #fmd-plan-dialog { width: calc(100vw - 20px); }
  #fmd-plan-table :is(th, td) { padding: 5px 2px; font-size: .68rem; }
  #fmd-plan-table td:is(:nth-child(4), :nth-child(6)) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
