:root {
  --tea-dark: #0d3b24;
  --tea-deep: #0f4d2e;
  --tea-green: #1b7a43;
  --tea-mid: #2e9e5b;
  --tea-light: #7ed99a;
  --tea-pale: #e7f7ec;
  --cream: #faf9f2;
  --gold: #c9a227;
  --ink: #17281f;
  --muted: #5c7568;
  --danger: #c0392b;
  --card-radius: 18px;
  --shadow-soft: 0 10px 30px rgba(13, 59, 36, 0.08);
  --shadow-lift: 0 16px 40px rgba(13, 59, 36, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', 'Inter', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--cream) 0%, #f3f8f3 100%);
  color: var(--ink);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }

/* ---------- Layout ---------- */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(195deg, var(--tea-dark), var(--tea-deep) 70%);
  color: #eafcf1;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 26px; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.3px; }
.brand .leaf { font-size: 1.5rem; }

.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  color: #cdeed9; font-size: 0.95rem; transition: all .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: var(--tea-mid); color: #fff; box-shadow: var(--shadow-soft); }
.nav-link .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 0.8rem; color: #a9d4b8; }

.main-area { padding: 28px 34px 60px; max-width: 1400px; }

.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.topbar .greeting h1 { font-size: 1.5rem; color: var(--tea-dark); }
.topbar .greeting p { color: var(--muted); margin-top: 4px; font-size: 0.92rem; }

.farm-select { display: flex; align-items: center; gap: 10px; }
.farm-select select { padding: 10px 14px; border-radius: 12px; border: 1.5px solid #cfe9d8; background: #fff; font-family: inherit; font-size: 0.9rem; color: var(--ink); }

/* ---------- Cards ---------- */
.card { background: #fff; border-radius: var(--card-radius); box-shadow: var(--shadow-soft); padding: 22px; border: 1px solid #eef5f0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 22px; }

.stat-card { border-radius: var(--card-radius); padding: 20px 22px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow-soft); }
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; background: rgba(255,255,255,0.12); border-radius: 50%; }
.stat-card .label { font-size: 0.8rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .value { font-size: 1.85rem; font-weight: 700; margin-top: 6px; }
.stat-card .sub { font-size: 0.78rem; opacity: 0.85; margin-top: 6px; }

.stat-1 { background: linear-gradient(135deg, var(--tea-green), var(--tea-dark)); }
.stat-2 { background: linear-gradient(135deg, #2e9e5b, #16653a); }
.stat-3 { background: linear-gradient(135deg, #c9a227, #8a6d16); }
.stat-4 { background: linear-gradient(135deg, #3a7bd5, #1c4f8a); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } .app-shell { grid-template-columns: 1fr; } .sidebar { display:none; } }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 1.05rem; color: var(--tea-dark); }
.card-header .hint { font-size: 0.78rem; color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
label { font-size: 0.78rem; color: var(--muted); display: block; margin-bottom: 5px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1.5px solid #dcefe1; border-radius: 10px; font-family: inherit; font-size: 0.9rem; background: #fbfdfb; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tea-mid); background: #fff; }
textarea { resize: vertical; min-height: 70px; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: none; font-family: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer; transition: transform .1s ease, box-shadow .1s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--tea-green); color: #fff; box-shadow: 0 8px 18px rgba(27,122,67,0.28); }
.btn-primary:hover { background: var(--tea-dark); }
.btn-outline { background: transparent; border: 1.5px solid var(--tea-mid); color: var(--tea-green); }
.btn-gold { background: var(--gold); color: #3a2e05; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-danger { background: #fdecea; color: var(--danger); }

/* ---------- Tables / lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef3ee; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-good { background: #e4f7e9; color: #1c7a3c; }
.badge-repair { background: #fff4e0; color: #a6720b; }
.badge-damaged { background: #fdeceb; color: #b83127; }
.badge-lost { background: #efeef3; color: #55506b; }

.note-card { background: var(--tea-pale); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.note-card .note-title { font-weight: 600; font-size: 0.9rem; color: var(--tea-dark); margin-bottom: 4px; }
.note-card .note-date { font-size: 0.72rem; color: var(--muted); margin-top: 6px; }

.weather-card { color: #fff; background: linear-gradient(135deg, #2c8ee0, #14547d); border-radius: var(--card-radius); padding: 18px 20px; }
.weather-card .temp { font-size: 2.1rem; font-weight: 700; }

/* ---------- Chatbot widget ---------- */
.chat-toggle { position: fixed; bottom: 26px; right: 26px; width: 58px; height: 58px; border-radius: 50%; background: linear-gradient(135deg, var(--tea-green), var(--tea-dark)); color: #fff; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lift); border: none; cursor: pointer; z-index: 60; }
.chat-window { position: fixed; bottom: 96px; right: 26px; width: 320px; max-height: 440px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lift); display: none; flex-direction: column; overflow: hidden; z-index: 60; border: 1px solid #e3f1e6; }
.chat-window.open { display: flex; }
.chat-header { background: var(--tea-dark); color: #eafcf1; padding: 14px 16px; font-weight: 600; font-size: 0.9rem; }
.chat-body { flex: 1; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: #f7fbf8; }
.chat-msg { padding: 9px 12px; border-radius: 12px; font-size: 0.83rem; max-width: 85%; line-height: 1.4; }
.chat-msg.bot { background: var(--tea-pale); color: var(--ink); align-self: flex-start; white-space: pre-line; }
.chat-msg.user { background: var(--tea-green); color: #fff; align-self: flex-end; }
.chat-input { display: flex; border-top: 1px solid #eef3ee; }
.chat-input input { border: none; border-radius: 0; flex: 1; padding: 12px; font-size: 0.85rem; }
.chat-input input:focus { border: none; }
.chat-input button { border: none; background: var(--tea-green); color: #fff; padding: 0 16px; cursor: pointer; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #1e8a4c, #0d3b24 65%); padding: 20px; }
.auth-card { background: #fff; border-radius: 22px; padding: 38px 36px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lift); }
.auth-card h1 { color: var(--tea-dark); font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--muted); font-size: 0.88rem; margin-bottom: 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.auth-foot a { color: var(--tea-green); font-weight: 600; }

/* ---------- Landing ---------- */
.landing-hero { min-height: 100vh; background: linear-gradient(160deg, #0d3b24 0%, #145c34 45%, #1e8a4c 100%); color: #fff; display: flex; flex-direction: column; }
.landing-nav { display: flex; justify-content: space-between; align-items: center; padding: 26px 6%; }
.landing-nav .brand { font-size: 1.2rem; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.landing-nav .links { display: flex; gap: 14px; }
.landing-nav .links a { padding: 10px 18px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; }
.landing-nav .links a.solid { background: #fff; color: var(--tea-dark); }
.landing-nav .links a.ghost { border: 1.5px solid rgba(255,255,255,0.5); }

.hero-content { flex: 1; display: flex; align-items: center; padding: 20px 6% 80px; gap: 40px; flex-wrap: wrap; }
.hero-text { max-width: 560px; }
.hero-text .eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; color: var(--tea-light); font-weight: 700; }
.hero-text h1 { font-size: 2.5rem; line-height: 1.2; margin: 14px 0 18px; }
.hero-text p { font-size: 1.02rem; opacity: 0.9; line-height: 1.6; margin-bottom: 26px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

.hero-visual { flex: 1; min-width: 300px; background: rgba(255,255,255,0.08); border-radius: 22px; padding: 26px; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.15); }
.feature-list { display: grid; gap: 14px; }
.feature-item { display: flex; gap: 14px; align-items: flex-start; background: rgba(255,255,255,0.06); padding: 16px; border-radius: 14px; }
.feature-item .icon { font-size: 1.4rem; }
.feature-item h4 { font-size: 0.95rem; margin-bottom: 4px; }
.feature-item p { font-size: 0.82rem; opacity: 0.85; line-height: 1.5; }

.flash-wrap { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.flash { padding: 12px 18px; border-radius: 12px; font-size: 0.85rem; font-weight: 500; box-shadow: var(--shadow-soft); min-width: 240px; color: #fff; }
.flash-success { background: var(--tea-green); }
.flash-error { background: var(--danger); }
.flash-info { background: #34495e; }

.empty-state { text-align: center; padding: 30px 10px; color: var(--muted); font-size: 0.88rem; }
.section-title { font-size: 1.3rem; color: var(--tea-dark); margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 20px; }

/* ---------- News page ---------- */
.news-toolbar { display:flex; flex-wrap:wrap; gap:14px; align-items:center; justify-content:space-between; margin-bottom:20px; }
.news-search { flex:1; min-width:220px; max-width:340px; position:relative; }
.news-search input { padding-left:38px; }
.news-search .icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); opacity:0.5; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; }
.tab-btn { padding:8px 16px; border-radius:999px; border:1.5px solid #d9eee0; background:#fff; font-size:0.82rem; font-weight:600; color: var(--muted); cursor:pointer; transition: all .15s ease; }
.tab-btn:hover { border-color: var(--tea-mid); color: var(--tea-green); }
.tab-btn.active { background: var(--tea-green); border-color: var(--tea-green); color:#fff; }
.hero-news { display:grid; grid-template-columns: 1.1fr 1fr; gap:0; border-radius:20px; overflow:hidden; box-shadow: var(--shadow-lift); margin-bottom:26px; background:#fff; border:1px solid #eef5f0; }
.hero-news .hero-img { min-height: 260px; background-size:cover; background-position:center; background-color: var(--tea-pale); display:flex; align-items:flex-end; }
.hero-news .hero-img.placeholder { display:flex; align-items:center; justify-content:center; font-size:4rem; background: linear-gradient(135deg, var(--tea-mid), var(--tea-dark)); }
.hero-news .hero-body { padding:28px 30px; display:flex; flex-direction:column; justify-content:center; gap:12px; }
.hero-news .pill { align-self:flex-start; background: var(--tea-pale); color: var(--tea-green); font-size:0.72rem; font-weight:700; padding:5px 12px; border-radius:999px; text-transform:uppercase; letter-spacing:0.04em; }
.hero-news h2 { font-size:1.4rem; color: var(--tea-dark); line-height:1.35; }
.hero-news p { color: var(--muted); font-size:0.9rem; line-height:1.55; }
.hero-news .meta { font-size:0.78rem; color: var(--muted); }
.news-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap:20px; }
.news-card { background:#fff; border-radius:16px; overflow:hidden; border:1px solid #eef5f0; box-shadow: var(--shadow-soft); display:flex; flex-direction:column; transition: transform .15s ease, box-shadow .15s ease; }
.news-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.news-card .thumb { height:150px; background-size:cover; background-position:center; background-color: var(--tea-pale); }
.news-card .thumb.placeholder { display:flex; align-items:center; justify-content:center; font-size:2.4rem; background: linear-gradient(135deg, #bfe6cc, var(--tea-pale)); }
.news-card .body { padding:16px 18px; display:flex; flex-direction:column; gap:8px; flex:1; }
.news-card .cat-pill { font-size:0.68rem; font-weight:700; color: var(--tea-green); text-transform:uppercase; letter-spacing:0.04em; }
.news-card h4 { font-size:0.96rem; line-height:1.4; color: var(--ink); }
.news-card p.snippet { font-size:0.82rem; color: var(--muted); line-height:1.5; flex:1; }
.news-card .meta { font-size:0.75rem; color: var(--muted); display:flex; justify-content:space-between; margin-top:6px; border-top:1px solid #f1f6f2; padding-top:10px; }
