/* ============================================================
   HUSO Merch Store — Theme
   คณะมนุษยศาสตร์และสังคมศาสตร์ มหาวิทยาลัยราชภัฏนครราชสีมา
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  /* โทนสีอ้างอิงจากโลโก้สโมสรนักศึกษา HS — ชมพูบานเย็น → ม่วง */
  --ink:        #2A1526;
  --ink-soft:   #6A5265;
  --ink-faint:  #9B8394;
  --line:       #F2DEE9;
  --line-soft:  #FAF0F5;
  --paper:      #FDF8FB;
  --card:       #FFFFFF;

  --brand:      #D62C7C;   /* ชมพูหลัก (จาก H ในโลโก้) */
  --brand-2:    #8B3DBE;   /* ม่วง (จาก S ในโลโก้) */
  --brand-dk:   #3E1B52;   /* ม่วงเข้ม — แถบหัว/ท้าย/แถบข้าง */
  --brand-lt:   #FCE6F0;   /* ชมพูอ่อน */
  --accent:     #7C3FC0;   /* ม่วงเน้น */
  --accent-lt:  #F2E8FC;
  --petal:      #F262A7;   /* ชมพูกลีบซากุระ */

  --ok:         #2E7D5B;
  --ok-lt:      #E4F2EB;
  --warn:       #B0741A;
  --warn-lt:    #FDF1DE;
  --info:       #6E33B0;
  --info-lt:    #F0E7FB;
  --danger:     #C0334F;
  --danger-lt:  #FBEAEE;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;
  --shadow:    0 1px 2px rgba(42,21,38,.06), 0 8px 24px rgba(42,21,38,.06);
  --shadow-lg: 0 2px 6px rgba(42,21,38,.08), 0 18px 48px rgba(139,61,190,.14);
  --wrap: 1180px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Sans Thai', 'Segoe UI', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p  { margin: 0 0 1em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .88rem; }
.tnum  { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center{ text-align: center; }
.mt0 { margin-top: 0 } .mb0 { margin-bottom: 0 }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--brand-dk);
  color: #E3CFE0;
  font-size: .8rem;
  padding: 7px 0;
  letter-spacing: .01em;
}
.topbar .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.site-header .wrap {
  display: flex; align-items: center; gap: 20px;
  min-height: 74px;
}
/* ชื่อร้านยอมหดได้ แต่ห้ามดันเมนูจนคำแตกบรรทัด */
.brand {
  display: flex; align-items: center; gap: 12px; color: var(--brand);
  flex: 0 1 auto; min-width: 0;
}
.brand img { width: 46px; height: 46px; flex: none; object-fit: contain; }
.brand-txt { min-width: 0; }
.brand-txt b {
  display: block; font-size: 1.02rem; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.15; white-space: nowrap;
}
.brand-txt span {
  display: block; font-size: .7rem; color: var(--ink-faint); letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42ch;
}

.nav {
  display: flex; gap: 4px; margin-left: auto; align-items: center;
  flex: none;                       /* เมนูไม่ยอมหด */
}
.nav a {
  padding: 8px 14px; border-radius: 999px; font-size: .92rem; font-weight: 500;
  color: var(--ink-soft); transition: .15s;
  white-space: nowrap;              /* ★ กันคำแตกบรรทัด */
}
.nav a:hover { background: var(--line-soft); color: var(--ink); }
.nav a.active { background: var(--brand-lt); color: var(--brand); font-weight: 600; }

