:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #6c8cff;
  --accent-2: #00d4a0;
  --danger: #ff5a6e;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2030 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #0b0d12; font-weight: 800;
}
nav.tabs { display: flex; gap: 6px; }
nav.tabs a {
  padding: 8px 16px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px;
}
nav.tabs a.active, nav.tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 28px; }

.layout { display: grid; grid-template-columns: 1fr 420px; gap: 24px; align-items: start; }
@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  /* show the preview first (above the form) instead of buried at the bottom */
  .preview-wrap { order: -1; position: static; top: auto; }
  .qr-stage { min-height: 240px; padding: 18px; }
  #qr-canvas { width: 220px; height: 220px; }
  #qr-canvas canvas, #qr-canvas svg { width: 220px !important; height: 220px !important; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 22px; }
@media (max-width: 560px) { .type-grid { grid-template-columns: repeat(3, 1fr); } }
.type-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  border-radius: 10px; padding: 12px 6px; cursor: pointer; font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 6px; transition: all .15s;
}
.type-btn .ico { font-size: 18px; }
.type-btn:hover { border-color: var(--accent); color: var(--text); }
.type-btn.active { border-color: var(--accent); background: rgba(108,140,255,.14); color: var(--text); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.toggle { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); margin-bottom: 16px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle .t-text strong { display: block; font-size: 14px; }
.toggle .t-text span { font-size: 12px; color: var(--muted); }

.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] { width: 40px; height: 36px; padding: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-weight: 700; font-size: 14px; transition: all .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #5a78ff); color: #fff; width: 100%; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }

.preview-wrap { position: sticky; top: 92px; }
.qr-stage {
  background: #fff; border-radius: var(--radius); padding: 28px; display: grid; place-items: center;
  min-height: 340px;
}
#qr-canvas { width: 300px; height: 300px; }
#qr-canvas canvas, #qr-canvas svg { width: 300px !important; height: 300px !important; }
#barcode-svg { max-width: 100%; height: auto; }
.preview-value {
  margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted);
  word-break: break-all; line-height: 1.4;
}
.preview-value strong { color: var(--text); font-weight: 600; }
.preview-meta { margin-top: 12px; text-align: center; }
.dl-row { display: flex; gap: 8px; margin-top: 14px; }
.dl-row .btn { flex: 1; }

.accordion summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; color: var(--muted); }
.accordion[open] summary { color: var(--text); margin-bottom: 12px; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag-dyn { background: rgba(0,212,160,.16); color: var(--accent-2); }
.tag-static { background: rgba(154,163,178,.16); color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* dashboard */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 720px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

table.codes { width: 100%; border-collapse: collapse; }
table.codes th, table.codes td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.codes th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
table.codes tr:hover td { background: var(--surface-2); }
.code-name { font-weight: 600; }
.code-dest { color: var(--muted); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; place-items: center; z-index: 50; padding: 20px;
}
.modal-backdrop.show { display: grid; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-body { padding: 22px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 600px) { .chart-grid { grid-template-columns: 1fr; } }
.mini-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.mini-card h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; }
.bar .track { background: var(--bg); border-radius: 6px; height: 8px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.close-x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }

/* social login */
.social-btn { width: 100%; background: #fff; color: #1a1a1a; border: 1px solid var(--border); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; }
.social-btn:hover { filter: brightness(0.97); text-decoration: none; }
.social-btn.apple { background: #000; color: #fff; border-color: #000; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 6px 0 16px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* language picker */
.lang-picker { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.lang-picker:focus { outline: none; border-color: var(--accent); }

/* auth slot */
.auth-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.auth-user .email { color: var(--text); font-weight: 600; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.seg button { background: none; border: none; color: var(--muted); padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }

/* presets */
.preset-row { display: flex; flex-wrap: wrap; gap: 12px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); width: 128px; }
.preset:hover { border-color: var(--accent); }
.preset .swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.15); }
.preset .preset-qr { width: 108px; height: 108px; border-radius: 10px; overflow: hidden; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid rgba(255,255,255,.12); }
.preset .preset-qr canvas, .preset .preset-qr svg { width: 108px !important; height: 108px !important; display: block; }

.inline-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.inline-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* caption frame around preview */
.qr-frame { display: inline-flex; flex-direction: column; align-items: center; }
.qr-frame .cap { margin-top: 10px; font-weight: 800; letter-spacing: 1px; font-size: 15px; }

/* ===== menus: builder ===== */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.menu-card { cursor: pointer; transition: border-color .15s; }
.menu-card:hover { border-color: var(--accent); }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.title-input { background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text); font-size: 22px; font-weight: 700; padding: 4px 2px; min-width: 200px; flex: 1; }
.title-input:focus { outline: none; border-color: var(--accent); }
.cat-card { margin-bottom: 16px; }
.cat-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.cat-name { flex: 1; font-weight: 700; font-size: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; color: var(--text); }
.item-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.item-row { display: flex; gap: 8px; align-items: center; }
.item-row input, .item-desc, .opt-card input, .opt-card select { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 14px; }
.item-name { flex: 1; }
.item-price { width: 90px; text-align: right; }
.item-desc { width: 100%; margin-top: 8px; }
.opts { margin-top: 10px; }
.opt-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; }
.opt-head { display: flex; gap: 8px; align-items: center; }
.opt-name { flex: 1; }
.opt-type { font-size: 13px; }
.choice-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.choice-row input:first-child { flex: 1; }
.choice-price { width: 80px; text-align: right; }
.btn-xs { padding: 5px 9px; font-size: 12px; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 60%, transparent); padding: 16px 0 4px; margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.link-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 11px; font-size: 13px; word-break: break-all; }

