:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f0ebe3;
  --text: #2b2420;
  --muted: #7a6f66;
  --line: #e4ddd3;
  --brand: #c2410c;
  --brand-ink: #ffffff;
  --brand-soft: #fde8dc;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --ok-ink: #ffffff;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412; --surface: #221e1b; --surface-2: #2c2723; --text: #f3ede7; --muted: #a89c91; --line: #3a332e;
    --brand: #fb923c; --brand-ink: #1a1007; --brand-soft: #3b2415; --ok: #4ade80; --ok-ink: #052e16; --ok-soft: #15301f;
    --warn: #fbbf24; --warn-soft: #3a2c0d; --danger: #f87171; --danger-soft: #3b1717;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: .75rem; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .75rem 1rem; display: flex; gap: .75rem; align-items: center; justify-content: space-between;
}
.topbar .title { font-weight: 700; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: .75rem; }
.grid.items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: .55rem .9rem; cursor: pointer; min-height: 42px;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn-ok { background: var(--ok); color: var(--ok-ink); border-color: var(--ok); font-weight: 600; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .65rem; min-height: 40px; width: 100%;
}
input[type=checkbox] { width: auto; min-height: 0; }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
label.field > .hint { font-size: .8rem; line-height: 1.45; margin: .3rem 0 0; }
label.field > .hint b { color: var(--text); font-weight: 600; }
textarea.prompt { min-height: 220px; font-size: .85rem; line-height: 1.5; resize: vertical; }

.item {
  text-align: left; display: flex; flex-direction: column; gap: .25rem; padding: .8rem; min-height: 92px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.item .name { font-weight: 600; }
.item .price { color: var(--brand); font-weight: 700; margin-top: auto; }
.item:active { transform: scale(.98); }

.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; background: var(--surface-2); color: var(--muted); }
.chip.new { background: var(--warn-soft); color: var(--warn); }
.chip.cooking { background: var(--brand-soft); color: var(--brand); }
.chip.served { background: var(--ok-soft); color: var(--ok); }
.chip.cancelled { background: var(--danger-soft); color: var(--danger); }
.chip.qr { background: var(--brand-soft); color: var(--brand); }

.tabs { display: flex; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
.tabs button { white-space: nowrap; border-radius: 999px; }
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: .45rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 500; }
table.list td.num, table.list th.num { text-align: right; }
.table-scroll { overflow-x: auto; }

.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.4rem; font-weight: 700; }

.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 1.1rem; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); color: #fff; }

.qty { display: inline-flex; align-items: center; gap: .35rem; }
.qty button { min-width: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

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