:root {
  --bg: #f5f6f1;
  --surface: #ffffff;
  --surface-soft: #f9faf6;
  --ink: #18221d;
  --muted: #69746e;
  --line: #dde2d9;
  --sidebar-bg: #e9edf1;
  --sidebar-line: #cbd3dc;
  --green: #234236;
  --blue: #315f86;
  --gold: #b47a28;
  --red: #a34b43;
  --brand-green: #d5b065;
  --brand-yellow: #18221d;
  --shadow: 0 14px 34px rgba(24, 34, 29, 0.07);
  --radius: 8px;
  --sidebar: 240px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  color: var(--ink);
  border-right: 1px solid var(--sidebar-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--brand-green);
  color: var(--brand-yellow);
  font-size: 0.82rem;
  font-weight: 850;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 0;
  background: transparent;
  color: #34443d;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nav-list a:hover {
  background: rgba(35, 66, 54, 0.08);
  color: var(--green);
}

.sidebar-section {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.sidebar-section strong {
  line-height: 1.2;
}

.sidebar-section small,
.sidebar-label {
  color: #607064;
}

.sidebar-label {
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
}

.quick-links a {
  padding: 5px 0;
  color: #34443d;
}

.quick-links a:hover {
  color: var(--green);
}

.sidebar-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(238, 243, 236, 0.72);
  color: #607064;
  font-size: 0.88rem;
}

.user-note {
  align-items: flex-start;
  flex-wrap: wrap;
}

.user-note form {
  width: 100%;
  margin: 4px 0 0;
}

.link-button {
  min-height: 0;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6fc17c;
}

.page {
  width: min(1240px, 100%);
  padding: 28px clamp(18px, 3vw, 38px) 56px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.page-header h1 {
  margin: 2px 0 4px;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.header-logout {
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  align-self: center;
}

.header-logout button {
  min-width: 128px;
  min-height: 66px;
  padding: 14px 18px;
}

.page-tabs {
  display: flex;
  gap: 14px;
  margin: -2px 0 18px;
  border-bottom: 1px solid var(--line);
}

.page-tabs a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 750;
}

.page-tabs a:hover,
.page-tabs a[aria-current="page"] {
  color: var(--green);
}

.page-tabs a[aria-current="page"] {
  border-bottom-color: var(--green);
}

.field-header {
  align-items: flex-start;
}

.eyebrow {
  text-transform: uppercase;
  font-weight: 800;
  font-size: 0.76rem;
  color: var(--gold);
  letter-spacing: 0;
}

.card {
  display: block;
  min-width: 0;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.farm-kpis, .admin-kpis {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 128px;
}

.compact-kpi {
  min-height: 104px;
  padding: 14px 15px;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--green);
}

.kpi span, .card span, .panel-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
}

.compact-kpi strong {
  font-size: 2rem;
}

