/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #1a8c4e;
  --green-light: #2db86d;
  --green-pale: #e8f7ef;
  --amber: #f5a623;
  --amber-pale: #fff7e6;
  --red: #e74c3c;
  --red-pale: #fdecea;
  --dark: #0f1f14;
  --dark2: #1c3325;
  --mid: #4a7a5c;
  --grey: #8fa99a;
  --light: #f4f9f6;
  --white: #ffffff;
  --card-shadow: 0 4px 24px rgba(15,31,20,0.10);
  --radius: 18px;
  --radius-sm: 10px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--light);
  color: var(--dark);
  overflow-x: hidden;
}

/* ===== SPLASH ===== */
.splash {
  position: fixed;
  inset: 0;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s, transform 0.5s;
  overflow: hidden;
}

.splash.hide {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.splash-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.logo-icon {
  font-size: 3.5rem;
  animation: float 3s ease-in-out infinite;
}

.splash-logo h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1.1;
}

.splash-logo h1 span {
  color: var(--green-light);
}

.splash-sub {
  color: var(--grey);
  font-size: 0.95rem;
  margin-bottom: 2.5rem;
  letter-spacing: 0.02em;
}

.splash-bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.07;
  background: var(--green-light);
}

.s1 { width: 320px; height: 320px; top: -80px; right: -80px; }
.s2 { width: 200px; height: 200px; bottom: -50px; left: -60px; background: var(--amber); }
.s3 { width: 120px; height: 120px; top: 40%; left: 10%; }

/* ===== APP WRAPPER ===== */
.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--light);
  position: relative;
}

.app.hidden { display: none; }

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo { font-size: 1.4rem; }

.header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--dark);
}

.step-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dde8e2;
  transition: background 0.3s, width 0.3s;
}

.dot.active {
  background: var(--green);
  width: 22px;
  border-radius: 4px;
}

/* ===== STEP SECTIONS ===== */
.step {
  display: none;
  padding: 1.5rem 1.25rem 6rem;
  animation: fadeUp 0.4s ease both;
}

.step.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-badge {
  display: inline-block;
  background: var(--green-pale);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.step-header h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--dark);
  margin-bottom: 0.4rem;
}

.step-header h2 .accent { color: var(--green); }
.step-header p { color: var(--grey); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 0.9rem 1.8rem;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(26,140,78,0.28);
}

.btn-primary:hover { background: var(--green-light); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.full { width: 100%; margin-top: 1.5rem; }

.btn-secondary {
  background: transparent;
  color: var(--green);
  border: 2px solid var(--green);
  padding: 0.85rem 1.5rem;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--green-pale); }

/* ===== FORM CARD ===== */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}

/* Crop grid */
.crop-grid, .location-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.crop-btn, .loc-btn {
  background: var(--light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  font-size: 0.82rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  color: var(--dark);
  transition: all 0.2s;
  text-align: center;
}

.crop-btn:hover, .loc-btn:hover { border-color: var(--green-light); }
.crop-btn.active, .loc-btn.active {
  background: var(--green-pale);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

/* Quantity */
.qty-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  margin-bottom: 0.75rem;
}

.qty-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background: var(--white);
  color: var(--green);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover { background: var(--green); color: #fff; }

.qty-display {
  text-align: center;
  min-width: 80px;
}

.qty-display span {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--dark);
}

.qty-display small {
  display: block;
  font-size: 0.75rem;
  color: var(--grey);
  margin-top: -4px;
}

.qty-slider {
  width: 100%;
  accent-color: var(--green);
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
}

/* ===== STEP 2: ANALYSIS ===== */
.analysis-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
  min-height: 120px;
}

.analysis-msg {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--white);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: var(--card-shadow);
  animation: fadeUp 0.35s ease both;
}

.analysis-msg .msg-icon { font-size: 1.2rem; flex-shrink: 0; }
.analysis-msg .msg-text { font-size: 0.9rem; color: var(--dark); }
.analysis-msg .msg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-light);
  margin-left: auto;
  flex-shrink: 0;
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:0.4; transform:scale(0.7); }
}

.result-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border-top: 4px solid var(--green);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.result-item small {
  display: block;
  font-size: 0.75rem;
  color: var(--grey);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-item strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
}

.demand-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.demand-badge.high { background: #d4f4e2; color: #1a6b3a; }
.demand-badge.medium { background: var(--amber-pale); color: #8a5a00; }
.demand-badge.low { background: var(--red-pale); color: var(--red); }

.demand-bar-wrap small {
  font-size: 0.75rem;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.demand-bar {
  height: 12px;
  background: var(--light);
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 0 4px;
  position: relative;
}

.demand-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green), var(--green-light));
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
}

.demand-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--grey);
}

.location-tag {
  background: var(--green-pale);
  color: var(--green);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin-top: 1rem;
}

/* ===== STEP 3: PRICING ===== */
.pricing-compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.price-block {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.2rem 0.8rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.price-block small {
  font-size: 0.72rem;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.4rem;
}

.price-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--dark);
}

.price-num span { font-size: 0.9rem; font-weight: 500; color: var(--grey); }

.price-block.old .price-num { color: var(--red); text-decoration: line-through; text-decoration-color: var(--red); }
.price-block.new { border: 2px solid var(--green); }
.price-block.new .price-num { color: var(--green); }

.price-label {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 0.4rem;
}

.price-label.loss { background: var(--red-pale); color: var(--red); }
.price-label.gain { background: #d4f4e2; color: #1a6b3a; }

.vs-arrow {
  font-size: 1.6rem;
  color: var(--green);
  flex-shrink: 0;
}

.income-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.income-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--green-light), var(--amber));
}

