/* ═══════════════════════════════════════════════════════════════
   Firsthoro — Premium Mutelu Theme  (ทอง · ครีม · ดาร์กอุ่น)
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* พื้นหลังน้ำตาลเข้มอุ่น (ไม่ดำสนิท) — ดูพรีเมียม อ่านง่าย ไม่น่ากลัว */
  --bg:          #211a11;
  --bg-soft:     #2a2115;
  --panel:       #2e2417;
  --panel-2:     #382b1a;

  --cream:       #f7efda;
  --cream-dim:   #ded2b0;
  --cream-card:  #faf3e1;
  --cream-card2: #f3e9cd;

  --ink:         #2b2114;
  --ink-soft:    #5d4c30;
  --ink-faint:   #8a7350;

  --gold:        #c9a24b;
  --gold-2:      #e7c873;
  --gold-3:      #f2dd9a;
  --gold-deep:   #9a7733;
  --gold-shadow: rgba(120,90,35,.30);

  --line:        rgba(201,162,75,.24);
  --line-strong: rgba(201,162,75,.48);

  --ok:          #3c7a4e;
  --warn:        #b07a1e;
  --danger:      #9c3b2e;

  /* เงานุ่ม โทนอุ่น (ลดความเข้ม/ดราม่า) */
  --shadow:      0 14px 38px rgba(33,20,6,.28);
  --shadow-sm:   0 6px 18px rgba(33,20,6,.18);
  --radius:      20px;
  --radius-sm:   13px;

  --grad-gold:      linear-gradient(135deg, #f3dd97 0%, #d4ad55 46%, #a87f31 100%);
  --grad-gold-soft: linear-gradient(135deg, #e7c873, #c9a24b 60%, #9a7733);
  --grad-panel:     linear-gradient(180deg, #322715, #271f13);
  --grad-card:      linear-gradient(180deg, #fdf7e9, #f5ebd2);

  --font-serif: 'Noto Serif Thai', 'Cormorant Garamond', serif;
  --font-sans:  'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--cream);
  line-height: 1.7;
  background:
    radial-gradient(1100px 560px at 50% -8%, rgba(201,162,75,.11), transparent 64%),
    radial-gradient(820px 460px at 105% 4%, rgba(201,162,75,.05), transparent 60%),
    radial-gradient(820px 460px at -5% 8%,  rgba(201,162,75,.045), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

body.home-page {
  background: var(--bg);
  position: relative;
}

body.home-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(13,10,6,.54) 0%, rgba(13,10,6,.78) 44%, rgba(13,10,6,.96) 100%),
    url("/assets/hero-mutelu.jpg") center top / cover no-repeat;
}

body.home-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(760px 420px at 50% 18%, rgba(201,162,75,.18), transparent 68%),
    radial-gradient(900px 520px at 50% 112%, rgba(0,0,0,.72), transparent 58%);
}

/* ยกเนื้อหาขึ้นเหนือภาพ hero — ยกเว้น overlay (modal/toast/loading) ที่ต้องคง position:fixed */
body.home-page > *:not(.modal-host):not(.toast-host):not(.loading-overlay) {
  position: relative;
  z-index: 1;
}

/* ── ตัวอักษร ── */
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.3; margin: 0; letter-spacing: .2px; }
a { color: inherit; }
p { margin: 0 0 12px; }

.gold-text {
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── โครง ── */
.wrap { width: 100%; max-width: 780px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1140px; }
.section { padding: 40px 0; }
.center { text-align: center; }
.muted { color: var(--cream-dim); }
.hidden { display: none !important; }

.home-main {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.home-main .card {
  width: min(540px, calc(100vw - 40px));
}

/* ── เส้นคั่นมีลวดลาย ── */
.divider {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  color: var(--gold-2); margin: 22px 0;
}
.divider::before, .divider::after {
  content: ""; height: 1px; flex: 1; max-width: 150px;
  background: linear-gradient(90deg, transparent, var(--line-strong));
}
.divider::after { transform: scaleX(-1); }
.divider .mark { font-size: 15px; letter-spacing: .35em; }

/* ── การ์ด ── */
.card {
  background: var(--grad-card);
  color: var(--ink);
  border: 1px solid rgba(154,119,51,.32);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), inset 0 0 0 1px rgba(255,255,255,.18);
}
.card + .card { margin-top: 20px; }
.card h2, .card h3 { color: var(--ink); }
.card .sub { color: var(--ink-soft); }

.panel {
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

/* ── ป้ายกำกับ / แท็ก ── */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--gold-2);
  border: 1px solid var(--line-strong);
  padding: 6px 16px; border-radius: 999px;
  background: rgba(201,162,75,.06);
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-pending { background: rgba(176,122,30,.16); color: #b07a1e; border-color: rgba(176,122,30,.4); }
.badge-confirmed { background: rgba(60,122,78,.16); color: #2f7a4a; border-color: rgba(60,122,78,.4); }

/* ── ปุ่ม ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-sans); font-weight: 600; font-size: 16px;
  padding: 14px 28px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  text-decoration: none; line-height: 1; user-select: none;
}
.btn:active { transform: translateY(0) scale(.99); }
.btn-gold {
  background: var(--grad-gold); color: #3a2c12;
  border-color: rgba(255,255,255,.28);
  box-shadow: 0 12px 26px var(--gold-shadow), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 18px 34px var(--gold-shadow), inset 0 1px 0 rgba(255,255,255,.5); }
.btn-gold:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: rgba(201,162,75,.08); color: var(--gold-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: rgba(201,162,75,.15); }
.card .btn-ghost,
.modal.card .btn-ghost {
  background: rgba(154,119,51,.10);
  color: var(--gold-deep);
  border-color: rgba(154,119,51,.45);
}
.card .btn-ghost:hover,
.modal.card .btn-ghost:hover { background: rgba(154,119,51,.18); }
.btn-dark {
  background: rgba(43,33,20,.88);
  color: var(--cream);
  border-color: rgba(247,239,218,.26);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-dark:hover { background: rgba(43,33,20,.96); border-color: rgba(231,200,115,.46); }
.btn-danger {
  background: rgba(156,59,46,.10);
  color: #8a2f25;
  border-color: rgba(156,59,46,.58);
}
.btn-danger:hover { background: rgba(156,59,46,.18); border-color: rgba(156,59,46,.76); }
.panel .btn-danger,
.admin-page .panel .btn-danger {
  color: #ffd9d0;
  background: rgba(156,59,46,.28);
  border-color: rgba(255,217,208,.44);
}
.panel .btn-danger:hover,
.admin-page .panel .btn-danger:hover { background: rgba(156,59,46,.38); }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn-block { width: 100%; }

/* ── ฟอร์ม ── */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.panel .field > label { color: var(--cream); }
input, select, textarea {
  width: 100%; font-family: var(--font-sans); font-size: 16px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(154,119,51,.4);
  background: #fffdf6; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.panel input, .panel select, .panel textarea {
  background: rgba(255,253,246,.96);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,162,75,.22);
}
textarea { resize: vertical; min-height: 78px; }
.hint { font-size: 13px; color: var(--ink-soft); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── checkbox รับเงื่อนไข ── */
.accept {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius-sm);
  background: rgba(201,162,75,.10); border: 1px solid var(--line-strong);
  cursor: pointer;
}
.accept input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--gold-deep); cursor: pointer; }
.accept span { font-size: 15px; color: var(--ink); }

/* ── รายการสินค้า/บริการ ── */
.line-items { display: flex; flex-direction: column; gap: 12px; }
.line-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid rgba(154,119,51,.25);
  background: #fff8e7;
}
.line-item .li-thumb {
  width: 62px; height: 62px; flex: none; border-radius: 12px;
  background: var(--grad-gold-soft); display: grid; place-items: center;
  color: #fff8e6; font-size: 26px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}
.line-item .li-thumb img { width: 100%; height: 100%; object-fit: cover; }
.line-item .li-body { flex: 1; min-width: 0; }
.line-item .li-name { font-weight: 700; color: var(--ink); }
.line-item .li-ref {
  font-size: 13px; margin-top: 8px; display: inline-flex; gap: 5px;
  color: var(--gold-deep); font-weight: 700; text-decoration: none;
  border: 1px solid rgba(154,119,51,.34); border-radius: 999px;
  padding: 6px 11px; background: rgba(201,162,75,.10);
}
.line-item .li-ref:hover { background: rgba(201,162,75,.18); }
.line-item .li-meta { text-align: right; white-space: nowrap; }
.line-item .li-price { font-weight: 700; color: var(--ink); }

.compact-card { padding: 20px; }
.history-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.history-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px;
}
.history-total {
  min-width: 96px; border: 1px solid rgba(154,119,51,.28); border-radius: 16px;
  padding: 12px 14px; text-align: center; background: rgba(201,162,75,.10);
}
.history-total span {
  display: block; font-family: var(--font-serif); font-size: 30px; line-height: 1; color: var(--gold-deep);
}
.history-total small { color: var(--ink-soft); }
.history-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px;
}
.history-stats div {
  border: 1px solid rgba(154,119,51,.24); border-radius: 14px; padding: 10px 12px; background: rgba(255,253,246,.58);
}
.history-stats strong { display: block; color: var(--ink); }
.history-stats span { color: var(--ink-soft); font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-order {
  border: 1px solid rgba(154,119,51,.26); border-radius: 16px; padding: 15px; background: rgba(255,253,246,.66);
}
.history-order-main {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
}
.history-order h3 { margin-top: 3px; font-size: 18px; }
.history-order p,
.history-date { margin: 0; color: var(--ink-soft); font-size: 13.5px; }
.history-order-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 7px; white-space: nowrap;
}
.history-order-side strong { color: var(--ink); }
.history-note {
  margin-top: 10px !important; padding-top: 10px; border-top: 1px dashed rgba(154,119,51,.30);
}

