:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #191f28;
  --muted: #6b7684;
  --line: #e5e8eb;
  --primary: #e8590c;
  --primary-ink: #ffffff;
  --primary-soft: #fff1e6;
  --ok: #0f9d58;
  --ok-soft: #e6f6ee;
  --warn: #d9480f;
  --warn-soft: #fff0e8;
  --info: #1c64f2;
  --info-soft: #e8f0fe;
  --danger: #e03131;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.3; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.5em; margin: 8px 0 0; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; flex-wrap: wrap; }
.gap-s { gap: 6px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.narrow { max-width: 420px; margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); }
a.btn { text-decoration: none; color: inherit; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px;
}
.badge:empty { display: none; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #191f28; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100;
  max-width: calc(100% - 32px); box-shadow: var(--shadow); text-align: center;
}
.toast.bad { background: var(--danger); }

/* ---------- 사장님 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card input { margin: 8px 0 12px; font-size: 20px; text-align: center; letter-spacing: 4px; }

.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.tabs button.on { background: var(--primary-soft); color: var(--primary); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.off { background: var(--danger); }

.admin-main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; }
.tab.on { display: block; }
.tables-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tables-head h2 { margin: 0; }
.stepper { display: flex; gap: 6px; align-items: center; }
.stepper input { width: 72px; text-align: center; }
.stepper .btn:not(.primary) { width: 40px; padding: 0; font-size: 20px; }

.layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tcard {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
  border: 2px solid transparent; cursor: pointer; text-align: left; min-height: 128px;
  display: flex; flex-direction: column; gap: 4px; position: relative;
}
.tcard:hover { border-color: var(--line); }
.tcard .no { font-size: 22px; font-weight: 800; }
.tcard .state { font-size: 13px; font-weight: 700; color: var(--muted); }
.tcard.busy { background: var(--info-soft); }
.tcard.busy .state { color: var(--info); }
.tcard.alert { border-color: var(--warn); background: var(--warn-soft); }
.tcard.alert .state { color: var(--warn); }
.tcard .amt { margin-top: auto; font-weight: 700; font-size: 16px; }
.tcard .flags { display: flex; gap: 4px; flex-wrap: wrap; }
.flag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: var(--warn); color: #fff; }
.flag.cook { background: var(--info); }
.flag.call { background: var(--danger); }

.inbox { position: sticky; top: 72px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; max-height: calc(100vh - 100px); overflow: auto; }
.inbox-empty { color: var(--muted); font-size: 14px; padding: 16px 0; text-align: center; }
.ibox { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.ibox.order { border-color: var(--warn); }
.ibox.call { border-color: var(--danger); }
.ibox-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; margin-bottom: 4px; }
.ibox ul { margin: 4px 0 8px; padding-left: 18px; }
.ibox .memo { font-size: 13px; background: var(--bg); border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; }
.ibox .acts { display: flex; gap: 6px; }
.ibox .acts .btn { flex: 1; }

.drawer, .modal, .sheet { position: fixed; inset: 0; z-index: 50; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 100%); background: var(--bg);
  overflow: auto; padding: 16px; box-shadow: -8px 0 24px rgba(0,0,0,.15);
}
.dhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.dhead h2 { margin: 0; font-size: 24px; }
.dsec { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.dsec h3 { display: flex; justify-content: space-between; }
.order-row { border-top: 1px solid var(--line); padding: 10px 0; }
.order-row:first-of-type { border-top: 0; }
.order-row .meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); gap: 8px; }
.order-row ul { margin: 4px 0; padding-left: 18px; }
.order-row.canceled ul, .order-row.canceled .tot { text-decoration: line-through; color: var(--muted); }
.st { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.st.new { background: var(--warn); color: #fff; }
.st.accepted { background: var(--info-soft); color: var(--info); }
.st.served { background: var(--ok-soft); color: var(--ok); }
.st.canceled { background: var(--bg); color: var(--muted); }
.bill { width: 100%; border-collapse: collapse; }
.bill td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.bill td:nth-child(2) { text-align: center; color: var(--muted); width: 50px; }
.bill td:last-child { text-align: right; width: 100px; }
.bill tfoot td { font-weight: 800; font-size: 18px; border: 0; padding-top: 10px; }
.dactions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.modal { display: grid; place-items: center; padding: 16px; }
.modal-panel { position: relative; width: 100%; max-width: 440px; }
.modal-panel .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.cat-block { margin-bottom: 16px; }
.cat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cat-head h3 { margin: 0; }
.menu-table { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; }
.mrow .info { flex: 1; min-width: 0; }
.mrow .name { font-weight: 700; }
.mrow .desc { font-size: 13px; color: var(--muted); }
.mrow .price { font-weight: 700; white-space: nowrap; }
.mrow.soldout .name, .mrow.soldout .price { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; cursor: pointer; white-space: nowrap; }
.switch input { width: auto; margin: 0; }
.empty-cat { padding: 14px; color: var(--muted); font-size: 14px; }

.inline-input { width: 280px; display: inline-block; margin-left: 6px; padding: 6px 10px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; break-inside: avoid; }
.qr-card .qno { font-size: 28px; font-weight: 800; }
.qr-card .qhint { font-size: 13px; color: #555; margin: 4px 0 10px; }
.qr-card .qbox { display: inline-block; }
.qr-card .qbox img, .qr-card .qbox canvas { display: block; }
.qr-card .qstore { font-size: 13px; color: #555; margin-top: 8px; }

@media (max-width: 900px) {
  .topbar { gap: 4px 12px; padding-bottom: 0; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -8px; }
  .layout { grid-template-columns: 1fr; }
  .inbox { position: static; max-height: none; order: -1; }
  .inline-input { width: 100%; margin: 4px 0 0; }
}
@media print {
  body { background: #fff; }
  .topbar, .no-print, .tab:not(#tab-qr) { display: none !important; }
  .admin-main { padding: 0; }
  #tab-qr { display: block !important; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 손님 ---------- */