/* orders board */
.orders-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.order-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 10px; padding: 14px; }
.order-card.status-new { border-left-color: var(--accent); }
.order-card.status-preparing { border-left-color: #ffb24a; }
.order-card.status-ready { border-left-color: var(--accent-2); }
.order-card.status-completed, .order-card.status-cancelled { opacity: .6; }
.order-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.olines { margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.oline { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.order-total { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
.order-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== customer menu page ===== */
body.customer { background: var(--bg); }
.menu-langbar { max-width: 640px; margin: 0 auto; padding: 12px 16px 0; display: flex; justify-content: flex-end; }
.menu-root { max-width: 640px; margin: 0 auto; padding: 8px 16px 20px; }
.menu-header { text-align: center; padding: 16px 0 22px; }
.menu-header h1 { margin: 0 0 6px; font-size: 26px; }
.menu-header p { color: var(--muted); margin: 0 auto; max-width: 460px; }
.table-pill { display: inline-block; margin-top: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 600; }
.menu-cat { margin-bottom: 26px; }
.menu-cat h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 6px; }
.menu-item { display: flex; justify-content: space-between; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.menu-item:hover { background: var(--surface); }
.mi-name { font-weight: 600; }
.mi-desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.mi-opt-hint { color: var(--accent); font-size: 12px; margin-top: 4px; }
.mi-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mi-price { font-weight: 600; white-space: nowrap; }
.mi-add { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 18px; font-weight: 700; }

.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px; background: linear-gradient(to top, var(--bg), transparent); display: flex; justify-content: center; z-index: 40; }
.cart-bar .btn { max-width: 640px; width: 100%; padding: 15px; font-size: 15px; }

.opt-group { margin-bottom: 16px; }
.opt-title { font-weight: 600; margin-bottom: 8px; }
.opt-title .req { color: var(--danger); font-size: 12px; font-weight: 700; }
.choice { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 7px; cursor: pointer; background: var(--surface-2); }
.choice.on { border-color: var(--accent); background: rgba(108,140,255,.12); }
.choice .cmark { opacity: .35; }
.choice.on .cmark { opacity: 1; color: var(--accent); }
.choice .cname { flex: 1; }
.choice .cprice { color: var(--muted); font-size: 13px; }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; }
.qty-ctl { display: flex; align-items: center; gap: 14px; }
.qty-ctl button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 18px; cursor: pointer; }
.qty-ctl span { min-width: 20px; text-align: center; font-weight: 600; }

.cart-lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cart-line { display: flex; justify-content: space-between; gap: 12px; }
.link-x { display: block; background: none; border: none; color: var(--danger); font-size: 12px; cursor: pointer; padding: 2px 0 0; margin-left: auto; }
.cart-total-row { display: flex; justify-content: space-between; font-size: 17px; padding: 8px 0; }
.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.order-done { text-align: center; padding: 16px 0; }
.order-done .check { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-2); color: #06281f; font-size: 30px; display: grid; place-items: center; margin: 0 auto 14px; font-weight: 800; }
