/* ระบบร้าน — สไตล์ร่วมทุกหน้า */
:root {
  --bg: #f5f2eb;
  --card: #ffffff;
  --ink: #1f1c17;
  --ink-2: #5b554a;
  --ink-3: #8a8375;
  --line: #e4ddcf;
  --line-2: #d3cab8;
  --brand: #8a1c1c;
  --brand-2: #6f1515;
  --brand-soft: #f7e9e6;
  --gold: #b7862c;
  --gold-soft: #fbf3e2;
  --ok: #1d7a4a;
  --ok-soft: #e6f4ec;
  --warn: #a8570a;
  --warn-soft: #fdf1e1;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #1d4ed8;
  --info-soft: #e8eefc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 28, 23, .06), 0 2px 8px rgba(31, 28, 23, .05);
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Thonburi", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 14px; }
.small { font-size: 14px; }
.right { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }

/* แถบบน */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; }
.topbar .brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar .brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--gold); color: #fff; display: grid; place-items: center; font-size: 16px; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; min-width: 0; }
.topbar .who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar .chip-price { background: rgba(255,255,255,.14); border-radius: 999px; padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.topbar button { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.topbar button:hover { background: rgba(255,255,255,.24); }
.topbar select.input { color: var(--ink); background: #fff; }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 56px; z-index: 19; }
.tabs button { border: 0; background: none; padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .badge { margin-left: 6px; }

.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page.narrow { max-width: 560px; }

/* การ์ด */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.pad-s { padding: 12px; }
.card h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.buy { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.grid.checkin { grid-template-columns: 360px minmax(0, 1fr); align-items: start; }
.grid.metals { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 960px) {
  .grid.two, .grid.buy, .grid.checkin { grid-template-columns: minmax(0, 1fr); }
}

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; min-height: 42px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #faf8f3; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0c4bf; }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.big { min-height: 56px; font-size: 18px; padding: 12px 20px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 14px; }

/* ชิปเลือก */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; min-height: 42px; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips.seg button { border-radius: 10px; }

/* ช่องกรอก */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; background: #fff; min-height: 44px; }
.input:focus { outline: 3px solid rgba(138, 28, 28, .18); border-color: var(--brand); }
.input.big { font-size: 26px; font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; }
.input.bad { border-color: var(--bad); background: var(--bad-soft); }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.input-unit .input { padding-right: 52px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* ป้ายสถานะ */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; background: #eee9df; color: var(--ink-2); }
.badge.locked { background: var(--warn-soft); color: var(--warn); }
.badge.checked { background: var(--info-soft); color: var(--info); }
.badge.paid, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled, .badge.void, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gold { background: var(--gold-soft); color: #8a6114; }
.badge.count { background: var(--brand); color: #fff; padding: 0 7px; min-width: 22px; justify-content: center; }

/* กล่องข้อความ */
.note { border-radius: 10px; padding: 10px 12px; font-size: 15px; border: 1px solid; }
.note.warn { background: var(--warn-soft); border-color: #f3d3a8; color: #6b3a06; }
.note.bad { background: var(--bad-soft); border-color: #f1bdb7; color: #7a1a12; }
.note.ok { background: var(--ok-soft); border-color: #b9dfc9; color: #0f4d2d; }
.note.info { background: var(--info-soft); border-color: #c4d3f7; color: #183b9c; }

/* ตาราง */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.table { border-collapse: collapse; width: 100%; font-size: 15px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #faf7f1; font-size: 13px; color: var(--ink-2); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.void td { color: var(--ink-3); text-decoration: line-through; }
.table tr.void td.keep { text-decoration: none; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fbf8f2; }
.table tr.sel td { background: var(--gold-soft); }

/* คู่ค่า */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kv .sep { grid-column: 1 / -1; border-top: 1px dashed var(--line-2); margin: 4px 0; }
.kv .total { font-size: 20px; font-weight: 800; }

.amount { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.amount.mid { font-size: 24px; }
.amount small { font-size: 16px; font-weight: 600; color: var(--ink-2); }

/* รายการโลหะในหน้าเจ้าของ */
.metal-card { border-left: 5px solid var(--line-2); }
.metal-card.need { border-left-color: var(--warn); background: linear-gradient(0deg, #fff, #fffaf2); }
.metal-card.over { border-left-color: var(--bad); }
.metal-card.zero { border-left-color: var(--ok); }
.metal-card .big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* รายการล็อกแบบการ์ด */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; width: 100%; }
.item:hover { border-color: var(--line-2); }
.item.on { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(138, 28, 28, .15); }
.item .t { font-weight: 700; }
.item.overdue { border-left: 5px solid var(--bad); }

/* ข้อความแจ้ง */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 15px; animation: tin .2s ease-out; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.alert { background: var(--gold); color: #1f1c17; font-weight: 700; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* หน้าต่างซ้อน */
.modal-back { position: fixed; inset: 0; background: rgba(20, 17, 12, .45); z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 16px 18px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-body { padding: 14px 18px; }
.modal-foot { padding: 0 18px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--ink-3); line-height: 1; padding: 4px 8px; }

/* แถบล่างของหน้ามือถือ */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav button { border: 0; background: none; padding: 8px 4px 10px; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottomnav button .ic { font-size: 20px; line-height: 1; }
.bottomnav button.on { color: var(--brand); }
.has-bottomnav { padding-bottom: 84px; }

.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; }
.divider { border-top: 1px solid var(--line); margin: 12px 0; }
.pill-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* หน้าเข้าสู่ระบบ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #fff6e3, var(--bg) 60%); }
.login-card { width: min(400px, 100%); }
.login-pair { display: flex; gap: 16px; align-items: flex-start; justify-content: center; flex-wrap: wrap; width: 100%; }
#demo .list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#demo .item { padding: 8px 10px; }
#demo .item .t { font-size: 15px; }
#demo .item .faint { font-size: 12.5px; }
@media (max-width: 420px) { #demo .list { grid-template-columns: 1fr; } }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: var(--gold); display: grid; place-items: center; font-size: 28px; margin: 0 auto 12px; }

/* ช่องราคาทองเรียลไทม์ */
.livep { background: linear-gradient(135deg, #fffaf0, #fff 70%); border: 1px solid #ecd9ae; border-left: 6px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; display: grid; gap: 4px; }
.livep.bad { border-left-color: var(--bad); border-color: #f1bdb7; background: linear-gradient(135deg, #fff3f1, #fff 70%); }
.livep.warn { border-left-color: #e08a12; }
.livep.manual, .livep.wait { border-left-color: var(--ink-3); background: var(--card); border-color: var(--line); }
.lp-head { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; }
.lp-title { font-weight: 700; color: var(--ink-2); }
.lp-status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--ink-3); flex: none; }
.dot.ok { background: #22a35a; animation: pulse 2s infinite; }
.dot.bad { background: var(--bad); }
.dot.warn { background: #e08a12; }
.dot.wait, .dot.manual { background: #9a9385; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 163, 90, .55); } 70% { box-shadow: 0 0 0 8px rgba(34, 163, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 163, 90, 0); } }
.lp-main { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; }
.lp-price { font-size: 44px; font-weight: 800; letter-spacing: -1px; color: #3d2a06; line-height: 1.1; border-radius: 8px; padding: 0 6px; margin-left: -6px; }
.lp-price.dim { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 3px; }
.lp-unit { font-weight: 700; color: var(--ink-2); }
.lp-delta { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.lp-delta.up { color: var(--ok); }
.lp-delta.down { color: var(--bad); }
.flash-up { animation: flashUp 1.6s ease-out; }
.flash-down { animation: flashDown 1.6s ease-out; }
@keyframes flashUp { from { background: #bdebcd; } to { background: transparent; } }
@keyframes flashDown { from { background: #f6cbc4; } to { background: transparent; } }
.lp-src { display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; justify-self: start; }
.src-badge { border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; background: #e6e1d6; color: var(--ink-2); }
.src-badge.asso { background: #8a6114; color: #fff; }
.src-badge.mts { background: var(--brand); color: #fff; }
.lp-both { font-variant-numeric: tabular-nums; justify-self: start; }
.lp-warn { background: var(--warn-soft); color: #6b3a06; border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 600; }
.livep.bad .lp-warn { background: var(--bad-soft); color: #7a1a12; }
.lp-lock { display: flex; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; font-weight: 700; font-size: 14px; border-top: 1px dashed var(--line-2); padding-top: 6px; margin-top: 2px; }
.lp-lock.open { color: var(--ok); }
.lp-lock.closed { color: var(--bad); }
.lp-pgm { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; border-top: 1px dashed var(--line-2); padding-top: 6px; margin-top: 2px; font-size: 15px; }
.lp-pgm-t { font-size: 13px; font-weight: 700; color: #8a6114; background: var(--gold-soft); border-radius: 999px; padding: 1px 8px; }
.bad-t { color: var(--bad); font-weight: 700; }
.lp-board { font-size: 14px; font-weight: 600; justify-self: start; }
.livep.compact .lp-price { font-size: 32px; }
.topbar .chip-price .dot { width: 8px; height: 8px; margin-right: 6px; vertical-align: 1px; animation: none; }
.topbar .chip-price .dot.ok { background: #6ee39a; }
.topbar .chip-price .dot.bad { background: #ffb0a5; }
.price-live { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: stretch; margin-bottom: 16px; }
@media (max-width: 960px) { .price-live { grid-template-columns: minmax(0, 1fr); } }
.input:disabled { background: #f3efe6; color: var(--ink-2); }
.auto-tag { font-size: 12px; font-weight: 700; color: #8a6114; background: var(--gold-soft); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.timegrid { display: grid; grid-template-columns: auto auto auto auto; gap: 8px 10px; align-items: center; justify-content: start; align-self: flex-start; }
.timegrid .input { width: 96px; min-height: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.feed-table td, .feed-table th { padding: 6px 10px; }

/* ภาพถ่ายสินค้า */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumbs figure { position: relative; margin: 0; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.thumbs figcaption { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; border-radius: 6px; padding: 0 6px; }
.thumbs button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; }
.chips.small button { min-height: 36px; padding: 5px 12px; font-size: 14px; }

/* จอแสดงราคาให้ลูกค้าดู (/board) */
body.board { background: #1d0d0b; color: #fff; }
.board-wrap { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.board-top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--brand); }
.board-top .brand { font-weight: 800; font-size: clamp(18px, 2.6vw, 30px); display: flex; align-items: center; gap: 10px; }
.board-top .mark { width: 1.4em; height: 1.4em; border-radius: 10px; background: var(--gold); display: grid; place-items: center; }
.board-top .clock { margin-left: auto; font-size: clamp(16px, 2.2vw, 26px); font-variant-numeric: tabular-nums; }
.board-top button { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.board-main { display: grid; place-items: center; text-align: center; padding: 24px; gap: 8px; align-content: center; }
.board-title { font-size: clamp(22px, 3.6vw, 44px); font-weight: 700; color: #f3dfb0; }
.board-price { font-size: clamp(72px, 16vw, 230px); font-weight: 800; line-height: 1; color: #ffd36b; font-variant-numeric: tabular-nums; letter-spacing: -2px; border-radius: 16px; padding: 0 16px; }
.board-price.dim { color: #8d7b6a; text-decoration: line-through; }
.board-unit { font-size: clamp(18px, 2.4vw, 30px); color: #e9d9c0; }
.board-src { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: clamp(16px, 2vw, 24px); color: #e9d9c0; }
.board-src .src-badge { font-size: clamp(16px, 2vw, 24px); padding: 4px 16px; }
.board-src .src-badge.asso { background: #c79a3a; color: #1d0d0b; }
.board-src .src-badge.mts { background: #fff; color: var(--brand); }
.board-warn { background: #7a1a12; color: #fff; border-radius: 12px; padding: 10px 18px; font-size: clamp(16px, 2vw, 24px); font-weight: 700; }
.board-more { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.board-more div { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 12px 22px; min-width: 220px; }
.board-more b { display: block; font-size: clamp(26px, 3.6vw, 44px); color: #ffe7b0; font-variant-numeric: tabular-nums; }
.board-more span { color: #d6c6ad; font-size: clamp(14px, 1.6vw, 18px); }
.board-foot { padding: 12px 24px; color: #bba88e; font-size: 14px; text-align: center; }
.board .dot.ok { background: #6ee39a; }

@media (max-width: 600px) {
  .page { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .topbar .chip-price { display: none; }
  .amount { font-size: 28px; }
  .tabs { padding: 4px 8px 0; }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- ลูกค้า: ราคาทุกโลหะ และราคาที่จะล็อก ---------- */
.pc { display: grid; gap: 10px; padding: 14px; }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; width: 100%; }
.pc-name { font-size: 22px; font-weight: 800; color: var(--brand); }
.pc-go { font-weight: 700; color: var(--brand); font-size: 15px; white-space: nowrap; }
.pc-base { background: var(--gold-soft); border: 1px solid #ecd9ae; border-radius: 10px; padding: 6px 10px; font-size: 15px; }
.pc-base b { font-size: 18px; }
.pc-prod { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.pc-sub { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; width: 100%; font-weight: 700; font-size: 17px; color: var(--ink); }
.pc-sub .faint { font-weight: 600; white-space: nowrap; }
.pc-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 15px; }
.pc-line b { font-size: 19px; }
.pc-line small, .pc-cell small { color: var(--ink-3); font-weight: 600; }
.pc-line.hit { background: var(--gold-soft); border-radius: 8px; padding: 3px 8px; margin: 0 -8px; }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.pc-cell { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; border: 1px solid var(--line); background: #fcfaf6; border-radius: 10px; padding: 8px 10px; cursor: pointer; text-align: left; font-size: 15px; }
.pc-cell b { font-size: 17px; }
.pc-cell:hover, .pc-sub:hover span:first-child, .pc-head:hover .pc-name { color: var(--brand-2); }
.pc-bands { display: grid; gap: 2px; }
.lock-price { border: 2px solid var(--gold); background: linear-gradient(135deg, #fffaf0, #fff 70%); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.lock-price.paused { border-color: var(--bad); }
.lk-k { font-weight: 700; color: var(--ink-2); font-size: 14px; }
.lk-k2 { font-weight: 700; font-size: 17px; }
.lk-v { line-height: 1.1; }
.lk-v .num { font-size: 40px; font-weight: 800; letter-spacing: -1px; color: #3d2a06; }
.lk-v small { font-size: 15px; font-weight: 700; color: var(--ink-2); }
/* ---------- ตารางทองแท่ง/รูปพรรณ (หน้าตั้งค่า) ---------- */
.gtab input.input { min-height: 36px; padding: 4px 8px; width: 96px; text-align: right; }
.gtab td, .gtab th { vertical-align: middle; }
.gtab .res { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.gtab.row input.input { width: 110px; }
.pc-cell > span { display: grid; }
.pc-one { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; width: 100%; color: var(--ink); }
.pc-one .t { font-weight: 700; font-size: 17px; }
.pc-one .v { text-align: right; }
.pc-one .v b { font-size: 21px; }
.pc-one .v small { display: block; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.gtab .ov { background: var(--warn-soft); }

/* แถบแจ้งเจ้าของร้านเปลี่ยนสิทธิ์ */
.perm-banner { position: sticky; top: 0; z-index: 60; margin: 0; border-radius: 0; border-width: 0 0 1px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* ตารางตั้งสิทธิ์ตามตำแหน่ง */
.perm-table th, .perm-table td { vertical-align: middle; }
.perm-table td:first-child, .perm-table th:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 230px; max-width: 340px; white-space: normal; }
.perm-table th:first-child { background: #faf7f1; z-index: 2; }
.perm-table td.pcell { text-align: center; min-width: 150px; }
.perm-table td.pcell input[type="checkbox"] { width: 22px; height: 22px; cursor: pointer; }
.perm-table td.pcell select.input { min-height: 38px; padding: 6px 8px; font-size: 14px; }
.perm-table tr.grp td { background: #f6f1e6; font-weight: 700; color: var(--ink-2); font-size: 14px; }
.perm-table th.pos { min-width: 150px; text-align: center; white-space: normal; }
.perm-table th.pos input.input { min-height: 38px; padding: 6px 8px; text-align: center; font-weight: 700; }
.perm-table .hint { display: block; font-weight: 400; color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.perm-scope { font-size: 14px; }
.input[readonly], select.input:disabled { background: #f6f3ec; color: var(--ink-2); }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; gap: 8px; z-index: 10; }
@media (max-width: 600px) {
  .perm-table td:first-child, .perm-table th:first-child { min-width: 150px; max-width: 170px; font-size: 14px; padding: 8px; }
  .perm-table th.pos, .perm-table td.pcell { min-width: 118px; padding: 8px 6px; }
  .perm-table .hint { font-size: 12px; }
}

/* ประวัติการซื้อขายของลูกค้า */
.hist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; }
.hist-grid .wide { grid-column: span 2; }
.hist-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.hist-cust { border-left: 5px solid var(--brand); }
.hist-table { min-width: 940px; }
.linkish { border: 0; background: none; padding: 0; margin: 0; font: inherit; font-weight: 700; color: var(--brand); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: rgba(138, 28, 28, .35); text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: currentColor; }
@media (max-width: 600px) {
  .hist-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hist-grid .wide { grid-column: 1 / -1; }
}
