:root {
  --forest: #234d2e;
  --forest-dark: #16331e;
  --green: #4f9e52;
  --green-dark: #3a7d3d;
  --green-light: #eaf5e6;
  --cream: #f7f8f2;
  --cream-dark: #ecefe3;
  --accent: #ff9f45;
  --accent-dark: #e8862a;
  --success: #3f8f52;
  --text: #22301f;
  --muted: #6c7a63;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(35, 77, 46, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
}

/* HEADER */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(35,77,46,0.06);
}
.logo { font-size: 1.35rem; font-weight: 800; color: var(--forest); white-space: nowrap; }
.logo span { color: var(--green); }
.main-nav { display: flex; gap: 18px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav-link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.nav-link.active, .nav-link:hover { color: var(--forest); }
.header-actions { display: flex; gap: 10px; align-items: center; }

.pill-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.pill-btn:hover { transform: translateY(-1px); }
.pill-btn.solid { background: var(--green); color: #fff; }
.pill-btn.solid:hover { background: var(--green-dark); }
.pill-btn.ghost { background: var(--cream-dark); color: var(--forest); }
.pill-btn.outline { background: #fff; color: var(--forest); border: 2px solid var(--forest); }
.pill-btn.lg { padding: 14px 26px; font-size: 1rem; }
.cart-count {
  background: var(--forest-dark);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  padding: 0 5px;
}

/* STEPPER */
.stepper {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 20px 16px 8px;
  max-width: 1000px;
  margin: 0 auto;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
}
.step.active { color: var(--forest); background: var(--green-light); }
.step.completed { color: var(--success); }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--muted);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.step.active .step-num { background: var(--green); }
.step.completed .step-num { background: var(--success); }

main { max-width: 1100px; margin: 0 auto; padding: 8px 24px 60px; }

.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
.view h2 { color: var(--forest); }

.panel { display: none; animation: fadeIn .25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none; } }

/* DATA BANNER (demo data disclosure) */
.data-banner {
  background: #fff4e0;
  border: 1px solid #f3d9a8;
  color: #8a5a12;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  margin: 16px 0;
}

/* CUSTOMER DASHBOARD (sau khi đăng nhập) */
.customer-dashboard {
  display: none;
  background: linear-gradient(135deg, var(--green-light), #fff);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin: 16px 0;
}
.customer-dashboard.show { display: block; }
.customer-dashboard h2 { margin: 0 0 4px; color: var(--forest); }
.customer-dashboard .tier-line { color: var(--muted); font-weight: 600; margin: 0 0 16px; }
.dash-grid { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 150px;
}
.dash-card span { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.dash-card strong { font-size: 1.15rem; color: var(--forest); }
.dash-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* HERO */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
  align-items: center;
  padding: 40px 0 30px;
}
.hero-badge {
  display: inline-block;
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero-copy h1 {
  font-size: 2.4rem;
  line-height: 1.18;
  color: var(--forest);
  margin: 0 0 14px;
}
.hero-copy p { color: var(--muted); font-size: 1.02rem; max-width: 480px; margin: 0 0 22px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; }
.hero-stats { display: flex; gap: 30px; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.3rem; color: var(--forest); }
.hero-stats span { color: var(--muted); font-size: 0.8rem; }

.hero-art {
  position: relative;
  height: 340px;
  border-radius: 28px;
  background: linear-gradient(160deg, var(--green) 0%, var(--forest) 100%);
  overflow: hidden;
}
.hero-blob {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.18) 0, transparent 45%),
    radial-gradient(circle at 75% 70%, rgba(255,255,255,0.12) 0, transparent 40%);
}
.hero-bean {
  position: absolute;
  font-size: 2.6rem;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.2));
  animation: float 5s ease-in-out infinite;
}
.hero-bean.b1 { top: 18%; left: 15%; font-size: 3.4rem; animation-delay: 0s; }
.hero-bean.b2 { top: 55%; left: 55%; animation-delay: .8s; }
.hero-bean.b3 { top: 30%; left: 65%; font-size: 4rem; animation-delay: 1.6s; }
.hero-bean.b4 { top: 68%; left: 20%; font-size: 2.2rem; animation-delay: 2.2s; }
@keyframes float { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-14px);} }

