:root {
  color-scheme: light;
  --bg: #f5f2e8;
  --panel: #ffffff;
  --panel-2: #edf4e8;
  --ink: #17241a;
  --muted: #657165;
  --line: #d4decf;
  --green: #2f7a4f;
  --green-dark: #195239;
  --gold: #b77a1c;
  --blue: #2f7fa3;
  --pink: #9b4b80;
  --red: #b94a3a;
  --shadow: 0 18px 45px rgba(51, 76, 55, 0.13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(47, 122, 79, 0.16) 0 18%, transparent 18% 100%),
    radial-gradient(circle at 88% 12%, rgba(47, 127, 163, 0.22), transparent 26rem),
    radial-gradient(circle at 16% 28%, rgba(183, 122, 28, 0.14), transparent 24rem),
    linear-gradient(180deg, #f7f4ea, #e9f1e4 58%, #f5f2e8);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(25, 82, 57, 0.12);
  background: rgba(247, 244, 234, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  color: #ffffff;
  background: var(--green);
  font-weight: 900;
}

.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); font-size: 0.78rem; }

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #324234;
  font-size: 0.92rem;
  white-space: nowrap;
}

nav a { padding: 0.5rem 0; }
.nav-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
}

.hero,
.system-section,
.prototype,
.architecture,
.implementation,
.deployment {
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1rem, 4vw, 3rem);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(22rem, 0.56fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  min-height: calc(100vh - 4.1rem);
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
}

h3 { margin: 0; font-size: 1.15rem; }

.lead {
  max-width: 56rem;
  margin: 1.35rem 0 0;
  color: #405044;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.65;
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  font-weight: 900;
}

.button.primary {
  color: #ffffff;
  background: var(--green);
}

.button.secondary,
.button.compact {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.button.compact { width: 100%; }

.challenge-card,
.system-grid article,
.panel,
.phone-panel,
.architecture-card,
.stack-grid article,
.implementation-grid article,
.deployment-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 248, 239, 0.84));
  box-shadow: var(--shadow);
}

.challenge-card { padding: 1.25rem; }
.challenge-card ol {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.challenge-card li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
}

.challenge-card li::before {
  content: counter(list-item, decimal-leading-zero);
  color: var(--gold);
  font-weight: 900;
}

.challenge-card span,
.system-grid p,
.section-head p,
.callout,
.ticket p,
.implementation-grid p,
.stack-grid p {
  color: var(--muted);
  line-height: 1.55;
}

.system-section {
  display: grid;
  grid-template-columns: minmax(16rem, 0.5fr) 1fr;
  gap: 1.2rem;
  align-items: start;
}

.system-grid,
.prototype-grid,
.stack-grid,
.implementation-grid,
.deployment-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.system-grid article,
.stack-grid article,
.implementation-grid article,
.deployment-grid article {
  padding: 1rem;
}

.system-grid span,
.implementation-grid span,
.deployment-grid span {
  display: block;
  color: var(--blue);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
}

.system-grid h3,
.implementation-grid h3,
.stack-grid h3 {
  margin-top: 1.1rem;
}

.section-head {
  max-width: 58rem;
  margin-bottom: 1.2rem;
}

.prototype-grid {
  grid-template-columns: 0.95fr 1.05fr;
  align-items: stretch;
}

.phone-panel,
.panel { padding: 1rem; }

.phone-top,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.status,
.mini-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.38rem 0.65rem;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.status.active { background: var(--gold); }
.status.done,
.mini-pill { background: var(--green); }
.mini-pill.danger { color: #ffffff; background: var(--red); }

.transcript {
  display: grid;
  gap: 0.72rem;
  min-height: 12rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #f4f7ef;
}

.transcript p,
.sms-card p {
  margin: 0;
  color: #354238;
  line-height: 1.5;
}

.sms-card {
  margin-top: 1rem;
  border-left: 4px solid var(--blue);
  padding: 0.9rem 1rem;
  background: #eef7fb;
}

.sms-card span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.map-panel,
.rsk-panel { grid-row: span 2; }

canvas,
.architecture-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #dbe7cf;
}

.legend,
.input-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.legend i {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  border-radius: 3px;
}

.legend .low { background: #d28a58; }
.legend .healthy { background: #5ca76c; }
.legend .water { background: #5aa4cf; }

.input-chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.38rem 0.6rem;
  background: rgba(255, 255, 255, 0.7);
}

.crop-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.crop-row {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.8rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.74);
}

.crop-row b {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 999px;
  color: #ffffff;
  background: var(--blue);
}

.crop-row.best b { background: var(--green); }
.crop-row.avoid b { color: #ffffff; background: var(--red); }
.crop-row span { display: block; margin-top: 0.18rem; color: var(--muted); font-size: 0.88rem; }

.risk-meter {
  height: 1rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(47, 122, 79, 0.13);
}

.risk-meter span {
  display: block;
  width: 78%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--red));
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.stats div {
  border-radius: 8px;
  padding: 0.75rem;
  background: #f1f5ec;
}

.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 0.18rem 0 0; font-weight: 900; }

