:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --brand: #f97316;
  --brand-2: #ef4444;
  --accent: #3b82f6;
  --green: #16a34a;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  --shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.logo {
  font-weight: 800; font-size: 1.35rem; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.logo .logo-box {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-size: 1.1rem;
}
.logo .dot { color: var(--brand); }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 14px; max-width: 460px;
}
.search input {
  border: none; outline: none; flex: 1; font-size: 0.95rem; background: transparent;
}
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.icon-btn {
  position: relative; border: 1px solid var(--border); background: #fff;
  width: 42px; height: 42px; border-radius: 12px; font-size: 1.2rem;
  display: grid; place-items: center;
}
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px;
  background: var(--brand); color: #fff; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; display: grid; place-items: center; padding: 0 5px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: none; border-radius: 11px; padding: 11px 18px;
  font-size: 0.95rem; font-weight: 600; transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-wa { background: #25d366; color: #fff; margin-top: 8px; }
.btn-wa:hover { background: #1ebc58; }
.btn-wa svg { flex-shrink: 0; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(120deg, #fff7ed 0%, #fff1f2 100%);
  border: 1px solid #fed7aa; border-radius: var(--radius);
  padding: 34px 30px; margin: 22px 0 10px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.hero h1 { margin: 0 0 6px; font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
.hero p { margin: 0; color: var(--muted); font-size: 1.02rem; }
.hero .pill {
  display: inline-block; background: #fff; border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--brand);
}

/* ---------- Categories ---------- */
.catbar {
  display: flex; gap: 10px; overflow-x: auto; padding: 16px 0 8px; scrollbar-width: none;
}
.catbar::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 9px 16px; font-size: 0.9rem; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; transition: .15s ease;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 50%; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip:hover { border-color: var(--brand); }

/* ---------- Products grid ---------- */
.section-title {
  display: flex; align-items: center; justify-content: space-between; margin: 22px 0 14px;
}
.section-title h2 { margin: 0; font-size: 1.3rem; font-weight: 700; }
.section-title .count { color: var(--muted); font-size: 0.9rem; }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: .18s ease; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-tile {
  aspect-ratio: 1 / 1; display: grid; place-items: center; font-size: 3.4rem;
  position: relative;
}
.card-tile img { width: 100%; height: 100%; object-fit: cover; }
.discount {
  position: absolute; top: 12px; left: 12px; background: var(--brand-2); color: #fff;
  font-size: 0.72rem; font-weight: 700; padding: 4px 9px; border-radius: 8px;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-cat { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card-name { font-weight: 700; margin: 4px 0 6px; font-size: 0.98rem; min-height: 2.8em; }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price { font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 0.85rem; }
.card-stock { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.card-stock.out { color: var(--brand-2); font-weight: 700; }
.add-btn { margin-top: 10px; }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .big { font-size: 3rem; display: block; margin-bottom: 10px; }

/* ---------- Drawer / modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: #fff; z-index: 95; transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column; box-shadow: -6px 0 30px rgba(0,0,0,0.12);
}
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 1.15rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px; }
.drawer-foot { padding: 16px 20px; border-top: 1px solid var(--border); background: #fafafa; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.96);
  background: #fff; z-index: 96; width: 620px; max-width: 94vw; max-height: 90vh;
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); opacity: 0; pointer-events: none;
  transition: .2s ease; display: flex; flex-direction: column;
}
.modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.close-x { border: none; background: transparent; font-size: 1.6rem; color: var(--muted); line-height: 1; }

/* ---------- Cart items ---------- */
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-thumb {
  width: 54px; height: 54px; border-radius: 10px; display: grid; place-items: center; font-size: 1.6rem; flex-shrink: 0;
}
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-weight: 600; font-size: 0.9rem; }
.cart-meta { color: var(--muted); font-size: 0.8rem; }
.qty { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; }
.qty button { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--border); background: #fff; font-weight: 700; }
.cart-price { font-weight: 700; white-space: nowrap; }
.cart-item .rm { border: none; background: transparent; color: var(--brand-2); font-size: 0.8rem; }

.total-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-size: 0.95rem; }
.total-row.grand { color: var(--ink); font-weight: 800; font-size: 1.1rem; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 12px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font-size: 0.95rem; font-family: inherit; background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.pay-option {
  display: flex; align-items: center; gap: 12px; border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px; margin-bottom: 10px; cursor: pointer; transition: .12s ease;
}
.pay-option:hover { border-color: var(--brand); }
.pay-option.selected { border-color: var(--brand); background: #fff7ed; }
.pay-option .ico { font-size: 1.5rem; }
.pay-option .lab { font-weight: 600; font-size: 0.95rem; }
.pay-option .sub { font-size: 0.78rem; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 12px;
  font-weight: 600; z-index: 120; opacity: 0; transition: .25s ease; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: #dc2626; }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border); margin-top: 48px; background: #fff; }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 32px 20px; display: grid; gap: 26px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.footer-inner h4 { margin: 0 0 10px; font-size: 0.95rem; }
.footer-inner p, .footer-inner li { color: var(--muted); font-size: 0.88rem; margin: 4px 0; }
.footer-inner ul { list-style: none; padding: 0; }

/* ---------- Admin ---------- */
.admin-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 18px 0; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 1.7rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 0.85rem; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { background: #fafafa; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.tag.en_attente { background: #fef3c7; color: #92400e; }
.tag.confirmee { background: #dbeafe; color: #1d4ed8; }
.tag.payée { background: #dcfce7; color: #166534; }
.tag.livrée { background: #d1fae5; color: #065f46; }
.tag.annulée { background: #fee2e2; color: #b91c1c; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button { border: none; background: transparent; padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.login-wrap { max-width: 380px; margin: 80px auto; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }

.hidden { display: none !important; }
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .modal { width: 96vw; }
}
