:root {
  --primary: #ff7a1a;
  --primary-dark: #e8650a;
  --primary-light: #fff1e0;
  --secondary: #4caf50;
  --secondary-dark: #388e3c;
  --secondary-light: #e8f5e9;
  --text: #2c2c2c;
  --text-light: #777;
  --bg: #fafaf7;
  --border: #ececec;
  --danger: #e53935;
  --warning: #ff9800;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; }

/* ===== Header ===== */
.header { position: sticky; top: 0; z-index: 100; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 20px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.logo .leaf { color: var(--secondary); }
.search-bar { flex: 1; display: flex; max-width: 560px; background: var(--bg); border-radius: 22px; padding: 4px 4px 4px 16px; border: 2px solid transparent; transition: .2s; }
.search-bar:focus-within { border-color: var(--primary); background: #fff; }
.search-bar input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; padding: 8px 0; }
.search-bar button { background: var(--primary); color: #fff; padding: 8px 18px; border-radius: 18px; font-size: 14px; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-actions a, .nav-actions button { padding: 8px 12px; font-size: 14px; border-radius: 8px; transition: .2s; display: inline-flex; align-items: center; gap: 4px; }
.nav-actions a:hover, .nav-actions button:hover { background: var(--primary-light); color: var(--primary-dark); }
.cart-link { position: relative; }
.cart-badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.page-title { font-size: 22px; margin: 8px 0 20px; display: flex; align-items: center; gap: 10px; }
.page-title::before { content: ""; width: 4px; height: 22px; background: var(--primary); border-radius: 2px; }

/* ===== Carousel ===== */
.carousel { position: relative; height: 320px; border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow); }
.carousel-slides { display: flex; height: 100%; transition: transform .5s ease; }
.carousel-slide { min-width: 100%; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 60px; color: #fff; position: relative; }
.carousel-slide h2 { font-size: 36px; margin-bottom: 12px; }
.carousel-slide p { font-size: 16px; opacity: .95; margin-bottom: 18px; }
.carousel-slide .slide-emoji { font-size: 140px; opacity: .9; }
.carousel-slide .btn { background: #fff; color: var(--primary); padding: 10px 28px; border-radius: 24px; font-weight: 600; }
.carousel-dots { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.carousel-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.5); cursor: pointer; transition: .2s; }
.carousel-dots span.active { width: 24px; border-radius: 4px; background: #fff; }
.carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.3); color: #fff; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.carousel-arrow:hover { background: rgba(0,0,0,.5); }
.carousel-arrow.prev { left: 16px; } .carousel-arrow.next { right: 16px; }

/* ===== Categories ===== */
.category-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 28px; }
.category-card { background: #fff; border-radius: var(--radius); padding: 18px 12px; text-align: center; transition: .2s; cursor: pointer; box-shadow: var(--shadow); }
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.category-card .icon { font-size: 40px; margin-bottom: 8px; display: block; }
.category-card .name { font-size: 14px; font-weight: 500; }

/* ===== Section ===== */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 14px; }
.section-head h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.section-head h3::before { content: ""; width: 4px; height: 18px; background: var(--secondary); border-radius: 2px; }
.section-head a { color: var(--primary); font-size: 14px; }

/* ===== Product grid ===== */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.product-card { background: #fff; border-radius: var(--radius); overflow: hidden; transition: .2s; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-card .img-box { height: 160px; background: linear-gradient(135deg, var(--secondary-light), var(--primary-light)); display: flex; align-items: center; justify-content: center; font-size: 80px; position: relative; }
.product-card .origin-tag { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.95); color: var(--secondary-dark); padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.product-card .info { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }
.product-card .name { font-size: 14px; font-weight: 500; margin-bottom: 6px; line-height: 1.4; min-height: 40px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .meta { font-size: 12px; color: var(--text-light); margin-bottom: 8px; display: flex; gap: 8px; }
.product-card .stock-low { color: var(--danger); }
.product-card .bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-card .price { color: var(--primary); font-size: 18px; font-weight: 700; }
.product-card .price small { font-size: 12px; font-weight: 400; }
.product-card .add-btn { background: var(--primary); color: #fff; padding: 6px 12px; border-radius: 16px; font-size: 12px; }
.product-card .add-btn:hover { background: var(--primary-dark); }
.product-card .add-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ===== Product detail ===== */
.product-detail { background: #fff; border-radius: var(--radius); padding: 28px; display: grid; grid-template-columns: 380px 1fr; gap: 32px; box-shadow: var(--shadow); }
.product-detail .img-large { background: linear-gradient(135deg, var(--secondary-light), var(--primary-light)); border-radius: var(--radius); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 200px; }
.product-detail .pd-name { font-size: 26px; margin-bottom: 12px; }
.product-detail .pd-desc { color: var(--text-light); margin-bottom: 18px; line-height: 1.6; }
.product-detail .pd-price-box { background: var(--primary-light); padding: 18px 20px; border-radius: var(--radius); margin-bottom: 20px; }
.product-detail .pd-price { color: var(--primary); font-size: 32px; font-weight: 700; }
.product-detail .pd-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.product-detail .pd-meta-item { padding: 10px 14px; background: var(--bg); border-radius: 8px; font-size: 14px; }
.product-detail .pd-meta-item span { color: var(--text-light); margin-right: 8px; }
.qty-control { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.qty-control button { padding: 6px 12px; background: var(--bg); }
.qty-control input { width: 50px; text-align: center; border: none; outline: none; padding: 6px 0; font-size: 14px; -moz-appearance: textfield; }
.qty-control input::-webkit-outer-spin-button, .qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pd-actions { display: flex; gap: 12px; margin-top: 20px; }
.btn { padding: 12px 28px; border-radius: 24px; font-weight: 600; font-size: 14px; transition: .2s; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Cart ===== */
.cart-table { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.cart-item { display: grid; grid-template-columns: 80px 1fr 100px 140px 100px 60px; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.cart-item .ci-img { width: 80px; height: 80px; background: linear-gradient(135deg, var(--secondary-light), var(--primary-light)); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 40px; }
.cart-item .ci-name { font-weight: 500; }
.cart-item .ci-meta { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.cart-item .ci-price { color: var(--primary); font-weight: 600; }
.cart-item .ci-total { color: var(--primary); font-weight: 700; }
.cart-summary { background: #fff; border-radius: var(--radius); padding: 20px 24px; margin-top: 16px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.cart-summary .total { font-size: 20px; }
.cart-summary .total strong { color: var(--primary); font-size: 26px; }

/* ===== Forms ===== */
.form-card { background: #fff; border-radius: var(--radius); padding: 32px; max-width: 440px; margin: 30px auto; box-shadow: var(--shadow); }
.form-card.wide { max-width: 720px; }
.form-card h2 { text-align: center; margin-bottom: 24px; color: var(--primary); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: .2s; font-family: inherit; background: #fff;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--primary); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.form-actions .btn { flex: 1; }
.form-switch { text-align: center; margin-top: 14px; font-size: 14px; color: var(--text-light); }
.form-switch a { color: var(--primary); font-weight: 500; }

/* ===== Order ===== */
.order-card { background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.order-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px dashed var(--border); margin-bottom: 14px; }
.order-no { color: var(--text-light); font-size: 13px; }
.order-no strong { color: var(--text); font-family: monospace; }
.status-tag { padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.status-pending { background: #fff3e0; color: var(--warning); }
.status-paid { background: #e3f2fd; color: #1976d2; }
.status-shipped { background: #f3e5f5; color: #7b1fa2; }
.status-completed { background: var(--secondary-light); color: var(--secondary-dark); }
.status-cancelled { background: #f5f5f5; color: var(--text-light); }
.order-items { display: flex; flex-direction: column; gap: 8px; }
.order-item-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.order-item-row .oi-img { width: 50px; height: 50px; background: linear-gradient(135deg, var(--secondary-light), var(--primary-light)); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.order-item-row .oi-info { flex: 1; }
.order-item-row .oi-info strong { font-weight: 500; }
.order-item-row .oi-info small { color: var(--text-light); display: block; margin-top: 2px; }
.order-foot { padding-top: 14px; margin-top: 8px; border-top: 1px dashed var(--border); display: flex; justify-content: space-between; align-items: center; }
.order-total { font-size: 16px; }
.order-total strong { color: var(--primary); font-size: 22px; }
.order-actions { display: flex; gap: 8px; }
.order-actions .btn { padding: 6px 14px; font-size: 13px; }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty .icon { font-size: 80px; margin-bottom: 12px; opacity: .6; }
.empty p { font-size: 14px; margin-bottom: 16px; }

/* ===== Toast ===== */
.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 12px 22px; border-radius: 24px; font-size: 14px; z-index: 1000; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.success { background: var(--secondary); }
.toast.error { background: var(--danger); }

/* ===== Footer ===== */
.footer { background: #2c2c2c; color: #999; padding: 30px 20px; margin-top: 50px; text-align: center; font-size: 13px; }
.footer .logo { justify-content: center; color: #fff; margin-bottom: 10px; }
.footer p { margin-bottom: 4px; }

/* ===== Admin ===== */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-sidebar { background: linear-gradient(180deg, #2c3e2d, #1d2a1e); color: #fff; padding: 24px 0; }
.admin-sidebar .logo { padding: 0 20px 24px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 16px; color: #fff; }
.admin-sidebar .logo .leaf { color: #8bc34a; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 12px 24px; font-size: 14px; transition: .2s; cursor: pointer; }
.admin-nav a:hover { background: rgba(255,255,255,.08); }
.admin-nav a.active { background: var(--primary); }
.admin-main { background: var(--bg); padding: 24px 28px; overflow: auto; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-topbar h1 { font-size: 22px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card.green .value { color: var(--secondary); }
.data-table { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); overflow-x: auto; }
.data-table h3 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.data-table h3 .alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table th { background: var(--bg); color: var(--text-light); font-weight: 500; font-size: 13px; }
table tr:hover { background: var(--bg); }
.stock-warn { color: var(--danger); font-weight: 600; }
.tbl-actions { display: flex; gap: 6px; }
.tbl-actions button { padding: 4px 10px; border-radius: 4px; font-size: 12px; }
.btn-mini-edit { background: var(--secondary-light); color: var(--secondary-dark); }
.btn-mini-del { background: #ffebee; color: var(--danger); }
.btn-mini-edit:hover { background: var(--secondary); color: #fff; }
.btn-mini-del:hover { background: var(--danger); color: #fff; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 500px; width: 90%; max-height: 90vh; overflow: auto; }
.modal h3 { margin-bottom: 16px; }

/* ===== Mobile responsive ===== */
@media (max-width: 768px) {
  .header-inner { padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .logo { font-size: 18px; }
  .search-bar { order: 3; flex-basis: 100%; max-width: none; }
  .nav-actions a, .nav-actions button { padding: 6px 8px; font-size: 13px; }
  .container { padding: 14px; }
  .carousel { height: 200px; }
  .carousel-slide { padding: 0 24px; }
  .carousel-slide h2 { font-size: 22px; }
  .carousel-slide p { font-size: 13px; }
  .carousel-slide .slide-emoji { font-size: 80px; }
  .category-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .category-card { padding: 12px 4px; }
  .category-card .icon { font-size: 28px; }
  .category-card .name { font-size: 12px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card .img-box { height: 130px; font-size: 60px; }
  .product-card .name { font-size: 13px; min-height: 36px; }
  .product-card .price { font-size: 16px; }
  .product-detail { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .product-detail .img-large { font-size: 120px; }
  .product-detail .pd-name { font-size: 20px; }
  .product-detail .pd-price { font-size: 26px; }
  .cart-item { grid-template-columns: 60px 1fr 70px; grid-template-rows: auto auto; gap: 8px; padding: 12px 0; }
  .cart-item .ci-img { width: 60px; height: 60px; font-size: 30px; grid-row: span 2; }
  .cart-item .ci-price-wrap { grid-column: 2; font-size: 13px; }
  .cart-item .ci-qty-wrap { grid-column: 2; }
  .cart-item .ci-del { grid-column: 3; grid-row: 1; }
  .cart-item .ci-total-wrap { grid-column: 3; grid-row: 2; text-align: right; }
  .form-card { padding: 22px; margin: 16px auto; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: flex; overflow-x: auto; padding: 8px; }
  .admin-sidebar .logo { display: none; }
  .admin-nav { display: flex; gap: 4px; }
  .admin-nav a { padding: 8px 12px; white-space: nowrap; }
  .admin-main { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 22px; }
}
