/* app.css — สไตล์กลางของทั้งแอป
   โทนสีมาจากของจริงในร้าน: ครัว = ไฟเตา (ส้ม), บาร์ = น้ำแข็ง (มิ้นต์)
   สองสีนี้ใช้แยก "ใครเป็นคนทำ" ตลอดทั้งระบบ ไม่ใช่แค่ตกแต่ง

   ทุกหน้าเป็นพื้นมืด เพราะร้านกลางคืนแสงน้อย และจอครัวต้องอ่านจากระยะ 2 เมตร */

:root {
  --night:   #17141f;
  --surface: #221d30;
  --raised:  #2a2438;
  --line:    #332c46;
  --text:    #efeaf7;
  --muted:   #9d94b4;

  --kitchen: #f97b2f;
  --bar:     #3fd0c9;
  --accent:  #8b7bd8;
  --ok:      #4ec97a;
  --warn:    #f5c542;
  --late:    #ff5470;

  /* สีชุดกราฟ — ผ่านการตรวจ contrast/ตาบอดสีบนพื้นมืดแล้ว (ΔE 15.4 deutan)
     เข้มกว่าสีใช้งานทั่วไปเล็กน้อยเพราะพื้นที่สีเยอะกว่า */
  --ck: #d96a1c;
  --cb: #22a89f;

  --thai: "Leelawadee UI", "Noto Sans Thai", "Sukhumvit Set", "Thonburi",
          "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--night); color: var(--text);
  font-family: var(--thai); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabnum { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* ── โครงแอป: แถบบน + เนื้อหา + แถบล่าง ── */
.app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }

.view { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.view.flush { padding: 0; }

/* แถบล่าง — หัวใจของ "แอปเดียว" */
.tabbar {
  flex: 0 0 auto; display: grid; border-top: 1px solid var(--line);
  background: var(--surface); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); position: relative;
  padding: 9px 0 11px; display: grid; gap: 3px; justify-items: center;
  font-size: 11.5px; font-weight: 600;
}
.tabbar button i { font-style: normal; font-size: 20px; line-height: 1; }
.tabbar button.on { color: var(--text); }
.tabbar .badge-dot {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--late);
}

/* ── ปุ่ม ── */
.btn {
  font-size: 14.5px; font-weight: 600; padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); color: var(--night); border-color: var(--text); }
.btn.ghost { background: transparent; }
.btn.k { background: var(--kitchen); color: #3a1a04; border-color: var(--kitchen); }
.btn.b { background: var(--bar); color: #06322f; border-color: var(--bar); }
.btn.go { background: var(--ok); color: #10331d; border-color: var(--ok); }
.btn.danger { background: var(--late); color: #3a0713; border-color: var(--late); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 16px; padding: 14px 18px; width: 100%; border-radius: 12px; }
.btn.big + .btn.big { margin-top: 8px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot.k { background: var(--kitchen); } .dot.b { background: var(--bar); }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.sw.k { background: var(--ck); } .sw.b { background: var(--cb); }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 6px;
}
.badge.k { background: rgba(249,123,47,.16); color: var(--kitchen); }
.badge.b { background: rgba(63,208,201,.16); color: var(--bar); }
.chip-shift { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
              background: rgba(78,201,122,.14); color: var(--ok); }
.chip-shift.off { background: rgba(245,197,66,.14); color: var(--warn); }

/* ── การ์ดบอกขั้นถัดไป ── */
.todo {
  background: linear-gradient(160deg, rgba(139,123,216,.18), rgba(139,123,216,.05));
  border: 1px solid rgba(139,123,216,.42); border-radius: 13px;
  padding: 14px 15px; margin-bottom: 13px;
}
.todo h4 { margin: 0 0 3px; font-size: 15px; }
.todo p { margin: 0 0 11px; font-size: 13px; color: var(--muted); }
.todo .btn { width: 100%; }

/* ── แจ้งเตือน ── */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(120%);
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 100;
  transition: transform .22s ease; box-shadow: 0 14px 40px -14px rgba(0,0,0,.7);
  max-width: min(92vw, 460px); text-align: center;
}
#toast.on { transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--late); }
#toast.good { border-color: var(--ok); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ── กล่องลอย ── */
dialog {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 16px; padding: 0; max-width: min(94vw, 460px); width: 100%;
}
dialog::backdrop { background: rgba(10,6,20,.72); }
dialog .head { padding: 16px 18px 10px; font-size: 17px; font-weight: 700; }
dialog .body { padding: 0 18px; max-height: 62vh; overflow-y: auto; }
dialog .foot { display: flex; gap: 8px; padding: 14px 18px 16px; }
dialog .foot .btn { flex: 1; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--night); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 15.5px; width: 100%;
}

.empty { color: var(--muted); text-align: center; padding: 44px 20px; font-size: 15px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 14px 15px; }
.panel h3 { margin: 0 0 11px; font-size: 14.5px; font-weight: 700; }
.cap { margin: 11px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ── ผังโต๊ะ ── */
.zone { font-size: 11.5px; letter-spacing: .11em; text-transform: uppercase;
        color: var(--muted); font-weight: 700; margin: 18px 2px 9px; }
.zone:first-child { margin-top: 2px; }
.floor { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 9px; }
.tb {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 11px; text-align: left; color: inherit; position: relative;
}
.tb::after { content: ""; position: absolute; right: 10px; top: 11px;
             width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tb.busy { border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); }
.tb.busy::after { background: var(--accent); }
.tb.dirty::after { background: var(--warn); }
.tb.paid { border-color: var(--ok); }
.tb.paid::after { background: var(--ok); }
.tb .code { font-size: 16px; font-weight: 700; }
.tb .meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tb .amt { font-size: 15px; font-weight: 700; margin-top: 6px; }
.tb.free .amt { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.tb.dirty .amt { color: var(--warn); font-size: 12.5px; font-weight: 600; }