/* ── สรุปยอด ── */
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 16px; margin-top: 8px; border-top: 1.5px dashed rgba(154,119,51,.45);
}
.total-row .label { font-family: var(--font-serif); font-size: 19px; color: var(--ink); }
.total-row .amount { font-family: var(--font-serif); font-size: 30px; font-weight: 700; color: var(--gold-deep); }

/* ── เงื่อนไข ── */
.terms-box {
  max-height: 340px; overflow-y: auto;
  padding: 4px 18px 4px 4px; margin: 6px 0 4px;
}
.terms-box::-webkit-scrollbar { width: 8px; }
.terms-box::-webkit-scrollbar-thumb { background: rgba(154,119,51,.4); border-radius: 8px; }
.term-clause { margin-bottom: 16px; }
.term-clause h4 {
  font-size: 16px; color: var(--ink); display: flex; gap: 9px; align-items: baseline;
}
.term-clause h4 .num {
  font-family: var(--font-serif); color: var(--gold-deep); font-weight: 700;
}
.term-clause p { font-size: 14.5px; color: var(--ink-soft); margin: 5px 0 0; }

/* ── ลายเซ็น ── */
.sigpad-wrap { margin-top: 8px; }
.sigpad {
  position: relative; border-radius: var(--radius-sm);
  border: 1.5px solid rgba(154,119,51,.5);
  background:
     linear-gradient(180deg, #fffdf6, #fbf4e3);
  box-shadow: inset 0 2px 8px rgba(154,119,51,.12);
  overflow: hidden;
}
.sigpad canvas { display: block; width: 100%; height: 210px; touch-action: none; cursor: crosshair; }
.sigpad .sig-baseline {
  position: absolute; left: 7%; right: 7%; bottom: 46px;
  border-bottom: 1.5px dashed rgba(154,119,51,.5); pointer-events: none;
}
.sigpad .sig-x { position: absolute; left: 7%; bottom: 48px; color: var(--gold-deep); font-size: 18px; pointer-events: none; }
.sigpad .sig-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(154,119,51,.55); font-size: 15px; pointer-events: none; letter-spacing: .04em;
}
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* ── toast ── */
.toast-host { position: fixed; left: 0; right: 0; bottom: 26px; display: flex; justify-content: center; z-index: 1200; pointer-events: none; }
.toast {
  pointer-events: auto;
  background: #221a11; color: var(--cream);
  border: 1px solid var(--line-strong);
  padding: 13px 22px; border-radius: 999px; box-shadow: var(--shadow);
  font-size: 15px; opacity: 0; transform: translateY(14px);
  transition: opacity .25s, transform .25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(194,91,72,.7); }

