:root {
  --paper: #faf7f2;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e1d8;
  --accent: #d9480f;
  --accent-soft: #fdefe8;
  --green: #157f3d;
  --green-soft: #e7f5ec;
  --amber: #a16207;
  --amber-soft: #fdf3d7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 8px 24px rgba(28, 25, 23, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans Thai", -apple-system, "SF Thai", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

.shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--paper); position: relative; padding-bottom: 92px; }
.shell.wide { max-width: 900px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 247, 242, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
}
.topbar-row { display: flex; align-items: center; gap: 10px; }
.table-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff;
  padding: 5px 11px; border-radius: 999px;
  font-size: 14px; font-weight: 700; letter-spacing: .2px;
}
.table-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.title { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: auto; }

.search {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding: 9px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
}
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; }
.search input::placeholder { color: #a8a29e; }
.search svg { flex: none; opacity: .45; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  font-size: 14px; color: var(--muted); white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* ---------- menu list ---------- */
.section-label { padding: 18px 16px 8px; font-size: 13px; font-weight: 700; letter-spacing: .4px; color: var(--muted); text-transform: uppercase; }
.list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow);
  text-align: left; width: 100%;
}
.item:active { transform: scale(.995); }
.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 15.5px; font-weight: 600; line-height: 1.35; }
.item-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: #f5f2ec; color: var(--muted); }
.tag.hot { background: var(--accent-soft); color: var(--accent); }
.item-price { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.add {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; font-size: 22px; line-height: 1;
  display: grid; place-items: center; align-self: center;
  box-shadow: 0 3px 10px rgba(217, 72, 15, .28);
}

/* ---------- bottom bar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 62%, rgba(250, 247, 242, 0));
}
.cta {
  width: 100%; padding: 14px 18px; border-radius: 13px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 6px 18px rgba(217, 72, 15, .28);
}
.cta:disabled { background: #d6d3d1; box-shadow: none; }
.cta-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; padding: 9px 0 10px; font-size: 11.5px; color: var(--muted); display: grid; justify-items: center; gap: 3px; }
.tabbar button.on { color: var(--accent); font-weight: 700; }
.tabbar .badge { position: absolute; margin-left: 18px; margin-top: -4px; background: var(--accent); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(28, 25, 23, .38);
}
.sheet.open { display: block; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 12px; }
.sheet h2 { font-size: 19px; margin: 0 0 2px; line-height: 1.35; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.group { margin: 16px 0; }
.group-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.group-name { font-size: 14px; font-weight: 700; }
.group-req { font-size: 11.5px; color: var(--accent); }

.opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 7px; background: #fff; width: 100%; text-align: left; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt .mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #d6d3d1; flex: none; display: grid; place-items: center; }
.opt.on .mark { border-color: var(--accent); background: var(--accent); }
.opt.on .mark::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.opt.multi .mark { border-radius: 6px; }
.opt.multi.on .mark { border-radius: 6px; }
.opt-label { flex: 1; font-size: 15px; }
.opt-delta { font-size: 13.5px; color: var(--muted); }

textarea.note { width: 100%; min-height: 62px; resize: none; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; outline: 0; }
textarea.note:focus { border-color: var(--accent); }

.qty { display: flex; align-items: center; gap: 4px; background: #f5f2ec; border-radius: 999px; padding: 3px; }
.qty button { width: 34px; height: 34px; border-radius: 50%; background: #fff; font-size: 19px; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.qty span { min-width: 30px; text-align: center; font-weight: 700; }

/* ---------- cart / bill ---------- */
.rows { padding: 4px 16px 0; }
.row { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 15px; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.row-note { font-size: 13px; color: var(--accent); margin-top: 2px; }
.row-price { font-weight: 700; white-space: nowrap; }

.total { margin: 14px 16px 0; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.total-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.total-line.grand { font-size: 18px; color: var(--ink); font-weight: 700; margin: 8px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); }

.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- order status ---------- */
.status-card { margin: 12px 16px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.status-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.code { font-weight: 800; letter-spacing: .5px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.queued { background: var(--amber-soft); color: var(--amber); }
.pill.cooking { background: var(--accent-soft); color: var(--accent); }
.pill.served { background: var(--green-soft); color: var(--green); }
.status-items { font-size: 14px; color: #44403c; }
.status-items div { padding: 2px 0; }

/* ---------- staff ---------- */
.tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tab { flex: 1; padding: 9px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px 16px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; text-align: left; box-shadow: var(--shadow); }
.tcard.open { border-color: var(--accent); background: #fffdfb; }
.tcard-name { font-weight: 700; font-size: 16px; }
.tcard-state { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tcard-amt { font-weight: 700; margin-top: 8px; font-size: 15px; }

.kds { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.kcard { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--amber); border-radius: 12px; padding: 13px 14px; }
.kcard.cooking { border-left-color: var(--accent); }
.kcard-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kcard-table { font-weight: 800; font-size: 17px; }
.kcard-time { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.kitem { display: flex; gap: 8px; font-size: 15px; padding: 3px 0; }
.kitem b { min-width: 22px; }
.kitem-opt { font-size: 12.5px; color: var(--muted); }
.kitem-note { color: var(--accent); font-weight: 600; }
.kactions { display: flex; gap: 8px; margin-top: 10px; }
.kbtn { flex: 1; padding: 10px; border-radius: 10px; font-size: 14px; font-weight: 700; background: #f5f2ec; }
.kbtn.primary { background: var(--accent); color: #fff; }
.kbtn.done { background: var(--green); color: #fff; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hint { margin: 10px 16px; padding: 10px 12px; border-radius: 10px; background: #fdf3d7; color: #713f12; font-size: 12.5px; line-height: 1.45; }