/* QUICK ORDER BAR */
.quick-bar {
  display: flex;
  align-items: end;
  gap: 16px;
  background: #fff;
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin: 10px 0 34px;
  flex-wrap: wrap;
}
.quick-field { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }
.quick-field label { font-size: 0.72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.quick-field select, .quick-field input {
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  outline: none;
  width: 160px;
}

/* CATEGORY TABS */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0 20px;
}
.cat-btn {
  border: none;
  background: var(--cream-dark);
  color: var(--forest);
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.cat-btn.active, .cat-btn:hover { background: var(--forest); color: #fff; }

/* PRODUCT GRID */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}
.product-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-thumb {
  height: 120px;
  font-size: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #cfe8c8, var(--green));
  position: relative;
}
.origin-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(255,255,255,0.9);
  color: var(--forest);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.product-info { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 800; font-size: 1.05rem; color: var(--forest); }
.product-desc { color: var(--muted); font-size: 0.82rem; min-height: 32px; }
.product-price { color: var(--accent-dark); font-weight: 800; font-size: 1.1rem; margin-top: auto; }
.product-price small { color: var(--muted); font-weight: 600; font-size: 0.75rem; }
.min-order { font-size: 0.72rem; color: var(--muted); }
.orig-price { text-decoration: line-through; color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-right: 4px; }

.stock-badge {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e4f3e6;
  color: var(--success);
}
.stock-badge.low { background: #fff2e2; color: var(--accent-dark); }
.stock-badge.out { background: #fbe4e1; color: #c0392b; }
.product-card.out-of-stock { opacity: 0.65; }
.add-btn:disabled, .qty-control button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}
.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--cream-dark);
  border-radius: 999px;
  overflow: hidden;
}
.qty-control button {
  width: 28px; height: 28px;
  border: none;
  background: var(--cream-dark);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.qty-control input {
  width: 44px;
  text-align: center;
  border: none;
  font-weight: 700;
}
.add-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease;
}
.add-btn:hover { background: var(--green-dark); }

.tier-note {
  background: var(--green-light);
  color: var(--forest);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 0.9rem;
  margin-top: 28px;
}

/* CART ITEMS */
.cart-items { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.cart-item-icon { font-size: 1.6rem; }
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 700; }
.cart-item-price { color: var(--muted); font-size: 0.85rem; }
.cart-item-discount { color: var(--success); font-size: 0.75rem; font-weight: 700; }
.cart-item-line-total { font-weight: 700; color: var(--accent-dark); min-width: 100px; text-align: right; }
.remove-btn {
  border: none;
  background: transparent;
  color: #c0392b;
  font-size: 1.1rem;
  cursor: pointer;
}
.empty-msg { text-align: center; color: var(--muted); padding: 30px 0; }

.cart-summary {
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.cart-summary .row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.cart-summary .row.discount { color: var(--success); font-weight: 600; }
.cart-summary .row.total { font-weight: 800; font-size: 1.2rem; color: var(--text); border-top: 1px dashed var(--cream-dark); margin-top: 6px; padding-top: 10px; }

.panel-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 24px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  transition: transform .12s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.secondary { background: var(--cream-dark); color: var(--forest); }
.btn.full { width: 100%; }
.btn.sm { padding: 8px 14px; font-size: 0.82rem; }

/* CHECKOUT FORM */
.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.checkout-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.checkout-form input, .checkout-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--cream-dark);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}
.checkout-form textarea { resize: vertical; min-height: 60px; }
.payment-methods { border: 1px solid var(--cream-dark); border-radius: 12px; padding: 10px 14px; }
.payment-methods legend { font-weight: 700; padding: 0 6px; color: var(--forest); }
.radio { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; margin: 6px 0; }
.order-mini-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--green-light);
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 700;
}
.order-mini-summary strong { color: var(--forest); font-size: 1.15rem; }
.debt-note { color: var(--muted); font-size: 0.78rem; margin-top: -4px; }
.conditional-field { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 4px 14px; border-left: 3px solid var(--green-light); }
.form-error {
  background: #fbe4e1;
  color: #c0392b;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 14px;
  white-space: pre-line;
}
.auth-disclaimer {
  background: #fff4e0;
  color: #8a5a12;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.78rem;
  margin-top: 14px;
}
.no-price { color: var(--muted); font-style: italic; }
.btn.danger { background: #fbe4e1; color: #c0392b; }
.btn.danger:hover { background: #f6c9c3; }

/* REVIEW BOX (xác nhận đơn hàng trước khi tạo) */
.review-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; margin: 16px 0; }
.review-box h4 { color: var(--forest); margin: 18px 0 8px; }
.review-box h4:first-child { margin-top: 0; }
.review-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.92rem; }
.review-row span:first-child { color: var(--muted); }
.review-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--cream-dark); font-size: 0.92rem; }

/* CONFIRMATION */
.confirm-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 26px;
  text-align: center;
}
.confirm-icon { font-size: 3rem; }
.order-status-track {
  display: flex;
  justify-content: space-between;
  margin: 28px auto;
  max-width: 680px;
  position: relative;
  flex-wrap: wrap;
  gap: 10px;
}
.status-step {
  flex: 1;
  min-width: 100px;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.status-step .dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--cream-dark);
  border: 3px solid var(--cream-dark);
}
.status-step.done { color: var(--success); font-weight: 700; }
.status-step.done .dot { background: var(--success); border-color: var(--success); }
.status-step.current { color: var(--green-dark); font-weight: 700; }
.status-step.current .dot { background: var(--green); border-color: var(--green); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(79,158,82,.5);} 50%{ box-shadow: 0 0 0 6px rgba(79,158,82,0);} }

