/* ==========================================================================
   Bhumiadhara — Farm Decision & Profit Planning System
   Design system + application styles. Zero external dependencies.
   ========================================================================== */

/* ---------------- Design tokens ---------------- */
:root {
  --forest-950: #052017;
  --forest-900: #08281D;
  --forest-800: #0B3D2E;
  --forest-700: #12513C;
  --forest-600: #176B4C;
  --forest-500: #1E7A57;
  --green-700: #15803D;
  --green-600: #16A34A;
  --green-500: #22C55E;
  --green-200: #86EFAC;
  --green-100: #DCFCE7;
  --green-50: #F0FDF4;

  --cream: #F7F5EF;
  --cream-2: #F1EEE4;
  --surface: #FFFFFF;
  --surface-2: #FBFAF6;
  --surface-3: #F5F2EA;
  --line: #E5E0D3;
  --line-soft: #EEE9DE;
  --line-strong: #D6CEBC;

  --text: #1E2923;
  --text-2: #35423B;
  --muted: #66746C;
  --muted-2: #8A968F;

  --brown: #8A5A34;
  --brown-soft: #B08968;
  --brown-100: #F3E9DC;
  --amber: #B45309;
  --amber-100: #FEF3C7;
  --red: #B42318;
  --red-100: #FEE4E2;
  --blue: #175CD3;
  --blue-100: #EAF1FD;
  --purple: #6941C6;
  --purple-100: #F1ECFC;

  --shadow-xs: 0 1px 2px rgba(22, 40, 30, .05);
  --shadow-sm: 0 1px 2px rgba(22, 40, 30, .04), 0 6px 16px -12px rgba(22, 40, 30, .28);
  --shadow-md: 0 2px 4px rgba(22, 40, 30, .04), 0 18px 40px -28px rgba(8, 40, 29, .42);
  --shadow-lg: 0 4px 10px rgba(22, 40, 30, .06), 0 32px 60px -30px rgba(8, 40, 29, .45);

  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 999px;

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 82px;
  --topbar-h: 70px;
  --page-max: 1440px;
  --gutter: 28px;
  --focus: 0 0 0 3px rgba(34, 197, 94, .38);
}

/* ---------------- Reset / base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
svg { display: block; }
ul, ol { margin: 0; padding: 0; }
li { list-style: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--green-600);
  outline-offset: 2px;
  border-radius: 4px;
}
::selection { background: var(--green-200); color: var(--forest-900); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  top: -60px; left: 16px;
  z-index: 200;
  padding: 12px 18px;
  background: var(--forest-900);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; text-decoration: none; }

.noscript, .page-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px;
  color: var(--muted);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- App shell ---------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--forest-900);
  color: #E7F0EA;
  border-right: 1px solid rgba(255, 255, 255, .06);
  transition: width .2s ease, transform .22s ease;
}
.sidebar__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--topbar-h);
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: #fff; text-decoration: none !important; }
.brand:hover { color: #fff; }
.brand__logo { flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
.brand__logo svg { width: 32px; height: 32px; }
.brand__text { display: grid; min-width: 0; }
.brand__name { font-family: var(--font-display); font-weight: 750; letter-spacing: .01em; font-size: 1.06rem; line-height: 1.2; color: #fff; }
.brand__tag { font-size: .64rem; color: #9FB8AA; letter-spacing: .015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__collapse {
  margin-left: auto;
  flex: none;
  color: #A9C1B3;
  border-color: rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
}
.sidebar__collapse:hover { color: #fff; background: rgba(255,255,255,.1); }

.nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px 22px;
  scrollbar-width: thin;
  scrollbar-color: #2A4B3C transparent;
}
.nav__label {
  margin: 16px 10px 7px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7E9A8B;
}
.nav__label:first-child { margin-top: 0; }
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 11px;
  margin: 2px 0;
  border-radius: 10px;
  color: #C8D8CF;
  font-size: .875rem;
  font-weight: 550;
  text-decoration: none !important;
  transition: background .15s ease, color .15s ease;
}
.nav__item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav__item:focus-visible { outline-color: var(--green-200); }
.nav__item.is-active { background: #1A4B39; color: #fff; box-shadow: inset 0 0 0 1px rgba(134,239,172,.16); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--green-400, #4ADE80);
}
.nav__icon { flex: none; width: 20px; height: 20px; color: #9FB8AA; }
.nav__icon svg { width: 20px; height: 20px; }
.nav__item.is-active .nav__icon { color: #86EFAC; }
.nav__text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar__foot { padding: 12px 12px 18px; }
.storage-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
  color: #93AC9D;
  font-size: .7rem;
  line-height: 1.45;
}
.storage-note strong { color: #C5D7CC; font-weight: 650; }
.storage-note__icon { flex: none; color: #86EFAC; margin-top: 1px; }
.storage-note__icon svg { width: 15px; height: 15px; }

.app__main {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}

/* Collapsed desktop sidebar */
@media (min-width: 981px) {
  .app.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .app.is-collapsed .app__main { margin-left: var(--sidebar-w-collapsed); }
  .app.is-collapsed .brand__text,
  .app.is-collapsed .nav__label,
  .app.is-collapsed .nav__text,
  .app.is-collapsed .storage-note { display: none; }
  .app.is-collapsed .sidebar__head { padding-inline: 15px; justify-content: center; }
  .app.is-collapsed .sidebar__collapse { display: inline-grid; margin-left: 0; }
  .app.is-collapsed .sidebar__collapse svg { transform: rotate(180deg); }
  .app.is-collapsed .nav { padding-inline: 10px; }
  .app.is-collapsed .nav__item { justify-content: center; padding: 10px; }
  .app.is-collapsed .nav__item.is-active::before { left: -10px; }
  .app.is-collapsed .nav__label + .nav__item { margin-top: 9px; }
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 0 var(--gutter);
  background: rgba(247, 245, 239, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.topbar__brand { display: none; align-items: center; gap: 8px; color: var(--forest-900); font-weight: 750; text-decoration: none !important; }
.topbar__brandLogo { flex: none; }
.topbar__brandName { font-family: var(--font-display); font-size: 1rem; letter-spacing: -.01em; }

.farm-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 210px;
  max-width: 300px;
  height: 40px;
  padding: 0 10px 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
}
.farm-picker__icon { flex: none; color: var(--forest-600); }
.farm-picker__icon svg { width: 17px; height: 17px; }
.farm-picker__select {
  appearance: none;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0 18px 0 0;
  font-size: .83rem;
  font-weight: 650;
  color: var(--text);
  cursor: pointer;
  text-overflow: ellipsis;
}
.farm-picker__select:focus { outline: none; }
.farm-picker:focus-within { box-shadow: var(--focus); border-color: var(--green-500); }
.farm-picker__chevron { position: absolute; right: 9px; pointer-events: none; color: var(--muted); }
.farm-picker__chevron svg { width: 14px; height: 14px; }
.topbar__meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.topbar__pill--soft { background: transparent; color: var(--muted); border-color: transparent; }
.topbar__spacer { flex: 1; }

.profile-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 4px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: transparent;
  text-align: left;
}
.profile-btn:hover { background: var(--surface); border-color: var(--line); }
.profile-btn__avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--forest-800);
  color: #fff;
  font-weight: 750;
  font-size: .85rem;
  flex: none;
}
.profile-btn__text { display: grid; line-height: 1.25; }
.profile-btn__name { font-size: .76rem; font-weight: 650; color: var(--text); }
.profile-btn__sub { font-size: .65rem; color: var(--muted); }
.profile-btn__chevron { color: var(--muted); }
.profile-btn__chevron svg { width: 14px; height: 14px; }