.ticket-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.ticket {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.76);
}

.ticket span {
  display: inline-block;
  margin-bottom: 0.45rem;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.75rem;
  font-weight: 900;
}

.ticket.urgent span { color: #ffffff; background: var(--red); }
.ticket strong { display: block; margin-bottom: 0.3rem; }

.architecture-card {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.72);
}

.stack-grid { margin-top: 1rem; }

.deployment-grid article {
  min-height: 8.5rem;
  box-shadow: none;
}

.deployment-grid strong {
  display: block;
  margin-top: 1.1rem;
  font-size: 1.05rem;
}

.evidence-band {
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1rem, 4vw, 3rem);
  background: rgba(255, 255, 255, 0.34);
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.evidence-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.evidence-card strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--green-dark);
}

.evidence-card p,
.evidence-table td {
  color: var(--muted);
  line-height: 1.55;
}

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.evidence-table th,
.evidence-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem;
  text-align: left;
  vertical-align: top;
}

.evidence-table tr:last-child th,
.evidence-table tr:last-child td { border-bottom: 0; }
.evidence-table th { width: 24%; color: var(--green-dark); }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

footer p { margin: 0; }
footer span { color: var(--blue); font-weight: 900; }

.farmer-form {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.farmer-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.farmer-form input,
.farmer-form select,
.farmer-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.72rem 0.8rem;
  color: var(--ink);
  background: #fffdf7;
  font: inherit;
}

.farmer-form textarea {
  resize: vertical;
}

.code-block {
  max-height: 18rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  color: #223226;
  background: #fffdf7;
  font: 0.82rem ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
  white-space: pre-wrap;
}

.check-grid {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.check-grid label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.76);
  color: #354238;
}

.tour-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  border: 1px solid rgba(25, 82, 57, 0.25);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  color: #ffffff;
  background: var(--green-dark);
  box-shadow: 0 12px 30px rgba(25, 82, 57, 0.26);
  cursor: pointer;
  font-weight: 900;
}

.tour-root[hidden] { display: none; }

.tour-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(11, 25, 15, 0.48);
  backdrop-filter: blur(2px);
}

.tour-card {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 1rem;
  width: min(46rem, calc(100vw - 2rem));
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 1rem 1rem 1.1rem;
  color: var(--ink);
  background: #fffdf7;
  box-shadow: 0 24px 60px rgba(11, 25, 15, 0.34);
  transform: translateX(-50%);
}

.tour-card h2 {
  margin: 0.75rem 0 0;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  line-height: 1.15;
}

.tour-card p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.tour-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.tour-close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.tour-progress {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tour-bar {
  overflow: hidden;
  height: 0.45rem;
  margin-top: 0.6rem;
  border-radius: 999px;
  background: rgba(47, 122, 79, 0.14);
}

.tour-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 180ms ease;
}

.tour-hint {
  border-left: 4px solid var(--green);
  padding: 0.65rem 0.75rem;
  background: #eef7ee;
  font-weight: 800;
}

.tour-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 0.55rem;
  margin-top: 1rem;
}

.tour-actions .button {
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
}

.tour-back:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tour-highlight {
  position: relative;
  z-index: 95;
  outline: 5px solid rgba(183, 122, 28, 0.92);
  outline-offset: 8px;
  box-shadow: 0 0 0 9999px rgba(11, 25, 15, 0.12), 0 18px 45px rgba(51, 76, 55, 0.28);
}

@media (max-width: 1050px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  nav { width: 100%; overflow-x: auto; }
  .hero,
  .system-section,
  .prototype-grid,
  .system-grid,
  .evidence-grid,
  .stack-grid,
  .implementation-grid,
  .deployment-grid {
    grid-template-columns: 1fr;
  }
  .map-panel,
  .rsk-panel { grid-row: auto; }
}

@media (max-width: 640px) {
  h1 { font-size: 3rem; }
  h2 { font-size: 2.1rem; }
  .phone-top,
  .panel-head,
  footer { flex-direction: column; }
  .stats,
  .form-grid { grid-template-columns: 1fr; }
  .tour-card {
    left: 1rem !important;
    right: 1rem;
    bottom: 1rem;
    top: auto !important;
    width: auto;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    transform: none;
  }
  .tour-actions { grid-template-columns: 1fr; }
}
