:root {
  /* OmletPOS: ไข่เจียวเหลือง + ตัวอักษรดำถ่าน */
  --bg: #f8f4ec; --panel: #fffdf9; --ink: #222326; --muted: #6d6a63; --line: #e8e1d3;
  --green: #26272b; --green-2: #f2b705; --green-soft: #fff1c7; --amber: #e8a400; --amber-soft: #fff3cf;
  --yolk: #f7b80f; --yolk-dark: #d99a00; --ok: #2f7d4a; --ok-soft: #e1f1e6;
  --red: #b4432f; --red-soft: #f8e1dc; --blue: #2d6a9f; --blue-soft: #dfeaf4;
  --radius: 14px; --shadow: 0 1px 2px rgba(31,42,34,.06), 0 4px 14px rgba(31,42,34,.06);
  --font: 'IBM Plex Sans Thai', 'Sukhumvit Set', 'Thonburi', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-2); outline-offset: -1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* buttons */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.amber { background: var(--amber); color: #fff; border-color: var(--amber); }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: #efc5bc; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* layout */
#app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; color: var(--ink); border-bottom: 1px solid var(--line); padding-top: max(8px, env(safe-area-inset-top)); }
.topbar .tb-mark { height: 26px; flex-shrink: 0; }
.topbar .btn.ghost { color: var(--muted); }
.topbar .brand { font-weight: 700; font-size: 17px; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.topbar nav button { color: var(--muted); padding: 8px 12px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.topbar nav button.on { background: var(--yolk); color: var(--ink); }
.plan-banner { display: block; text-align: center; padding: 8px 12px; background: var(--amber-soft); color: #7a5300; font-weight: 600; font-size: 14px; text-decoration: none; border-bottom: 1px solid #f1dca0; }
.plan-banner.bad { background: var(--red-soft); color: var(--red); border-color: #efc5bc; }
.topbar .who { font-size: 13px; opacity: .85; white-space: nowrap; }
main { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 16px; max-width: 1280px; margin: 0 auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #ffe28a 0, #fbcf43 28%, #f2b705 60%, #d99a00 100%); }
.login-logo { height: 46px; display: block; margin: 0 auto 10px; }
.login .box.acct { text-align: left; width: min(400px, 100%); }
.login .box.acct h2 { text-align: center; margin: 4px 0 10px; }
.login .box.acct .muted { text-align: center; }
.login a { color: var(--yolk-dark); font-weight: 700; }
.login .box { background: var(--panel); border-radius: 22px; padding: 26px; width: min(360px, 100%); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login h1 { margin: 0 0 4px; font-size: 22px; color: var(--green); }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--green); }
.pin-dots span.f { background: var(--green); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { height: 62px; border-radius: 14px; background: var(--bg); font-size: 24px; font-weight: 600; }
.pinpad button:active { background: var(--green-soft); }
.err { color: var(--red); min-height: 22px; font-size: 14px; }

/* tabs list */
.tab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tab-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-height: 112px; position: relative; }
.tab-card .label { font-size: 18px; font-weight: 700; }
.tab-card .total { font-size: 20px; font-weight: 700; color: var(--green); margin-top: auto; }
.tab-card .meta { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--amber-soft); color: #8a5c00; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.tab-card .badge { position: absolute; top: 10px; right: 10px; }
.new-card { border: 2px dashed #b9c9b3; background: transparent; box-shadow: none; align-items: center; justify-content: center; color: var(--green); font-weight: 700; font-size: 16px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { padding: 10px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 600; min-width: 64px; }
.quick button.busy { background: var(--amber-soft); color: #8a5c00; }
.seg { display: inline-flex; background: #e9e4d8; border-radius: 11px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* order screen */
.order { display: grid; grid-template-columns: minmax(0,1fr) 380px; height: 100%; }
.menu-side { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.menu-head { padding: 10px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.cats button { white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; }
.cats button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.items { flex: 1; overflow: auto; padding: 6px 12px 100px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; grid-auto-rows: max-content; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: left; min-height: 92px; display: flex; flex-direction: column; gap: 4px; border-left: 5px solid var(--c, var(--green)); box-shadow: var(--shadow); }
.item:active { transform: scale(.97); background: var(--green-soft); }
.item .n { font-weight: 600; line-height: 1.25; }
.item .en { font-size: 12px; color: var(--muted); }
.item .p { margin-top: auto; font-weight: 700; color: var(--green); }
.item .st { font-size: 11px; color: var(--muted); }
.item.out { opacity: .4; }
.item.low .st { color: var(--red); font-weight: 600; }
.bill-side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.bill-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.bill-head .label { font-size: 19px; font-weight: 700; }
.lines { flex: 1; overflow: auto; padding: 4px 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 14px; border-bottom: 1px solid #f0ebe0; }
.line .nm { font-weight: 600; }
.line .nt { font-size: 12px; color: var(--amber); grid-column: 1; }
.line .amt { text-align: right; font-weight: 600; }
.line .ctl { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.line .ctl .q { min-width: 28px; text-align: center; font-weight: 700; }
.line .ctl button.qb { width: 34px; height: 34px; border-radius: 9px; background: var(--bg); font-size: 18px; font-weight: 700; }
.line.pending { background: #fffbef; }
.line.void .nm, .line.void .amt { text-decoration: line-through; color: var(--muted); }
.totals { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.totals .r { display: flex; justify-content: space-between; }
.totals .grand { font-size: 22px; font-weight: 700; color: var(--green); }
.bill-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.empty { padding: 30px 14px; text-align: center; color: var(--muted); }
.phone-bar { display: none; }

/* modal / sheet */
.overlay { position: fixed; inset: 0; background: rgba(20,28,22,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 20px; width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(760px, 100%); }
.modal h3 { font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.pay-methods button { padding: 12px 6px; border-radius: 12px; border: 2px solid var(--line); font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.pay-methods button .ic { font-size: 22px; }
.pay-methods button.on { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.due { text-align: center; padding: 10px; background: var(--bg); border-radius: 14px; margin-bottom: 14px; }
.due .v { font-size: 34px; font-weight: 800; color: var(--green); }
.cash-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; }
.cash-quick button { padding: 12px 4px; border-radius: 10px; background: var(--bg); font-weight: 700; }
.change { font-size: 20px; font-weight: 700; text-align: center; padding: 10px; border-radius: 12px; background: var(--amber-soft); color: #7a5000; }
.qr { text-align: center; }
.qr img { width: 260px; max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.toast-wrap { position: fixed; bottom: max(90px, calc(env(safe-area-inset-bottom) + 90px)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-weight: 600; animation: pop .2s; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

/* kds */
.kds { background: #161b17; color: #eef2ec; min-height: 100%; }
.kds .page { max-width: none; }
.kds .head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.kds .seg { background: #2a322b; }
.kds .seg button { color: #9aa79a; }
.kds .seg button.on { background: #eef2ec; color: #161b17; }
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.ticket { background: #222a23; border-radius: 14px; overflow: hidden; border: 2px solid #2f3a30; }
.ticket .th { padding: 10px 12px; display: flex; justify-content: space-between; align-items: baseline; background: #2f5d3a; }
.ticket.warn .th { background: #9a6a0a; }
.ticket.late .th { background: #a03a28; }
.ticket.fresh { animation: flash 1.2s 3; }
@keyframes flash { 50% { border-color: #f5c242; } }
.ticket .tl { font-size: 20px; font-weight: 800; }
.ticket .tt { font-size: 14px; font-weight: 700; }
.ticket ul { list-style: none; margin: 0; padding: 8px 12px; }
.ticket li { padding: 7px 0; border-bottom: 1px dashed #3a463b; font-size: 18px; }
.ticket li b { color: #f5c242; margin-right: 6px; }
.ticket li .nt { display: block; font-size: 14px; color: #f5a442; margin-left: 26px; }
.ticket li.void { text-decoration: line-through; color: #7d877d; }
.ticket .tf { padding: 10px 12px; display: flex; gap: 8px; }
.ticket .tf .btn { flex: 1; }
.ticket .meta { font-size: 12px; color: #9aa79a; padding: 0 12px; }
.kds .btn { background: #2a322b; border-color: #3a463b; color: #eef2ec; }
.kds .btn.primary { background: #3f9a54; border-color: #3f9a54; }

/* admin / tables */
.subnav { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
td.r, th.r { text-align: right; }
.tbl-wrap { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; max-width: 46px; background: var(--green-2); border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.bars .b span { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: middle; }
.chk { display: flex; align-items: center; gap: 8px; }
.chk input { width: auto; }

/* print */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 0; }
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 72mm; padding: 2mm 3mm; font-family: var(--font); font-size: 12px; color: #000; }
  #print-area .c { text-align: center; }
  #print-area table td { padding: 2px 0; border: 0; font-size: 12px; }
  #print-area hr { border: 0; border-top: 1px dashed #000; }
  #print-area .big { font-size: 16px; font-weight: 700; }
  #print-area img { width: 40mm; }
}

/* responsive */
@media (max-width: 860px) {
  .order { grid-template-columns: minmax(0,1fr); }
  .bill-side { position: fixed; inset: 0; z-index: 40; transform: translateY(100%); transition: transform .25s; border-left: 0; }
  .bill-side.open { transform: none; }
  .phone-bar { display: flex; position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 30; background: var(--green); color: #fff; border-radius: 16px; padding: 14px 18px; font-weight: 700; font-size: 16px; justify-content: space-between; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
  .two-col, .grid2 { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
  .items { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 480px) {
  .page { padding: 12px; }
  .tab-grid { grid-template-columns: 1fr 1fr; }
  .pay-methods { grid-template-columns: repeat(2, 1fr); }
  .topbar .brand { display: none; }
}

/* toasts for QR orders / calls (tap to open bill) */
.toast.sticky { pointer-events: auto; cursor: pointer; padding: 14px 18px; font-size: 16px; }
.toast.qr { background: var(--blue); }
.toast.call { background: var(--amber); }
.thumb { width: 44px; height: 44px; border-radius: 9px; background: var(--bg); border: 1px dashed var(--line); overflow: hidden; display: grid; place-items: center; font-size: 18px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* แพ็กเกจ */
.plan-card { border-left: 6px solid var(--yolk); }
.plan-card.bad { border-left-color: var(--red); }
.price-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.price-pick button { border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; text-align: left; background: #fff; }
.price-pick button b { font-size: 22px; }
.price-pick button small { color: var(--muted); font-size: 12px; }
.price-pick button.on { border-color: var(--yolk); background: var(--amber-soft); }
.slip-img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; background: var(--bg); cursor: zoom-in; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
