: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-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%, 1260px);
  margin-inline: auto;
  padding: var(--vf-space-5);
}
.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-space-4), calc((100vw - 1260px) / 2 + var(--vf-space-5)));
  color: #fff;
  background: #29473e;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.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: 560px; 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-search-table-scroll { max-height: 282px; overflow: auto; scrollbar-width: thin; }
.farm-search-table-scroll table { width: max-content; min-width: 100%; margin: 0; }
.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 { white-space: nowrap; }
.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 {
  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 .card { margin: 0; box-shadow: none; }
.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 { flex: 1; }
.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(65vh, 620px); 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;
}
.vet-activity-scroll {
  width: 100%;
  max-height: 250px;
  overflow: auto;
  scrollbar-width: thin;
}
.vet-activity-scroll table {
  display: table;
  width: max-content;
  min-width: 100%;
  margin: 0;
  overflow: visible;
}
.vet-activity-scroll thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.litter-table-scroll {
  width: 100%;
  max-height: 560px;
  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; }
.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, .litter-table-scroll) thead { z-index: 3; }
:is(.dashboard-litter-scroll, .litter-table-scroll) tr > :nth-child(-n+2) {
  position: sticky;
  left: 0;
  z-index: 1;
}
:is(.dashboard-litter-scroll, .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, .litter-table-scroll) tr > :first-child {
  max-width: min(240px, 40vw);
  overflow: hidden;
  text-overflow: ellipsis;
}
:is(.dashboard-litter-scroll, .litter-table-scroll) tbody tr > :nth-child(-n+2) {
  background: var(--vf-surface);
}
:is(.dashboard-litter-scroll, .litter-table-scroll) tbody tr:hover > :nth-child(-n+2) {
  background: #f8f8f4;
}
:is(.dashboard-litter-scroll, .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); }
@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; }

.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; }
}
@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; }
}
@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 { 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); }
.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); }
#kpi-drilldown { width: min(1100px, calc(100vw - 32px)); }
.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); }
.kpi-drill-row { cursor: pointer; }
.kpi-drill-row:hover { background: var(--vf-success-soft); }
