:root {
  --primary: #c58b4c;
  --primary-dark: #9c6a35;
  --bg: #fff8ef;
  --text: #2b2118;
  --muted: #7a6f64;
  --border: #e6d8c2;
  --danger: #c0392b;
  --ok: #3d8b5f;
  --shadow: 0 6px 20px rgba(75, 58, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; display: block; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--primary); color: #fff8ef; font-weight: 900; }
.brand-name { font-size: 18px; letter-spacing: 0.05em; }
.site-nav { display: flex; gap: 20px; align-items: center; }
.site-nav a { color: var(--text); font-weight: 500; }
.cart-link { position: relative; }
.badge { background: var(--primary); color: #fff; font-size: 11px; border-radius: 10px; padding: 2px 6px; margin-left: 4px; }

/* Hero */
.hero { background: linear-gradient(180deg, #fff7e6 0%, #fff8ef 100%); padding: 80px 0; text-align: center; }
.hero h1 { font-size: 42px; margin: 0 0 10px; letter-spacing: 0.1em; }
.hero p { max-width: 600px; margin: 0 auto 24px; color: var(--muted); font-size: 18px; }

/* Buttons */
.btn { display: inline-block; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; cursor: pointer; background: #fff; color: var(--text); transition: all .2s; font-size: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--primary); color: var(--primary-dark); }
.btn-ghost:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a0281d; }
.link-btn { background: none; border: 0; color: var(--danger); cursor: pointer; text-decoration: underline; }

/* Brand story */
.brand-story { padding: 60px 0; display: flex; flex-direction: column; gap: 40px; }
.brand-block { display: grid; gap: 24px; align-items: center; background: #fff; padding: 30px; border-radius: 12px; box-shadow: var(--shadow); }
.brand-block h2 { margin-top: 0; }
.brand-block-center .brand-block-text { text-align: center; }
.brand-block-image_left { grid-template-columns: 1fr 1fr; }
.brand-block-image_right { grid-template-columns: 1fr 1fr; }
.brand-block-image_right .brand-block-img { order: 2; }
.brand-block-img img { border-radius: 8px; }
.video-wrap { position: relative; padding-bottom: 56.25%; height: 0; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; }

/* Product grid */
.featured { padding: 40px 0 80px; }
.featured h2 { text-align: center; margin-bottom: 24px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.product-card { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: transform .2s; display: block; color: var(--text); }
.product-card:hover { transform: translateY(-2px); color: var(--text); }
.product-card-img { aspect-ratio: 1/1; background: #f1e5d2; overflow: hidden; }
.product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.no-img { display: flex; align-items: center; justify-content: center; color: var(--muted); height: 100%; min-height: 200px; font-weight: 600; letter-spacing: 0.2em; }
.product-card-body { padding: 14px 16px 18px; }
.product-card-body h3 { margin: 0 0 6px; font-size: 16px; }
.product-card .price { margin: 0; color: var(--primary-dark); font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; background: #f1e5d2; border-radius: 999px; font-size: 11px; margin-right: 4px; }
.tag-out { background: #e6d8c2; color: var(--muted); }
.tag-ok { background: #dff4e6; color: var(--ok); }
.tag-hl { background: var(--primary); color: #fff; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 20px; gap: 16px; flex-wrap: wrap; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Product detail */
.product-detail { padding: 40px 0 80px; }
.product-detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; }
@media (max-width: 800px) { .product-detail-grid { grid-template-columns: 1fr; } }
.gallery-main { aspect-ratio: 1/1; background: #f1e5d2; border-radius: 12px; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.gallery-thumbs button { border: 2px solid transparent; background: none; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; width: 72px; height: 72px; }
.gallery-thumbs button:hover { border-color: var(--primary); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

.buy-panel h1 { margin-top: 0; }
.buy-panel .price { color: var(--primary-dark); font-size: 28px; font-weight: 700; margin: 6px 0 16px; }
.desc { color: var(--muted); }
.label { display: block; font-weight: 600; margin: 16px 0 8px; }
.variant-options { display: grid; gap: 8px; }
.variant-option { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: #fff; }
.variant-option input { accent-color: var(--primary); }
.variant-option.disabled { opacity: .5; cursor: not-allowed; }
.variant-label { font-weight: 600; }
.variant-meta em { font-style: normal; color: var(--danger); margin-left: 6px; }
.qty-input { width: 100px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
.brand-story-box { margin-top: 24px; }

/* Cart */
.cart-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.cart-table th, .cart-table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
.cart-item { display: flex; gap: 12px; align-items: center; }
.cart-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.qty-form { display: flex; gap: 6px; align-items: center; }
.qty-form input { width: 60px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.cart-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
.cart-total { text-align: right; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.warn { color: var(--danger); font-size: 12px; }

/* Checkout */
.checkout-page { padding: 40px 0 80px; }
.checkout-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
@media (max-width: 800px) { .checkout-grid { grid-template-columns: 1fr; } }
.card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.checkout-form fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.checkout-form legend { font-weight: 700; margin-bottom: 10px; }
.checkout-form label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.checkout-form input, .checkout-form select, .checkout-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; color: var(--text); background: #fff; }
.radio-option { display: flex !important; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text) !important; }
.address-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .address-row { grid-template-columns: 1fr; } }
.checkout-summary .checkout-items { list-style: none; padding: 0; margin: 0 0 16px; }
.checkout-summary li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.checkout-summary .row { display: flex; justify-content: space-between; padding: 6px 0; }
.checkout-summary .total { font-size: 18px; font-weight: 700; border-top: 2px solid var(--border); margin-top: 8px; padding-top: 10px; }

/* Success */
.success-card { text-align: center; max-width: 600px; margin: 60px auto; }
.order-no { color: var(--primary-dark); font-family: monospace; letter-spacing: 0.1em; }
.success-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 24px 0; text-align: left; }
.success-grid div { display: flex; flex-direction: column; }

/* Empty */
.empty-state { background: #fff; padding: 40px; border-radius: 12px; text-align: center; color: var(--muted); box-shadow: var(--shadow); }

/* Flashes */
.flashes { padding: 10px 0; }
.flash { padding: 10px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.flash-success { background: #dff4e6; color: var(--ok); }
.flash-error { background: #fce7e3; color: var(--danger); }

/* Footer */
.site-footer { background: #fff; border-top: 1px solid var(--border); padding: 30px 0; margin-top: 60px; text-align: center; }
.site-footer p { margin: 4px 0; }

/* ===== Admin ===== */
.admin { display: flex; min-height: 100vh; margin: 0; background: #f8f2e6; }
.admin-side { width: 220px; background: #231c14; color: #f1e5d2; padding: 24px 16px; position: sticky; top: 0; align-self: flex-start; height: 100vh; display: flex; flex-direction: column; }
.admin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.admin-brand .brand-name { font-size: 16px; color: #fff8ef; }
.admin-brand .muted { color: #a8988c; font-size: 12px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a { color: #e6d8c2; padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.admin-nav a:hover { background: #3a2e22; color: #fff; }
.admin-nav .logout { margin-top: auto; color: #c58b4c; }
.admin-main { flex: 1; padding: 30px 40px; overflow-x: auto; }
.admin-main h1 { margin-top: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border-radius: 12px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 24px; }
.stat small { font-size: 11px; }
.stat-hl { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; }
.stat-hl .muted { color: #fff; opacity: .9; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.data-table th { background: #f1e5d2; }
.data-table input, .data-table select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }

.progress-bar { width: 100%; height: 18px; background: #f1e5d2; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%); transition: width .4s; }

.mini-bars { display: flex; gap: 8px; align-items: flex-end; height: 160px; padding-top: 10px; }
.mini-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.mini-bar .bar { width: 100%; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%); border-radius: 6px 6px 0 0; min-height: 2px; margin-top: auto; transition: height .3s; }
.mini-bar span { font-size: 11px; color: var(--muted); }

.admin label { display: block; font-weight: 500; margin-bottom: 10px; font-size: 14px; }
.admin input[type="text"], .admin input[type="number"], .admin input[type="password"], .admin input[type="date"], .admin input[type="color"], .admin input[type="email"], .admin input[type="tel"], .admin input[type="file"], .admin select, .admin textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 14px; }
.checkbox-row { display: flex; gap: 16px; align-items: center; }
.checkbox-row label { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 14px; align-items: end; }
.grid-7 { display: grid; grid-template-columns: repeat(7, 1fr) auto; gap: 10px; align-items: end; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-5, .grid-7 { grid-template-columns: 1fr; } }

.inline-form { display: inline-block; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.image-item { background: #f1e5d2; border-radius: 8px; overflow: hidden; }
.image-item img { aspect-ratio: 1/1; object-fit: cover; width: 100%; }
.image-item form { padding: 4px; text-align: center; }
.cms-preview { max-width: 240px; border-radius: 8px; margin: 10px 0; }

.cell-with-img { display: flex; gap: 10px; align-items: center; }
.cell-with-img img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

.badge-paid, .badge-completed, .badge-shipped { background: #dff4e6; color: var(--ok); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge-unpaid, .badge-pending { background: #fff3d6; color: #a07216; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge-cancelled { background: #f1e5d2; color: var(--muted); padding: 3px 10px; border-radius: 999px; font-size: 12px; }

.icon-preview { display: flex; gap: 16px; align-items: center; padding: 14px; background: #f1e5d2; border-radius: 8px; margin-bottom: 14px; }
.icon-preview img { width: 96px; height: 96px; border-radius: 12px; }

/* Login page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #fff8ef 0%, #f1e5d2 100%); margin: 0; }
.login-card { background: #fff; padding: 40px; border-radius: 16px; box-shadow: var(--shadow); width: 360px; max-width: 90%; }
.login-card h1 { margin-top: 0; text-align: center; }
.login-card label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