.kpi small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.accent-blue::before { background: var(--blue); }
.accent-green::before { background: #3d8a62; }
.accent-gold::before { background: var(--gold); }
.accent-red::before { background: var(--red); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.gmd-overview {
  display: grid;
  grid-template-columns: minmax(210px, 0.58fr) minmax(420px, 1.42fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

.gmd-gauge-card {
  min-height: 218px;
}

.weight-history-card {
  min-height: 218px;
}

.gmd-gauge {
  --gmd-pct: 0%;
  --gmd-color: #3d8a62;
  position: relative;
  display: grid;
  place-items: center;
  width: min(148px, 100%);
  aspect-ratio: 1;
  margin: 2px auto 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 56%, transparent 57%),
    conic-gradient(var(--gmd-color) 0 var(--gmd-pct), #dfe6dc var(--gmd-pct) 100%);
}

.gmd-gauge strong {
  margin-top: 8px;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.gmd-gauge span {
  margin-top: -28px;
  color: var(--muted);
  font-weight: 750;
}

.gauge-current-weight {
  display: grid;
  gap: 3px;
  margin: 10px 0 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(105, 116, 110, 0.22);
  text-align: center;
}

.gauge-current-weight span {
  color: var(--muted);
  font-size: 0.86rem;
}

.gauge-current-weight strong {
  color: var(--ink);
  font-size: 11px;
  line-height: 1.1;
}

.gmd-gauge-card .gauge-current-weight strong {
  font-size: 1.7rem;
}

.metric-pair {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.metric-pair span {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-pair strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plotly-chart {
  width: 100%;
  height: 238px;
}

.projection-plot {
  height: 310px;
}

.max-projection-plot {
  height: 330px;
}

.ranking-plot {
  height: 278px;
}

.plotly-chart > div {
  width: 100% !important;
  height: 100% !important;
}

.metrics-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.projection-max-row {
  display: grid;
  margin-bottom: 16px;
}

.gmd-ranking {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.model-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
}

.panel-wide {
  min-width: 0;
}

.dashboard-grid .panel-wide {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.chart-filter-status-wrap {
  flex: 0 0 auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-filter-status {
  margin: 0;
  padding: 5px 9px;
  border: 1px solid rgba(49, 95, 134, 0.28);
  border-radius: 999px;
  background: #f1f6fa;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: right;
}

.chart-filter-help {
  position: relative;
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-color: rgba(49, 95, 134, 0.38);
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.chart-filter-help::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: min(260px, 72vw);
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(24, 34, 29, 0.14);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.chart-filter-help:hover::after,
.chart-filter-help:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.is-filtering-charts [data-chart-slot] {
  opacity: 0.62;
  transition: opacity 0.14s ease;
}

.panel-title h2, .form-card h2, .section-title h2 {
  margin: 2px 0 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

.table-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 66px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.table-row strong {
  display: block;
  margin-bottom: 3px;
}

.table-row small {
  color: var(--muted);
}

.table-row > span {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--green);
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

.section-title {
  margin: 24px 0 12px;
}

.task-card, .animal-card {
  min-height: 148px;
}

.task-card h2, .card h2, .card h3 {
  margin: 6px 0 8px;
  font-size: 1.08rem;
  line-height: 1.22;
}

.task-card p, .card p {
  margin: 6px 0;
  color: var(--muted);
}

.task-management-card {
  display: grid;
  gap: 8px;
}

.task-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.task-card-header form {
  margin: 0;
}

.task-card-actions {
  display: grid;
  gap: 8px;
  width: 128px;
}

.task-card-actions button {
  width: 100%;
  min-height: 66px;
  padding: 14px 18px;
}

.task-card strong, .animal-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.85rem;
  color: var(--green);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

input, select, textarea, button, .button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
}

input, select, textarea {
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.secondary {
  border-color: var(--blue);
  background: var(--blue);
}

.inline-action {
  margin: 0;
}

.pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef5ef;
  color: var(--green) !important;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.list-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.weight-alert-list {
  display: grid;
  gap: 10px;
}

.trend-alert-panel {
  border-color: rgba(180, 122, 40, 0.34);
  background: #fffdf8;
  box-shadow: 0 14px 34px rgba(180, 122, 40, 0.09);
}

.trend-alert-panel .panel-title {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(180, 122, 40, 0.2);
}

.trend-alert-panel .panel-title h2 {
  font-size: 1.2rem;
}

.trend-alert-panel .panel-title span,
.trend-alert-panel .muted {
  font-size: 0.98rem;
}

.weight-alert-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.weight-alert-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.weight-alert-card span,
.weight-alert-card small {
  color: var(--muted);
}

.weight-alert-card strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.05;
}

.weight-alert-card p {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.weight-alert-card small {
  grid-column: 1 / -1;
  font-size: 0.92rem;
}

.alert-badge {
  grid-column: auto !important;
  align-self: start;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff1ef;
  color: var(--red) !important;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.collect-card {
  width: min(640px, 100%);
}

.sidebar-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(24, 34, 29, 0.05);
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}

.sidebar-tabs button {
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  color: #435249;
  font-weight: 800;
}

.sidebar-tabs button[aria-selected="true"] {
  border-color: var(--sidebar-line);
  background: #fff;
  color: var(--green);
  box-shadow: 0 6px 16px rgba(24, 34, 29, 0.06);
}

.sidebar-card h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  line-height: 1.2;
}

.lot-sidebar-card {
  gap: 12px;
}

.lot-sidebar-card h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
  line-height: 1.15;
}

.sidebar-metric-list {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.sidebar-metric {
  display: grid;
  gap: 3px;
  padding-top: 9px;
  border-top: 1px solid rgba(105, 116, 110, 0.18);
}

.sidebar-metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.sidebar-metric strong {
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.1;
}

.side-form label {
  margin: 0;
  gap: 5px;
  color: #435249;
  font-size: 0.84rem;
}

.side-form input,
.side-form select,
.side-form textarea {
  min-height: 38px;
  padding: 8px 10px;
}

.side-form button {
  width: 100%;
  min-height: 40px;
}

.autocomplete-field {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: grid;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 26px rgba(24, 34, 29, 0.12);
}

.autocomplete-option {
  display: grid;
  justify-content: stretch;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.autocomplete-option:hover {
  background: #f4f7f2;
}

.autocomplete-option strong,
.autocomplete-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-option small {
  color: var(--muted);
}

.sidebar-button {
  width: 100%;
  min-height: 40px;
}

.sidebar form + .sidebar-button,
.sidebar .sidebar-button + .sidebar-button {
  margin-top: 10px;
}

.sidebar .danger-soft.sidebar-button {
  margin-bottom: 10px;
}

.sidebar-mini-link {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-mini-link:last-child {
  border-bottom: 0;
}

.sidebar-mini-link strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.sidebar-mini-link small {
  color: var(--muted);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
  max-width: 980px;
}

.login-page {
  margin: 0 auto;
}

.login-brand {
  width: fit-content;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 3px 0 18px;
  font-size: 2rem;
  line-height: 1.05;
}

.login-hints h2 {
  word-break: break-word;
}

.login-help-link {
  display: inline-flex;
  width: fit-content;
  margin-top: 12px;
  color: var(--blue);
  font-weight: 750;
}

.reset-layout {
  grid-template-columns: minmax(280px, 420px) minmax(260px, 360px);
}

.reset-note {
  align-self: stretch;
}

.password-result {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(61, 138, 98, 0.32);
  border-radius: var(--radius);
  background: #eef7ef;
}

.password-result span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.password-result strong {
  color: var(--green);
  font-size: 2rem;
  line-height: 1;
}

.password-result p {
  margin: 4px 0 0;
  color: var(--muted);
}

.alert {
  padding: 10px 12px;
  border: 1px solid #e0b8b3;
  border-radius: var(--radius);
  background: #fff1ef;
  color: var(--red) !important;
}

.success-alert {
  border-color: rgba(61, 138, 98, 0.32);
  background: #eef7ef;
  color: var(--green) !important;
}

.preview {
  display: none;
  width: 100%;
  max-height: 390px;
  object-fit: cover;
  margin: 8px 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 102px minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}

.bar-row div {
  height: 11px;
  background: #e4e8df;
  border-radius: 999px;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.lot-card {
  min-height: 150px;
}

.lot-card.is-chart-hidden {
  opacity: 0.46;
}

.lot-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.7rem;
  color: var(--green);
}

.lot-gauge-card {
  display: grid;
  gap: 10px;
  min-height: 268px;
  align-content: start;
  text-align: center;
}

.lot-card-title {
  display: grid;
  gap: 2px;
}

.lot-card-title h2 {
  margin: 0;
}

.lot-gauge {
  width: min(132px, 100%);
  margin-top: 4px;
}

.lot-gauge strong {
  margin-top: 8px;
  color: var(--ink);
  font-size: 1.72rem;
}

.admin-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.admin-hero {
  align-items: flex-start;
}

.admin-tabs {
  display: flex;
  gap: 14px;
  margin: 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.admin-tabs button {
  width: auto;
  min-height: 40px;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.admin-tabs button:hover,
.admin-tabs button[aria-selected="true"] {
  color: var(--green);
}

.admin-tabs button[aria-selected="true"] {
  border-bottom-color: var(--green);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 280px);
  gap: 14px;
  margin-bottom: 16px;
}

.filter-row label {
  margin: 0;
}

.single-filter-row {
  grid-template-columns: minmax(240px, 1fr);
}

.admin-board {
  margin-top: 18px;
}

.admin-table-card {
  padding: 0;
  overflow: hidden;
}

.admin-table {
  display: grid;
}

.admin-table-head,
.admin-table-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-table-head {
  background: #f4f7f2;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.admin-users .admin-table-head {
  grid-template-columns: minmax(140px, 0.9fr) minmax(120px, 0.7fr) minmax(190px, 1fr) minmax(120px, 0.65fr) minmax(120px, 0.65fr) 160px;
}

.admin-farms .admin-table-head {
  grid-template-columns: minmax(150px, 0.9fr) minmax(120px, 0.65fr) minmax(100px, 0.55fr) minmax(210px, 1fr) minmax(160px, 0.8fr) 160px;
}

.admin-table-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.admin-table-row:last-child {
  border-bottom: 0;
}

.admin-row-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(120px, 0.7fr) minmax(190px, 1fr) minmax(120px, 0.65fr) minmax(120px, 0.65fr) auto;
  gap: 10px;
  align-items: end;
}

.farm-row-form {
  grid-template-columns: minmax(150px, 0.9fr) minmax(120px, 0.65fr) minmax(100px, 0.55fr) minmax(210px, 1fr) minmax(160px, 0.8fr) auto;
}

.task-filter-row {
  margin-bottom: 16px;
}

.admin-row-form label {
  margin: 0;
}

.delete-form {
  align-self: end;
  margin: 0;
}

.danger-soft {
  border-color: #fee0df;
  background: #fff0ef;
  color: #d23e38;
}

.danger-soft:hover {
  border-color: #d23e38;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 16px;
}

.access-pill {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  margin: 0;
  padding: 5px 7px 5px 10px;
  border: 1px solid #c8d6c8;
  border-radius: 999px;
  background: #fbfdf9;
}

.access-pill span {
  color: var(--ink);
  font-weight: 750;
}

.access-pill small {
  color: var(--muted);
}

.access-pill button {
  min-height: 24px;
  width: 24px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--red);
}

.field-body {
  min-height: 100vh;
  background: #f6f8f4;
}

.field-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 12px clamp(14px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.field-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.field-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-nav a,
.field-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  text-align: center;
}

.field-nav form {
  display: flex;
  margin: 0;
}

.field-page {
  width: min(980px, 100%);
  padding: 22px clamp(14px, 4vw, 34px) 48px;
  margin: 0 auto;
}

.field-task-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.field-task-card {
  min-height: 170px;
}

.field-collect-card {
  margin: 0 auto;
}

.field-collect-card label {
  font-weight: 750;
}

.field-collect-card input,
.field-collect-card textarea {
  font-weight: 400;
}

.image-picker-field {
  cursor: pointer;
}

.image-picker-field .image-input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.file-name {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.manual-weight-field {
  margin-top: 4px;
}

.field-kpis {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  max-width: 760px;
}

.field-kpis .compact-kpi {
  min-height: 118px;
}

.field-kpis .compact-kpi strong {
  max-width: 100%;
  font-size: clamp(1.55rem, 4vw, 2rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.field-pending-list {
  max-width: 760px;
}

.pending-record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 104px;
  padding: 15px 17px;
  box-shadow: 0 10px 26px rgba(24, 34, 29, 0.06);
}

.pending-record-card h2 {
  margin: 4px 0 5px;
  font-size: 1.15rem;
}

.pending-record-card p {
  margin: 0;
}

.pending-record-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.pending-record-card .pill {
  justify-self: end;
  min-width: 92px;
  margin: 0;
  text-align: center;
}

.compact-form {
  display: grid;
  gap: 10px;
}

.compact-form label {
  margin-bottom: 0;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.admin-edit-grid label {
  margin-bottom: 0;
}

.row-actions,
.delete-form {
  display: flex;
  align-items: end;
  margin: 0;
}

.danger {
  border-color: var(--red);
  background: var(--red);
}

.link-row form {
  margin: 0;
}

@media (min-width: 1440px) {
  :root {
    --sidebar: clamp(280px, 15vw, 340px);
  }

  .sidebar {
    gap: 16px;
    padding: 24px clamp(22px, 1.4vw, 30px);
  }

  .page {
    width: 100%;
    padding: 32px clamp(28px, 2.4vw, 58px) 64px;
  }

  .gmd-overview {
    grid-template-columns: minmax(260px, 0.55fr) minmax(620px, 1.45fr);
  }

  .farm-kpis,
  .admin-kpis {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }

  .lot-summary {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px;
    overflow-x: auto;
  }

  .brand {
    flex: 0 0 auto;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .nav-list {
    display: flex;
    gap: 6px;
    min-width: max-content;
  }

  .nav-list a {
    min-height: 36px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.06);
  }

  .sidebar-note {
    display: none;
  }

  .sidebar-section {
    display: none;
  }

  .sidebar-card {
    display: none;
  }

  .page {
    padding: 18px 14px 42px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .gmd-overview,
  .metrics-charts,
  .gmd-ranking {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-row,
  .admin-edit-grid,
  .admin-row-form,
  .farm-row-form,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .admin-table-head {
    display: none;
  }

  .admin-table-row {
    grid-template-columns: 1fr;
  }

  .field-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .field-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .field-nav a,
  .field-nav button,
  .field-nav form {
    width: 100%;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-logout {
    margin-left: 0;
    align-self: stretch;
  }

  .page-tabs {
    gap: 18px;
    overflow-x: auto;
  }

  .page-header h1 {
    font-size: 2rem;
  }

  .kpi-grid, .field-kpis {
    grid-template-columns: 1fr;
  }

  .field-kpis,
  .field-pending-list {
    max-width: none;
  }

  .pending-record-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .pending-record-card .pill {
    justify-self: stretch;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  button, .button {
    width: 100%;
    min-height: 50px;
  }

  input, select, textarea {
    min-height: 50px;
  }
}
