:root {
  --brand: #d10a5b;
  --brand-dark: #a80748;
  --brand-soft: #ffe3ef;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #ececf1;
  --bg: #f6f6f9;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 20, 40, .06);
  --shadow-lg: 0 10px 30px rgba(20, 20, 40, .12);
  --max: 1080px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Sarabun", "Noto Sans Thai", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; box-shadow: var(--shadow);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: cover; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; opacity: .9; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cart-btn {
  position: relative; background: rgba(255,255,255,.16); color: #fff;
  border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer;
  font-size: 14px;
}
.cart-btn .count {
  position: absolute; top: -7px; right: -7px; background: #fff; color: var(--brand);
  border-radius: 999px; min-width: 20px; height: 20px; font-size: 12px; font-weight: 800;
  display: grid; place-items: center; padding: 0 5px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; padding: 8px 0 26px;
}
.hero .wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: center; }
.hero h1 { font-size: 30px; margin: 6px 0 8px; line-height: 1.2; }
.hero p { margin: 0 0 16px; opacity: .95; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: rgba(255,255,255,.18); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; }
.hero-img { border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
@media (max-width: 720px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .hero-img { display: none; }
}

/* ---------- Sections ---------- */
.section { padding: 26px 0; }
.section h2 { font-size: 21px; margin: 0 0 4px; }
.section .sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ---------- Product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px){ .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px){ .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s;
  border: 1px solid var(--line);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card .thumb { aspect-ratio: 1/1; background: #fafafb; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .name { font-weight: 600; font-size: 14px; line-height: 1.35; }
.card .meta { color: var(--muted); font-size: 12.5px; }
.card .price { color: var(--brand); font-weight: 800; font-size: 17px; margin-top: 2px; }
.card .price small { color: var(--muted); font-weight: 500; font-size: 12px; }
.card .btn { margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 700; font-size: 14.5px; cursor: pointer;
  font-family: inherit; transition: background .12s;
}
.btn:hover { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Order table (page 2) ---------- */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 18px;
}
.order-rows { width: 100%; }
.order-row {
  display: grid; grid-template-columns: 64px 1fr 130px 96px; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.order-row:last-child { border-bottom: 0; }
.order-row .rthumb { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: #fafafb; }
.order-row .rthumb img { width: 100%; height: 100%; object-fit: cover; }
.order-row .rname { font-weight: 600; font-size: 14.5px; }
.order-row .rmeta { color: var(--muted); font-size: 12.5px; }
.order-row .rline { text-align: right; font-weight: 700; min-width: 90px; }
.order-row .rline small { display:block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
@media (max-width: 620px){
  .order-row { grid-template-columns: 52px 1fr auto; grid-template-areas: "t n l" "t q l"; row-gap: 6px; }
  .order-row .rthumb { grid-area: t; width: 52px; height: 52px; }
  .order-row .rinfo { grid-area: n; }
  .order-row .stepper { grid-area: q; }
  .order-row .rline { grid-area: l; }
}

/* stepper */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 34px; height: 36px; border: 0; background: #f4f4f7; font-size: 18px; font-weight: 700; cursor: pointer; color: var(--brand); }
.stepper button:hover { background: var(--brand-soft); }
.stepper input { width: 48px; height: 36px; border: 0; text-align: center; font-size: 15px; font-weight: 700; font-family: inherit; }
.stepper input:focus { outline: none; }

/* ---------- Summary / sticky ---------- */
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14.5px; }
.summary-line.total { border-top: 2px dashed var(--line); margin-top: 8px; padding-top: 12px; font-size: 20px; font-weight: 800; }
.summary-line.total .v { color: var(--brand); }
.muted { color: var(--muted); }

.field { margin-bottom: 13px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px){ .row2 { grid-template-columns: 1fr; } }

.layout2 { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.layout2 .side { position: sticky; top: 78px; }
@media (max-width: 860px){ .layout2 { grid-template-columns: 1fr; } .layout2 .side { position: static; } }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.pay { background: #fff4e5; color: var(--warn); }
.badge.paid { background: #e7f8ee; color: var(--ok); }
.badge.check { background: #eef2ff; color: #4f46e5; }
.badge.cancel { background: #fdeaea; color: #dc2626; }
.badge.ship { background: var(--brand-soft); color: var(--brand); }

/* ---------- Payment ---------- */
.qr-box { text-align: center; padding: 8px; }
.qr-box .qr { width: 250px; height: 250px; margin: 6px auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.qr-box .amount { font-size: 30px; font-weight: 800; color: var(--brand); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #1f2430; color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer { background: #1f2430; color: #cfd2da; padding: 26px 0; margin-top: 34px; font-size: 14px; }
.site-footer a { color: #fff; font-weight: 600; }
.site-footer .cols { display: flex; flex-wrap: wrap; gap: 26px; justify-content: space-between; }

.line-btn { background: #06c755; color:#fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; display: inline-flex; gap: 8px; align-items: center; }

.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.spinner { text-align: center; padding: 60px 0; color: var(--muted); }

/* breadcrumb / steps */
.steps { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin: 16px 0; flex-wrap: wrap; }
.steps b { color: var(--brand); }
