:root {
  --ink: #17201c;
  --muted: #657069;
  --paper: #f3f0e8;
  --paper-strong: #fffdf7;
  --forest: #17372d;
  --forest-soft: #255144;
  --line: #d9d6cc;
  --lime: #d9ef7d;
  --terracotta: #c96d4b;
  --gold: #d3a941;
  --danger: #b84f45;
  --shadow: 0 18px 50px rgba(23, 32, 28, .08);
  --radius: 18px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }

html { background: var(--paper); scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 0%, rgba(217, 239, 125, .14), transparent 26rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  color: #f8f5eb;
  background:
    linear-gradient(145deg, rgba(217, 239, 125, .08), transparent 35%),
    var(--forest);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 26px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 45% 55%;
  color: var(--forest);
  background: var(--lime);
  transform: rotate(-7deg);
  font-weight: 900;
}

.brand-copy strong { display: block; font-size: 15px; letter-spacing: .18em; }
.brand-copy span { color: rgba(255,255,255,.58); font-size: 11px; text-transform: uppercase; }

.nav-label {
  margin: 26px 10px 9px;
  color: rgba(255,255,255,.4);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.nav-list { display: grid; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 43px;
  padding: 0 12px;
  border-radius: 11px;
  color: rgba(255,255,255,.68);
  transition: 160ms ease;
}

.nav-link:hover { color: white; background: rgba(255,255,255,.07); }
.nav-link.active { color: var(--forest); background: var(--lime); font-weight: 800; }
.nav-icon { width: 22px; text-align: center; font-size: 15px; }
.nav-count { margin-left: auto; font-size: 11px; opacity: .66; }

.sidebar-foot {
  margin-top: auto;
  padding: 15px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.045);
}
.sidebar-foot small { display: block; color: rgba(255,255,255,.48); }
.sidebar-foot strong { display: block; margin-top: 4px; font-size: 13px; }
.sync { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--lime); font-size: 11px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(217,239,125,.08); }

.app { min-height: 100vh; margin-left: var(--sidebar); }

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 15px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(243, 240, 232, .84);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 25;
}

.farm-switcher { min-width: 0; }
.farm-switcher small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.farm-switcher strong { display: block; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn, .menu-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  color: var(--ink);
  cursor: pointer;
}
.menu-btn { display: none; border-radius: 11px; }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--terracotta); font-weight: 800; }

.content { width: min(1500px, 100%); margin: 0 auto; padding: 38px clamp(20px, 4vw, 54px) 70px; }

