:root {
  --choc: #4a2c20;
  --choc-2: #6b4130;
  --cream: #f7f0e4;
  --cream-2: #efe3cf;
  --paper: #fffaf2;
  --caramel: #c47f3e;
  --ink: #2b1a12;
  --muted: #8a7363;
  --line: #e2d3bd;
  --ok: #3f7d4e;
  --warn: #b7791f;
  --bad: #b23b2e;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(74, 44, 32, .08);
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); min-height: 100%; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

.btn {
  background: var(--choc); color: var(--cream); padding: 14px 18px; border-radius: 12px; font-weight: 600;
  min-height: 48px; transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.light { background: var(--paper); color: var(--choc); border: 1.5px solid var(--line); }
.btn.caramel { background: var(--caramel); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: transparent; color: var(--bad); border: 1.5px solid #e7b9b2; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper);
  min-height: 48px; font-size: 16px;
}
.input:focus { outline: 2px solid var(--caramel); outline-offset: 1px; border-color: transparent; }
label.field { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }

.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--cream-2); color: var(--choc); }
.pill.ok { background: #dcefe0; color: var(--ok); }
.pill.warn { background: #fbecd0; color: var(--warn); }
.pill.bad { background: #f6dcd8; color: var(--bad); }

.brand { font-weight: 700; letter-spacing: .5px; color: var(--choc); }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); letter-spacing: 0; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(43, 26, 18, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--paper); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 20px 18px 24px; max-height: 92vh; overflow: auto; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 22px; } }
.modal h2 { margin-bottom: 12px; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--choc); color: var(--cream); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); transition: opacity .3s; text-align: center; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; }

/* ---------- customer page ---------- */
.c-wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; }
.c-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 14px; }
.c-head h1 { font-size: 26px; color: var(--choc); }
.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; position: sticky; top: 0; background: var(--cream); z-index: 5; padding-top: 6px; }
.cats button { white-space: nowrap; padding: 9px 16px; border-radius: 99px; background: var(--paper); border: 1.5px solid var(--line); font-weight: 600; color: var(--choc); }
.cats button.on { background: var(--choc); color: var(--cream); border-color: var(--choc); }
.cat-title { margin: 18px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.mi { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--paper); border-radius: 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.mi .name { font-weight: 600; }
.mi .price { color: var(--caramel); font-weight: 700; margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; background: var(--cream-2); color: var(--choc); font-size: 22px; font-weight: 700; line-height: 1; }
.stepper button.add { background: var(--choc); color: var(--cream); }
.stepper .q { min-width: 26px; text-align: center; font-weight: 700; }
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--cream) 30%); }
.cartbar .btn { width: 100%; max-width: 528px; display: flex; justify-content: space-between; margin: 0 auto; font-size: 17px; }
.big-q { font-size: 72px; font-weight: 800; color: var(--choc); letter-spacing: 2px; line-height: 1; margin: 8px 0; }
.steps { display: flex; justify-content: space-between; margin: 18px 0 6px; position: relative; }
.steps div { flex: 1; text-align: center; font-size: 13px; color: var(--muted); }
.steps div b { display: block; width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 50%; background: var(--cream-2); line-height: 30px; color: var(--muted); }
.steps div.on { color: var(--choc); font-weight: 600; }
.steps div.on b { background: var(--choc); color: var(--cream); }
.qr-img { width: 100%; max-width: 320px; display: block; margin: 10px auto; border-radius: 12px; background: #fff; padding: 8px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { padding: 16px 10px; border-radius: 14px; background: var(--paper); border: 2px solid var(--line); font-weight: 600; }
.choice button.on { border-color: var(--choc); background: var(--cream-2); }

/* ---------- POS ---------- */
.pos-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--choc); color: var(--cream); position: sticky; top: 0; z-index: 20; }
.pos-top .brand { color: var(--cream); font-size: 20px; }
.pos-top .brand small { color: #d9c4a8; }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tabs button { background: transparent; color: #e7d6bf; padding: 10px 14px; border-radius: 10px; font-weight: 600; white-space: nowrap; position: relative; }
.tabs button.on { background: var(--cream); color: var(--choc); }
.tabs .badge { position: absolute; top: 2px; right: 2px; background: var(--caramel); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 6px; }
.userchip { font-size: 14px; color: #e7d6bf; white-space: nowrap; }
.view { padding: 16px; }

.sell { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .sell { grid-template-columns: 1fr; } .cart-panel { position: static !important; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--paper); border-radius: 14px; padding: 14px 12px; text-align: left; min-height: 92px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; border: 2px solid transparent; }
.tile:active { border-color: var(--caramel); }
.tile .n { font-weight: 600; font-size: 15px; }
.tile .p { color: var(--caramel); font-weight: 700; }
.cart-panel { position: sticky; top: 76px; }
.cart-line { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-line .stepper button { width: 34px; height: 34px; font-size: 18px; }
.total { display: flex; justify-content: space-between; font-size: 22px; font-weight: 700; margin: 14px 0; color: var(--choc); }

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.col h3 { font-size: 15px; color: var(--muted); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.ticket { background: var(--paper); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 5px solid var(--line); }
.ticket.pending { border-left-color: var(--caramel); }
.ticket.preparing { border-left-color: var(--choc-2); }
.ticket.ready { border-left-color: var(--ok); }
.ticket .qn { font-size: 26px; font-weight: 800; color: var(--choc); }
.ticket ul { margin: 8px 0; padding-left: 18px; }
.ticket li { margin: 2px 0; }
.ticket .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 16px auto; }
.numpad button { height: 64px; border-radius: 16px; background: var(--paper); font-size: 26px; font-weight: 700; color: var(--choc); box-shadow: var(--shadow); }
.dots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--choc); }
.dots i.f { background: var(--choc); }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.who button { background: var(--paper); padding: 18px 10px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); border: 2px solid transparent; }
.who button.on { border-color: var(--choc); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--paper); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; color: var(--choc); margin-top: 4px; }
table.t { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
.t th, .t td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--cream-2); }
.t th { background: var(--cream-2); font-weight: 600; color: var(--choc); }
.t td.r, .t th.r { text-align: right; }
.scroll-x { overflow-x: auto; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick button { padding: 10px 14px; border-radius: 10px; background: var(--cream-2); font-weight: 600; color: var(--choc); }
.change { font-size: 28px; font-weight: 800; color: var(--ok); text-align: center; margin: 12px 0; }
.section-title { font-size: 18px; margin: 22px 0 10px; color: var(--choc); }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.switch input { width: 22px; height: 22px; accent-color: var(--choc); }
.center { text-align: center; }
.mw { max-width: 760px; }

#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  body { background: #fff; }
}

/* kitchen screen */
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.kt { background: var(--paper); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); border-top: 8px solid var(--choc-2); }
.kt.new { border-top-color: var(--caramel); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(196, 127, 62, .35); } }
.kt .qn { font-size: 44px; font-weight: 800; color: var(--choc); line-height: 1; }
.kt ul { list-style: none; padding: 0; margin: 10px 0; }
.kt li { font-size: 20px; font-weight: 600; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kt li .nt { display: block; font-size: 16px; font-weight: 400; color: var(--bad); }
.kt .age { font-size: 14px; color: var(--muted); }
.kt .age.late { color: var(--bad); font-weight: 700; }
.kt .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.kt .acts .btn { min-height: 56px; font-size: 17px; }