.menu-popover {
  position: fixed;
  top: calc(var(--topbar-h) - 6px);
  right: var(--gutter);
  z-index: 80;
  width: 232px;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } }
.menu-popover__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: .82rem;
  text-align: left;
  text-decoration: none !important;
}
.menu-popover__item svg { width: 16px; height: 16px; color: var(--muted); }
.menu-popover__item:hover { background: var(--surface-3); color: var(--text); }
.menu-popover__item + .menu-popover__item { margin-top: 1px; }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter);
  background: var(--amber-100);
  border-bottom: 1px solid #F2D58A;
  color: #664300;
  font-size: .8rem;
}
.demo-banner__icon { flex: none; color: var(--amber); }
.demo-banner__icon svg { width: 17px; height: 17px; }
.demo-banner p { flex: 1; }
.demo-banner strong { font-weight: 750; }

/* ---------------- Main content ---------------- */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
}
.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  padding: 20px var(--gutter) 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .72rem;
}
.app-footer strong { color: var(--text-2); }
.app-footer__meta { color: var(--muted-2); }

/* ---------------- Page header ---------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-head__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--green-700);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.page-head__title {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  line-height: 1.16;
  letter-spacing: -.028em;
  font-weight: 760;
  color: var(--forest-950);
}
.page-head__sub { max-width: 720px; margin-top: 6px; color: var(--muted); font-size: .9rem; }
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: none; }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-head__title { font-size: 1.02rem; font-weight: 720; letter-spacing: -.012em; color: var(--forest-950); }
.section-head__sub { margin-top: 2px; color: var(--muted); font-size: .79rem; }
.section-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none !important;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--forest-800);
  color: #fff;
  border-color: var(--forest-800);
  box-shadow: 0 6px 16px -10px rgba(8, 40, 29, .7), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn--primary:hover { background: var(--forest-700); border-color: var(--forest-700); color: #fff; }
.btn--accent {
  background: var(--green-600);
  color: #fff;
  border-color: var(--green-600);
  box-shadow: 0 6px 16px -10px rgba(22, 163, 74, .8), inset 0 1px 0 rgba(255,255,255,.14);
}
.btn--accent:hover { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn--outline { background: var(--surface); border-color: var(--line-strong); color: var(--text-2); }
.btn--outline:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--surface); border-color: #F3B7B2; color: var(--red); }
.btn--danger:hover { background: var(--red-100); border-color: #EDA29C; }
.btn--dangerSolid { background: var(--red); border-color: var(--red); color: #fff; }
.btn--dangerSolid:hover { background: #981B13; border-color: #981B13; color: #fff; }
.btn--sm { min-height: 31px; padding: 5px 10px; font-size: .74rem; border-radius: 7px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--lg { min-height: 46px; padding: 11px 20px; font-size: .9rem; border-radius: 10px; }
.btn--block { width: 100%; }
.btn--link { min-height: auto; padding: 0; color: var(--green-700); font-weight: 650; }
.btn--link:hover { text-decoration: underline !important; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn--danger:hover { background: var(--red-100); color: var(--red); }
.icon-btn--border { border-color: var(--line); background: var(--surface); }

.btn-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.btn-row--end { justify-content: flex-end; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 22px; }
.card--flat { box-shadow: none; }
.card--accent { border-top: 3px solid var(--forest-700); }
.card--soft { background: var(--surface-2); }
.card__head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 18px 20px 0;
}
.card__head--bordered { padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.card__icon {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--green-100);
  color: var(--forest-700);
}
.card__icon svg { width: 18px; height: 18px; }
.card__title { font-size: .98rem; font-weight: 720; color: var(--forest-950); letter-spacing: -.01em; }
.card__sub { margin-top: 2px; font-size: .78rem; color: var(--muted); }
.card__body { padding: 18px 20px 20px; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid--sidebarWide { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.tiny { font-size: .7rem; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.text-green { color: var(--green-700); }
.text-red { color: var(--red); }
.text-brown { color: var(--brown); }
.text-forest { color: var(--forest-800); }

/* ---------------- KPI metrics ---------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.kpi {
  position: relative;
  padding: 16px 17px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.kpi--hero { background: linear-gradient(155deg, var(--forest-900), var(--forest-800)); border-color: var(--forest-700); color: #EAF3ED; }
.kpi--hero .kpi__label { color: #A8C6B6; }
.kpi--hero .kpi__sub { color: #A8C6B6; }
.kpi--hero .kpi__value { color: #fff; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.kpi__label { font-size: .71rem; font-weight: 650; letter-spacing: .015em; color: var(--muted); }
.kpi__icon {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--forest-700);
}
.kpi--hero .kpi__icon { background: rgba(255,255,255,.1); color: #86EFAC; }
.kpi__icon svg { width: 15px; height: 15px; }
.kpi__value {
  font-family: var(--font-num);
  font-size: clamp(1.3rem, 1.8vw, 1.68rem);
  line-height: 1.15;
  font-weight: 740;
  letter-spacing: -.025em;
  color: var(--forest-950);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kpi__value--sm { font-size: 1.28rem; }
.kpi__value--muted { color: var(--muted-2); font-weight: 620; }
.kpi__sub { margin-top: 4px; font-size: .71rem; color: var(--muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.kpi__trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; }
.kpi__trend svg { width: 12px; height: 12px; }
.kpi__accent { position: absolute; left: 17px; right: 17px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--line-soft); overflow: hidden; }
.kpi__accent span { display: block; height: 100%; background: var(--green-500); }

/* ---------------- Badges, chips, callouts ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge--green { background: var(--green-100); color: #146B36; border-color: #BBF0CB; }
.badge--amber { background: var(--amber-100); color: #7A4A05; border-color: #F0D28A; }
.badge--red { background: var(--red-100); color: #8F1D14; border-color: #F6C3BE; }
.badge--blue { background: var(--blue-100); color: #124A9C; border-color: #C7DCF8; }
.badge--purple { background: var(--purple-100); color: #5231A0; border-color: #DCCEF7; }
.badge--brown { background: var(--brown-100); color: #6D4423; border-color: #E4CCB3; }
.badge--neutral { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.badge--outline { background: transparent; border-color: var(--line-strong); color: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .7rem;
  color: var(--text-2);
  font-weight: 600;
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: .8rem;
  line-height: 1.5;
}
.callout__icon { flex: none; margin-top: 1px; color: var(--muted); }
.callout__icon svg { width: 17px; height: 17px; }
.callout strong { color: var(--text); }
.callout--info { background: var(--blue-100); border-color: #C8DCF7; color: #1E3A5F; }
.callout--info .callout__icon { color: var(--blue); }
.callout--warn { background: #FFFAEB; border-color: #F0D28A; color: #664300; }
.callout--warn .callout__icon { color: var(--amber); }
.callout--danger { background: #FFF5F4; border-color: #F6C3BE; color: #7A1B13; }
.callout--danger .callout__icon { color: var(--red); }
.callout--success { background: var(--green-50); border-color: #BBF0CB; color: #14532D; }
.callout--success .callout__icon { color: var(--green-600); }
.callout__body { flex: 1; min-width: 0; }
.callout__title { font-weight: 700; color: inherit; }
.callout__body p + p { margin-top: 3px; }

.warning-list { display: grid; gap: 8px; }
.warning-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .79rem;
}
.warning-item__icon { flex: none; margin-top: 1px; color: var(--amber); }
.warning-item__icon svg { width: 16px; height: 16px; }
.warning-item__body { flex: 1; min-width: 0; }
.warning-item__title { font-weight: 700; color: var(--text-2); }
.warning-item__text { color: var(--muted); margin-top: 1px; }
.warning-item--danger .warning-item__icon { color: var(--red); }
.warning-item--success .warning-item__icon { color: var(--green-600); }

/* ---------------- Forms ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 16px;
}
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid--1 { grid-template-columns: 1fr; }
.field { display: grid; gap: 5px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .76rem;
  font-weight: 650;
  color: var(--text-2);
}
.field__label .req { color: var(--red); font-weight: 700; }
.field__hint { font-size: .7rem; color: var(--muted); line-height: 1.4; }
.field__error { min-height: 0; font-size: .7rem; color: var(--red); font-weight: 600; }
.field__error:empty { display: none; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: #E49A94; background: #FFF9F8; }
.field__suffix { position: relative; }
.field__suffix .input { padding-right: 54px; }
.field__unit {
  position: absolute;
  right: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  pointer-events: none;
  background: inherit;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: .86rem;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: #A5AEA9; }
.input:hover, .select:hover, .textarea:hover { border-color: #C2B9A5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: var(--focus);
}
.textarea { min-height: 78px; resize: vertical; }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2366746C' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select--sm { min-height: 34px; font-size: .78rem; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input[readonly] { background: var(--surface-3); color: var(--muted); }
.input--sm { min-height: 33px; font-size: .78rem; padding: 5px 8px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input-addon {
  display: flex; align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-3);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
  white-space: nowrap;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .78rem;
  color: var(--text-2);
  cursor: pointer;
}
.check-row:hover { border-color: var(--line-strong); }
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--green-600); flex: none;
}
.check-row strong { color: var(--text); font-weight: 650; }
.check-row small { display: block; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.form-actions--between { justify-content: space-between; }
.form-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.form-section + .form-section { margin-top: 14px; }
.form-section__title { font-size: .86rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.form-section__sub { font-size: .73rem; color: var(--muted); margin-bottom: 12px; }
.form-error-summary {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #F6C3BE;
  border-radius: var(--radius-sm);
  background: #FFF5F4;
  color: #7A1B13;
  font-size: .78rem;
}
.form-error-summary ul { list-style: disc; padding-left: 18px; }
.form-error-summary li { list-style: disc; }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.segmented__btn {
  padding: 5px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 650;
}
.segmented__btn[aria-pressed="true"] { background: var(--surface); color: var(--forest-800); box-shadow: var(--shadow-xs); }

/* Toggle */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  width: 34px; height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .15s ease;
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.switch input:checked + .switch__track { background: var(--green-600); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus); }

