/* =============================================================================
   POS storefront + back-office shared styles.
   Mobile-first; on desktop the content floats as a centered card panel over a
   soft surface, with multi-column grids so it never reads as a bare strip.
   Visual language: modern, bright, vibrant — clean airy surfaces, soft cool
   shadows, generous radii, lively colour accents. The storefront accent
   (--primary) is the tenant's brand colour (set at runtime); the extra colour
   comes from brand-safe accents (gradient actions, multi-colour category chips,
   vibrant pills, colour-coded back-office cards), never by overriding the brand.
   ============================================================================= */
/* Smooth same-origin page navigations (back-office + storefront): the browser
   cross-fades the outgoing/incoming documents instead of a hard flash. Must be a
   render-blocking rule (here, not injected by script) so the browser opts in
   before first paint. Unsupported browsers (older LINE webviews) ignore it and
   fall back to a normal load. */
@view-transition { navigation: auto; }
html { background: var(--app-bg, #f1f4fb); }   /* avoid a white flash on browsers without view-transitions */
:root {
  --primary:       #16a34a;     /* default; storefront overrides with tenant theme */
  --primary-dark:  #14823c;
  --primary-light: #e7f6ec;
  --on-primary:    #ffffff;

  --fg:       #1f2430;          /* crisp ink */
  --muted:    #6b7280;          /* cool grey */
  --line:     #e6e9f2;          /* clean hairline */
  --line-soft:#eef1f8;

  --app-bg:   #f1f4fb;          /* airy cool-light page background */
  --surface:  #ffffff;          /* clean white: content panel + cards */
  --surface-2:#f3f5fb;          /* soft fill: chips, inputs, thumbs */
  --card:     var(--surface-2);

  --radius:    16px;
  --radius-sm: 11px;
  --radius-lg: 24px;
  --maxw:      min(1280px, 94vw);   /* storefront fills the desktop screen; admin has its own wider rule */

  /* soft cool shadows for a clean modern lift */
  --shadow-sm: 0 1px 2px rgba(30,41,72,.06), 0 1px 1px rgba(30,41,72,.04);
  --shadow-md: 0 8px 24px rgba(30,41,72,.10), 0 3px 8px rgba(30,41,72,.06);
  --shadow-lg: 0 24px 56px rgba(30,41,72,.15), 0 8px 20px rgba(30,41,72,.08);
  --ring:      0 0 0 3px rgba(22,163,74,.18);

  /* decorative masks (brand-tinted via mask; guarded by @supports below) */
  --mag:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  /* hero watermark = a scattered sparkle field (8 stars, varied sizes), masked +
     brand-tinted; spans the whole hero behind the logo/text */
  --spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 100'%3E%3Cg transform='translate(45 35) scale(.5)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(100 72) scale(.34)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(150 26) scale(.42)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(205 55) scale(.68)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(255 30) scale(.52)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(283 74) scale(.4)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(122 50) scale(.26)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3Cg transform='translate(75 60) scale(.24)'%3E%3Cpath d='M0 -32 C3 -6 6 -3 32 0 C6 3 3 6 0 32 C-3 6 -6 3 -32 0 C-6 -3 -3 -6 0 -32 Z'/%3E%3C/g%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { margin: 0; }
body {
  font: 16px/1.55 -apple-system, "Noto Sans Thai", "Sukhumvit Set", system-ui, sans-serif;
  color: var(--fg); background: var(--app-bg);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .002em;
}

/* content panel ------------------------------------------------------------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 0 18px 108px; background: var(--surface); min-height: 100vh; }
@media (min-width: 760px) {
  body { padding: 8px 0 44px; }
  .wrap {
    max-width: var(--maxw); margin: 30px auto; min-height: auto;
    padding: 18px 36px 48px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  }
}

/* header / branding --------------------------------------------------------- */
.shop-head { display: flex; align-items: center; gap: 15px; padding: 22px 0 14px; }
.shop-logo {
  width: 60px; height: 60px; border-radius: 16px; object-fit: cover; background: var(--surface-2);
  flex: 0 0 auto; box-shadow: var(--shadow-sm); border: 1px solid var(--line-soft);
}
.shop-name { font-size: 23px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.shop-desc { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }

/* storefront hero header — big logo card + name on a soft branded panel ------ */
.shop-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 18px; margin: 14px 0 14px; padding: 20px 22px;
  border-radius: 26px; border: 1px solid var(--line-soft);
  background: linear-gradient(135deg, var(--primary-light), var(--surface) 78%);
  box-shadow: var(--shadow-md);
}
.shop-hero .shop-logo {
  width: 96px; height: 96px; border-radius: 22px; object-fit: cover; background: #fff;
  border: 3px solid #fff; box-shadow: var(--shadow-md); flex: 0 0 auto;
  position: relative; z-index: 1;   /* above the sparkle watermark */
}
.shop-hero .shop-meta { min-width: 0; position: relative; z-index: 1; }
.shop-hero .shop-name { font-size: 27px; line-height: 1.12; }
.shop-hero .shop-accent { width: 52px; height: 4px; border-radius: 999px; background: var(--primary); margin: 9px 0; }
.shop-hero .shop-desc { font-size: 14px; margin: 0; }
@media (max-width: 360px) { .shop-hero .shop-logo { width: 76px; height: 76px; } .shop-hero .shop-name { font-size: 23px; } }

/* quick actions under the hero — ONE row of tappable tiles (circular icon + label).
   Shops show 2–4 (rewards + orders always; courses/passes when sold). flex:1 1 0 makes
   however many there are share the row equally, so 4 stay a single row on mobile too
   (not 2×2). nowrap + min-width:0 + break-anywhere guarantees the row never wraps.
   The storefront is light-theme only, so the pastel card tints below are safe. */
.quick-row { display: flex; flex-wrap: nowrap; gap: 8px; padding: 0 0 14px; }
.quick-btn {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; gap: 7px; padding: 13px 6px; text-align: center;
  border-radius: 18px; font-weight: 800; font-size: 12px; line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line-soft); background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .12s, filter .15s;
}
.quick-btn:active { transform: scale(.98); }
.quick-btn .qic { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 21px; background: var(--surface-2); flex: 0 0 auto; }
.quick-btn .qlabel { width: 100%; min-width: 0; line-height: 1.2; overflow-wrap: anywhere; }
.quick-btn .qchev { display: none; }   /* tile layout: whole card is tappable, no chevron */
/* per-shortcut pastel tint (soft card wash + matching icon holder) — mirrors the icon hue */
.quick-btn.q-blue   { background: #eff6ff; border-color: #e2edfd; }  .quick-btn.q-blue   .qic { background: #dbeafe; }
.quick-btn.q-green  { background: #f0fdf4; border-color: #daf3e4; }  .quick-btn.q-green  .qic { background: #d5f5e0; }
.quick-btn.q-purple { background: #faf6ff; border-color: #eee0fb; }  .quick-btn.q-purple .qic { background: #f0e6ff; }
.quick-btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: var(--shadow-md); }
.quick-btn.primary .qic { background: rgba(255,255,255,.24); }
.quick-btn.primary .qchev { opacity: .8; }
.quick-btn.primary:hover { filter: brightness(1.04); }
/* wider screens (tablet/desktop): roomier tiles, same single row */
@media (min-width: 760px) {
  .quick-row { gap: 12px; }
  .quick-btn { gap: 9px; padding: 16px 10px; font-size: 13.5px; }
  .quick-btn .qic { width: 48px; height: 48px; font-size: 23px; }
}


/* sticky search ------------------------------------------------------------- */
.search { position: sticky; top: 0; background: var(--surface); padding: 10px 0; z-index: 5; }
.search input {
  width: 100%; padding: 14px 16px; font-size: 16px; color: var(--fg);
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); outline: none;
  transition: box-shadow .15s, border-color .15s, background .15s;
}
.search input:focus { border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
/* search magnifier — AFTER the base .search rules so padding-left wins over the
   shorthand padding above; .search is already position:sticky (a positioning
   context) so ::before anchors to it. Guarded so unsupported webviews show nothing. */
@supports ((-webkit-mask: url(x)) or (mask: url(x))) {
  .search input { padding-left: 44px; }
  .search::before {
    content: ""; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); z-index: 1;
    width: 18px; height: 18px; background: var(--primary); pointer-events: none;
    -webkit-mask: var(--mag) center/contain no-repeat; mask: var(--mag) center/contain no-repeat;
  }
}

/* chips (category / order filters) ------------------------------------------ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 16px; scrollbar-width: none; flex-wrap: wrap; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 0 17px; min-height: 39px; border-radius: 999px; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm);
  transition: transform .08s, background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-md); }
/* multi-colour category chips (colour comes from --cc, set per chip) */
.chip.cc { color: var(--cc); border-color: var(--line); }
.chip.cc[aria-pressed="true"] { background: var(--cc); border-color: var(--cc); color: #fff; box-shadow: 0 6px 16px -2px var(--cc); }
.chip .chip-ic { margin-right: 6px; font-size: 15px; line-height: 1; }

/* product grid -------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.store-pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin: 16px 0 4px; }
.store-pager .pg { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm); }
.store-pager .pg.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.store-pager .pg:disabled { opacity: .4; cursor: default; }
.store-pager .pg-dots { color: var(--muted); padding: 0 2px; }
.card {
  position: relative;
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; background: var(--surface);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; height: 100%; box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card.dim { opacity: .55; }
.thumb { aspect-ratio: 1/1; background: var(--surface-2); width: 100%; object-fit: cover; transition: transform .25s ease; }
.card:hover .thumb { transform: scale(1.045); }
.thumb.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 30px; }
.card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
/* clamp name to 2 lines + reserve that height so price/button line up across cards */
.card-name { font-weight: 700; font-size: 15px; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.card-price { color: var(--primary); font-weight: 800; }
/* pin the call-to-action to the bottom so every card's button aligns on one line */
.card-body .add-btn, .card-body .badge-off { margin-top: auto; }
.badge-off { align-self: flex-start; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; padding: 1px 7px; }
/* product badges (🔥 ขายดี / ⭐ แนะนำ) — overlay the image corner so they never
   push the price row down; stacked top-right, clear of the number tag on the photo */
.card-badges { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.badge-hot, .badge-star { font-size: 11px; font-weight: 700; border-radius: 7px; padding: 2px 8px; line-height: 1.5; white-space: nowrap; box-shadow: 0 1px 5px rgba(15, 23, 42, .16); }
.badge-hot { color: #c2410c; background: #fff1e6; border: 1px solid #fdba74; }
.badge-star { color: #a16207; background: #fefce8; border: 1px solid #fde047; }

/* states -------------------------------------------------------------------- */
.state { text-align: center; color: var(--muted); padding: 46px 16px; }
.state.err { color: #dc2626; }
.retry { margin-top: 12px; min-height: 44px; padding: 12px 20px; font-size: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); cursor: pointer; }

/* product detail ------------------------------------------------------------ */
.detail-img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: var(--surface-2); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.detail-name { font-size: 25px; font-weight: 800; margin: 16px 0 4px; letter-spacing: -.02em; }
.detail-price { font-size: 21px; color: var(--primary); font-weight: 800; }
.detail-desc { color: var(--muted); margin-top: 10px; white-space: pre-wrap; }
.back { display: inline-block; padding: 10px 0; color: var(--primary); text-decoration: none; font-weight: 700; }
.back:hover { text-decoration: underline; }

/* buttons ------------------------------------------------------------------- */
.btn-primary, .btn-ghost, .btn-start, .btn-finish, .btn-handoff {
  min-height: 50px; padding: 12px 20px; font-size: 16px; font-weight: 700;
  border-radius: 14px; cursor: pointer; border: 1px solid var(--primary);
  transition: transform .08s, box-shadow .12s, background .15s, filter .15s; line-height: 1.2;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; width: 100%; box-shadow: var(--shadow-md); }
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; box-shadow: none; filter: none; }
.btn-ghost { background: var(--surface); color: var(--fg); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); }
.muted { color: var(--muted); }

/* semantic action buttons (kitchen flow: distinct hues so steps aren't confused) */
.btn-start, .btn-finish, .btn-handoff { color: #fff; box-shadow: var(--shadow-sm); }
.btn-start   { background: #f97316; border-color: #f97316; }   /* เริ่มทำ — orange */
.btn-start:hover   { filter: brightness(1.04); }
.btn-finish  { background: #2563eb; border-color: #2563eb; }   /* ทำเสร็จ — blue   */
.btn-finish:hover  { filter: brightness(1.04); }
.btn-handoff { background: #16a34a; border-color: #16a34a; }   /* รับ/ส่งแล้ว — green */
.btn-handoff:hover { filter: brightness(1.04); }
.btn-start:active, .btn-finish:active, .btn-handoff:active { transform: translateY(1px); }
.btn-start:disabled, .btn-finish:disabled, .btn-handoff:disabled { opacity: .5; box-shadow: none; }

/* sticky add-to-cart bar ---------------------------------------------------- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 13px 16px;
  background: rgba(255,255,255,.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center;
  max-width: 640px; margin: 0 auto; box-shadow: 0 -8px 24px rgba(30,41,72,.08);
}
.cart-bar .grow { flex: 1; font-weight: 600; }
.cart-bar a, .cart-bar button { text-decoration: none; }
.add-btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; font-weight: 800; cursor: pointer; font-size: 20px; box-shadow: var(--shadow-sm); transition: transform .08s, filter .15s; }
.add-btn:active { transform: scale(.94); }
@media (min-width: 760px) { .cart-bar { max-width: var(--maxw); border-radius: 18px 18px 0 0; } }

/* line items (cart / order / lists) ----------------------------------------- */
.line { display: flex; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.line:last-child { border-bottom: 0; }
.line .grow { flex: 1; min-width: 0; }
.line .name { font-weight: 700; letter-spacing: -.01em; }
.line .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.qty { display: inline-flex; align-items: center; gap: 12px; margin-top: 8px; }
.qty button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 18px; cursor: pointer; }
.qty button:active { transform: scale(.95); }
.line .price { font-weight: 800; color: var(--primary); white-space: nowrap; }
.note-in { width: 100%; margin-top: 8px; padding: 9px 10px; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }

/* totals + forms ------------------------------------------------------------ */
.totals { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 19px; font-weight: 800; padding: 16px 0; border-top: 1px dashed var(--line); margin-top: 6px; }
.field { margin: 14px 0; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px;
  box-sizing: border-box; background: var(--surface-2); color: var(--fg); outline: none; transition: box-shadow .15s, border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.collapse summary { cursor: pointer; font-weight: 700; padding: 10px 0; }

/* date-group headers + "show more" (order / reward history) ------------------ */
.group-h { font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: .03em; margin: 18px 0 2px; }
.group-h:first-child { margin-top: 6px; }
.more-btn { display: block; width: 100%; margin: 14px 0 0; min-height: 46px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--primary); font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm); }
.more-btn:hover { background: var(--surface-2); }
/* compact order/history row as a tappable card */
.ord-card { display: flex; gap: 12px; align-items: center; padding: 13px 15px; margin: 9px 0; border: 1px solid var(--line-soft); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; transition: transform .1s, box-shadow .12s; }
.ord-card:active { transform: scale(.99); }
.ord-card .grow { flex: 1; min-width: 0; }
.ord-card .right { text-align: right; flex: 0 0 auto; }
.ord-card .ord-thumb { width: 46px; height: 46px; border-radius: 11px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.ord-card .ord-thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.ord-card.dim { opacity: .58; }

/* rewards page: hero + featured reward + section header ----------------------- */
.reward-hero { position: relative; overflow: hidden; border-radius: 24px; padding: 20px 22px; margin: 6px 0 16px; border: 1px solid var(--line-soft); background: linear-gradient(135deg, var(--primary-light), var(--surface) 80%); box-shadow: var(--shadow-md); }
.reward-hero .rh-titlerow { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.reward-hero .rh-gift { width: 50px; height: 50px; border-radius: 15px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 26px; box-shadow: var(--shadow-sm); flex: 0 0 auto; }
.reward-hero h1 { font-size: 27px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.rh-points { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; padding: 9px 16px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 700; font-size: 15px; }
.rh-points b { color: var(--primary); font-size: 18px; }
.reward-hero .rh-deco { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 64px; opacity: .9; pointer-events: none; }
@media (max-width: 420px) { .reward-hero .rh-deco { display: none; } }

.reward-feat { display: flex; gap: 14px; padding: 14px; margin: 0 0 18px; border-radius: 20px; border: 1px solid var(--line-soft); background: linear-gradient(135deg, var(--primary-light), var(--surface) 85%); box-shadow: var(--shadow-sm); }
.reward-feat .feat-img { width: 128px; aspect-ratio: 1/1; object-fit: cover; border-radius: 16px; background: var(--surface-2); flex: 0 0 auto; box-shadow: var(--shadow-sm); }
.reward-feat .feat-img.ph { display: flex; align-items: center; justify-content: center; font-size: 44px; color: var(--muted); }
.reward-feat .feat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feat-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; background: var(--primary); color: #fff; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; box-shadow: var(--shadow-sm); }
.feat-name { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 9px 0 4px; }
.feat-cost b { color: var(--primary); font-size: 20px; }
.feat-stock { color: var(--muted); font-size: 13px; margin-top: 2px; }
.reward-feat .btn-primary { margin-top: 12px; }
@media (max-width: 360px) { .reward-feat .feat-img { width: 100px; } }

.sec-head { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; }
.sec-head .sec-ic { width: 34px; height: 34px; border-radius: 11px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: 0 0 auto; }
.sec-head h2 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -.01em; }

/* announced coupons (storefront home) --------------------------------------- */
.promos { margin: 2px 0 14px; }
.promos .sec-head { margin: 0 0 8px; }
.promo-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.promo-row::-webkit-scrollbar { display: none; }
.promo-card {
  flex: 0 0 auto; width: 80%; max-width: 300px; scroll-snap-align: start;
  border: 1px solid var(--line-soft); border-radius: 16px; padding: 13px 15px;
  background: linear-gradient(135deg, var(--primary-light), var(--surface) 82%);
  display: flex; flex-direction: column; gap: 3px;
}
.promo-off { color: var(--primary-dark); font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.promo-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.promo-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.promo-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.promo-code-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.promo-code {
  flex: 1 1 auto; min-width: 0; text-align: center; font-weight: 800; letter-spacing: .5px; font-size: 14px;
  color: var(--fg); background: var(--surface); border: 1px dashed var(--primary); border-radius: 8px;
  padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.promo-copy {
  flex: 0 0 auto; border: 0; border-radius: 8px; padding: 8px 13px; font: inherit; font-weight: 700;
  font-size: 13px; color: #fff; background: var(--primary); cursor: pointer; white-space: nowrap;
}
.promo-copy:active { transform: scale(.97); }
.promo-copy.done { background: var(--primary-dark); }
@media (min-width: 620px) { .promo-card { width: 290px; } }

/* storefront announcement — a compact single-line strip ---------------------- */
.announce { margin: 0 0 12px; }
.announce-card {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line-soft); border-left: 3px solid var(--primary);
  border-radius: 11px; padding: 8px 12px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.announce-ic { font-size: 15px; line-height: 1; flex: 0 0 auto; }
.announce-thumb { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex: 0 0 auto; }
/* title + body share one line and ellipsis together */
.announce-main { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; line-height: 1.5; }
.announce-title { font-weight: 800; letter-spacing: -.01em; }
.announce-text { color: var(--muted); }
.announce-title + .announce-text::before { content: "·"; margin: 0 6px; color: var(--line); }
.announce-link { flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--primary); text-decoration: none; white-space: nowrap; }
.announce-link::after { content: " ›"; }
.announce-link:active { opacity: .6; }

/* status pill --------------------------------------------------------------- */
.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 700; margin-top: 6px; }
.pill.wait   { background: #fef0c7; color: #b45309; }
.pill.paid   { background: #d1fae5; color: #047857; }
.pill.done   { background: #dbeafe; color: #1d4ed8; }
.pill.cancel { background: #fee2e2; color: #b91c1c; }

/* QR / payment -------------------------------------------------------------- */
.qr-box { text-align: center; padding: 18px; background: var(--surface-2); border-radius: var(--radius); margin: 14px 0; }
.qr-box canvas, .qr-box img { width: 240px; height: 240px; max-width: 100%; background: #fff; border-radius: 10px; }
.acct { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; }
.acct .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; }
.copy { padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; box-shadow: var(--shadow-sm); transition: background .15s; }
.copy:hover { background: var(--surface-2); }

/* modal --------------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,28,48,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-box { background: var(--surface); border-radius: 24px 24px 0 0; padding: 24px; max-width: 560px; width: 100%; box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto; }
.modal-box h2 { font-size: 19px; margin: 0 0 10px; letter-spacing: -.01em; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { width: auto; flex: 1; min-height: 46px; }
@media (min-width: 480px) { .modal-overlay { align-items: center; padding: 20px; } .modal-box { border-radius: 22px; } }

/* ---- back-office ---------------------------------------------------------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; }
.admin-head h1 { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
/* admin home hero (owner-set image on the right; falls back to an illustration) */
.admin-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px; min-height: 116px;
  margin: 8px 0 18px; padding: 22px; border-radius: 24px; border: 1px solid var(--line-soft);
  /* default neutral tint; an owner-set background image replaces this inline */
  background: linear-gradient(135deg, #eef0fb, var(--surface) 80%); box-shadow: var(--shadow-md);
}
.admin-hero .ah-logo { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 28px; box-shadow: var(--shadow-md); border: 2px solid #fff; flex: 0 0 auto; position: relative; z-index: 1; }
/* icon-only refresh floats at the page top-right, level with the "← หลังร้าน" link */
.wrap:has(.admin-hero) { position: relative; }
.ah-refresh { position: absolute; top: 6px; right: 16px; z-index: 6; width: 38px; height: 38px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line-soft); background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer;
  font-size: 17px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.ah-refresh:disabled { opacity: .7; cursor: default; }
.ah-refresh.spin { animation: ahspin .7s linear infinite; }
@keyframes ahspin { to { transform: rotate(360deg); } }
.admin-hero .ah-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.admin-hero .ah-title { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
.admin-hero .ah-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
@media (max-width: 400px) { .admin-hero .ah-title { font-size: 22px; } }
/* page-level action buttons (CSV, +add, …) relocated below the hero */
.admin-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin: -6px 0 14px; }
.admin-actions:empty { display: none; }

/* nav cards: colour icon tile + title/desc + chevron (horizontal) */
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 13px; }
.nav-card {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px; border-radius: 20px;
  border: 1px solid var(--line-soft); background: var(--surface); box-shadow: var(--shadow-sm);
  text-decoration: none; color: inherit; transition: transform .14s ease, box-shadow .14s ease;
}
.nav-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.nav-card .ic {
  width: 60px; height: 60px; border-radius: 17px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; flex: 0 0 auto; background: linear-gradient(135deg, var(--ncl, var(--surface-2)), #fff);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
}
.nav-card .body { flex: 1; min-width: 0; }
.nav-card .t { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.nav-card .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.nav-card .chev { opacity: .35; font-size: 22px; flex: 0 0 auto; }

/* footer banner on the admin home */
.nav-banner {
  display: flex; align-items: center; gap: 16px; margin-top: 16px; padding: 18px 20px; border-radius: 20px;
  border: 1px solid var(--line-soft); background: linear-gradient(135deg, #ede9fe, var(--surface) 80%); box-shadow: var(--shadow-sm);
}
.nav-banner .bic { width: 62px; height: 62px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 32px; background: var(--surface); box-shadow: var(--shadow-sm); flex: 0 0 auto; }
.nav-banner .bt { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.nav-banner .bd { color: var(--muted); font-size: 13px; margin-top: 3px; }
/* the whole back-office (home has .admin-hero, sub-pages have .admin-head) fills the
   desktop screen; the storefront keeps its centred panel. Form controls are capped
   to a readable column so settings inputs don't stretch the full width. :has is
   desktop-only here, so browsers without it fall back to the default width. */
@media (min-width: 760px) {
  .wrap:has(.admin-hero), .wrap:has(.admin-head) { max-width: min(1600px, 94vw); }
  .wrap:has(.admin-hero) .field, .wrap:has(.admin-head) .field,
  .wrap:has(.admin-hero) .btn-primary, .wrap:has(.admin-head) .btn-primary { max-width: 680px; }
  /* storefront is now wide by default (--maxw) so every customer page fills the
     screen; keep form fields + the product image in a readable column so they
     don't stretch the full width */
  .field { max-width: 720px; }
  .detail-img { max-width: 520px; }
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* phones: an admin list row is [info .grow] + [.row-actions buttons/role select].
   Let the row wrap and drop the action group to its own full-width line so the
   name/points/phone aren't crushed into a sliver. Mobile-only → desktop rows keep
   the side-by-side layout; item lines (name+price) are unaffected (their .grow
   shrinks to fit rather than triggering a wrap). */
@media (max-width: 680px) {
  .line { flex-wrap: wrap; }
  .line > .row-actions { width: 100%; }
}
/* coloured stat tiles (admin dashboards: pass --ac accent + --acl light per tile) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px; padding: 15px 16px; box-shadow: var(--shadow-sm); border-top: 3px solid var(--ac, var(--primary)); }
.stat-ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; background: var(--acl, var(--surface-2)); }
.stat-n { font-size: 25px; font-weight: 800; color: var(--ac, var(--primary)); letter-spacing: -.02em; margin-top: 10px; }
.stat-l { color: var(--muted); font-size: 13px; margin-top: 1px; }
/* clickable stat tile that jumps to its section */
.stat.go { cursor: pointer; position: relative; transition: transform .1s, box-shadow .12s; }
.stat.go:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat.go::after { content: "›"; position: absolute; top: 12px; right: 14px; color: var(--muted); font-size: 18px; line-height: 1; }
/* small stat tile — compact horizontal (icon left, number + label right) */
.stat.sm { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-top: 0; border-left: 4px solid var(--ac, var(--primary)); border-radius: 13px; }
.stat.sm .stat-ic { width: 36px; height: 36px; font-size: 17px; border-radius: 11px; margin: 0; flex: 0 0 auto; }
.stat.sm .stat-n { font-size: 19px; margin: 0; line-height: 1.15; }
.stat.sm .stat-l { font-size: 11.5px; margin: 0; }
/* stat tile that doubles as a filter (click to filter; .active = selected) */
.stat.sm.fcard { cursor: pointer; transition: transform .1s, box-shadow .12s; }
.stat.sm.fcard:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat.sm.active { background: var(--acl, #eef1ff); border-left-width: 5px; box-shadow: inset 0 0 0 2px var(--ac, var(--primary)), var(--shadow-md); transform: translateY(-1px); }
.stat.sm.active .stat-n, .stat.sm.active .stat-l { color: var(--ac, var(--primary)); }
.stat.sm.active .stat-ic { background: #fff; }
/* a row of stat cards: wraps on mobile; one narrow non-wrapping row on desktop */
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-row > .stat { flex: 1 1 132px; min-width: 0; }
.stat-row .stat-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .stat-row { flex-wrap: nowrap; } .stat-row > .stat { flex: 1 1 0; padding-left: 11px; padding-right: 11px; } .stat-row .stat-ic { width: 32px; height: 32px; font-size: 15px; } }
/* compact list row (e.g. reward catalogue) */
.ord-card.compact { padding: 9px 13px; gap: 10px; margin: 7px 0; }
.ord-card.compact .ord-thumb { width: 38px; height: 38px; }
.ord-card.compact .name { font-size: 14px; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.tag.off { color: #b91c1c; border-color: #fbcfcf; background: #fdecec; }
.tag.on  { color: #047857; border-color: #a7e8cc; background: #e6fbf1; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 0 14px; align-items: center; }
.toolbar .btn-primary { width: auto; min-height: 44px; padding: 10px 18px; }
/* unify search boxes / selects / date inputs that sit in a toolbar */
.toolbar > input, .toolbar > select {
  min-height: 44px; padding: 10px 14px; font-size: 15px; color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  outline: none; transition: box-shadow .15s, border-color .15s;
}
.toolbar > input:focus, .toolbar > select:focus { border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
/* settings: a centred column of section cards */
.set-col { max-width: 720px; margin: 0 auto; }
.set-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 18px; padding: 18px 20px 20px; margin: 16px 0; box-shadow: var(--shadow-sm); }
.set-card .sec-head { margin: 0 0 10px; }
.set-card .field:first-of-type { margin-top: 4px; }
.ok { color: #047857; }
.help { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

/* printable receipt — hidden on screen; on print, only this shows. Scoped to
   body.has-receipt so the print-isolation never blanks other pages (which have
   no #receipt and must still print/PDF their own content normally). The browser
   letterhead (page title / URL / date) is dropped via @page margin:0 set on the
   receipt page itself (orders.html), not here, so other pages keep their margins. */
#receipt { display: none; }
@media print {
  body.has-receipt > *:not(#receipt) { display: none !important; }
  body.has-receipt #receipt { display: block !important; }
  body.has-receipt { margin: 0; padding: 5mm; }
  /* thermal slips: the @page (injected by applyReceiptPaper) handles the margin,
     so drop the page padding and let the receipt fill the roll width */
  body.rcw-58, body.rcw-80 { padding: 0 !important; }
}
.receipt { width: 280px; margin: 0 auto; padding: 4px 10px; color: #000;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, monospace; line-height: 1.45; }
/* match the slip-printer roll width (58mm / 80mm); default stays 280px for A4 */
body.rcw-58 .receipt { width: 54mm; padding: 2px 2mm; }
body.rcw-80 .receipt { width: 74mm; padding: 2px 3mm; }
.rc-logo { display: block; width: 64px; height: 64px; object-fit: contain; margin: 0 auto 6px; border-radius: 8px; }
.rc-shop { text-align: center; font-weight: 800; font-size: 17px; }
.rc-addr { text-align: center; font-size: 11px; line-height: 1.35; }
.rc-sub  { text-align: center; font-size: 12px; margin: 4px 0 2px; }
.rc-meta { font-size: 12px; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 7px 0; }
.rc-line  { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin: 3px 0 0; }
.rc-line .rc-lp { white-space: nowrap; }
.rc-qd   { font-size: 11px; color: #444; margin: 0 0 2px; }
.rc-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 15px; margin-top: 5px; }
.rc-foot  { text-align: center; margin-top: 12px; font-size: 12px; }

/* printable parcel address slip (ใบปะหน้า) — same isolation trick as the receipt
   but on body.has-label, which printLabel() toggles on before window.print() and
   restores after. Sized for a 100mm parcel sticker (prints fine on A4 too). */
#label { display: none; }
@media print {
  body.has-label > *:not(#label) { display: none !important; }
  body.has-label #label { display: block !important; }
  body.has-label { margin: 0; padding: 4mm; }
}
.label { width: 100mm; margin: 0 auto; color: #000;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, sans-serif; line-height: 1.4; }
.lb-h { text-align: center; font-weight: 800; font-size: 13px; letter-spacing: .03em; margin-bottom: 6px; }
.lb-from { border: 1px solid #000; border-radius: 6px; padding: 6px 9px; font-size: 12px; line-height: 1.35; }
.lb-to { border: 2px solid #000; border-radius: 8px; padding: 10px 11px; margin-top: 7px; }
.lb-tag { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 2px; }
.lb-to-name { font-size: 19px; font-weight: 800; line-height: 1.2; }
.lb-to-line { font-size: 14.5px; line-height: 1.5; }
.lb-track { text-align: center; border: 1px dashed #000; border-radius: 6px; padding: 6px; margin-top: 7px; font-weight: 800; font-size: 15px; letter-spacing: .06em; }
.lb-cod { text-align: center; border: 2px solid #000; border-radius: 6px; padding: 7px; margin-top: 7px; font-weight: 800; font-size: 16px; }
.lb-meta { display: flex; justify-content: space-between; font-size: 11px; margin-top: 7px; }
