:root {
  --pri: #1677ff; --pri-d: #0b5ad9; --pri-l: #e8f1ff;
  --green: #1fb84a; --cyan: #17b8d8; --red: #f0384a; --gray: #5f6b7a;
  --ink: #14213d; --muted: #6b7686; --line: #e3e9f2; --bg: #eef3fa;
  --radius: 16px;
}
* { box-sizing: border-box; }
body { font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--ink); font-size: 16px; }
h1, h2, h3, h4, h5, .k { font-family: 'Kanit', 'Sarabun', sans-serif; font-weight: 600; }
a { color: var(--pri); }

/* ---------- ความกว้างเว็บไซต์ 1500px ---------- */
:root { --site-w: 1500px; }
html { background: #dde6f1; }
.site { max-width: var(--site-w); margin: 0 auto; background: var(--bg); min-height: 100vh; box-shadow: 0 0 40px rgba(20, 50, 100, .12); overflow-x: clip; }

/* ---------- แถบบน ---------- */
.topbar { position: relative; z-index: 20; display: flex; align-items: center; gap: 24px; height: 84px; padding: 0 28px 0 0;
  background: #fff; box-shadow: 0 4px 18px rgba(20, 50, 100, .08); }
.brand { display: flex; align-items: center; gap: 10px; height: 100%; padding: 6px 30px 6px 22px; background: #fff;
  border-radius: 0 0 26px 0; text-decoration: none; color: var(--ink); align-self: flex-start; height: 96px;
  box-shadow: 6px 6px 18px rgba(20, 50, 100, .10); }
.brand-logo { height: 70px; }
.brand-logo-sq { height: 62px; width: 62px; object-fit: contain; }
.brand-text b { display: block; font-family: 'Kanit'; font-size: 24px; line-height: 1.05; }
.brand-text small { letter-spacing: 3px; font-size: 11px; font-weight: 600; }
.topnav { gap: 6px; margin: 0 auto; }
.topnav a { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 12px; color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: 16.5px; transition: .15s; }
.topnav a i { font-size: 1.15rem; color: #3b4a63; }
.topnav a:hover { background: var(--pri-l); }
.topnav a.active { background: var(--pri); color: #fff; box-shadow: 0 6px 16px rgba(22, 119, 255, .35); }
.topnav a.active i { color: #fff; }.userbox { margin-left: auto; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem;
  color: #fff; background: linear-gradient(135deg, #3b8bff, #0b5ad9); border: 3px solid #dbe8ff; }
.shop-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dropdown-item.active, .dropdown-item:active { background: var(--pri); }

/* ---------- แบนเนอร์ ---------- */
.hero { margin-top: 0; line-height: 0; position: relative; }
.hero-img { width: 100%; height: auto; display: block; }
/* แสงสีขาวไล่เฉียงพาดผ่านแบนเนอร์ (ใช้ background-position จึงไม่ต้อง overflow:hidden ซึ่งจะตัด hero-pop) */
.hero::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 42%, rgba(255, 255, 255, .55) 50%, transparent 58%) no-repeat;
  background-size: 250% 100%; background-position: 150% 0; animation: hero-shine 12s ease-in-out infinite; }
@keyframes hero-shine { 0% { background-position: 150% 0; } 50%, 100% { background-position: -50% 0; } }
/* ฟองลอยขึ้น (ตำแหน่ง/ขนาด/ความเร็วสุ่มจาก header.php) */
.hero-bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hero-bubbles span { position: absolute; bottom: calc(var(--s) * -1); width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, .95) 0 12%, rgba(255, 255, 255, .25) 30%, rgba(255, 255, 255, .08) 65%);
  border: 1px solid rgba(255, 255, 255, .7); box-shadow: 0 0 6px rgba(255, 255, 255, .35);
  animation: bubble-up var(--d) linear var(--delay) infinite; }
@keyframes bubble-up {
  0%   { bottom: calc(var(--s) * -1); transform: translateX(0) scale(.6); opacity: 0; }
  10%  { opacity: .9; }
  50%  { transform: translateX(var(--x)) scale(1); }
  90%  { opacity: .7; }
  100% { bottom: 105%; transform: translateX(calc(var(--x) * -.5)) scale(1.1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .hero::after, .hero-bubbles { animation: none; display: none; } }
/* ส่วนหัวการ์ตูนที่โผล่ขึ้นเหนือแบนเนอร์ (ตำแหน่งเป็น % ให้ตรงกับภาพแบนเนอร์ทุกขนาดจอ) */
.hero-pop { position: absolute; left: 72.266%; width: 12.109%; bottom: 100%; z-index: 30; pointer-events: none; display: none; }
@media (min-width: 1500px) { .hero-pop { display: block; } }
@media (max-width: 1720px) { .topnav { margin: 0 auto 0 12px; } }
.site .topnav { margin: 0 auto 0 12px; }
.user-txt { max-width: 190px; } .user-txt small, .user-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- โครงหน้า ---------- */
.layout { display: flex; gap: 22px; padding: 0 22px 22px; margin-top: -18px; position: relative; }
.layout.no-hero { margin-top: 22px; }
.sidebar { width: 236px; flex: none; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 14px; align-self: flex-start; } }
.side-card { background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: 0 6px 22px rgba(20, 50, 100, .08); }
.sidemenu a { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 4px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 500; }
.sidemenu a i { font-size: 1.2rem; color: #42506a; width: 22px; text-align: center; }
.sidemenu a:hover { background: var(--pri-l); }
.sidemenu a.active { background: var(--pri); color: #fff; font-weight: 600; box-shadow: 0 6px 14px rgba(22, 119, 255, .3); }
.sidemenu a.active i { color: #fff; }
/* เส้นกั้นระหว่างเมนู (ซ่อนเส้นที่ชิดปุ่มที่เลือกอยู่) */
.sidemenu a { position: relative; }
.sidemenu a + a::before { content: ''; position: absolute; left: 14px; right: 14px; top: -3px; border-top: 1px solid #e3e9f2; }
.sidemenu a.active::before, .sidemenu a.active + a::before { display: none; }
.side-shopfront { margin-top: 16px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 6px 22px rgba(20, 50, 100, .1); line-height: 0; }
.side-shopfront img { width: 100%; }
.content { flex: 1; min-width: 0; }
/* เมนูซ้ายซ้อนขึ้นบนแบนเนอร์ได้ แต่เนื้อหาต้องเริ่มใต้แบนเนอร์ (หัวข้อที่ไม่มีพื้นขาวจะได้ไม่ทับรูป) */
.layout:not(.no-hero) .content { padding-top: 38px; }
@media (max-width: 991.98px) {
  .topbar { height: 68px; gap: 10px; padding-right: 12px; }
  .brand { height: 76px; padding: 4px 16px; } .brand-logo { height: 52px; }
  .layout { padding: 0 12px 12px; margin-top: -8px; }
  .layout:not(.no-hero) .content { padding-top: 22px; }
  .sidebar .side-card { box-shadow: none; }
}

/* ---------- ช่องวันที่ พ.ศ. (ดู footer.php) ---------- */
.be-date-wrap { position: relative; }
.be-date-wrap input[type=text] { padding-left: 10px; padding-right: 32px; }
.be-date-wrap input[type=date] { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.be-date-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  padding: 4px 8px; color: var(--ink); font-size: 1.05rem; line-height: 1; }

.be-cal { position: absolute; z-index: 1080; width: 280px; padding: 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 50, 100, .18); font-size: 14px; }
.be-cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.be-cal-head select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-weight: 600; background: #fff; }
.be-cal-head select[data-y] { flex: 0 0 72px; }
.be-cal button { border: 0; background: none; border-radius: 8px; color: var(--ink); }
.be-cal-head button { padding: 4px 8px; }
.be-cal button:hover { background: var(--pri-l); }
.be-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.be-cal-grid b { font-size: 12px; color: #6b7a90; padding: 4px 0; }
.be-cal-grid button { padding: 6px 0; }
.be-cal-grid button.out { color: #b4bdca; }
.be-cal-grid button.today { box-shadow: inset 0 0 0 1px var(--pri); }
.be-cal-grid button.sel { background: var(--pri); color: #fff; font-weight: 600; }
.be-cal-foot { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.be-cal-foot button { color: var(--pri); padding: 4px 10px; }

/* ---------- แจ้งเตือนแบบ Toast มุมขวาบน ---------- */
.app-toasts { z-index: 1090; }
.app-toast { --c: var(--pri); width: 380px; max-width: calc(100vw - 32px); border: 0; border-left: 5px solid var(--c);
  border-radius: 12px; background: #fff; box-shadow: 0 12px 32px rgba(20, 50, 100, .22); overflow: hidden; font-size: .95rem; }
.app-toast .toast-ic { color: var(--c); font-size: 1.3rem; line-height: 1.2; }
.app-toast .toast-bar { height: 3px; background: var(--c); opacity: .5; transform-origin: left;
  animation: toast-bar var(--toast-delay, 5s) linear forwards; }
.app-toast:hover .toast-bar { animation-play-state: paused; }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast-success { --c: #16a34a; } .toast-danger { --c: #dc2626; } .toast-warning { --c: #f59e0b; } .toast-info { --c: #0ea5e9; }

/* ---------- ปุ่มเลื่อนดูใบเสร็จก่อนหน้า / ถัดไป (หน้าทำใบเสร็จ) ---------- */
.bill-nav { gap: 4px; }
.bill-nav .nav-btn { width: 36px; height: 38px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line);
  border-radius: 10px; color: var(--pri); background: #fff; }
.bill-nav .nav-btn:hover { background: var(--pri); color: #fff; border-color: var(--pri); }
.bill-nav .nav-btn.disabled { color: #c3cad6; background: #f8fafd; opacity: 1; }
.bill-no-find { cursor: zoom-in; user-select: none; }
.bill-no-find:hover { box-shadow: 0 0 0 .15rem rgba(22, 119, 255, .25); }

/* ---------- สถานะชำระเงิน ---------- */
/* สวิตช์: เปิด (เขียว) = ค้างชำระ · ปิด (เทา) = ชำระแล้ว */
.pay-switch { padding-left: 0; }
.pay-switch .form-check-input { width: 3.2em; height: 1.65em; margin: 0; cursor: pointer; float: none;
  background-color: #9ca3af; border-color: #9ca3af;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); }
.pay-switch .form-check-input:focus { border-color: #9ca3af; box-shadow: 0 0 0 .2rem rgba(156, 163, 175, .3);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); }
.pay-switch .form-check-input:checked { background-color: #16a34a; border-color: #16a34a; }
.pay-switch .form-check-input:checked:focus { box-shadow: 0 0 0 .2rem rgba(22, 163, 74, .3); }
.pay-switch .form-check-label { font-weight: 600; color: #6b7280; cursor: pointer; min-width: 64px; }
.pay-switch .form-check-input:checked + .form-check-label { color: #16a34a; }
.pay-switch-sm .form-check-input { width: 2.6em; height: 1.35em; }
.pay-switch-sm .form-check-label { font-size: .85rem; min-width: 58px; text-align: left; }
.badge-paid { background: #dcfce7; color: #15803d; font-weight: 600; }
.badge-unpaid { background: #ffedd5; color: #c2410c; font-weight: 600; }

/* ---------- การ์ด / แผง ---------- */
.panel { background: #fff; border-radius: var(--radius); box-shadow: 0 6px 22px rgba(20, 50, 100, .08); padding: 22px; }
.panel + .panel { margin-top: 18px; }
.panel-title { display: flex; align-items: center; gap: 12px; font-family: 'Kanit'; font-weight: 600; font-size: 22px; margin: 0 0 16px; }
.ic-sq { width: 40px; height: 44px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--pri); font-size: 1.35rem; flex: none; }
.sec-title { display: flex; align-items: center; gap: 10px; font-family: 'Kanit'; font-weight: 600; font-size: 19px; margin: 0 0 12px; }
.sec-title i { color: var(--pri); font-size: 1.35rem; }
.sub-box { border: 1px solid var(--line); border-radius: 12px; padding: 16px; height: 100%; }
.card { border: 0; border-radius: var(--radius); box-shadow: 0 6px 22px rgba(20, 50, 100, .08); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-family: 'Kanit'; font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; padding: 14px 18px; }
.card-header i { color: var(--pri); }

/* ---------- ฟอร์ม ---------- */
.form-label { font-weight: 600; margin-bottom: 4px; color: #2c3a52; }
.form-control, .form-select { border-color: #d8e0eb; border-radius: 9px; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--pri); box-shadow: 0 0 0 .2rem rgba(22, 119, 255, .15); }
.input-icon { position: relative; } .input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon input { padding-left: 36px; }
.req::after { content: ' *'; color: var(--red); }

/* ---------- ปุ่ม ---------- */
.btn { border-radius: 9px; font-weight: 600; padding: .55rem 1.05rem; }
.btn-sm { padding: .3rem .65rem; border-radius: 7px; }
.btn-pri, .btn-shop { background: var(--pri); color: #fff; border: 0; box-shadow: 0 4px 12px rgba(22, 119, 255, .28); }
.btn-pri:hover, .btn-shop:hover { background: var(--pri-d); color: #fff; }
.btn-grn { background: var(--green); color: #fff; border: 0; box-shadow: 0 4px 12px rgba(31, 184, 74, .3); }
.btn-grn:hover { background: #169a3c; color: #fff; }
.btn-cyan { background: var(--cyan); color: #fff; border: 0; } .btn-cyan:hover { background: #119ab6; color: #fff; }
.btn-gry { background: var(--gray); color: #fff; border: 0; } .btn-gry:hover { background: #4a5462; color: #fff; }
.btn-red { background: var(--red); color: #fff; border: 0; } .btn-red:hover { background: #d42536; color: #fff; }
.btn-big { padding: .75rem 1.4rem; font-size: 17px; }

/* ---------- ตาราง ---------- */
.table thead th { background: #f4f7fc; font-weight: 600; white-space: nowrap; color: #34425a; }
.tbl-blue { border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl-blue thead th { background: var(--pri); color: #fff; font-weight: 600; text-align: center; padding: 11px 8px; border: 0; }
.tbl-blue td { border-color: var(--line); vertical-align: middle; padding: 6px; }
/* เส้นแบ่งคอลัมน์ (ใส่ class tbl-cols เพิ่ม) */
.tbl-cols th + th { border-left: 1px solid rgba(255, 255, 255, .35); }
.tbl-cols td + td { border-left: 1px solid var(--line); }
.items-table input:not([type=checkbox]) { min-width: 0; padding: .3rem .45rem; }
.items-table td { padding: 6px 4px; }
.items-table textarea.desc { resize: none; overflow: hidden; min-height: 0; line-height: 1.5; } .items-table .form-check-input { width: 1.1em; height: 1.1em; }
.size-pair { display: flex; align-items: center; gap: 4px; } .size-pair input { min-width: 0; } .size-pair span { color: var(--muted); }
.row-del { color: var(--red); background: #ffe9ec; border: 0; width: 32px; height: 32px; border-radius: 8px; }
.row-del:hover { background: var(--red); color: #fff; }
.badge-no { font-family: ui-monospace, monospace; font-size: .92rem; font-weight: 600; background: var(--pri-l); color: var(--pri-d); }

/* ---------- สรุปยอด ---------- */
.sum-row { display: flex; flex-wrap: wrap; gap: 10px; }
.sum-cell { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; flex: 1; min-width: 150px; }
.sum-cell span { color: var(--muted); white-space: nowrap; }
.sum-cell b { margin-left: auto; font-size: 18px; }
.sum-cell.net { background: #ffe8ee; border-color: #ffc9d6; } .sum-cell.net span, .sum-cell.net b { color: #e11d48; font-weight: 700; }
.sum-cell input { border: 0; text-align: right; font-weight: 700; font-size: 18px; width: 100%; padding: 0; outline: 0; }

/* ---------- ตัวอย่างใบเสร็จ ---------- */
.preview-wrap { background: #fff3f6; border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 22px rgba(20, 50, 100, .08); position: sticky; top: 14px; }
.preview-wrap .sec-title i { color: #e11d48; }
.rc { background: #fff; border-radius: 12px; padding: 18px 16px; font-size: 13px; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.rc-head { text-align: center; border-bottom: 2px solid #222; padding-bottom: 8px; }
.rc-head img { max-height: 60px; max-width: 220px; }
.rc-shop { font-weight: 700; font-size: 15px; margin-top: 4px; }
.rc-title { text-align: center; font-family: 'Kanit'; font-weight: 600; font-size: 18px; padding: 6px 0; border-bottom: 1px solid #ccc; }
.rc-meta { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; padding: 8px 0; }
.rc table { width: 100%; font-size: 12.5px; }
.rc th { background: #eef1f5; padding: 4px; font-weight: 600; }
.rc td { padding: 3px 4px; border-bottom: 1px solid #f0f0f0; }
.rc .tot { display: flex; justify-content: flex-end; gap: 30px; padding: 3px 4px; }
.rc .tot b { min-width: 90px; text-align: right; }
.rc .net { background: #ffe1e8; border-radius: 8px; padding: 8px 12px; margin-top: 6px; font-weight: 700; color: #be123c; font-size: 16px; }
.rc .net b { font-size: 20px; }
.rc .txt { text-align: center; color: #444; margin-top: 6px; }
.rc .sigl { width: 150px; border-top: 1px dotted #555; margin: 40px 0 0 auto; text-align: center; padding-top: 4px; }

/* ---------- แดชบอร์ด ---------- */
.stat { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 6px 22px rgba(20, 50, 100, .08); display: flex; gap: 16px; align-items: center; height: 100%; }
.stat .ico { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; flex: none; }
.stat .num { font-family: 'Kanit'; font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .92rem; }
/* การ์ดสรุปยอดขนาดเล็กบนแถบด้านบน (หน้าหลัก) */
.top-stats { gap: 10px; margin-left: 10px; min-width: 0; }
.stat.stat-sm { padding: 8px 14px 8px 10px; gap: 10px; border-radius: 12px; height: auto; box-shadow: 0 4px 14px rgba(20, 50, 100, .1); }
.stat-sm .ico { width: 40px; height: 40px; border-radius: 10px; font-size: 1.15rem; }
.stat-sm .num { font-size: 1.15rem; white-space: nowrap; }
.stat-sm .lbl { font-size: .75rem; line-height: 1.2; white-space: nowrap; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding-top: 10px; }
.bar-chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; }
.bar-chart .b .fill { width: 100%; max-width: 46px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #4b9bff, var(--pri)); min-height: 2px; }
.bar-chart .b .v { color: var(--muted); font-size: 11px; margin-bottom: 3px; white-space: nowrap; }
.bar-chart .b .m { margin-top: 5px; color: #34425a; }

.img-thumb { max-height: 110px; max-width: 100%; border: 1px solid #ddd; border-radius: 8px; padding: 3px; background: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty i { font-size: 3rem; color: #b8c4d6; }
