:root {
  --green: #1b6e20;
  --green-dark: #124d16;
  --yellow: #f2b705;
  --bg: #fafaf7;
  --text: #1f2a1f;
  --muted: #6b746b;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--green); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 3px solid var(--green);
}
.brand img { display: block; height: 56px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.nav a, .nav .link-btn { text-decoration: none; font-weight: 600; white-space: nowrap; }

.lang-switch { display: flex; border: 2px solid var(--green); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  border: 0; padding: 6px 14px; font: inherit; cursor: pointer;
  background: #fff; color: var(--green);
}
.lang-switch button[aria-pressed="true"] { background: var(--green); color: #fff; }
.lang-switch button:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }

main { max-width: 1080px; margin: 0 auto; padding: 16px; }

.hero {
  background: var(--green);
  color: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  border-bottom: 6px solid var(--yellow);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 4vw, 2.25rem); }
.hero p { margin: 0; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.cat-card {
  display: block; padding: 24px 16px; text-align: center;
  background: #fff; border: 2px solid var(--green); border-radius: var(--radius);
  font-weight: 700; text-decoration: none;
}
.cat-card:hover { background: var(--green); color: #fff; }

.muted { color: var(--muted); }

.site-footer { text-align: center; padding: 24px 16px; color: var(--muted); }

/* buttons & forms */
.btn {
  display: inline-block; padding: 10px 20px; border: 0; border-radius: 999px;
  background: var(--green); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn:focus-visible, .link-btn:focus-visible, .tabs button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--green); cursor: pointer; }

.card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form label.check { display: flex; gap: 8px; align-items: center; }
.form input:not([type=checkbox]) {
  font: inherit; padding: 10px 12px; border: 1px solid #c8cfc8; border-radius: 8px; width: 100%;
}
.form input:focus { outline: 2px solid var(--green); border-color: var(--green); }
.error { color: #b3261e; margin: 0; min-height: 1.6em; }

.auth { max-width: 420px; }
.tabs { display: flex; margin-bottom: 12px; border-bottom: 2px solid #dfe5df; }
.tabs button {
  flex: 1; padding: 10px; border: 0; background: none; font: inherit; font-weight: 700;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--yellow); color: var(--text); font-weight: 700; font-size: .9em; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-grid p { margin: 0; }
.stat { font-size: 2rem; font-weight: 800; color: var(--green); }

/* admin */
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 3px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters label { display: flex; gap: 6px; align-items: center; font-weight: 600; }
select, textarea, .filters input { font: inherit; padding: 8px 10px; border: 1px solid #c8cfc8; border-radius: 8px; background: #fff; }
.form textarea, .form select { width: 100%; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef1ee; vertical-align: middle; }
.table th { background: #f3f6f3; font-size: .9em; white-space: nowrap; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; }
.thumb-empty { background: #eef1ee; }
.thumb-lg { max-width: 160px; border-radius: 8px; margin-top: 6px; }
dialog { border: 0; border-radius: var(--radius); padding: 24px; width: min(720px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0; }
.btn-ghost { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn-ghost:hover { background: #f3f6f3; }
.badge-red { background: #b3261e; color: #fff; }
.danger { color: #b3261e; }
.cat-list { list-style: none; padding: 0; margin: 0 0 8px; }
.cat-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eef1ee; }

/* storefront catalog */
.cart-count { display: inline-block; min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: var(--yellow); color: var(--text); font-size: .8em; text-align: center; }
.top-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.top-tabs a { flex: 1; text-align: center; padding: 12px; border-radius: var(--radius); background: #fff; border: 2px solid var(--green); font-weight: 700; text-decoration: none; }
.top-tabs a[aria-current="page"] { background: var(--green); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { flex: none; padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid #c8cfc8; text-decoration: none; color: var(--text); white-space: nowrap; }
.chip[aria-current="true"] { background: var(--yellow); border-color: var(--yellow); font-weight: 700; }
.sort { display: flex; gap: 6px; align-items: center; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.product-card { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgb(0 0 0 / .08); text-decoration: none; color: var(--text); }
.product-card:hover { box-shadow: 0 2px 8px rgb(0 0 0 / .15); }
.product-card img, .product-card .img-empty { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; background: #f3f6f3; display: block; }
.product-card.is-oos img { opacity: .5; }
.product-name { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { color: #c0392b; font-weight: 800; }
.price-lg { font-size: 1.5rem; }
.product-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; background: #fff; padding: 20px; border-radius: var(--radius); }
.product-detail img, .product-detail .img-empty { width: 100%; aspect-ratio: 1; object-fit: contain; background: #f3f6f3; border-radius: var(--radius); display: block; }
.product-detail h1 { margin-top: 0; }
.buy { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.buy label { display: grid; gap: 4px; font-weight: 600; }
.buy input { font: inherit; width: 90px; padding: 9px; border: 1px solid #c8cfc8; border-radius: 8px; }
.success { color: var(--green); font-weight: 600; min-height: 1.6em; }
.back { display: inline-block; margin-bottom: 12px; }
.badge-green { background: var(--green); color: #fff; }
.actions { white-space: nowrap; }
.actions .link-btn { margin-right: 10px; }
button.chip { font: inherit; cursor: pointer; }
.narrow { max-width: 720px; }
.card h2 { margin: 0; font-size: 1.1rem; }
.product-card .badge { align-self: flex-start; }

/* cart, checkout, orders */
.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; }
.btn-line { background: #06c755; color: #fff; text-decoration: none; }
.btn-line:hover { background: #05a647; }
.notice { background: #fff6d6; border-left: 4px solid var(--yellow); padding: 10px 14px; border-radius: 8px; }
.cart-line { display: grid; grid-template-columns: 64px 1fr auto; grid-template-areas: "img info info" "img qty total" "img remove remove"; gap: 6px 12px; align-items: center; margin-bottom: 10px; padding: 12px; }
.cart-line img, .cart-line .img-empty { grid-area: img; width: 64px; height: 64px; object-fit: contain; background: #f3f6f3; border-radius: 8px; }
.cart-info { grid-area: info; display: flex; flex-direction: column; }
.cart-info a { font-weight: 600; color: var(--text); text-decoration: none; }
.qty { grid-area: qty; display: flex; align-items: center; gap: 4px; }
.qty input { width: 56px; text-align: center; font: inherit; padding: 6px; border: 1px solid #c8cfc8; border-radius: 8px; }
.qty-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid #c8cfc8; background: #fff; font: inherit; font-size: 1.1rem; cursor: pointer; }
.line-total { grid-area: total; justify-self: end; }
.cart-line [data-remove] { grid-area: remove; justify-self: end; font-size: .9em; }
.summary { display: grid; gap: 8px; margin-top: 12px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; }
.sum-row.total { font-size: 1.2rem; font-weight: 800; border-top: 1px solid #eef1ee; padding-top: 8px; }
.hint { margin: 0; color: #c0392b; font-weight: 600; }
.empty { text-align: center; }
#checkout-view { display: grid; gap: 16px; }
.order-items { list-style: none; padding: 0; margin: 8px 0; }
.order-items li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed #e3e8e3; }
.done { text-align: center; display: grid; gap: 10px; }
.temp-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .2em; color: var(--green); margin: 0; font-family: ui-monospace, Consolas, monospace; }
.temp-code-sm { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.order-no { font-size: 1.15rem; color: var(--green); }
.order { margin-bottom: 12px; display: grid; gap: 6px; }
.small { font-size: .85em; }
.recipient { margin: 4px 0; background: #f7f9f7; padding: 8px 12px; border-radius: 8px; }
.status { padding: 2px 12px; border-radius: 999px; font-weight: 700; font-size: .9em; white-space: nowrap; align-self: start; }
.status-pending { background: #fff1c2; color: #7a5a00; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-shipped { background: #e0e7ff; color: #3730a3; }
.status-completed { background: #dcfce7; color: var(--green-dark); }
.status-cancelled { background: #eee; color: #666; }

/* rewards */
.text-green { color: var(--green); font-weight: 700; }
.checkin-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; list-style: none; padding: 0; margin: 8px 0 12px; }
.checkin-days li { text-align: center; padding: 6px 0; border-radius: 8px; background: #f1f1f1; font-size: .85em; font-weight: 700; }
.checkin-days li.is-done { background: var(--green); color: #fff; }
.coupon { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border: 2px dashed var(--yellow); border-radius: 10px; margin-bottom: 8px; }
.coupon-amt { font-size: 1.3rem; color: var(--green); white-space: nowrap; }
.coupon-row { padding: 10px 0; border-bottom: 1px solid #eee; }
.right { text-align: right; }
#rewards { display: grid; gap: 12px; margin-top: 12px; }
.nowrap { white-space: nowrap; }
