/* ==========================================================================
   Doutor da Lavoura — Mini App (modern, brand-aligned with the landing)
   Palette: canopy green + terra roxa. Works over Telegram light/dark.
   Class names unchanged — HTML/JS untouched.
   ========================================================================== */
:root {
  --canopy:      #0F3020;
  --canopy-2:    #16442B;
  --leaf:        #4F9D5D;
  --leaf-bright: #7BC96F;
  --terra:       #A6432D;
  --terra-deep:  #7E3220;
  --paper:       #EEF1E8;
  --surface:     #ffffff;
  --ink:         #14201A;
  --muted:       #5b6b5c;
  --hair:        #e0e7dc;

  --radius:      16px;
  --radius-sm:   12px;
  --shadow:      0 6px 20px rgba(15,48,32,.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; min-height: 100vh; padding-bottom: 78px; }

/* ---- Header ---- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--canopy) 0%, var(--canopy-2) 100%);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
}
.app-header h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; }
.badge {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px; font-weight: 600;
  padding: 4px 11px; border-radius: 999px;
  min-width: 30px; text-align: center;
}

.screen { display: none; padding: 18px 16px; flex: 1; }
.screen.active { display: block; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

/* ---- Upload zone ---- */
.upload-zone {
  border: 2px dashed var(--leaf);
  border-radius: var(--radius);
  min-height: 210px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; margin-bottom: 18px;
  background: linear-gradient(150deg, #eef7ee, #f6faf4);
  transition: border-color .18s ease, background .18s ease;
}
.upload-zone:active { border-color: var(--canopy); }
.upload-placeholder { text-align: center; color: var(--muted); padding: 24px; }
.upload-placeholder span { font-size: 42px; display: block; margin-bottom: 10px; }
.upload-placeholder p { font-size: 14px; }
.preview { width: 100%; height: 100%; object-fit: cover; }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1.5px solid var(--hair);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:active { transform: scale(.96); }
.chip.selected { background: var(--leaf); border-color: var(--leaf); color: #fff; }

/* ---- Buttons ---- */
.primary-btn {
  width: 100%;
  background: var(--terra);
  color: #fff; border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(166,67,45,.26);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.primary-btn:active { transform: scale(.98); }
.primary-btn:disabled { background: #cbd6c9; color: #fff; box-shadow: none; cursor: not-allowed; }

.secondary-btn {
  width: 100%; background: transparent;
  color: var(--terra); border: 1.5px solid var(--terra);
  border-radius: 14px; padding: 13px;
  font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px;
}
.secondary-btn.small {
  width: auto; padding: 8px 15px; font-size: 13px;
  color: var(--canopy); border-color: var(--hair);
}

/* ---- Result card ---- */
.result {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 14px; line-height: 1.6;
  box-shadow: var(--shadow);
}

/* ---- History ---- */
.history-list { list-style: none; margin-top: 12px; }
.history-list li {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 13px 14px; margin-bottom: 9px; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.history-list li::before { content: "🌿"; font-size: 15px; }
.top-culture {
  background: linear-gradient(135deg, #eef7ee, #e2f1e2);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 13px 14px; font-size: 14px; font-weight: 600; color: var(--canopy);
  margin-bottom: 10px;
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 50;
}
.nav-btn {
  flex: 1; background: none; border: none;
  padding: 9px 0 8px; font-size: 19px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #9aa79a; cursor: pointer;
  transition: color .15s ease;
  position: relative;
}
.nav-btn span { font-size: 10.5px; font-weight: 500; }
.nav-btn.active { color: var(--terra); }
.nav-btn.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; background: var(--terra); border-radius: 0 0 3px 3px;
}

/* ---- Labels & cards ---- */
.section-label { font-size: 13px; font-weight: 700; color: var(--canopy); margin-bottom: 10px; letter-spacing: .01em; }
.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--canopy); letter-spacing: -.01em; }
.card-desc { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }

.text-input {
  width: 100%;
  border: 1.5px solid var(--hair);
  border-radius: 12px; padding: 13px;
  font-size: 14px; margin-bottom: 12px;
  background: #fbfdfa; color: var(--ink);
  transition: border-color .15s ease;
}
.text-input:focus { outline: none; border-color: var(--leaf); }

.status-pill {
  display: inline-block;
  background: #e6f5ea; color: var(--canopy);
  border: 1px solid #cfe6cf;
  border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; margin-bottom: 12px;
}

/* ---- Plans ---- */
.plans-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.plan-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.plan-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.plan-card-header h3 { font-size: 16px; font-weight: 700; color: var(--canopy); }
.plan-price { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--terra); }
.plan-features { list-style: none; font-size: 13.5px; color: var(--ink); margin-bottom: 14px; line-height: 1.9; }
.pix-code {
  background: #f4f7f2; border: 1px solid var(--hair);
  border-radius: 10px; padding: 12px;
  font-size: 12px; font-family: var(--mono);
  word-break: break-all; margin-bottom: 12px;
}
.stub-note { font-size: 12px; color: var(--terra-deep); margin-bottom: 12px; }

/* ---- Profile ---- */
.profile-summary { display: flex; flex-direction: column; gap: 12px; }
.profile-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.profile-row strong { color: var(--canopy); }
.referral-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f4f7f2; border: 1px solid var(--hair);
  border-radius: 10px; padding: 11px 12px;
  font-size: 12px; word-break: break-all; margin-bottom: 8px;
}
.link-btn {
  display: flex; align-items: center; width: 100%;
  background: none; border: none; text-align: left;
  padding: 15px 4px; font-size: 14.5px; color: var(--ink);
  border-bottom: 1px solid var(--hair); cursor: pointer;
}
.link-btn:last-child { border-bottom: none; }

/* ==========================================================================
   NDVI (índice do talhão)
   ========================================================================== */
.ndvi-map {
  width: 100%; height: 280px;
  border-radius: var(--radius);
  overflow: hidden; margin: 12px 0;
  border: 1px solid var(--hair);
  z-index: 0;
}
.ndvi-point {
  font-family: var(--mono);
  font-size: 13px; font-weight: 600; color: var(--canopy);
  background: #e6f5ea; border: 1px solid #cfe6cf;
  border-radius: 999px; padding: 6px 13px;
  display: inline-block; margin-bottom: 12px;
}
.ndvi-scale { margin: 16px 0 4px; }
.ndvi-scale-bar {
  display: block; height: 13px; border-radius: 7px; position: relative;
  background: linear-gradient(90deg, #b5502f 0%, #c98a2e 28%, #e8b13a 45%, #7bc96f 70%, #219150 100%);
}
.ndvi-scale-bar::after {
  content: ""; position: absolute; top: -4px; left: var(--pos, 0%);
  width: 3px; height: 21px; background: var(--ink);
  border-radius: 2px; transform: translateX(-50%); transition: left .6s ease;
}
.ndvi-scale-labels {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 5px;
}
.ndvi-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 16px 0; }
.ndvi-metric {
  background: #f4f7f2; border: 1px solid var(--hair);
  border-radius: 12px; padding: 13px 8px; text-align: center;
}
.ndvi-k { display: block; font-family: var(--mono); font-size: 21px; font-weight: 700; color: var(--canopy); }
.ndvi-l { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.ndvi-class {
  grid-column: 1 / -1; text-align: center;
  font-size: 13.5px; font-weight: 600; color: var(--canopy);
  padding: 10px; background: #e6f5ea; border: 1px solid #cfe6cf; border-radius: 10px;
}