/* กลุ่มปุ่มผู้ใช้ (ชื่อ · แอดมิน · ออกจากระบบ) */
.nav-user {
  display: flex; align-items: center; gap: 6px;
  margin-left: 8px; padding-left: 12px;
  border-left: 1px solid var(--line);
  flex: none;
}
.nav-name { max-width: 160px; overflow: hidden; }
.nav-name span {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-mini {
  font-size: .82rem !important; color: var(--ink-faint) !important;
  padding: 6px 8px !important; white-space: nowrap;
}
.nav-mini:hover { color: var(--brand) !important; background: var(--brand-lt) !important; }

.cart-btn { position: relative; }
.cart-count {
  position: absolute; top: 0; right: 2px;
  background: var(--accent); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 1;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; display: grid; place-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--r-sm);
  font-family: inherit; font-size: .93rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: .15s;
  background: var(--brand); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--brand-dk); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-lg { padding: 14px 26px; font-size: 1rem; width: 100%; }
.btn-sm { padding: 7px 13px; font-size: .82rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-accent { background: linear-gradient(135deg, var(--brand), #B23BA0); }
.btn-accent:hover { background: linear-gradient(135deg, #BD1E6C, var(--brand-2)); }
.btn-danger { background: transparent; color: var(--danger); border-color: #EFC9D3; }
.btn-danger:hover { background: var(--danger-lt); color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Cards & panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 24px;
}
.panel + .panel { margin-top: 18px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { margin: 0; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #B23BA0 45%, var(--brand-2) 100%);
  color: #fff; padding: 56px 0 60px; margin-bottom: 40px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -80px; top: -80px;
  width: 340px; height: 340px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.hero .wrap { position: relative; }
.hero .eyebrow {
  font-size: .78rem; letter-spacing: .18em; text-transform: uppercase;
  color: #FFDCEC; font-weight: 600; margin-bottom: 10px;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 12px; max-width: 18ch; }
.hero p { color: rgba(255,255,255,.88); max-width: 52ch; margin-bottom: 0; }
.hero::before {
  content: ''; position: absolute; left: -60px; bottom: -120px;
  width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}

/* ---------- Product grid ---------- */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 22px; flex-wrap: wrap;
}
.section-head h2 { margin: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 15px; border-radius: 999px; font-size: .85rem; font-weight: 500;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.grid-products {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
}

.pcard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
  display: flex; flex-direction: column;
  transition: .2s; position: relative;
}
.pcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: #E7C4DA; }
.pcard-media { position: relative; aspect-ratio: 1/1; background: var(--line-soft); overflow: hidden; }
.pcard-media img { width: 100%; height: 100%; object-fit: cover; transition: .35s; }
.pcard:hover .pcard-media img { transform: scale(1.04); }
.pcard-body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard-name { font-weight: 600; font-size: .98rem; line-height: 1.4; }
.pcard-cat { font-size: .78rem; color: var(--ink-faint); }
.pcard-price {
  margin-top: auto; padding-top: 10px;
  font-size: 1.12rem; font-weight: 700; color: var(--brand);
}
.pcard-price small { font-size: .72rem; font-weight: 500; color: var(--ink-faint); }

.badge-corner {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: rgba(62,27,82,.86); color: #fff; backdrop-filter: blur(4px);
  font-size: .72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.badge-corner.hot  { background: rgba(214,44,124,.94); }
.badge-corner.soon { background: rgba(124,63,192,.92); }
.badge-3d {
  position: absolute; bottom: 12px; right: 12px; z-index: 2;
  background: rgba(255,255,255,.94); color: var(--brand);
  font-size: .7rem; font-weight: 700; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line);
}

/* ---------- Product detail ---------- */
.pdp { display: grid; grid-template-columns: 1.15fr .85fr; gap: 44px; align-items: start; }

.gallery-main {
  aspect-ratio: 1/1; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line);
  overflow: hidden; margin-bottom: 12px; position: relative;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.gallery-thumbs button {
  padding: 0; aspect-ratio: 1/1; border-radius: var(--r-sm); overflow: hidden;
  border: 2px solid var(--line); background: var(--card); cursor: pointer; transition: .15s;
}
.gallery-thumbs button:hover { border-color: var(--ink-faint); }
.gallery-thumbs button.active { border-color: var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumb-3d {
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  color: var(--brand); background: var(--brand-lt); height: 100%;
}

.pdp-info h1 { font-size: 1.7rem; margin-bottom: 6px; }
.pdp-cat { font-size: .82rem; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 14px; }
.pdp-price { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.2; }
.pdp-price small { font-size: .85rem; font-weight: 500; color: var(--ink-faint); }
.pdp-desc { color: var(--ink-soft); margin: 16px 0 4px; }

.field { margin: 20px 0; }
.field > label, .flabel {
  display: block; font-size: .86rem; font-weight: 600; margin-bottom: 8px; color: var(--ink);
}
.flabel .hint { font-weight: 400; color: var(--ink-faint); font-size: .8rem; }

.size-opts { display: flex; gap: 9px; flex-wrap: wrap; }
.size-opt { position: relative; }
.size-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.size-opt span {
  display: grid; place-items: center; min-width: 54px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 600; background: var(--card);
  cursor: pointer; transition: .15s; line-height: 1.2; text-align: center;
}
.size-opt span em { display: block; font-style: normal; font-size: .7rem; font-weight: 500; color: var(--ink-faint); }
.size-opt input:checked + span { border-color: var(--brand); background: var(--brand-lt); color: var(--brand); }
.size-opt input:checked + span em { color: var(--brand); }
.size-opt input:disabled + span { opacity: .38; cursor: not-allowed; text-decoration: line-through; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--card); }
.qty button { width: 40px; height: 42px; border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; color: var(--ink-soft); }
.qty button:hover { background: var(--line-soft); color: var(--ink); }
.qty input { width: 52px; height: 42px; border: 0; text-align: center; font: inherit; font-weight: 600; background: transparent; }

/* ---------- Pre-order quota ---------- */
.quota {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 14px; margin: 4px 0 18px;
}
.quota-top {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: .85rem; color: var(--ink-soft); margin-bottom: 8px;
}
.quota-top b { color: var(--brand); }
.quota .hb-track { display: block; }
/* แบบไม่โชว์ตัวเลข — บอกแค่ว่ารับจองจำนวนจำกัด */
.quota-plain { display: flex; gap: 10px; align-items: flex-start; font-size: .87rem; line-height: 1.55; }
.quota-plain b { color: var(--brand); }

.notice {
  display: flex; gap: 10px; padding: 13px 15px; border-radius: var(--r-sm);
  font-size: .87rem; line-height: 1.55; margin: 16px 0;
}
.notice b { font-weight: 600; }
.notice-info  { background: var(--info-lt);  color: #4B2280; }
.notice-warn  { background: var(--warn-lt);  color: #7A5210; }
.notice-ok    { background: var(--ok-lt);    color: #1F5B41; }
.notice-danger{ background: var(--danger-lt);color: #8C2033; }
.notice span:first-child { font-weight: 700; flex: none; }

.spec-list { border-top: 1px solid var(--line-soft); margin: 22px 0 0; padding: 0; }
.spec-list div {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: .9rem;
}
.spec-list dt { color: var(--ink-faint); }
.spec-list dd { margin: 0; font-weight: 500; }

/* ---------- Forms ---------- */
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; font: inherit;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink); transition: .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lt); }
.input[readonly] { background: var(--line-soft); color: var(--ink-soft); }
textarea.input { min-height: 88px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- ปุ่มรูปตาในช่องรหัสผ่าน (password-toggle.js) ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 46px; }        /* เว้นที่ให้ปุ่ม */
.pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%;
  color: var(--ink-faint); cursor: pointer; transition: .15s;
}
.pw-eye svg { width: 19px; height: 19px; }
.pw-eye:hover { background: var(--brand-lt); color: var(--brand); }
.pw-eye.is-on { color: var(--brand); }
.pw-eye:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.ferr { color: var(--danger); font-size: .82rem; margin-top: 5px; }
.ferr::before { content: '⚠ '; }

.auth-wrap { max-width: 430px; margin: 56px auto; }
.auth-wrap .panel { padding: 32px; }
.auth-tabs { display: flex; gap: 6px; background: var(--line-soft); padding: 5px; border-radius: var(--r-sm); margin-bottom: 24px; }
.auth-tabs a {
  flex: 1; text-align: center; padding: 9px; border-radius: 6px;
  font-size: .9rem; font-weight: 600; color: var(--ink-soft);
}
.auth-tabs a.active { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- ตัวเลือกวันเวลาแบบไทย (thai-datetime.js) ---------- */
.thdt { position: relative; }
.thdt-display {
  text-align: left; cursor: pointer; font: inherit;
  display: flex; align-items: center; gap: 8px; min-height: 42px;
}
.thdt-display::before { content: '📅'; font-size: .95rem; opacity: .7; }
.thdt-display.is-empty { color: var(--ink-faint); }
.thdt-display:hover { border-color: var(--brand); }
.thdt.is-open .thdt-display { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lt); }
.thdt.is-invalid .thdt-display { border-color: var(--danger); }

.thdt-pop {
  display: none; position: absolute; z-index: 80; top: calc(100% + 6px); left: 0;
  width: 306px; padding: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.thdt.is-open .thdt-pop { display: block; }

.thdt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.thdt-title { display: flex; gap: 6px; flex: 1; }
.thdt-nav {
  width: 30px; height: 30px; flex: none; border: 1px solid var(--line);
  background: var(--card); border-radius: var(--r-sm); cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: var(--ink-soft);
}
.thdt-nav:hover { background: var(--brand-lt); border-color: var(--brand); color: var(--brand); }

.thdt-sel {
  flex: 1; padding: 6px 8px; font: inherit; font-size: .88rem;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.thdt-sel:focus { outline: none; border-color: var(--brand); }

.thdt-dow, .thdt-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.thdt-dow span {
  text-align: center; font-size: .74rem; font-weight: 600;
  color: var(--ink-faint); padding: 4px 0;
}
.thdt-day {
  aspect-ratio: 1/1; border: 0; background: transparent; border-radius: var(--r-sm);
  font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: .12s;
}
.thdt-day:hover { background: var(--brand-lt); color: var(--brand); }
.thdt-day.is-today { box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.thdt-day.is-picked {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 600; box-shadow: none;
}

.thdt-time {
  display: flex; align-items: center; gap: 6px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.thdt-time-lab { font-size: .85rem; font-weight: 600; }
.thdt-time .thdt-sel { flex: none; width: 62px; text-align: center; }
.thdt-colon { font-weight: 700; color: var(--ink-faint); }
.thdt-now {
  margin-left: auto; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r-sm); padding: 5px 11px; font: inherit; font-size: .8rem;
  cursor: pointer; color: var(--ink-soft);
}
.thdt-now:hover { background: var(--brand-lt); border-color: var(--brand); color: var(--brand); }

.thdt-foot {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.thdt-foot button {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-sm);
  padding: 7px 12px; font: inherit; font-size: .84rem; cursor: pointer; color: var(--ink-soft);
}
.thdt-foot button:hover { background: var(--line-soft); color: var(--ink); }
.thdt-clear { color: var(--danger) !important; }
.thdt-today { margin-left: auto; }
.thdt-ok {
  background: var(--brand) !important; border-color: var(--brand) !important;
  color: #fff !important; font-weight: 600;
}
.thdt-ok:hover { background: var(--brand-dk) !important; }

/* ในแถบเครื่องมือของแอดมิน ให้กว้างพอดีข้อความ */
.toolbar .thdt { min-width: 190px; }
.toolbar .thdt-pop { left: auto; right: 0; }

@media (max-width: 480px) {
  .thdt-pop { width: min(300px, calc(100vw - 48px)); }
}

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--r);
  padding: 30px 20px; text-align: center; background: var(--paper);
  cursor: pointer; transition: .15s;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-lt); }
.dropzone .dz-icon { font-size: 1.8rem; margin-bottom: 6px; }
.dropzone .dz-main { font-weight: 600; font-size: .93rem; }
.dropzone .dz-sub { font-size: .8rem; color: var(--ink-faint); }

/* ---------- Cart / checkout ---------- */
.two-col { display: grid; grid-template-columns: 1fr 372px; gap: 28px; align-items: start; }
.sticky { position: sticky; top: 96px; }

.cart-row {
  display: grid; grid-template-columns: 84px 1fr auto; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--line-soft); align-items: center;
}
.cart-row:last-child { border-bottom: 0; }
.cart-row img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r-sm); background: var(--line-soft); }
.cart-row .cr-name { font-weight: 600; }
.cart-row .cr-meta { font-size: .84rem; color: var(--ink-faint); }
.cart-row .cr-price { font-weight: 700; white-space: nowrap; }

.sum-line { display: flex; justify-content: space-between; padding: 8px 0; font-size: .93rem; }
.sum-line.total {
  border-top: 1px solid var(--line); margin-top: 10px; padding-top: 14px;
  font-size: 1.18rem; font-weight: 700; color: var(--brand);
}

.pay-grid { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: start; }
@media (max-width: 700px) { .pay-grid { grid-template-columns: 1fr; } }

.qr-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px; text-align: center;
}
.qr-box img { width: 214px; margin: 0 auto 14px; border-radius: var(--r-sm); }
.qr-amount { font-size: 1.6rem; font-weight: 700; color: var(--brand); }

.steps { display: flex; gap: 0; margin-bottom: 32px; }
.step { flex: 1; text-align: center; position: relative; font-size: .85rem; color: var(--ink-faint); }
.step::before {
  content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.step:first-child::before { display: none; }
.step i {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 32px; height: 32px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--line);
  font-style: normal; font-weight: 700; font-size: .85rem;
}
.step.done i { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done { color: var(--brand); font-weight: 600; }
.step.done::before { background: var(--brand); }

/* ---------- Status badges ---------- */
.st {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pending  { background: var(--warn-lt);   color: var(--warn); }
.st-paid     { background: var(--info-lt);   color: var(--info); }
.st-ready    { background: var(--brand-lt); color: #B01F68; }
.st-done     { background: var(--ok-lt);     color: var(--ok); }
.st-cancel   { background: var(--danger-lt); color: var(--danger); }

/* ---------- Order timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 14px; padding-bottom: 22px; position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--line);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); background: var(--card);
  display: grid; place-items: center; font-size: .72rem; color: var(--ink-faint);
}
.timeline li.done .tl-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.timeline li.done::before { background: var(--ok); }
.timeline li.current .tl-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-lt); }
.timeline .tl-title { font-weight: 600; font-size: .95rem; }
.timeline .tl-time { font-size: .82rem; color: var(--ink-faint); }
.timeline li:not(.done):not(.current) .tl-title { color: var(--ink-faint); font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: .78rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--paper); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.center, table.tbl th.center { text-align: center; }
.cell-prod { display: flex; align-items: center; gap: 11px; }
.cell-prod img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--line-soft); }

/* ---------- Admin layout ---------- */
.admin { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand-dk); color: #C6ADC4; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .sb-brand {
  display: flex; align-items: center; gap: 10px; color: #fff;
  padding: 0 10px 20px; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .sb-brand img {
  width: 40px; height: 40px; flex: none; object-fit: contain;
  background: #fff; border-radius: 50%; padding: 2px;
}
.sidebar .sb-brand b { font-size: .95rem; display: block; line-height: 1.2; }
.sidebar .sb-brand span { font-size: .68rem; color: #9B7BA4; letter-spacing: .05em; }
.sidebar .sb-sec {
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: #8E6E96; padding: 16px 10px 6px;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: .91rem; font-weight: 500; transition: .15s;
}
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 600; }
.sidebar .sb-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: .82rem; }

.admin-main { padding: 30px 34px 60px; min-width: 0; }
.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; margin-bottom: 26px; flex-wrap: wrap;
}
.admin-head h1 { font-size: 1.5rem; margin: 0 0 2px; }
.admin-head .sub { font-size: .88rem; color: var(--ink-faint); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.kpi .k-lab { font-size: .8rem; color: var(--ink-faint); font-weight: 500; }
.kpi .k-val { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.kpi .k-delta { font-size: .8rem; font-weight: 600; }
.kpi .k-delta.up { color: var(--ok); }
.kpi .k-delta.down { color: var(--danger); }

/* ---------- Bar chart (pure CSS) ---------- */
.chart {
  display: flex; align-items: flex-end; gap: 10px;
  height: 220px; padding: 10px 0 0; border-bottom: 1px solid var(--line);
}
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.chart .bar i {
  display: block; width: 100%; max-width: 46px;
  background: linear-gradient(180deg, #E4589C, var(--brand));
  border-radius: 5px 5px 0 0; transition: .2s; position: relative;
}
.chart .bar:hover i { background: linear-gradient(180deg, var(--brand-2), var(--accent)); }
.chart .bar em { font-style: normal; font-size: .72rem; color: var(--ink-faint); font-weight: 600; }
.chart-x { display: flex; gap: 10px; padding-top: 8px; }
.chart-x span { flex: 1; text-align: center; font-size: .75rem; color: var(--ink-faint); }

.dash-2col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .dash-2col { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

.hbar { display: flex; align-items: center; gap: 12px; padding: 9px 0; font-size: .89rem; }
.hbar .hb-name { width: 148px; flex: none; font-weight: 500; }
.hbar .hb-track { flex: 1; height: 9px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.hbar .hb-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; }
.hbar .hb-val { width: 74px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Toolbar / tabs ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a {
  padding: 10px 16px; font-size: .9rem; font-weight: 600; color: var(--ink-faint);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count {
  font-size: .72rem; background: var(--line-soft); color: var(--ink-soft);
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; font-weight: 700;
}

/* ---------- Bulk bar ---------- */
.bulkbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--brand-lt); border: 1px solid #F0CFE2;
  border-radius: var(--r); padding: 14px 18px; margin-bottom: 18px;
}
.bulkbar .bb-title { font-weight: 600; color: var(--brand); }
.bulkbar select.input, .bulkbar input.input { width: auto; min-width: 150px; background: #fff; }

/* ---------- Misc ---------- */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  font-size: .76rem; font-weight: 600; background: var(--line-soft); color: var(--ink-soft);
}
.tag-3d { background: var(--accent-lt); color: var(--accent); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty .e-icon { font-size: 2.4rem; margin-bottom: 10px; opacity: .5; }

/* ---------- จัดการรูปสินค้าในหน้าแอดมิน ---------- */
.img-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.img-item { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--card); }
.img-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.img-cover {
  position: absolute; top: 6px; left: 6px; z-index: 1;
  background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.img-tools { display: flex; align-items: center; gap: 6px; padding: 7px 8px; }
.img-tools .input { width: 54px; padding: 5px 7px; font-size: .82rem; }
.img-tools label { display: flex; align-items: center; gap: 4px; font-size: .8rem; cursor: pointer; }

/* ---------- ปุ่มรูปสลิป ---------- */
.slip-btn {
  padding: 0; border: 0; background: none; cursor: zoom-in;
  position: relative; display: inline-block; line-height: 0;
}
.slip-thumb {
  width: 46px; height: 60px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: var(--line-soft);
  transition: .15s; display: block;
}
.slip-btn:hover .slip-thumb { border-color: var(--brand); transform: scale(1.04); }
.slip-btn::after {
  content: '🔍'; position: absolute; inset: 0;
  display: grid; place-items: center; font-size: .9rem;
  background: rgba(62,27,82,.55); color: #fff; border-radius: 6px;
  opacity: 0; transition: .15s;
}
.slip-btn:hover::after { opacity: 1; }
.slip-pdf {
  display: grid; place-items: center; text-align: center;
  width: 46px; height: 60px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--line-soft);
  font-size: .62rem; font-weight: 700; color: var(--danger); line-height: 1.3;
}

/* ---------- QR รับสินค้า ---------- */
.pickup-qr { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
.pickup-qr-box {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; display: grid; place-items: center; min-width: 250px;
}
.pickup-qr-box img, .pickup-qr-box canvas { display: block; }
@media (max-width: 700px) { .pickup-qr { grid-template-columns: 1fr; } }

/* ---------- หน้าสแกน QR ---------- */
#reader { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
#reader video { display: block; width: 100% !important; }
.scan-hint {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--brand-lt); color: var(--brand); font-size: .88rem; text-align: center;
}
.pick-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 10px; background: var(--card); transition: .15s;
}
.pick-row.is-done { background: var(--ok-lt); border-color: #BFE3D2; }
.pick-row img { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; flex: none; }
.pick-row .pk-name { font-weight: 600; }
.pick-row .pk-chk { width: 26px; height: 26px; flex: none; cursor: pointer; accent-color: var(--brand); }
.pick-info { flex: 1; min-width: 0; }

/* คู่ ป้ายกำกับ–ค่า (ข้อมูลลูกค้าในหน้ารับสินค้า) */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: .9rem; }
.kv > span { color: var(--ink-faint); }
.kv > b { text-align: right; word-break: break-word; }

/* ---------- สไลด์วิธีสั่งจอง (หน้าแรก) ---------- */
.howto-stage { display: flex; align-items: center; gap: 10px; }

.howto-view { flex: 1; overflow: hidden; border-radius: var(--r); }

.howto-track {
  display: flex;
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}
.howto-slide { flex: 0 0 100%; margin: 0; }

.howto-slide img {
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;         /* อินโฟกราฟิกเป็นแนวตั้ง ห้ามให้ถูกครอป */
  border-radius: var(--r);
  cursor: zoom-in;
  background: var(--line-soft);
}

.howto-nav {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 1.6rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--brand);
  cursor: pointer; transition: .15s;
}
.howto-nav:hover:not(:disabled) { background: var(--brand); color: #fff; border-color: var(--brand); }
.howto-nav:disabled { opacity: .3; cursor: default; }

.howto-dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.howto-dot {
  width: 9px; height: 9px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--line); cursor: pointer; transition: .2s;
}
.howto-dot:hover { background: var(--brand-lt); }
.howto-dot.is-on { background: var(--brand); width: 26px; border-radius: 5px; }

@media (max-width: 720px) {
  /* จอเล็กเอาปุ่มลูกศรออก ใช้ปัดนิ้วแทน จะได้เหลือที่ให้รูปเต็มๆ */
  .howto-nav { display: none; }
  .howto-slide img { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .howto-track { transition: none; }
}

/* ---------- Lightbox ---------- */
.lb { display: none; position: fixed; inset: 0; z-index: 200; }
.lb.is-open { display: block; }
.lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(28,10,38,.78); backdrop-filter: blur(3px);
  animation: lbFade .18s ease;
}
@keyframes lbFade { from { opacity: 0 } to { opacity: 1 } }

.lb-panel {
  position: relative; z-index: 1;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  margin: 20px auto; display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.45);
  animation: lbPop .2s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes lbPop { from { opacity: 0; transform: translateY(14px) scale(.97) } to { opacity: 1; transform: none } }

.lb-bar {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--brand-dk); color: #fff;
}
.lb-cap { font-size: .92rem; font-weight: 600; flex: 1; min-width: 0;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { font-size: .82rem; color: #C6ADC4; flex: none; }
.lb-btn {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.22); border-radius: var(--r-sm);
  background: rgba(255,255,255,.08); color: #fff;
  font-size: .95rem; cursor: pointer; text-decoration: none; transition: .15s;
}
.lb-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.lb-stage {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center; padding: 16px;
  background: repeating-conic-gradient(var(--line-soft) 0% 25%, var(--card) 0% 50%) 50% / 22px 22px;
  overflow: auto;
}
.lb-img {
  max-width: 100%; max-height: calc(100vh - 190px);
  border-radius: var(--r-sm); box-shadow: var(--shadow);
  cursor: zoom-in; transition: transform .2s;
}
.lb-img.is-zoomed { transform: scale(1.9); cursor: zoom-out; }
.lb-frame { width: 100%; height: calc(100vh - 190px); border: 0; border-radius: var(--r-sm); background: #fff; }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(255,255,255,.94); color: var(--ink);
  font-size: 1.5rem; line-height: 1; cursor: pointer; transition: .15s;
  box-shadow: var(--shadow);
}
.lb-nav:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-hint {
  flex: none; padding: 9px 14px; text-align: center;
  font-size: .8rem; color: var(--ink-faint);
  background: var(--paper); border-top: 1px solid var(--line);
}

@media (max-width: 620px) {
  .lb-panel { width: calc(100vw - 16px); margin: 8px auto; max-height: calc(100vh - 16px); }
  .lb-img, .lb-frame { max-height: calc(100vh - 170px); height: auto; }
  .lb-hint { display: none; }
}

.divider { height: 1px; background: var(--line-soft); margin: 22px 0; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--brand-dk); color: #C6ADC4;
  padding: 42px 0 30px; margin-top: 70px; font-size: .88rem;
}
.site-footer .f-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 36px; margin-bottom: 30px; }
.site-footer h4 { color: #fff; font-size: .92rem; margin-bottom: 12px; }
.site-footer a { display: block; padding: 3px 0; }
.site-footer a:hover { color: #fff; }
.site-footer .f-bot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 18px; font-size: .82rem; color: #8E6E96; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .pdp { grid-template-columns: 1fr; gap: 28px; }
  .two-col { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .admin { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; }
  .sidebar .sb-brand, .sidebar .sb-sec, .sidebar .sb-foot { display: none; }
  .sidebar a { white-space: nowrap; }
  .admin-main { padding: 20px 16px 48px; }
  .site-footer .f-grid { grid-template-columns: 1fr; gap: 22px; }
  .hero h1 { font-size: 1.9rem; }
  .form-row { grid-template-columns: 1fr; }
}
/* จอแคบลง: ตัดคำบรรยายใต้ชื่อร้านออกก่อน เพื่อให้เมนูมีที่พอ */
@media (max-width: 1180px) {
  .brand-txt span { max-width: 28ch; }
  .site-header .wrap { gap: 14px; }
  .nav a { padding: 8px 11px; }
}
@media (max-width: 1020px) {
  .brand-txt span { display: none; }
  .nav-name { max-width: 120px; }
}
@media (max-width: 880px) {
  .site-header .wrap { flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
  .nav {
    margin-left: 0; width: 100%; flex: 1 1 100%;
    overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px;
  }
  .nav-user { margin-left: auto; }
}

@media (max-width: 620px) {
  .site-header .wrap { min-height: 0; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; gap: 12px; }
  .brand-txt b { font-size: .95rem; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; }
  .nav-user { padding-left: 8px; margin-left: 4px; }
  .nav-name { max-width: 96px; }
  .grid-products { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .wrap { padding: 0 16px; }
  .panel { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
}

/* ---------- Print (สำหรับพิมพ์รายงาน) ---------- */
@media print {
  .sidebar, .site-header, .topbar, .site-footer, .toolbar, .btn { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
}