.guest { padding-bottom: 96px; }
.center-msg { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; }
.g-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.g-store { font-size: 13px; color: var(--muted); }
.g-table { font-size: 20px; font-weight: 800; }
.wait { margin: 12px 16px 0; padding: 16px; background: var(--primary-soft); border-radius: var(--radius); }
.wait h2 { font-size: 17px; color: var(--primary); }
.wait p { margin: 0 0 12px; font-size: 14px; }
.wait .small { margin: 8px 0 0; }
.cat-tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
  background: var(--bg); scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 6px 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.cat-tabs button.on { background: var(--text); color: #fff; border-color: var(--text); }
.g-menu { padding: 0 16px; }
.g-cat { margin: 8px 0 20px; scroll-margin-top: 60px; }
.g-cat h2 { font-size: 18px; margin: 0 0 8px; }
.g-list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.g-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-top: 1px solid var(--line); }
.g-item:first-child { border-top: 0; }
.g-item .info { flex: 1; min-width: 0; }
.g-item .name { font-weight: 700; font-size: 16px; }
.g-item .desc { font-size: 13px; color: var(--muted); }
.g-item .price { font-weight: 700; margin-top: 2px; }
.g-item.soldout .name, .g-item.soldout .price { color: var(--muted); }
.soldtag { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.qty button { width: 36px; height: 36px; border: 0; background: none; font-size: 18px; font-weight: 700; cursor: pointer; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.add-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; font-weight: 700; color: var(--primary); cursor: pointer; }

.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 20; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
.cline { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cline .info { flex: 1; }
.cline .name { font-weight: 700; }
.sum { display: flex; justify-content: space-between; font-weight: 800; font-size: 18px; margin: 14px 0; }
.call-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.call-opts .btn { min-height: 52px; }
.call-opts .btn.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.hist { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.hist.mine { border-color: var(--primary); }
.hist .meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.hist ul { margin: 0; padding-left: 18px; }
.hist .tot { text-align: right; font-weight: 700; margin-top: 4px; }
.hist.canceled ul, .hist.canceled .tot { text-decoration: line-through; color: var(--muted); }
