:root {
  --bg: #f4f1ea;
  --ink: #1f2926;
  --muted: #69746f;
  --panel: #fffdf8;
  --line: #ddd7cc;
  --green: #3a7d44;
  --green-dark: #204d2e;
  --amber: #c27a2c;
  --red: #b84a3d;
  --blue: #2d647a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button, select { font: inherit; }
.sidebar {
  min-height: 100vh;
  padding: 20px;
  background: #17221d;
  color: #f7f3e9;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d9b35b;
  color: #17221d;
  font-weight: 800;
}
.brand strong, .brand span { display: block; }
.brand span, .sidebar-footer span { color: #b8c4bd; font-size: 13px; margin-top: 3px; }
nav { display: grid; gap: 6px; }
nav button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dce5df;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
}
nav button.active, nav button:hover { background: #263930; color: #fff; }
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #33463d;
  padding-top: 18px;
}
.sidebar-footer strong { display: block; margin-top: 4px; font-size: 22px; }

main { padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}
h1 { margin: 0; max-width: 980px; font-size: 30px; line-height: 1.15; }
h2 { margin: 0; font-size: 18px; line-height: 1.2; }
p { color: var(--muted); line-height: 1.5; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.role-switch {
  min-width: 250px;
  display: grid;
  gap: 5px;
}
.role-switch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.primary, .icon-button {
  border: 1px solid var(--green-dark);
  border-radius: 6px;
  background: var(--green-dark);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.icon-button { width: 42px; padding: 10px 0; }
.capability-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.capability-chips span {
  padding: 7px 9px;
  border: 1px solid #c9d5c0;
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
}
.is-hidden { display: none !important; }

.view { display: none; }
.view.active { display: block; }
.kpi-grid, .dashboard-grid, .workspace, .passport-grid, .scenario-grid, .integrations, .similarity, .roles-grid, .field-passport, .season-grid, .risk-matrix, .knowledge-list, .flow-chain, .map-workspace {
  display: grid;
  gap: 14px;
}
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.kpi-grid article, .passport-grid article, .scenario-grid article, .integrations article, .similarity article, .season-grid article, .knowledge-list article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
article span, article em { display: block; color: var(--muted); font-style: normal; }
article strong { display: block; margin: 8px 0 4px; font-size: 25px; }
article em { font-size: 13px; }
.dashboard-grid { grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr); align-items: stretch; }
.workspace { grid-template-columns: minmax(0, 1.4fr) 320px; }
.flow-panel { margin-top: 14px; }
.flow-chain {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.flow-chain span {
  position: relative;
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid #cbd9c4;
  border-radius: 8px;
  background: #edf5e8;
  text-align: center;
  font-weight: 800;
  color: var(--green-dark);
}
.map-workspace { grid-template-columns: minmax(0, 1fr) 260px; }
.large-map { min-height: 560px; }
.expansion-field { background: rgba(45, 100, 122, .55); }
.map-legend {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fffdf8;
}
.map-legend h3 { margin: 0 0 10px; }
.map-legend p { margin: 0 0 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.panel-head p { margin: 6px 0 0; }
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 9px 10px;
}
.field-map {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #cfd8c4;
  background:
    linear-gradient(90deg, rgba(75, 97, 67, .12) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(rgba(75, 97, 67, .12) 1px, transparent 1px) 0 0 / 44px 44px,
    #dfe8cf;
}
.field {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  border: 2px solid rgba(31, 41, 38, .22);
  border-radius: 7px;
  color: #17221d;
  font-weight: 800;
  cursor: pointer;
}
.risk-high { background: rgba(184, 74, 61, .82); }
.risk-mid { background: rgba(194, 122, 44, .8); }
.ok { background: rgba(79, 143, 73, .72); }
.map-road {
  position: absolute;
  inset: 54% -5% auto -5%;
  height: 18px;
  background: rgba(99, 87, 68, .42);
  transform: rotate(-8deg);
}
.risk-list { display: grid; gap: 10px; }
.risk-matrix { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.risk {
  border-left: 5px solid var(--green);
  background: #faf7ef;
  border-radius: 7px;
  padding: 13px;
}
.risk strong { display: block; margin-bottom: 6px; }
.risk span, .risk em { display: block; color: var(--muted); font-size: 14px; line-height: 1.4; }
.risk.high { border-color: var(--red); }
.risk.mid { border-color: var(--amber); }
.risk.low { border-color: var(--green); }
.passport-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.season-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field-passport { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-passport article {
  border: 1px solid #cbd9c4;
  border-radius: 8px;
  background: #edf5e8;
  padding: 16px;
}
.field-passport article:nth-child(3),
.field-passport article:nth-child(8) {
  grid-column: 1 / -1;
}
.field-passport h3 {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--green-dark);
}
.field-passport dl {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) 1fr;
  gap: 8px 14px;
  margin: 0;
}
.field-passport dt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.field-passport dd {
  margin: 0;
  color: var(--ink);
  line-height: 1.35;
}
.mini-table {
  display: table;
  min-width: 860px;
  font-size: 13px;
}
.field-passport article:nth-child(3) {
  overflow-x: auto;
}
.roles-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.role-card {
  min-height: 280px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--green);
  border-radius: 8px;
  background: #fffdf8;
  padding: 16px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.role-card:hover { transform: translateY(-1px); }
.role-card.selected {
  border-color: var(--green-dark);
  box-shadow: inset 0 0 0 2px rgba(32, 77, 46, .14);
}
.role-head {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.role-index {
  display: grid;
  place-items: center;
  width: 42px;
  height: 32px;
  border-radius: 6px;
  background: #eef3e8;
  color: var(--green-dark);
  font-weight: 800;
}
.role-card h3 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.25;
}
.role-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}
.accent-owner { border-top-color: var(--green-dark); }
.accent-production { border-top-color: var(--blue); }
.accent-agro { border-top-color: var(--green); }
.accent-field { border-top-color: #6a8f3a; }
.accent-land { border-top-color: var(--amber); }
.accent-finance { border-top-color: #7a5a2d; }
.timeline { margin-top: 16px; display: grid; gap: 10px; }
.timeline div {
  display: grid;
  grid-template-columns: 70px 1fr minmax(150px, auto);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.clean-list { margin: 14px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }
.similarity { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.similarity strong { color: var(--green-dark); font-size: 34px; }
.similarity dl {
  margin: 12px 0 0;
}
.similarity dt {
  margin-top: 10px;
  color: var(--blue);
  font-weight: 800;
}
.similarity dd {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
table { width: 100%; border-collapse: collapse; overflow: hidden; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 13px 10px; vertical-align: top; }
th { color: var(--muted); font-size: 13px; }
.decision-table tbody tr:nth-child(odd) { background: #edf5e8; }
.decision-table tbody tr:nth-child(even) { background: #fffdf8; }
.decision-table td { color: var(--ink); line-height: 1.35; }
.decision-table th { background: #fffdf8; }
.field-list {
  display: grid;
  gap: 14px;
}
.field-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}
.field-record summary {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid transparent;
}
.field-record summary::-webkit-details-marker { display: none; }
.field-record summary strong {
  font-size: 18px;
  color: var(--ink);
}
.field-record summary span {
  color: var(--muted);
  line-height: 1.35;
}
.field-record[open] summary {
  border-bottom-color: var(--line);
  background: #f7faf2;
}
.field-record .field-passport {
  padding: 14px;
}
.scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.scenario-grid .selected { border-color: var(--green); box-shadow: inset 0 0 0 2px rgba(58, 125, 68, .16); }
.big-number { font-size: 76px; line-height: 1; color: var(--green-dark); margin: 16px 0 8px; font-weight: 800; }
.assistant-panel { max-width: 960px; }
.chat { display: grid; gap: 12px; }
.bubble {
  max-width: 760px;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.5;
}
.bubble.user { margin-left: auto; background: #e2ead9; }
.bubble.bot { background: #f8f4ea; border: 1px solid var(--line); }
dt { color: var(--muted); font-size: 13px; margin-top: 10px; }
dd { margin: 3px 0 0; }
.integrations { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.integrations strong { font-size: 18px; margin: 0 0 8px; }
.knowledge-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.knowledge-list strong { display: block; margin-bottom: 8px; color: var(--green-dark); }

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-footer { display: none; }
  main { padding: 18px; }
  .topbar, .panel-head { flex-direction: column; }
  .top-actions, .role-switch { width: 100%; }
  .kpi-grid, .dashboard-grid, .workspace, .passport-grid, .scenario-grid, .integrations, .similarity, .roles-grid, .field-passport, .season-grid, .risk-matrix, .knowledge-list, .flow-chain, .map-workspace { grid-template-columns: 1fr; }
  .field-passport article:nth-child(3),
  .field-passport article:nth-child(8) { grid-column: auto; }
  .field-passport dl { grid-template-columns: 1fr; }
  .field-map { min-height: 360px; }
  .timeline div { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  h1 { font-size: 24px; }
  .top-actions { width: 100%; }
  .primary { width: 100%; }
  nav { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}