/* ---------------- Tables ---------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  scrollbar-width: thin;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .79rem;
  font-variant-numeric: tabular-nums;
}
.table caption {
  padding: 12px 14px;
  text-align: left;
  font-size: .74rem;
  color: var(--muted);
}
.table th {
  padding: 9px 12px;
  text-align: left;
  font-size: .66rem;
  font-weight: 750;
  letter-spacing: .055em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FCFBF7; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .strong { font-weight: 700; color: var(--text); }
.table .muted-cell { color: var(--muted); }
.table tfoot td { border-top: 1px solid var(--line-strong); background: var(--surface-2); font-weight: 700; color: var(--text); }
.table--compact th, .table--compact td { padding: 7px 10px; }
.table--plain { border: 0; }
.table--plain th { background: transparent; }
.table--plain td { background: transparent; }
.table-scroll-hint { display: none; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; font-size: .72rem; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------------- Tooltip ---------------- */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: .58rem;
  font-weight: 750;
  cursor: help;
  vertical-align: middle;
  flex: none;
}
.tip:hover, .tip:focus-visible { border-color: var(--green-600); color: var(--green-700); }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: max-content;
  max-width: 250px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--forest-950);
  color: #EDF5F0;
  font-size: .68rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s ease;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; visibility: visible; }