/* ── modal ── */
.modal-host {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(8,6,3,.72); backdrop-filter: blur(4px);
}
.modal-host.show { display: flex; }
.modal {
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  animation: pop .22s ease;
}
.modal-wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(16px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── ตราสัญลักษณ์ / โลโก้ ── */
.brand-emblem {
  display: inline-flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.brand-emblem .ring {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 50% 35%, #20180e, #0d0a06);
  border: 2px solid transparent;
  background-origin: border-box;
  box-shadow: 0 0 0 1px rgba(201,162,75,.4), 0 14px 36px rgba(0,0,0,.5), 0 0 40px rgba(201,162,75,.18);
}
.brand-emblem .ring::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%; padding: 2px;
  background: var(--grad-gold);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.brand-emblem .ring img { width: 70%; height: 70%; object-fit: contain; border-radius: 50%; }
.logo-mark-img { width: 72%; height: 72%; object-fit: contain; border-radius: 50%; display: block; }
.brand-emblem .ring .glyph { font-family: var(--font-serif); font-size: 40px; line-height: 1; }
.brand-emblem .wordmark { font-family: var(--font-serif); font-size: 26px; letter-spacing: .06em; }
.brand-emblem .tag { font-size: 13px; color: var(--cream-dim); letter-spacing: .12em; }

/* โลโก้เต็ม (แสดงเมื่อมีไฟล์ /assets/logo.png) — ไม่มีแผ่นพื้นหลังหรือกรอบ */
.brand-plaque {
  display: inline-block; line-height: 0; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  filter: drop-shadow(0 22px 34px rgba(0,0,0,.46)) drop-shadow(0 0 24px rgba(201,162,75,.22));
  transition: transform .18s ease, box-shadow .18s ease;
}
.brand-plaque:hover { transform: translateY(-2px); }
.brand-plaque img { width: min(380px, 78vw); height: auto; }

/* ── ตาราง (หลังบ้าน) ── */
.table-scroll { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 640px; }
table.data th, table.data td { padding: 13px 14px; text-align: left; border-bottom: 1px solid rgba(154,119,51,.18); }
table.data th { color: var(--gold-2); font-weight: 600; font-size: 13px; letter-spacing: .04em; white-space: nowrap; }
table.data tbody tr:hover { background: rgba(201,162,75,.05); }
table.data td .row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ═══ รวมออเดอร์เป็นคอนแทคเดียว — จัดกลุ่มตามลูกค้า ═══ */
table.data tr.cust-group-row { background: rgba(201,162,75,.10); }
table.data tr.cust-group-row:hover { background: rgba(201,162,75,.16); }
table.data tr.cust-group-row.open { background: rgba(201,162,75,.18); }
.cust-group-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge.cust-count { background: rgba(201,162,75,.22); color: var(--gold-2); border-color: rgba(201,162,75,.45); }
.cust-toggle { white-space: nowrap; }
table.data tr.cust-sub { background: rgba(0,0,0,.10); }
table.data tr.cust-sub td:first-child { padding-left: 26px; }
.cust-sub-mark { color: var(--gold-2); margin-right: 7px; font-weight: 700; }
.history-chip {
  display: inline-flex; margin-top: 7px; border: 1px solid rgba(201,162,75,.38);
  border-radius: 999px; padding: 3px 9px; color: var(--gold-2);
  background: rgba(201,162,75,.09); font-size: 11.5px; font-weight: 600;
}

/* ── หลังบ้าน layout ── */
.admin-top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.admin-brand { display: flex; align-items: center; gap: 13px; }
.admin-brand .dot { width: 44px; height: 44px; border-radius: 50%; background: var(--grad-gold); display: grid; place-items: center; overflow: hidden; color: #3a2c12; font-family: var(--font-serif); font-size: 22px; font-weight: 700; box-shadow: 0 6px 16px var(--gold-shadow); }
.admin-brand .dot img { width: 76%; height: 76%; object-fit: contain; border-radius: 50%; }
.admin-brand .t1 { font-family: var(--font-serif); font-size: 20px; }
.admin-brand .t2 { font-size: 12.5px; color: var(--cream-dim); }

.tabs { display: flex; gap: 8px; margin: 22px 0; flex-wrap: wrap; }
.tab {
  padding: 10px 20px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 15px;
  border: 1px solid var(--line); color: var(--cream-dim); background: transparent; transition: .15s;
}
.tab:hover { color: var(--cream); }
.tab.active { background: var(--grad-gold); color: #3a2c12; border-color: transparent; box-shadow: 0 8px 18px var(--gold-shadow); }
.tabpane { display: none; }
.tabpane.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 18px 20px; }
.stat .n { font-family: var(--font-serif); font-size: 30px; color: var(--gold-2); }
.stat .l { font-size: 13px; color: var(--cream-dim); }

.admin-page .panel { padding: 22px; }
.oi-row {
  border: 1px solid rgba(154,119,51,.28);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(201,162,75,.05);
}
.oi-top { grid-template-columns: 1fr 1.35fr; align-items: end; }
.oi-name-field { margin: 12px 0 0; }
.oi-money-row {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  flex-wrap: wrap;
}

.admin-details-panel {
  margin-top: 18px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(201,162,75,.05);
}
.admin-details-panel > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--gold-2);
}
.admin-details-panel > summary::-webkit-details-marker { display: none; }
.admin-details-panel > summary::after {
  content: "+";
  float: right;
  color: var(--cream-dim);
}
.admin-details-panel[open] > summary { margin-bottom: 12px; }
.admin-details-panel[open] > summary::after { content: "−"; }
.admin-details-panel > summary span {
  font-weight: 400;
  color: var(--cream-dim);
  margin-left: 6px;
}

/* การ์ดบริการในแคตตาล็อก */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cat-item { display: flex; flex-direction: column; gap: 6px; }
.cat-item .cat-cat { font-size: 12px; color: var(--gold-deep); font-weight: 700; letter-spacing: .05em; }
.cat-item .cat-name { font-family: var(--font-serif); font-size: 18px; color: var(--ink); }
.cat-item .cat-detail { font-size: 13.5px; color: var(--ink-soft); flex: 1; }
.cat-item .cat-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.cat-item .cat-price { font-weight: 700; color: var(--gold-deep); }

/* สแกนโพสต์ Instagram */
.ig-scan-panel {
  margin-top: 16px; padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(201,162,75,.06);
}
.ig-scan-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  cursor: pointer; list-style: none;
}
.ig-scan-summary::-webkit-details-marker { display: none; }
.ig-scan-summary::after {
  content: "+";
  color: var(--cream-dim);
  font-size: 20px;
  line-height: 1;
}
.ig-scan-panel[open] .ig-scan-summary { margin-bottom: 12px; }
.ig-scan-panel[open] .ig-scan-summary::after { content: "−"; }
.ig-scan-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.ig-scan-title { font-weight: 700; color: var(--gold-2); }
.ig-scan-meta, .ig-scan-status { font-size: 12.5px; color: var(--cream-dim); }
.ig-scan-status { margin-top: 10px; }
.ig-scan-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 12px; flex-wrap: wrap;
}
.ig-scan-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--cream-dim); cursor: pointer;
}
.ig-scan-toggle input { width: 18px; height: 18px; accent-color: var(--gold); }
.ig-scan-results { display: grid; gap: 10px; margin-top: 12px; }
.ig-scan-item {
  display: grid; grid-template-columns: 74px 1fr; gap: 12px;
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(201,162,75,.22); background: rgba(255,253,246,.96);
  color: var(--ink);
}
.ig-scan-thumb {
  width: 74px; height: 74px; border-radius: 11px; overflow: hidden;
  display: grid; place-items: center; background: rgba(201,162,75,.18);
  color: var(--gold-deep); font-family: var(--font-serif); font-size: 24px;
}
.ig-scan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ig-scan-body { min-width: 0; }
.ig-scan-name { font-weight: 700; color: var(--ink); line-height: 1.45; }
.ig-scan-detail { margin-top: 3px; font-size: 13px; color: var(--ink-soft); }
.ig-scan-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 9px; }
.ig-scan-price { width: min(100%, 230px); padding: 9px 11px; font-size: 14px; }
.ig-scan-link { color: var(--gold-deep); font-size: 13px; font-weight: 700; text-decoration: none; }
.ig-scan-link:hover { text-decoration: underline; }
.badge-closed { background: rgba(156,59,46,.12); color: #9c3b2e; border-color: rgba(156,59,46,.35); }

.payment-scan-status {
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(201,162,75,.24);
  background: rgba(201,162,75,.08);
  color: var(--cream-dim);
  font-size: 12.5px;
  line-height: 1.45;
}
.payment-scan-status.ok {
  border-color: rgba(60,122,78,.42);
  background: rgba(60,122,78,.14);
  color: #d9f0df;
}
.payment-scan-status.warn {
  border-color: rgba(176,122,30,.48);
  background: rgba(176,122,30,.16);
  color: #f1dfb8;
}
.payment-scan-status.loading { color: var(--gold-3); }

/* กล่องลิงก์ที่สร้างเสร็จ */
.link-out {
  display: flex; gap: 10px; align-items: center; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px dashed var(--gold-deep);
  background: rgba(201,162,75,.10); word-break: break-all;
}
.link-out code { font-family: ui-monospace, monospace; font-size: 14px; color: var(--ink); flex: 1; }

/* รายละเอียดหลักฐาน */
.evidence { display: grid; grid-template-columns: 1fr; gap: 6px; }
.evidence .ev-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(154,119,51,.18); font-size: 14.5px; }
.evidence .ev-row .k { width: 150px; flex: none; color: var(--ink-soft); }
.evidence .ev-row .v { color: var(--ink); flex: 1; word-break: break-word; }
#detailBox {
  background: #181108;
  color: #f8edcf;
  border-color: rgba(231,200,115,.54);
  box-shadow: 0 24px 70px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08);
}
#detailBox::before {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 0 0 1px rgba(231,200,115,.08);
}
#detailBox h2,
#detailBox h3,
#detailBox strong { color: #fff7dc; }
#detailBox .muted,
#detailBox .sub {
  color: #e0ce9f !important;
}
#detailBox .eyebrow {
  color: #f0d57f;
  background: rgba(231,200,115,.12);
  border-color: rgba(231,200,115,.44);
}
#detailBox .badge-pending {
  background: rgba(176,122,30,.22);
  color: #f0d57f;
  border-color: rgba(231,200,115,.34);
}
#detailBox .badge-confirmed {
  background: rgba(82,150,100,.24);
  color: #c9f2d2;
  border-color: rgba(120,205,142,.46);
}
#detailBox .divider {
  color: #f0d57f;
  margin: 24px 0 14px;
}
#detailBox .divider::before,
#detailBox .divider::after {
  background: linear-gradient(90deg, transparent, rgba(231,200,115,.62));
}
#detailBox .evidence {
  gap: 8px;
}
#detailBox .evidence .ev-row {
  gap: 18px;
  padding: 12px 0;
  border-bottom-color: rgba(231,200,115,.22);
}
#detailBox .evidence .ev-row .k {
  color: #e7c873;
  font-weight: 700;
}
#detailBox .evidence .ev-row .v {
  color: #f8edcf;
}
#detailBox .customer-history-box {
  background: rgba(255,246,218,.06);
  border-color: rgba(231,200,115,.34);
}
#detailBox .customer-history-summary {
  color: #e0ce9f;
}
#detailBox .customer-history-summary strong,
#detailBox .history-admin-main strong,
#detailBox .history-admin-side strong {
  color: #fff7dc;
}
#detailBox .history-admin-row {
  border-top-color: rgba(231,200,115,.22);
}
#detailBox .history-admin-main span,
#detailBox .history-admin-main small {
  color: #ddc997;
}
#detailBox .btn-ghost {
  background: rgba(231,200,115,.11);
  color: #f0d57f;
  border-color: rgba(231,200,115,.46);
}
#detailBox .btn-ghost:hover {
  background: rgba(231,200,115,.18);
}
#detailBox .sig-show {
  background: #fff9ea;
  border-color: rgba(231,200,115,.48);
}
.customer-history-box {
  border: 1px solid rgba(154,119,51,.28); border-radius: 16px; padding: 12px;
  background: rgba(154,119,51,.06);
}
.customer-history-summary {
  display: flex; justify-content: space-between; gap: 10px; padding: 4px 2px 10px; color: var(--ink-soft);
}
.customer-history-summary strong { color: var(--ink); }
.profile-identity-line { margin: -3px 2px 10px; font-size: 12.5px; }
.history-admin-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 11px 0;
  border-top: 1px solid rgba(154,119,51,.18);
}
.history-admin-main {
  min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.history-admin-main strong { color: var(--ink); }
.history-admin-main span {
  color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px;
}
.history-admin-main small { color: var(--ink-faint); }
.history-admin-side {
  display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; min-width: 180px;
}
.history-admin-side strong { color: var(--ink); }
.sig-show { border: 1px solid rgba(154,119,51,.4); border-radius: 12px; background: #fbf6e9; padding: 8px; margin-top: 6px; }
.sig-show img { display: block; width: 100%; max-width: 420px; }

/* ── เฮดเดอร์หน้าลูกค้า ── */
.cust-hero { text-align: center; padding: 38px 0 8px; }
.page-logo-mark {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px;
  display: grid; place-items: center; overflow: hidden; background: var(--grad-gold);
  color: #3a2c12; font-family: var(--font-serif); font-size: 28px; font-weight: 700;
  box-shadow: 0 10px 26px var(--gold-shadow);
}
.cust-hero h1 { font-size: clamp(26px, 6vw, 38px); }
.greet { font-size: 17px; color: var(--cream-dim); margin-top: 6px; }

.success-wrap { text-align: center; padding: 22px 0; }
.success-seal {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 8px;
  background: var(--grad-gold); display: grid; place-items: center;
  color: #2f7a4a; font-size: 50px; box-shadow: 0 14px 34px var(--gold-shadow);
}
.brand-status-seal { position: relative; overflow: visible; color: #3a2c12; font-family: var(--font-serif); font-size: 32px; }
.brand-status-seal .logo-mark-img { width: 74%; height: 74%; }
.brand-status-seal .glyph { line-height: 1; }
.brand-status-seal .status-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #241a10; border: 1px solid rgba(243,221,151,.7);
  color: var(--gold-2); font-family: var(--font-sans); font-size: 17px; font-weight: 700;
  box-shadow: 0 8px 18px rgba(0,0,0,.32);
}

footer.foot { text-align: center; padding: 34px 0 40px; color: var(--cream-dim); font-size: 13.5px; }
footer.foot .divider { margin-bottom: 14px; }

/* ═══ สถานะเชื่อม Google Calendar (หน้าแอดมิน) ═══ */
.cal-sync { display: flex; align-items: center; gap: 9px; margin: -2px 0 16px; font-size: 13px; line-height: 1.45; }
.cal-sync-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--cream-dim); box-shadow: 0 0 0 3px rgba(222,210,176,.14); }
.cal-sync.is-on .cal-sync-dot { background: #5fd08a; box-shadow: 0 0 0 3px rgba(95,208,138,.20); }
.cal-sync.is-off .cal-sync-dot { background: #e7b84f; box-shadow: 0 0 0 3px rgba(231,184,79,.20); }
.cal-sync-text { color: var(--cream-dim); }
.cal-sync-text strong { color: var(--gold-2); font-weight: 700; }

.birthday-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}
.birthday-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--cream-dim);
  background: rgba(255,255,255,.035);
  font-size: 12.5px;
  font-weight: 650;
}
.birthday-pill.ok {
  color: #bfe8c6;
  border-color: rgba(94,164,108,.46);
  background: rgba(60,122,78,.14);
}
.birthday-pill.warn {
  color: #f3d27a;
  border-color: rgba(231,184,79,.42);
  background: rgba(201,162,75,.12);
}