.income-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.income-row.big { padding-top: 0.6rem; }
.income-row.big span { font-weight: 700; font-size: 1rem; }

.old-val { color: var(--red); font-size: 1.1rem; }
.new-val { color: var(--green); font-size: 1.1rem; }
.extra-val { color: var(--green); font-size: 1.25rem; font-family: var(--font-display); font-weight: 800; }

.income-divider { height: 1px; background: var(--light); margin: 0.4rem 0; }

.income-badge {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--amber);
  color: var(--dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  animation: bounce 0.7s 0.5s both;
}

@keyframes bounce {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ===== STEP 4: AGGREGATION ===== */
.aggregation-map {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  overflow: hidden;
  position: relative;
}

.agg-farmer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 2;
}

.agg-farmer .farmer-avatar {
  width: 54px; height: 54px;
  background: var(--green-pale);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 2px solid var(--green);
}

.agg-farmer small { font-size: 0.72rem; color: var(--grey); }
.agg-farmer span {
  background: var(--green);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.agg-farmer.pulse .farmer-avatar {
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(26,140,78,0.4); }
  70% { box-shadow: 0 0 0 14px rgba(26,140,78,0); }
  100% { box-shadow: 0 0 0 0 rgba(26,140,78,0); }
}

.agg-lines {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
}

.agg-peer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  animation: fadeUp 0.4s ease both;
}

.agg-peer .peer-avatar {
  width: 40px; height: 40px;
  background: var(--light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: 1.5px dashed var(--grey);
}

.agg-peer.joined .peer-avatar {
  border-color: var(--green-light);
  background: var(--green-pale);
  border-style: solid;
}

.agg-peer small { font-size: 0.68rem; color: var(--grey); }
.agg-peer span { font-size: 0.68rem; color: var(--green); font-weight: 600; }

.agg-total-card {
  background: var(--dark);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--white);
}

.agg-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
}

.agg-row.big span { color: #fff; font-weight: 700; }
.agg-row.big { padding-top: 0.5rem; }
.agg-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 0.4rem 0; }
.agg-row .accent { color: var(--green-light); font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.agg-note { font-size: 0.8rem; color: var(--green-light); margin-top: 0.75rem; text-align: center; }

/* ===== STEP 5: BUYERS ===== */
.buyers-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.buyer-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 2px solid transparent;
  transition: all 0.3s;
  opacity: 0;
  transform: translateX(-20px);
}

.buyer-card.visible { opacity: 1; transform: translateX(0); }
.buyer-card.winning { border-color: var(--green); background: var(--green-pale); }

.buyer-emoji { font-size: 1.5rem; }

.buyer-info { flex: 1; }
.buyer-info strong { display: block; font-size: 0.9rem; font-weight: 600; }
.buyer-info span { font-size: 0.78rem; color: var(--grey); }

.buyer-price {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--dark);
  transition: color 0.3s;
}

.buyer-card.winning .buyer-price { color: var(--green); }

.buyer-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--light);
  color: var(--grey);
}

.buyer-tag.best { background: var(--green); color: #fff; }

.best-offer-card {
  background: var(--dark);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: #fff;
  animation: fadeUp 0.4s ease both;
}

.best-label { font-size: 0.8rem; color: var(--green-light); font-weight: 600; margin-bottom: 0.4rem; }
.best-buyer { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.2rem; }
.best-price { font-family: var(--font-display); font-size: 2.5rem; font-weight: 800; color: var(--green-light); }
.best-distance { font-size: 0.82rem; color: rgba(255,255,255,0.5); margin-top: 0.3rem; }

/* ===== STEP 6: DELIVERY ===== */
.route-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1rem;
}

.route-point {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.route-icon {
  width: 44px; height: 44px;
  background: var(--green-pale);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.route-point.destination .route-icon { background: var(--amber-pale); }

.route-info strong { display: block; font-size: 0.85rem; color: var(--grey); font-weight: 500; }
.route-info span { font-size: 0.95rem; font-weight: 600; color: var(--dark); }

.route-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0 0.75rem 1.3rem;
  border-left: 2px dashed var(--green-light);
  margin: 0.4rem 0 0.4rem 1.3rem;
}

.route-truck {
  font-size: 1.2rem;
  animation: drive 1.5s linear infinite;
}

@keyframes drive {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(8px); }
  100% { transform: translateX(0); }
}

.route-distance {
  font-size: 0.82rem;
  color: var(--green);
  font-weight: 600;
  background: var(--green-pale);
  padding: 3px 10px;
  border-radius: 20px;
}

.delivery-status {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.status-item.done { color: var(--green); }
.status-item.active { color: var(--amber); font-weight: 600; }
.status-item.pending { color: var(--grey); }

.status-icon { width: 24px; text-align: center; }

/* ===== FINAL SUMMARY ===== */
.final-summary {
  background: var(--dark);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: #fff;
}

.final-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 1.2rem;
  text-align: center;
}

.final-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.final-item small {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.final-item strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.final-item strong.accent { color: var(--green-light); }

.final-cta {
  display: flex;
  gap: 0.75rem;
}

.final-cta .btn-secondary {
  border-color: rgba(255,255,255,0.3);
  color: #fff;
  flex: 1;
  font-size: 0.85rem;
  padding: 0.75rem;
}

.final-cta .btn-secondary:hover { background: rgba(255,255,255,0.08); }
.final-cta .btn-primary { flex: 1.5; font-size: 0.85rem; padding: 0.75rem; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--dark);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== HIDDEN UTIL ===== */
.hidden { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--green-light); border-radius: 2px; }

/* ===== FLOAT ANIMATION ===== */
@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}