/* ---------------- Details / explanations ---------------- */
.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
.disclosure summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  font-size: .8rem;
  font-weight: 650;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after {
  content: "";
  width: 8px; height: 8px;
  margin-left: auto;
  border-right: 1.8px solid var(--muted);
  border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .15s ease;
  flex: none;
}
.disclosure[open] summary::after { transform: rotate(-135deg); }
.disclosure summary:hover { background: var(--surface-2); }
.disclosure__body { padding: 0 14px 14px; font-size: .79rem; color: var(--muted); line-height: 1.6; }
.disclosure__body p + p { margin-top: 8px; }
.disclosure__body ul, .disclosure__body ol { margin: 7px 0; padding-left: 19px; display: grid; gap: 4px; }
.disclosure__body li { list-style: disc; }
.disclosure__body ol li { list-style: decimal; }
.disclosure__body strong { color: var(--text-2); }
.calc-steps { display: grid; gap: 6px; margin: 8px 0; }
.calc-step { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .75rem; }
.calc-step:last-child { border-bottom: 0; }
.calc-step__label { color: var(--muted); }
.calc-step__value { color: var(--text); font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Empty states ---------------- */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 44px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: var(--green-100);
  color: var(--forest-700);
}
.empty__icon svg { width: 24px; height: 24px; }
.empty__title { font-size: 1.02rem; font-weight: 720; color: var(--forest-950); }
.empty__text { max-width: 470px; margin-top: 5px; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.empty--sm { padding: 26px 18px; }

/* ---------------- Dashboard / overview ---------------- */
.dash-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--forest-950), var(--forest-800) 62%, #14563F);
  color: #E9F2EC;
  box-shadow: var(--shadow-md);
}
.dash-hero::after {
  content: "";
  position: absolute;
  right: -60px; top: -80px;
  width: 300px; height: 300px;
  border-radius: 50%;
  border: 44px solid rgba(134, 239, 172, .06);
  pointer-events: none;
}
.dash-hero__eyebrow { color: #86EFAC; font-size: .68rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.dash-hero__title { margin-top: 6px; font-size: clamp(1.35rem, 2vw, 1.8rem); line-height: 1.2; letter-spacing: -.025em; color: #fff; font-weight: 740; }
.dash-hero__text { margin-top: 7px; max-width: 560px; color: #B6CDBF; font-size: .82rem; line-height: 1.6; }
.dash-hero__metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: center; }
.dash-hero__metric { padding: 13px 14px; border-radius: var(--radius-md); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); }
.dash-hero__metricLabel { font-size: .65rem; color: #A9C4B5; font-weight: 600; }
.dash-hero__metricValue { margin-top: 2px; font-size: 1.15rem; font-weight: 730; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dash-hero__metricSub { margin-top: 1px; font-size: .64rem; color: #9FBBAC; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 18px; }
.dash-grid--wideLeft { grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr); }
.chart-card { min-width: 0; }
.chart-card__body { padding: 16px 18px 18px; }
.chart-frame { position: relative; width: 100%; }
.chart-frame svg { width: 100%; height: auto; overflow: visible; }
.chart-empty { display: grid; place-items: center; min-height: 190px; padding: 20px; text-align: center; color: var(--muted); font-size: .78rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.chart-data { margin-top: 10px; }
.chart-data summary { font-size: .7rem; color: var(--muted); cursor: pointer; font-weight: 600; }
.chart-data summary:hover { color: var(--green-700); }
.chart-data .table-wrap { margin-top: 8px; }

.donut-wrap { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; align-items: center; }
.donut { position: relative; width: 170px; height: 170px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut__value { font-size: 1.15rem; font-weight: 750; color: var(--forest-950); font-variant-numeric: tabular-nums; line-height: 1.1; }
.donut__label { font-size: .62rem; color: var(--muted); margin-top: 2px; }
.donut-legend { display: grid; gap: 8px; }
.donut-legend__item { display: grid; grid-template-columns: 9px minmax(0,1fr) auto; gap: 8px; align-items: center; font-size: .76rem; }
.donut-legend__swatch { width: 9px; height: 9px; border-radius: 3px; }
.donut-legend__name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend__value { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .71rem; }

.insight-list { display: grid; gap: 0; }
.insight-item { display: flex; gap: 11px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.insight-item:last-child { border-bottom: 0; }
.insight-item__icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--surface-3); color: var(--muted); }
.insight-item__icon svg { width: 14px; height: 14px; }
.insight-item--good .insight-item__icon { background: var(--green-100); color: var(--green-700); }
.insight-item--warn .insight-item__icon { background: var(--amber-100); color: var(--amber); }
.insight-item--bad .insight-item__icon { background: var(--red-100); color: var(--red); }
.insight-item__body { min-width: 0; flex: 1; }
.insight-item__title { font-size: .79rem; font-weight: 650; color: var(--text); }
.insight-item__text { font-size: .72rem; color: var(--muted); margin-top: 1px; }

.timeline-list { display: grid; }
.timeline-item { position: relative; display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-date { font-size: .67rem; font-weight: 700; color: var(--muted); line-height: 1.35; text-transform: uppercase; letter-spacing: .03em; padding-top: 1px; }
.timeline-date strong { display: block; font-size: .85rem; color: var(--text); letter-spacing: 0; }
.timeline-body { min-width: 0; }
.timeline-title { font-size: .79rem; font-weight: 650; color: var(--text); }
.timeline-sub { font-size: .7rem; color: var(--muted); }
.timeline-amount { font-size: .78rem; font-weight: 650; color: var(--text-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------- Farm setup ---------------- */
.farm-list { display: grid; gap: 10px; }
.farm-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.farm-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.farm-card.is-active { border-color: var(--green-500); background: var(--green-50); box-shadow: inset 0 0 0 1px rgba(34,197,94,.25); }
.farm-card__icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--green-100); color: var(--forest-700); }
.farm-card__icon svg { width: 18px; height: 18px; }
.farm-card__body { min-width: 0; flex: 1; }
.farm-card__name { font-size: .84rem; font-weight: 700; color: var(--text); }
.farm-card__meta { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.farm-card__badge { flex: none; }

.setup-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--line);
  border: 1px solid var(--line);
}
.setup-summary__item { padding: 12px 14px; background: var(--surface); }
.setup-summary__label { font-size: .66rem; color: var(--muted); font-weight: 600; }
.setup-summary__value { font-size: .95rem; font-weight: 700; color: var(--forest-900); margin-top: 1px; }

/* ---------------- Plant population / layout ---------------- */
.pop-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.result-panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, var(--forest-900), var(--forest-800));
  color: #EAF3ED;
  padding: 22px;
  border: 1px solid var(--forest-700);
  box-shadow: var(--shadow-md);
}
.result-panel::after {
  content: "";
  position: absolute;
  right: -70px; bottom: -90px;
  width: 250px; height: 250px;
  border-radius: 50%;
  border: 38px solid rgba(134,239,172,.06);
  pointer-events: none;
}
.result-panel__label { font-size: .65rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: #86EFAC; }
.result-panel__value { margin-top: 4px; font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.05; font-weight: 780; letter-spacing: -.035em; color: #fff; font-variant-numeric: tabular-nums; }
.result-panel__unit { margin-left: 6px; font-size: .42em; font-weight: 600; letter-spacing: 0; color: #A9C4B5; }
.result-panel__sub { margin-top: 4px; font-size: .8rem; color: #B6CDBF; }
.result-panel__metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.result-panel__metric { padding: 9px 10px; border-radius: 9px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.09); }
.result-panel__metricValue { font-size: .98rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.result-panel__metricLabel { font-size: .62rem; color: #A9C4B5; margin-top: 1px; }
.result-panel__note { margin-top: 12px; font-size: .68rem; color: #9FBBAC; line-height: 1.5; }

.layout-canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  min-height: 260px;
}
.layout-canvas { width: 100%; }
.layout-canvas svg { width: 100%; height: auto; }
.layout-note { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: .68rem; }
.layout-note svg { width: 13px; height: 13px; flex: none; }

.pattern-fieldset { border: 0; padding: 0; margin: 0; }
.pattern-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.pattern-option { position: relative; }
.pattern-option input { position: absolute; opacity: 0; }
.pattern-option__label {
  display: block;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  background: var(--surface);
}
.pattern-option__label small { display: block; font-size: .65rem; font-weight: 500; color: var(--muted); margin-top: 1px; }
.pattern-option input:checked + .pattern-option__label { border-color: var(--green-600); background: var(--green-50); box-shadow: inset 0 0 0 1px var(--green-500); color: var(--forest-800); }
.pattern-option input:focus-visible + .pattern-option__label { box-shadow: var(--focus); }
.pattern-option input:disabled + .pattern-option__label { opacity: .55; cursor: not-allowed; }

/* ---------------- Crop planner ---------------- */
.allocation-bar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.allocation-bar__seg { height: 100%; min-width: 2px; }
.allocation-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 9px; }
.allocation-legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--muted); }
.allocation-legend__dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.allocation-legend__item strong { color: var(--text-2); font-weight: 650; }
.allocation-stats { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.allocation-stat__label { font-size: .67rem; color: var(--muted); }
.allocation-stat__value { font-size: .92rem; font-weight: 700; color: var(--text); }

.crop-list { display: grid; gap: 10px; }
.crop-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, .6fr)) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.crop-card:hover { border-color: var(--line-strong); }
.crop-card__main { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.crop-card__mark { width: 4px; align-self: stretch; border-radius: 3px; flex: none; }
.crop-card__name { font-size: .88rem; font-weight: 700; color: var(--text); }
.crop-card__meta { font-size: .7rem; color: var(--muted); margin-top: 1px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.crop-card__stat { min-width: 0; }
.crop-card__statLabel { font-size: .64rem; color: var(--muted); }
.crop-card__statValue { font-size: .83rem; font-weight: 680; color: var(--text-2); font-variant-numeric: tabular-nums; }
.crop-card__actions { display: flex; gap: 2px; justify-content: flex-end; }

.gantt {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.gantt__rows { display: grid; }
.gantt-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: stretch; min-height: 32px; border-bottom: 1px solid var(--line-soft); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-row__label { display: flex; align-items: center; gap: 7px; padding: 6px 10px; font-size: .71rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-right: 1px solid var(--line-soft); overflow: hidden; }
.gantt-row__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row__track { position: relative; background-image: linear-gradient(90deg, var(--line-soft) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.gantt-bar { position: absolute; top: 7px; bottom: 7px; min-width: 3px; border-radius: 4px; display: flex; align-items: center; }
.gantt-bar__label { padding: 0 6px; font-size: .6rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; }
.gantt__scale { display: flex; justify-content: space-between; padding: 5px 10px 5px 160px; font-size: .62rem; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--line-soft); }

/* ---------------- Cycle planner ---------------- */
.cycle-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}
.cycle-summary-strip__item { padding: 14px 16px; background: var(--surface); }
.cycle-summary-strip__label { font-size: .66rem; color: var(--muted); font-weight: 600; }
.cycle-summary-strip__value { font-size: 1.15rem; font-weight: 740; color: var(--forest-950); font-variant-numeric: tabular-nums; margin-top: 2px; }
.cycle-summary-strip__sub { font-size: .66rem; color: var(--muted); margin-top: 1px; }

.cycle-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cycle-tab { padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: .76rem; font-weight: 600; color: var(--muted); text-align: left; }
.cycle-tab:hover { border-color: var(--line-strong); color: var(--text); }
.cycle-tab.is-active { background: var(--forest-800); border-color: var(--forest-800); color: #fff; }
.cycle-tab small { display: block; font-size: .62rem; font-weight: 500; opacity: .75; }

.allocation-table { font-size: .75rem; }
.allocation-table td { padding: 8px 10px; }
.cost-line-row { display: grid; grid-template-columns: minmax(0,1.3fr) 110px 130px 110px 90px 32px; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cost-line-row:last-of-type { border-bottom: 0; }
.cost-line-row .field { gap: 3px; }
.cost-line-row .field__label { font-size: .64rem; }
.cost-line-row .input, .cost-line-row .select { min-height: 34px; font-size: .76rem; padding: 5px 8px; }
.cost-line-row__delete { margin-bottom: 1px; }
.cost-alloc-note { font-size: .68rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }

.cycle-compare { display: grid; gap: 10px; }
.cycle-compare__item { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.cycle-compare__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.cycle-compare__name { font-size: .8rem; font-weight: 700; }
.cycle-compare__bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; display: flex; }
.cycle-compare__bar span { display: block; height: 100%; }

/* ---------------- Expense tracker ---------------- */
.expense-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.filter-bar .field { gap: 3px; min-width: 130px; }
.filter-bar .field__label { font-size: .64rem; }
.filter-bar .input, .filter-bar .select { min-height: 34px; font-size: .78rem; }
.filter-bar__search { flex: 1 1 190px; }
.filter-bar__actions { display: flex; gap: 6px; margin-left: auto; align-self: flex-end; }

.expense-desc { display: flex; align-items: flex-start; gap: 8px; }
.expense-desc__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--surface-3); color: var(--muted); flex: none; }
.expense-desc__icon svg { width: 14px; height: 14px; }
.expense-desc__text { min-width: 0; }
.expense-desc__title { font-weight: 650; color: var(--text); font-size: .78rem; }
.expense-desc__sub { font-size: .68rem; color: var(--muted); }

/* ---------------- Profit / break-even ---------------- */
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.result-tile { padding: 14px 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }
.result-tile--primary { background: var(--forest-900); border-color: var(--forest-800); color: #EAF3ED; }
.result-tile__label { font-size: .68rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.result-tile--primary .result-tile__label { color: #A8C6B6; }
.result-tile__value { margin-top: 3px; font-size: 1.32rem; font-weight: 750; color: var(--forest-950); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result-tile--primary .result-tile__value { color: #fff; }
.result-tile__sub { margin-top: 2px; font-size: .68rem; color: var(--muted); }
.result-tile--primary .result-tile__sub { color: #A8C6B6; }
.pl-hero {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--forest-900);
  color: #EAF3ED;
  margin-bottom: 14px;
}
.pl-hero__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: #A8C6B6; }
.pl-hero__value { margin-top: 3px; font-size: clamp(1.65rem, 3vw, 2.2rem); font-weight: 780; letter-spacing: -.03em; color: #fff; font-variant-numeric: tabular-nums; }
.pl-hero__sub { margin-top: 2px; color: #A8C6B6; font-size: .75rem; }
.pl-hero--loss { background: #54140F; }
.pl-hero--loss .pl-hero__label, .pl-hero--loss .pl-hero__sub { color: #F3B7B2; }

.breakdown { display: grid; gap: 0; }
.breakdown__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: .79rem; }
.breakdown__row:last-child { border-bottom: 0; }
.breakdown__label { color: var(--muted); display: flex; align-items: center; gap: 5px; }
.breakdown__value { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.breakdown__row--total { border-top: 1px solid var(--line-strong); border-bottom: 0; padding-top: 11px; margin-top: 4px; }
.breakdown__row--total .breakdown__label { color: var(--text); font-weight: 700; }
.breakdown__row--total .breakdown__value { font-weight: 750; font-size: .92rem; }
.breakdown__row--profit .breakdown__value { color: var(--green-700); }
.breakdown__row--loss .breakdown__value { color: var(--red); }

.scenario-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.scenario-table th, .scenario-table td { padding: 8px 10px; }
.scenario-row--loss td:last-child { color: var(--red); font-weight: 650; }
.scenario-row--profit td:last-child { color: var(--green-700); font-weight: 650; }
.scenario-row--target { background: var(--green-50); }

/* ---------------- Harvest planner ---------------- */
.harvest-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.harvest-batch { display: flex; align-items: center; gap: 7px; }
.harvest-batch__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.capacity-bar {
  position: relative;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  overflow: hidden;
}
.capacity-bar__fill { height: 100%; background: var(--green-500); transition: width .2s ease; }
.capacity-bar__fill--over { background: var(--red); }
.capacity-labels { display: flex; justify-content: space-between; font-size: .67rem; color: var(--muted); margin-top: 4px; }

.harvest-months { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 8px; }
.harvest-month { padding: 10px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.harvest-month__label { font-size: .68rem; font-weight: 700; color: var(--text-2); }
.harvest-month__value { font-size: .9rem; font-weight: 700; color: var(--forest-900); margin-top: 2px; font-variant-numeric: tabular-nums; }
.harvest-month__sub { font-size: .66rem; color: var(--muted); margin-top: 1px; }
.harvest-month__bar { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.harvest-month__bar span { display: block; height: 100%; background: var(--green-500); }

.compare-types { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.compare-type { padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.compare-type__title { font-size: .77rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.compare-type__text { font-size: .7rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ---------------- Reports ---------------- */
.report-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.report-tab { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 600; }
.report-tab:hover { color: var(--text); }
.report-tab.is-active { color: var(--forest-800); border-bottom-color: var(--green-600); }
.report-section + .report-section { margin-top: 26px; }
.report-notes { font-size: .7rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.report-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.profit-bar { display: flex; align-items: center; gap: 7px; }
.profit-bar__track { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; min-width: 44px; }
.profit-bar__fill { height: 100%; border-radius: 4px; }
.profit-bar__fill--pos { background: var(--green-500); }
.profit-bar__fill--neg { background: #E26D64; }

/* ---------------- Intercropping planner ---------------- */
.ic-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.ic-plan-select { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ic-plan-select .label { font-size: .67rem; color: var(--muted); font-weight: 650; white-space: nowrap; }
.ic-plan-select strong { font-size: .82rem; color: var(--forest-900); }
.ic-plan-select .select { min-width: 230px; max-width: 100%; }
.ic-toolbar__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ic-kpi-grid { margin-top: 18px; }
.ic-warning-banner { margin: 16px 0; }
.ic-tabs { margin-top: 22px; }
.ic-panel { min-width: 0; }
.ic-estimate-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ic-disclaimer { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }
.ic-notes { font-size: .78rem; line-height: 1.6; white-space: pre-line; }
.ic-side-stack { display: grid; gap: 16px; align-content: start; }
.stat-list { display: grid; }
.label { font-size: .67rem; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-transform: uppercase; }
.field__static {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .8rem;
  color: var(--text-2);
}
.ic-check-stack { display: grid; gap: 7px; }

.ic-stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}
.ic-stat-strip--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ic-stat-strip > div { min-width: 0; padding: 12px 14px; background: var(--surface); }
.ic-stat-strip span { display: block; font-size: .65rem; color: var(--muted); font-weight: 600; }
.ic-stat-strip strong { display: block; margin-top: 2px; font-size: .86rem; font-weight: 700; color: var(--forest-950); font-variant-numeric: tabular-nums; line-height: 1.35; }
.ic-mini-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ic-mini-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.ic-mini-summary span { display: block; font-size: .64rem; color: var(--muted); font-weight: 600; }
.ic-mini-summary strong { display: block; margin-top: 2px; font-size: .83rem; color: var(--text); font-variant-numeric: tabular-nums; }

.ic-slot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ic-slot-card {
  position: relative;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--slot, var(--line-strong));
  border-radius: var(--radius-md);
  background: var(--surface);
}
.ic-slot-card.is-disabled { border-top-color: var(--line); background: var(--surface-2); }
.ic-slot-card__head { display: flex; align-items: flex-start; gap: 9px; }
.ic-slot-card__head > div:nth-child(2) { flex: 1; min-width: 0; }
.ic-slot-card__title { font-size: .86rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.ic-slot-card__sub { margin-top: 2px; font-size: .69rem; color: var(--muted); }
.ic-slot-card__empty { margin-top: 12px; font-size: .72rem; color: var(--muted); line-height: 1.55; }
.ic-slot-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; }
.ic-slot-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 12px; overflow: hidden; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--line-soft); }
.ic-slot-stats > div { min-width: 0; padding: 7px 9px; background: var(--surface-2); }
.ic-slot-stats span { display: block; font-size: .6rem; color: var(--muted); }
.ic-slot-stats strong { display: block; margin-top: 1px; font-size: .74rem; color: var(--text); font-variant-numeric: tabular-nums; }
.ic-compat { margin-top: 11px; }
.ic-compat summary { font-size: .69rem; }
.ic-note-list { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; font-size: .72rem; color: var(--muted); line-height: 1.55; }
.ic-note-list li { position: relative; padding-left: 14px; }
.ic-note-list li::before { content: ''; position: absolute; left: 2px; top: .58em; width: 5px; height: 5px; border-radius: 50%; background: var(--green-500); }
.ic-error-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; font-size: .75rem; line-height: 1.45; }

.ic-stack { display: flex; height: 22px; margin-top: 16px; border-radius: 6px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--line); }
.ic-stack__seg { display: block; height: 100%; min-width: 2px; }
.ic-stack-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 9px; font-size: .68rem; color: var(--muted); }
.ic-stack-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ic-stack-legend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.ic-stack-legend strong { color: var(--text-2); font-weight: 650; }
.ic-crop-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.ic-crop-name i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ic-mini-chip { display: inline-block; margin: 1px 3px 1px 0; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-size: .61rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ic-table-scroll { overflow-x: auto; }
.ic-table-scroll .table { min-width: 780px; }

.ic-gantt .ic-gantt-row { min-height: 42px; grid-template-columns: 190px minmax(0, 1fr); }
.ic-gantt .gantt-row__label { padding: 7px 10px; }
.ic-gantt-track { min-height: 42px; }
.ic-gantt-bar {
  position: absolute;
  top: 13px;
  height: 17px;
  min-width: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 2px rgba(8, 25, 18, .12);
}
.ic-gantt-bar--nonprod { top: 17px; height: 9px; background: #CFDBD2; box-shadow: none; }
.ic-gantt-bar.is-overlap { outline: 2px solid rgba(255,255,255,.75); outline-offset: -2px; }
.ic-gantt-mark {
  position: absolute;
  top: 10px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--forest-800);
  box-shadow: 0 0 0 1px rgba(255,255,255,.55);
  z-index: 2;
}

.ic-editor-errors { margin-bottom: 14px; }
.ic-editor-steps {
  position: sticky;
  top: 0;
  z-index: 3;
  gap: 4px;
  margin: -2px 0 18px;
  padding: 8px 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ic-editor-steps .cycle-tab { padding: 6px 9px; font-size: .7rem; }
.ic-editor-steps .cycle-tab small { display: none; }
.ic-editor-step { min-width: 0; }
.ic-editor-step .form-section + .form-section { margin-top: 22px; }
.ic-editor-preview > .kpi-grid { margin-bottom: 16px; }
.ic-geometry-block {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.ic-geometry-block:first-of-type { margin-top: 0; }
.ic-geometry-block__title { display: flex; align-items: center; gap: 7px; margin-bottom: 11px; font-size: .8rem; font-weight: 700; color: var(--forest-900); }
.ic-geometry-block__title .ic-slot-dot { margin-top: 0; }
.ic-slot-editor {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--slot, var(--line-strong));
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.ic-slot-editor__head { display: flex; align-items: center; gap: 9px; }
.ic-slot-editor__head > div:nth-child(2) { flex: 1; min-width: 0; }
.ic-slot-editor__head strong { display: block; font-size: .8rem; color: var(--text); }
.ic-slot-editor__head small { display: block; font-size: .66rem; color: var(--muted); }
.switch-row { display: inline-flex; align-items: center; gap: 7px; flex: none; font-size: .72rem; font-weight: 650; color: var(--text-2); cursor: pointer; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--green-700); }
.ic-slot-editor [data-ic-slot-body] { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.ic-cost-list { display: grid; }
.ic-cost-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.ic-cost-row .field { gap: 3px; }
.ic-cost-row .field__label { font-size: .62rem; }
.ic-cost-row .input, .ic-cost-row .select { min-height: 34px; font-size: .76rem; padding: 5px 8px; }
.ic-cost-row .field--costLabel { grid-column: span 2; }
.ic-cost-remove { justify-self: end; align-self: end; margin-bottom: 2px; }
.ic-cost-shares { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-3); }
.ic-cost-shares[hidden] { display: none; }
.ic-editor-foot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ic-editor-foot__step { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ic-editor-foot__actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }

/* ---------------- Settings ---------------- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.settings-row:last-child { border-bottom: 0; }
.settings-row__body { min-width: 0; }
.settings-row__title { font-size: .82rem; font-weight: 650; color: var(--text); }
.settings-row__text { font-size: .71rem; color: var(--muted); margin-top: 1px; line-height: 1.45; }
.settings-row__action { flex: none; }
.data-note { display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--line); font-size: .75rem; color: var(--muted); }
.data-note svg { width: 16px; height: 16px; flex: none; color: var(--forest-600); margin-top: 1px; }
.about-list { display: grid; gap: 8px; font-size: .76rem; color: var(--muted); }
.about-list li { display: flex; gap: 7px; align-items: flex-start; list-style: none; }
.about-list svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--green-600); }

/* ---------------- Modal ---------------- */
.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal--wide { width: min(980px, calc(100vw - 32px)); }
.modal--sm { width: min(430px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(8, 25, 18, .55); backdrop-filter: blur(2px); }
.modal__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
}
.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal__headBody { flex: 1; min-width: 0; }
.modal__title { font-size: 1.05rem; font-weight: 730; letter-spacing: -.015em; color: var(--forest-950); }
.modal__sub { margin-top: 2px; font-size: .76rem; color: var(--muted); }
.modal__close { margin: -4px -4px 0 0; }
.modal__body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
  flex-wrap: wrap;
}
.modal__foot--between { justify-content: space-between; }
.modal__icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--green-100); color: var(--forest-700); }
.modal__icon svg { width: 19px; height: 19px; }
.modal__icon--danger { background: var(--red-100); color: var(--red); }
.modal__icon--warn { background: var(--amber-100); color: var(--amber); }

/* ---------------- Toast ---------------- */
.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--forest-950);
  color: #EDF5F0;
  box-shadow: var(--shadow-lg);
  font-size: .78rem;
  line-height: 1.4;
  animation: toastIn .18s ease;
  pointer-events: auto;
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: #86EFAC; }
.toast--error { background: #5C160F; }
.toast--error svg { color: #FCA5A5; }
.toast--warn { background: #5A3B05; }
.toast--warn svg { color: #FCD34D; }
.toast__body { flex: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- Misc ---------------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.stat-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: .78rem; }
.stat-line:last-child { border-bottom: 0; }
.stat-line__label { color: var(--muted); }
.stat-line__value { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.stat-line--total { border-top: 1px solid var(--line-strong); border-bottom: 0; padding-top: 9px; }
.stat-line--total .stat-line__label, .stat-line--total .stat-line__value { font-weight: 750; color: var(--text); }
.money-pos { color: var(--green-700); }
.money-neg { color: var(--red); }
.money-muted { color: var(--muted); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex: none; }
.copy-note { font-size: .67rem; color: var(--muted-2); }
.hr-label { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hr-label::before, .hr-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.mini-tag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; font-size: .62rem; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.progress-thin { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress-thin span { display: block; height: 100%; background: var(--green-500); border-radius: 3px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .harvest-hero { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .topbar__meta .topbar__pill--soft { display: none; }
  .grid--sidebar, .grid--sidebarWide { grid-template-columns: minmax(0, 1fr); }
  .pop-layout { grid-template-columns: minmax(0, 1fr); }
  .dash-hero { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1080px) {
  .topbar__meta { display: none; }
  .dash-grid, .dash-grid--wideLeft { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crop-card { grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0,.7fr)) auto; }
  .crop-card__stat:nth-of-type(3) { display: none; }
}
@media (max-width: 980px) {
  :root { --gutter: 20px; }
  .sidebar {
    transform: translateX(-100%);
    width: min(300px, 86vw);
    box-shadow: var(--shadow-lg);
  }
  .app.is-nav-open .sidebar { transform: translateX(0); }
  .sidebar__collapse { display: none; }
  .app__main { margin-left: 0 !important; }
  .topbar__menu { display: inline-grid; }
  .topbar__brand { display: flex; }
  .farm-picker { margin-left: auto; min-width: 170px; max-width: 230px; }
  .topbar { gap: 10px; }
  .profile-btn__text { display: none; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(8, 25, 18, .48);
    backdrop-filter: blur(1px);
  }
  .app-footer { padding-bottom: 40px; }
}
@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .main { padding-top: 20px; padding-bottom: 36px; }
  .topbar { min-height: 62px; padding-inline: 12px; }
  .topbar__brand { display: none; }
  .topbar__menu { margin-right: 0; }
  .farm-picker { flex: 1; max-width: none; min-width: 0; height: 38px; margin-left: 0; }
  .profile-btn { padding: 2px; }
  .profile-btn__chevron { display: none; }
  .profile-btn__avatar { width: 32px; height: 32px; }
  .demo-banner { align-items: flex-start; flex-wrap: wrap; padding: 10px 14px; }
  .demo-banner p { flex-basis: calc(100% - 30px); }
  .demo-banner .btn { margin-left: 27px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head__actions { justify-content: flex-start; }
  .page-head__actions .btn { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi__value { font-size: 1.25rem; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .form-grid--2Mobile { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dash-hero { padding: 20px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .donut-legend { width: 100%; text-align: left; }
  .result-grid { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-grid .card { min-width: 0; }
  .cycle-summary-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .expense-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .harvest-hero { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .compare-types { grid-template-columns: 1fr; }
  .crop-card { grid-template-columns: 1fr auto; gap: 10px 12px; padding: 13px 14px; }
  .crop-card__main { grid-column: 1 / -1; }
  .crop-card__stat:nth-of-type(3) { display: block; }
  .crop-card__actions { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
  .crop-card__stat { padding-right: 8px; }
  .crop-card::after { content: ""; grid-column: 1 / -1; }
  .crop-card__statsWrap { display: contents; }
  .cost-line-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr) 32px; }
  .cost-line-row .field--costLabel { grid-column: 1 / -1; }
  .cost-line-row .field--costAlloc { grid-column: 1; }
  .cost-line-row .field--costCycle { grid-column: 2; }
  .cost-line-row .field--costShare { grid-column: 1; }
  .cost-line-row__delete { grid-column: 3; grid-row: 1; justify-self: end; }
  .gantt-row { grid-template-columns: 92px minmax(0,1fr); }
  .gantt__scale { padding-left: 102px; }
  .gantt-row__label { font-size: .65rem; }
  .modal__body { padding: 16px; }
  .modal__head { padding: 15px 16px 12px; }
  .modal__foot { padding: 12px 16px; }
  .modal__foot .btn { flex: 1 1 auto; }
  .filter-bar { align-items: stretch; }
  .filter-bar .field { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .filter-bar__search { flex-basis: 100%; }
  .filter-bar__actions { margin-left: 0; width: 100%; }
  .filter-bar__actions .btn { flex: 1; }
  .topbar .profile-btn { margin-left: 0; }
  .settings-row { align-items: flex-start; flex-direction: column; gap: 8px; }
  .settings-row__action { width: 100%; }
  .settings-row__action .btn { width: 100%; }
  .setup-summary { grid-template-columns: 1fr 1fr; }
  .timeline-item { grid-template-columns: 48px 1fr; }
  .timeline-amount { grid-column: 2; text-align: left; }
  .toast-region { right: 12px; bottom: 12px; }
  .report-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 1px; }
  .report-tab { white-space: nowrap; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi__value { font-size: 1.16rem; }
  .kpi__label { font-size: .67rem; }
  .dash-hero__metrics { grid-template-columns: 1fr 1fr; }
  .dash-hero__metricValue { font-size: 1rem; }
  .result-panel__metrics { grid-template-columns: 1fr; }
  .result-panel { padding: 18px; }
  .result-panel__metrics { gap: 7px; }
  .result-panel__metric { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 7px 9px; }
  .result-panel__metricLabel { margin-top: 0; }
  .harvest-hero { grid-template-columns: 1fr 1fr; }
  .harvest-hero .kpi { padding: 11px 12px; }
  .harvest-hero .kpi__value { font-size: 1.05rem; }
  .empty { padding: 32px 18px; }
  .donut { width: 150px; height: 150px; }
  .topbar__pill { display: none; }
  .form-grid--2Mobile { grid-template-columns: 1fr; }
  .cycle-summary-strip__value { font-size: 1rem; }
  .app-footer { display: block; text-align: center; }
  .app-footer__meta { margin-top: 4px; }
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 20px); }
  .modal__panel { max-height: calc(100vh - 20px); }
  .gantt-row { grid-template-columns: 76px minmax(0,1fr); }
  .gantt__scale { padding-left: 86px; }
  .gantt-bar__label { display: none; }
  .calc-step { font-size: .7rem; }
  .pattern-options { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .ic-slot-grid { grid-template-columns: 1fr; }
  .ic-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-stat-strip--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-cost-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-gantt .ic-gantt-row { grid-template-columns: 150px minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .ic-toolbar { align-items: stretch; }
  .ic-plan-select { flex: 1 1 100%; }
  .ic-plan-select .select { flex: 1; min-width: 0; width: 100%; }
  .ic-toolbar__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .ic-toolbar__actions .btn { justify-content: center; }
  .ic-mini-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-slot-stats { grid-template-columns: 1fr 1fr; }
  .ic-editor-steps { flex-wrap: nowrap; overflow-x: auto; }
  .ic-editor-steps .cycle-tab { flex: 0 0 auto; }
  .ic-editor-foot__step { display: none; }
  .ic-editor-foot__actions { width: 100%; }
  .ic-editor-foot__actions .btn { flex: 1; justify-content: center; }
  .ic-cost-shares { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-gantt .ic-gantt-row { grid-template-columns: 105px minmax(0, 1fr); }
  .ic-gantt .gantt-row__label { font-size: .64rem; }
  .ic-gantt .gantt-bar__label { display: none; }
}

@media (max-width: 520px) {
  .ic-kpi-grid { grid-template-columns: 1fr; }
  .ic-stat-strip--four { grid-template-columns: 1fr 1fr; }
  .ic-toolbar__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ic-cost-row { grid-template-columns: 1fr; }
  .ic-cost-row .field--costLabel { grid-column: auto; }
  .ic-cost-remove { grid-row: auto; justify-self: start; }
  .ic-gantt .ic-gantt-row { grid-template-columns: 86px minmax(0, 1fr); }
  .ic-editor-foot { display: none; }
  .pl-hero__aside { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------- Print ---------------- */
@media print {
  .sidebar, .topbar, .demo-banner, .app-footer, .page-head__actions,
  .btn, .icon-btn, .filter-bar, .report-tabs, .toast-region, .modal { display: none !important; }
  .app__main { margin-left: 0 !important; }
  .main { max-width: none; padding: 0; }
  .card, .kpi, .table-wrap { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
  .page-head__title { font-size: 1.5rem; }
  .ic-toolbar { display: none !important; }
  .ic-panel[hidden] { display: block !important; }
  .ic-panel { margin-top: 20px; }
  .ic-gantt-bar__label { display: block; }
  .ic-tabs { display: none !important; }
}
