/* QB POS — tablet-first UI (palette shared with the Queensbaker mockup) */
:root {
  --bg: #f6f4f0; --panel: #fff; --ink: #2b2522; --muted: #8a8076; --line: #e7e2da;
  --brand: #a4541c; --brand-soft: #f6e7d8;
  --ok: #2e7d32; --ok-soft: #e6f3e6; --warn: #b26a00; --warn-soft: #fdf2dd;
  --bad: #c62828; --bad-soft: #fdeaea; --info: #1565c0; --info-soft: #e8f1fb;
  --auto: #6a4fa3; --auto-soft: #efeaf8; --radius: 10px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Noto Sans Thai', 'Segoe UI', Tahoma, sans-serif; background: var(--bg);
  color: var(--ink); font-size: 16px; overscroll-behavior: none; }
button { font-family: inherit; }

/* topbar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 14px;
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar h1 { font-size: 17.5px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.c-brand { background: var(--brand-soft); color: var(--brand); }
.c-ok { background: var(--ok-soft); color: var(--ok); }
.c-warn { background: var(--warn-soft); color: var(--warn); }
.c-bad { background: var(--bad-soft); color: var(--bad); }
.c-info { background: var(--info-soft); color: var(--info); }
.c-auto { background: var(--auto-soft); color: var(--auto); }
.c-muted { background: #efece7; color: var(--muted); }
.chip.tap { cursor: pointer; border: 1px dashed currentColor; background: transparent; }

/* tabs */
.tabs { display: flex; gap: 2px; background: var(--panel); border-bottom: 2px solid var(--line);
  padding: 0 10px; position: sticky; top: 49px; z-index: 4; overflow-x: auto; }
.tabs button { border: none; background: none; font-size: 16px; padding: 12px 16px; cursor: pointer;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.tab-pane { display: none; padding: 12px; } .tab-pane.active { display: block; }

/* common */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; }
.card h2 { font-size: 16.5px; margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 10px 16px; border-radius: 9px; font-size: 16px; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-big { padding: 14px 20px; font-size: 18px; width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 14px; }
input, select { font-family: inherit; font-size: 17px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=number] { width: 110px; text-align: right; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 3px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { padding: 8px 15px; border-radius: 99px; border: 1px solid var(--line); background: #fff;
  font-size: 15px; cursor: pointer; user-select: none; }
.pill.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.banner { border-radius: 8px; padding: 9px 13px; font-size: 14.5px; margin-bottom: 10px; }
.banner.bad { background: var(--bad-soft); color: #8c1c1c; border: 1px solid #f3c4c4; }
.banner.info { background: var(--info-soft); color: #0d4d8c; border: 1px solid #c4dcf3; }
.banner.warn { background: var(--warn-soft); color: #7a4b00; border: 1px solid #efd9b0; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; color: var(--muted); padding: 7px; border-bottom: 1px solid var(--line); }
td { padding: 9px 7px; border-bottom: 1px solid #f0ece5; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); font-weight: 600; } .neg { color: var(--bad); font-weight: 600; }
.small { font-size: 13.5px; color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 14px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* login */
#view-login { max-width: 460px; margin: 6vh auto; padding: 16px; }
.emp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.emp-btn { padding: 18px 10px; font-size: 18px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; }
.emp-btn.active { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 280px; margin: 0 auto; }
.pinpad button { font-size: 22px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.pin-dots { text-align: center; font-size: 28px; letter-spacing: 10px; min-height: 40px; color: var(--brand); }

/* sale screen */
.pos-wrap { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .pos-wrap { grid-template-columns: 1fr; } }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px;
  max-height: calc(100vh - 290px); overflow-y: auto; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px; cursor: pointer;
  min-height: 78px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; }
.tile:active { border-color: var(--brand); background: var(--brand-soft); }
.tile img { width: calc(100% + 18px); margin: -9px -9px 6px; height: 64px; object-fit: cover;
  border-radius: 9px 9px 0 0; display: block; pointer-events: none; }
.tile .nm { font-size: 14px; font-weight: 600; line-height: 1.25; }
.tile .sku { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.15; }
.tile .pr { font-size: 14.5px; font-weight: 700; color: var(--brand); }
.tile .stk { font-size: 12px; color: var(--muted); }
.tile .stk.neg-stock { color: var(--warn); font-weight: 700; }
.ticket-panel { position: sticky; top: 110px; }
.tk-lines { max-height: calc(100vh - 430px); overflow-y: auto; }
.tk-line { display: flex; gap: 8px; padding: 9px 2px; border-bottom: 1px solid #f0ece5; align-items: center; cursor: pointer; }
.tk-line .qty { flex: 0 0 84px; display: flex; align-items: center; gap: 5px; }
.tk-line .qty b { min-width: 22px; text-align: center; font-size: 17px; }
.step { border: 1px solid var(--line); background: #fff; border-radius: 7px; width: 30px; height: 30px;
  font-size: 17px; cursor: pointer; }
.tk-line .what { flex: 1; min-width: 0; }
.tk-line .what .opt { font-size: 12.5px; color: var(--muted); }
.tk-line .amt { flex: 0 0 70px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tk-total { display: flex; justify-content: space-between; font-size: 19px; font-weight: 700; padding: 10px 2px 2px; }
.tender-big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.tender-big .btn { padding: 18px; font-size: 18px; }
.cash-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.change-big { font-size: 30px; font-weight: 700; color: var(--ok); }
#qr-target { display: flex; justify-content: center; margin: 10px 0; }
#qr-target img { width: 190px; height: 190px; image-rendering: pixelated; }

/* table map (cafe only) */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tbl { min-height: 92px; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  text-align: left; font: inherit; background: var(--panel); cursor: pointer; }
.tbl:active { transform: scale(.98); }
.tbl.free { color: var(--muted); }
.tbl.open { border-color: var(--brand); border-width: 2px; }
.tbl.open b { color: var(--brand); }
.tbl.stale { border-color: var(--bad); }
.tbl .age { font-size: 12px; color: var(--muted); }

/* modal */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(30,24,20,.45); z-index: 50;
  align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; padding: 16px 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px;
  border-top: 1px solid var(--line); padding-top: 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2b2522; color: #fff; padding: 11px 20px; border-radius: 99px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* cloud chip modal + back-office platform card (pkg-6) */
.cloud-error-list { max-height: 40vh; overflow-y: auto; }
.cloud-error-row { border-bottom: 1px solid #f0ece5; padding: 7px 2px; }
.cloud-error-row:last-child { border-bottom: none; }
.map-table select { width: 100%; min-width: 220px; }
.badge-local { display: inline-block; background: #efece7; color: var(--muted); font-size: 11.5px;
  font-weight: 700; padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
