:root {
  --forest: #124727;
  --forest-mid: #1b6337;
  --leaf: #2e8b47;
  --leaf-soft: #e8f5ec;
  --saffron: #d97706;
  --gold: #eab308;
  --gold-soft: #fef9e7;
  --cream: #faf6ee;
  --paper: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e0d3;
  --danger: #b91c1c;
  --shadow-sm: 0 2px 6px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 8px 24px rgba(18, 71, 39, 0.10);
  --radius: 16px;
}

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

html, body {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
}

img {
  max-width: 100%;
}

/* Top Navigation */
.topbar {
  background: linear-gradient(90deg, #0e3a1f 0%, var(--forest) 60%, #1b5e34 100%);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.brand h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.brand p {
  font-size: 12px;
  color: #d1fae5;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.lang-select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.3);
  font-size: 14px;
  font-weight: 700;
  background: rgba(255,255,255,0.96);
  color: var(--forest);
  max-width: 195px;
  cursor: pointer;
}

.helpline-pill {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1c1917;
  text-decoration: none;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Live Mandi Ticker */
.mandi-ticker {
  background: #1c1917;
  color: #fef3c7;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  display: flex;
  gap: 24px;
  overflow-x: auto;
  white-space: nowrap;
  border-bottom: 1px solid #44403c;
}

.mandi-ticker span strong {
  color: #4ade80;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 32px;
}

/* Hero Banner */
.hero-banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, #14532d, #166534);
}

.hero-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.62);
}

.hero-overlay {
  position: relative;
  z-index: 2;
  padding: 22px 24px;
  color: #fff;
  width: 100%;
  background: linear-gradient(0deg, rgba(14, 58, 31, 0.92) 0%, rgba(14, 58, 31, 0.35) 75%, transparent 100%);
}

.hero-overlay h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.hero-overlay p {
  font-size: 14px;
  color: #ecfdf5;
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  min-width: 0;
}

.topbar > *,
.form-grid > *,
.menu-tile > div {
  min-width: 0;
}

.auth-wrapper {
  max-width: 600px;
  margin: 8px auto;
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  background: var(--cream);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.mode-tabs {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
  background: #ecfdf5;
}

.role-tab {
  padding: 13px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.role-tab.active {
  background: var(--forest);
  color: #fff;
  box-shadow: 0 3px 10px rgba(18, 71, 39, 0.25);
}

.notice-badge {
  background: var(--leaf-soft);
  color: var(--forest);
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 4px solid var(--leaf);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mandi-filter-grid {
  grid-template-columns: 2fr 1fr 1fr;
}

.form-full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--forest);
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid #d6cfc2;
  border-radius: 11px;
  font-size: 16px;
  background: #fffefb;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  text-overflow: ellipsis;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(46, 139, 71, 0.15);
  background: #fff;
}

.otp-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.otp-row input {
  flex: 1;
  min-width: 0;
}

.otp-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.btn {
  padding: 13px 18px;
  border: none;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 48px;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--forest-mid), var(--forest));
  color: #fff;
  box-shadow: 0 3px 10px rgba(18, 71, 39, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-gold {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  color: #1c1917;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}

.btn-outline {
  background: #fff;
  color: var(--forest);
  border: 2px solid var(--forest);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 9px 13px;
  font-size: 14px;
  min-height: 38px;
}

.btn-block {
  width: 100%;
}

/* Dashboard Vertical Feature List */
.menu-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-tile {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--leaf);
  border-radius: 14px;
  padding: 14px 18px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.menu-tile:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-md);
  border-color: var(--forest);
}

.tile-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--leaf-soft);
  color: var(--forest);
  display: grid;
  place-items: center;
}

.menu-tile.tile-ai {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
  border-bottom-color: #d97706;
}

.menu-tile.tile-ai .tile-icon-box {
  background: #fde68a;
  color: #92400e;
}

.tile-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--forest);
}

.tile-sub {
  font-size: 13px;
  color: var(--muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cream);
}

.sticky-back-bar {
  position: sticky;
  top: 70px;
  z-index: 30;
  background: var(--paper);
  padding-top: 8px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(265px, 100%), 1fr));
  gap: 14px;
}

.item-card {
  background: #fffefb;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow-wrap: anywhere;
}

.price-big {
  font-size: 24px;
  font-weight: 900;
  color: var(--forest);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--leaf-soft);
  color: var(--forest);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1917;
  color: #fff;
  padding: 13px 22px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  max-width: 92vw;
  text-align: center;
  border-left: 4px solid var(--gold);
}

.hidden {
  display: none !important;
}

.progress-bar {
  height: 24px;
  border-radius: 999px;
  background: #fee2e2;
  overflow: hidden;
  display: flex;
  margin: 10px 0;
}