.order-receipt {
  text-align: left;
  background: var(--cream);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 18px 0;
  font-size: 0.9rem;
}
.order-receipt div { padding: 3px 0; display: flex; justify-content: space-between; }
.order-receipt .receipt-total { font-weight: 700; border-top: 1px dashed var(--cream-dark); margin-top: 6px; padding-top: 8px; }

/* HISTORY */
#historySection { margin-top: 44px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
}
.history-item .hid { font-weight: 700; color: var(--forest); }
.history-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--forest);
  font-weight: 700;
  font-size: 0.78rem;
}

/* CART DRAWER */
.cart-drawer {
  position: fixed;
  top: 0; right: -380px;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--cream);
  box-shadow: -6px 0 20px rgba(0,0,0,0.2);
  z-index: 40;
  padding: 18px;
  display: flex;
  flex-direction: column;
  transition: right .25s ease;
  overflow-y: auto;
}
.cart-drawer.open { right: 0; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-header button { background: none; border: none; font-size: 1.2rem; cursor: pointer; }
.overlay {
  position: fixed; inset: 0;
  background: rgba(22,51,30,0.35);
  z-index: 30;
  display: none;
}
.overlay.show { display: block; }

/* STOCK MODAL */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: 680px;
  max-width: 92vw;
  max-height: 84vh;
  overflow-y: auto;
}
.stock-table-wrap { overflow-x: auto; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.stock-table th, .stock-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--cream-dark); white-space: nowrap; }
.stock-table th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }
.restock-control { display: flex; gap: 6px; align-items: center; }
.restock-control input {
  width: 60px;
  padding: 5px 6px;
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  text-align: center;
}
.restock-control button {
  border: none;
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-weight: 700;
}
.restock-control button:hover { background: var(--green-dark); }

/* DEBT VIEW */
.debt-cards { display: flex; gap: 16px; flex-wrap: wrap; margin: 18px 0 10px; }
.debt-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.debt-card span { color: var(--muted); font-size: 0.76rem; font-weight: 700; text-transform: uppercase; }
.debt-card strong { font-size: 1.3rem; color: var(--forest); }
.debt-card strong.danger { color: #c0392b; }
.debt-card strong.success { color: var(--success); }
.progress-track { background: var(--cream-dark); border-radius: 999px; height: 10px; overflow: hidden; margin-bottom: 26px; }
.progress-fill { background: var(--green); height: 100%; border-radius: 999px; transition: width .3s ease; }

/* OFFERS VIEW */
.offer-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 20px;
}
.offer-card.highlight { background: linear-gradient(135deg, var(--green-light), #fff); }
.tier-badge {
  display: inline-block;
  background: var(--forest);
  color: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 10px;
}
.offer-discount { color: var(--forest); font-weight: 700; }
.tier-table { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 22px; }
.tier-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--cream-dark); font-weight: 600; color: var(--forest); }
.tier-row:last-child { border-bottom: none; }

/* LOGIN MODAL */
.modal-box.narrow { width: 440px; }
.muted-text { color: var(--muted); font-size: 0.9rem; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.login-form input { padding: 11px 14px; border: 1px solid var(--cream-dark); border-radius: 10px; font-size: 0.95rem; }
.login-hint { color: var(--muted); font-size: 0.8rem; }

.auth-tabs { display: flex; gap: 8px; margin: 14px 0 6px; }
.auth-tab {
  flex: 1;
  border: none;
  background: var(--cream-dark);
  color: var(--forest);
  padding: 10px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
}
.auth-tab.active { background: var(--forest); color: #fff; }
.auth-pane .checkout-form { padding: 0; box-shadow: none; margin-top: 10px; }

.form-success {
  background: #e4f3e6;
  color: var(--success);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 14px;
  white-space: pre-line;
}

.status-pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: 0.78rem; }
.status-pill.active { background: #e4f3e6; color: var(--success); }
.status-pill.pending { background: #fff2e2; color: var(--accent-dark); }
.status-pill.blocked { background: #fbe4e1; color: #c0392b; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { height: 220px; order: -1; }
}
@media (max-width: 640px) {
  .site-header { padding: 12px 16px; flex-wrap: wrap; }
  .main-nav { order: 3; flex: 1 1 100%; justify-content: flex-start; gap: 14px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .nav-link { white-space: nowrap; }
  .stepper { gap: 4px; }
  .step { font-size: 0.75rem; padding: 5px 8px; }
  .hero-copy h1 { font-size: 1.8rem; }
  .quick-bar { border-radius: 20px; }
  .quick-field select, .quick-field input { width: 120px; }
}