.eyebrow { margin: 0 0 8px; color: var(--terracotta); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-head h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(32px, 4vw, 54px); font-weight: 500; line-height: .98; letter-spacing: -.04em; }
.page-head p { max-width: 620px; margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 750;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); }
.btn.secondary { border-color: var(--line); background: var(--paper-strong); color: var(--ink); }
.btn.lime { border-color: var(--lime); background: var(--lime); color: var(--forest); }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 12px; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,253,247,.66);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.metric { min-width: 0; padding: 24px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 14px; font-family: Georgia, serif; font-size: clamp(27px, 3vw, 42px); letter-spacing: -.04em; white-space: nowrap; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 11px; }
.up { color: #327056; }
.down { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 20px; margin-top: 20px; }
.grid-equal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,253,247,.82); box-shadow: 0 12px 34px rgba(23,32,28,.045); overflow: hidden; }
.panel.dark { color: white; background: var(--forest); border-color: var(--forest); }
.panel-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dark .panel-head { border-color: rgba(255,255,255,.12); }
.panel-title { margin: 0; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.panel-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.dark .panel-subtitle { color: rgba(255,255,255,.5); }
.panel-body { padding: 22px; }

.season-row { display: grid; grid-template-columns: 110px minmax(180px, 1fr) 92px 85px; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.season-row:last-child { border: 0; }
.crop-name strong { display: block; }
.crop-name small { color: var(--muted); }
.progress { height: 7px; border-radius: 99px; background: #dfddd5; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--forest-soft); }
.progress.lime > span { background: #90ad35; }
.stage { color: var(--muted); font-size: 11px; text-align: right; }
.area { text-align: right; font-weight: 800; }

.timeline { position: relative; display: grid; gap: 0; }
.event { display: grid; grid-template-columns: 45px 1fr; gap: 14px; min-height: 78px; }
.event-dot { position: relative; display: flex; justify-content: center; }
.event-dot::before { content: ""; position: absolute; top: 13px; bottom: -13px; width: 1px; background: rgba(255,255,255,.15); }
.event:last-child .event-dot::before { display: none; }
.event-dot::after { content: ""; position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 9px; border: 4px solid var(--forest); border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 1px rgba(255,255,255,.2); }
.event-copy strong { display: block; font-size: 13px; }
.event-copy span { display: block; margin-top: 5px; color: rgba(255,255,255,.55); font-size: 11px; line-height: 1.45; }
.event-copy time { display: block; margin-top: 4px; color: var(--lime); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; }
.quick-action { min-height: 100px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,247,.55); transition: 160ms ease; }
.quick-action:hover { border-color: var(--forest); background: var(--paper-strong); transform: translateY(-2px); }
.quick-action b { font-size: 20px; font-family: Georgia, serif; font-weight: 500; }
.quick-action span { color: var(--muted); font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search { min-width: 220px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 13px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; }
.filter { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; color: var(--muted); background: rgba(23,55,45,.035); font-size: 10px; letter-spacing: .1em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 17px 18px; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: rgba(217,239,125,.08); }
.cell-main { font-weight: 780; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.number { font-variant-numeric: tabular-nums; text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 9px; border-radius: 99px; color: #2f634e; background: #e4efdf; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.warning { color: #876113; background: #f5ebc8; }
.badge.danger { color: #9b443b; background: #f4dcd6; }
.badge.neutral { color: #697069; background: #e9e8e2; }

.farm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.farm-card { position: relative; min-height: 270px; display: flex; flex-direction: column; padding: 22px; border-radius: 20px; overflow: hidden; color: white; background: var(--forest); }
.farm-card:nth-child(2) { background: #594b35; }
.farm-card:nth-child(3) { color: var(--ink); background: #d8debd; }
.farm-card::after { content: ""; position: absolute; width: 220px; height: 220px; right: -75px; bottom: -105px; border: 1px solid currentColor; border-radius: 44% 56% 51% 49%; opacity: .14; box-shadow: 0 0 0 27px transparent, 0 0 0 28px currentColor, 0 0 0 55px transparent, 0 0 0 56px currentColor; transform: rotate(15deg); }
.farm-index { color: var(--lime); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.farm-card:nth-child(3) .farm-index { color: var(--terracotta); }
.farm-card h2 { position: relative; z-index: 1; max-width: 80%; margin: 46px 0 8px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; line-height: 1; }
.farm-card p { margin: 0; opacity: .65; }
.farm-stats { position: relative; z-index: 1; display: flex; gap: 22px; margin-top: auto; padding-top: 24px; }
.farm-stats strong { display: block; font-size: 18px; }
.farm-stats small { opacity: .55; }

.field-map { position: relative; min-height: 460px; background: #d8d5c5; overflow: hidden; }
.field-map::before { content: ""; position: absolute; inset: 0; opacity: .38; background-image: linear-gradient(30deg, rgba(23,55,45,.2) 1px, transparent 1px), linear-gradient(120deg, rgba(23,55,45,.14) 1px, transparent 1px); background-size: 48px 48px; }
.plot { position: absolute; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.78); color: var(--forest); background: rgba(217,239,125,.72); font-size: 11px; font-weight: 850; clip-path: polygon(12% 5%, 91% 0%, 100% 78%, 73% 100%, 3% 81%); }
.plot.one { inset: 11% 49% 52% 10%; transform: rotate(-5deg); }
.plot.two { inset: 8% 8% 49% 54%; background: rgba(201,109,75,.58); transform: rotate(4deg); }
.plot.three { inset: 53% 56% 8% 14%; background: rgba(255,253,247,.68); transform: rotate(2deg); }
.plot.four { inset: 56% 9% 10% 61%; background: rgba(211,169,65,.6); transform: rotate(-6deg); }
.map-legend { position: absolute; left: 18px; bottom: 18px; display: flex; gap: 14px; padding: 10px 13px; border-radius: 10px; background: rgba(255,253,247,.88); box-shadow: var(--shadow); font-size: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-item::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--forest-soft); }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.form-section { padding: 25px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border: 0; }
.form-section h2 { margin: 0 0 6px; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.form-section > p { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: white; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--forest-soft); box-shadow: 0 0 0 3px rgba(37,81,68,.09); }
.field small { color: var(--muted); }
.summary-list { display: grid; gap: 14px; }
.summary-line { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.summary-line span { color: var(--muted); }
.summary-total { display: flex; justify-content: space-between; margin-top: 10px; font-family: Georgia, serif; font-size: 25px; }
.sticky { position: sticky; top: 98px; }

.finance-hero { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 290px; border-radius: 22px; color: white; background: var(--forest); overflow: hidden; }
.finance-copy { padding: clamp(28px, 4vw, 46px); }
.finance-copy small { color: var(--lime); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.finance-copy h2 { margin: 35px 0 5px; font-family: Georgia, serif; font-size: clamp(38px, 5vw, 62px); font-weight: 500; letter-spacing: -.04em; }
.finance-copy p { color: rgba(255,255,255,.55); }
.cash-chart { position: relative; min-height: 250px; align-self: stretch; background: linear-gradient(165deg, rgba(217,239,125,.18), transparent); }
.cash-chart svg { position: absolute; inset: 20px 0 0; width: 100%; height: calc(100% - 20px); }

.empty-note { padding: 42px 25px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 15px 18px; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); transform: translateY(120px); opacity: 0; transition: 220ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .grid-2, .form-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .farm-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  :root { --sidebar: 280px; }
  .sidebar { transform: translateX(-105%); transition: 200ms ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  body.nav-open .sidebar { transform: translateX(0); }
  .app { margin-left: 0; }
  .menu-btn { display: grid; }
  .content { padding-top: 28px; }
  .page-head { align-items: start; flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .metric-strip, .farm-grid, .grid-equal, .finance-hero { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .season-row { grid-template-columns: 80px 1fr 65px; }
  .season-row .stage { display: none; }
  .fields { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .topbar { padding-inline: 16px; }
  .farm-switcher strong { max-width: 155px; }
  .cash-chart { min-height: 210px; }
}

@media (max-width: 430px) {
  .quick-actions { grid-template-columns: 1fr; }
  .metric-value { font-size: 31px; }
  .icon-btn { display: none; }
  .farm-card { min-height: 235px; }
}