/* ═══ Transition & Loading feedback — ให้ลูกค้ารู้ว่าเปลี่ยนหน้า/กำลังดำเนินการ ═══ */
@keyframes pageEnter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fhSpin { to { transform: rotate(360deg); } }
@keyframes fhFade { from { opacity: 0; } to { opacity: 1; } }

/* แต่ละหน้าค่อยๆ ปรากฏ (รู้ว่าเปลี่ยนหน้าแล้ว ไม่กระตุก) */
main { animation: pageEnter .38s ease both; }

/* overlay "กำลังดำเนินการ" ตอนกดแล้วต้องรอ/เปลี่ยนหน้า */
.loading-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(20, 15, 9, .82); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  padding: 20px;
}
.loading-overlay.show { display: flex; animation: fhFade .2s ease; }
.loading-spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid rgba(201, 162, 75, .22); border-top-color: var(--gold-2);
  animation: fhSpin .8s linear infinite;
}
.loading-overlay .loading-text { color: var(--cream); font-family: var(--font-serif); font-size: 17px; letter-spacing: .04em; }

/* เคารพผู้ที่ปิดอนิเมชัน */
@media (prefers-reduced-motion: reduce) {
  main { animation: none; }
  .loading-spinner { animation-duration: 1.6s; }
}