.progress-good {
  background: linear-gradient(90deg, #16a34a, #15803d);
  height: 100%;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid var(--line);
  margin-top: 10px;
}

.footer-help {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* Three-line Hamburger Button & Slide-Out Vertical Drawer */
.hamburger-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
}

.site-nav {
  background: #fff;
  border-right: 2px solid var(--forest);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 6px 0 28px rgba(0, 0, 0, 0.24);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 82vw;
  overflow-y: auto;
  z-index: 85;
  transform: translateX(0);
  transition: transform 0.22s ease;
}

.site-nav.drawer-closed {
  transform: translateX(-105%);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 12px;
  margin-bottom: 6px;
  border-bottom: 1.5px solid var(--line);
  color: var(--forest);
  font-size: 18px;
}

.drawer-close {
  background: var(--cream);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.nav-pill {
  padding: 12px 14px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-pill:hover {
  background: var(--leaf-soft);
  color: var(--forest);
}

.nav-pill.active {
  background: var(--forest);
  color: #fff;
}

.nav-pill.nav-ai {
  background: var(--gold-soft);
  color: #92400e;
}

.nav-pill.nav-ai.active {
  background: var(--saffron);
  color: #fff;
}

/* Vertical Home Feed */
.home-split {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 18px;
}

.weather-mini {
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.promo-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.promo-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  min-height: 155px;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
}

.promo-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.promo-card:hover img {
  transform: scale(1.04);
}

.promo-overlay {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 16px;
  color: #fff;
  background: linear-gradient(0deg, rgba(12, 45, 24, 0.94) 0%, rgba(12, 45, 24, 0.45) 70%, transparent 100%);
}

.promo-overlay h3 {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 3px;
}

.promo-overlay p {
  font-size: 13px;
  color: #e2e8f0;
}

.feed-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}

.feed-section-head h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--forest);
}

@media (max-width: 820px) {
  .site-nav {
    width: 270px;
  }
}

/* Kissan Mitra Floating Chatbot */
.chat-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: linear-gradient(135deg, var(--forest), var(--leaf));
  color: #fff;
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(18, 71, 39, 0.32);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-window {
  position: fixed;
  bottom: 84px;
  right: 22px;
  width: 370px;
  max-width: calc(100vw - 24px);
  max-height: 76vh;
  background: #fff;
  border-radius: 18px;
  border: 2px solid var(--forest);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  background: var(--forest);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
}

.chat-messages {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
  min-height: 220px;
  max-height: 330px;
}

.chat-msg {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  max-width: 90%;
}

.chat-msg.bot {
  background: #fff;
  border: 1px solid var(--line);
  align-self: flex-start;
  color: var(--ink);
}

.chat-msg.user {
  background: var(--forest);
  color: #fff;
  align-self: flex-end;
}

.chat-chips {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.chat-chip {
  background: var(--leaf-soft);
  color: var(--forest);
  border: 1px solid var(--leaf);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.chat-input-row input {
  padding: 10px 12px;
  font-size: 14px;
}

/* Website Settings Modes */
body.font-large {
  font-size: 18px;
}

body.font-xlarge {
  font-size: 20px;
}

body.data-saver .hero-banner img,
body.data-saver .promo-card img {
  display: none;
}

body.data-saver .hero-banner,
body.data-saver .promo-card {
  min-height: 110px;
}

body.high-contrast {
  --cream: #ffffff;
  --line: #1c1917;
  --muted: #1c1917;
}

@media (min-width: 601px) and (max-width: 1024px) {
  .container {
    padding: 16px 18px 80px;
  }
  .mandi-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mandi-filter-grid > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .sticky-back-bar {
    position: static;
  }
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar-actions {
    width: 100%;
    gap: 6px;
  }
  .lang-select {
    max-width: 100%;
    flex: 1 1 150px;
    min-height: 40px;
  }
  .helpline-pill {
    font-size: 13px;
    padding: 8px 12px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 12px 10px 88px;
  }
  .card {
    padding: 14px;
    border-radius: 14px;
  }
  .brand-logo {
    width: 40px;
    height: 40px;
  }
  .brand h1 {
    font-size: 18px;
  }
  .hero-banner {
    min-height: 148px;
  }
  .hero-overlay {
    padding: 16px;
  }
  .hero-overlay h2 {
    font-size: 19px;
  }
  .form-grid,
  .mandi-filter-grid {
    grid-template-columns: 1fr;
  }
  .role-tabs {
    gap: 5px;
    padding: 5px;
  }
  .role-tab {
    padding: 10px 6px;
    font-size: 13.5px;
    gap: 5px;
    flex-wrap: wrap;
    text-align: center;
  }
  .mode-tabs .role-tab {
    font-size: 14px;
    padding: 11px 8px;
  }
  .menu-tile {
    padding: 12px 14px;
    gap: 12px;
    min-height: 68px;
  }
  .tile-icon-box {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  .tile-title {
    font-size: 16px;
  }
  .chat-fab {
    bottom: 14px;
    right: 12px;
    padding: 11px 16px;
    font-size: 14px;
  }
  .chat-window {
    left: 10px;
    right: 10px;
    bottom: 72px;
    width: auto;
    max-width: none;
    max-height: 74vh;
    max-height: 74dvh;
  }
  .chat-messages {
    min-height: 170px;
    max-height: 40vh;
    max-height: 40dvh;
  }
}

@media (max-width: 420px) {
  .otp-row {
    flex-direction: column;
  }
  .otp-row .btn {
    width: 100%;
  }
  .role-tab {
    font-size: 12.5px;
    padding: 9px 4px;
  }
}