/* ═══ responsive — Mobile First (ลูกค้าส่วนใหญ่ใช้มือถือ) ═══ */

/* กันคอนเทนต์ชนขอบ/ติ่งจอ (notch) */
.wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
body { min-height: 100dvh; }

/* แท็บเล็ต/มือถือ: ตารางหลังบ้าน → การ์ด (ไม่ต้องเลื่อนแนวนอน) */
@media (max-width: 760px) {
  .table-scroll { overflow: visible; }
  table.data { min-width: 0; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: rgba(201,162,75,.06); margin-bottom: 14px; padding: 4px 2px 8px;
  }
  table.data td { border: none; padding: 8px 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between; }
  table.data td::before {
    content: attr(data-label); color: var(--gold-2); font-weight: 600; font-size: 12.5px; flex: none;
  }
  table.data td:first-child { display: block; padding-top: 13px; font-size: 16px; }
  table.data td:first-child::before { display: none; }
  table.data td:last-child { justify-content: flex-end; padding-bottom: 12px; }
  table.data td:last-child::before { display: none; }
  table.data td .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  table.data td[data-label="รายการ"] > div { max-width: none; white-space: normal; text-align: right; }
}

@media (max-width: 620px) {
  .row2 { grid-template-columns: 1fr; }
  .oi-row .row2 { grid-template-columns: 1fr !important; }   /* แถวรายการ: ให้ select กับชื่อแยกบรรทัด */
  .oi-money-row .field { width: 100% !important; min-width: 0 !important; }
  .oi-del { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat .n { font-size: 26px; }
  .line-item { gap: 11px; padding: 13px; }
  .line-item .li-thumb { width: 50px; height: 50px; font-size: 21px; }
  .card { padding: 20px; }
  .panel { padding: 18px; }
  .btn { padding: 13px 22px; }
  .total-row .amount { font-size: 26px; }
  .terms-box { max-height: 300px; }
  .evidence .ev-row { flex-direction: column; gap: 2px; padding: 8px 0; }
  .evidence .ev-row .k { width: auto; font-size: 12.5px; }
  .history-entry,
  .history-head,
  .history-order-main,
  .history-admin-row,
  .customer-history-summary {
    flex-direction: column;
    align-items: stretch;
  }
  .history-stats { grid-template-columns: 1fr; }
  .history-order-side,
  .history-admin-side {
    align-items: flex-start;
    justify-content: flex-start;
    min-width: 0;
  }
  .history-admin-main span { max-width: 100%; white-space: normal; }
  .cust-hero { padding: 26px 0 6px; }
  .page-logo-mark { width: 50px; height: 50px; margin-bottom: 10px; }
  .admin-brand .t1 { font-size: 18px; }
  .ig-scan-summary { align-items: flex-start; }
  .ig-scan-head { align-items: stretch; flex-direction: column; }
  .ig-scan-head .btn { width: 100%; }
  .ig-scan-actions .btn { width: 100%; }
  .ig-scan-item { grid-template-columns: 58px 1fr; }
  .ig-scan-thumb { width: 58px; height: 58px; }
  .sigpad canvas { height: 200px; }
}

/* จอเล็กมาก: ราคาแต่ละรายการตกบรรทัดใหม่ให้อ่านชัด */
@media (max-width: 440px) {
  .line-item { flex-wrap: wrap; }
  .line-item .li-meta { width: 100%; text-align: right; margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(154,119,51,.3); }
  .tab { padding: 9px 15px; font-size: 14px; }
  .eyebrow { font-size: 11.5px; letter-spacing: .2em; }
  .total-row .label { font-size: 17px; }
}

/* ── print: ใบยืนยัน ── */
@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
}
