:root {
  --paper: #f4efe5;
  --paper-deep: #e9e0d2;
  --surface: #fffdf8;
  --ink: #1d1b18;
  --muted: #746d63;
  --line: rgba(29, 27, 24, 0.14);
  --accent: #c84a32;
  --accent-deep: #9f3423;
  --green: #147856;
  --amber: #a66312;
  --red: #a72f27;
  --blue: #236fba;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-lockup { display: flex; align-items: center; min-width: 0; }
.brand-lockup img { object-fit: contain; filter: none; }
.brand-cross { flex: 0 0 auto; color: var(--muted); font-weight: 600; }
.brand-lockup--login { gap: 14px; width: min(92vw, 470px); }
.brand-lockup--login img:first-child { width: 61%; max-height: 54px; }
.brand-lockup--login img:last-child { width: 25%; max-height: 42px; }
.brand-lockup--compact { gap: 7px; width: min(55vw, 270px); }
.brand-lockup--compact img:first-child { width: 60%; max-height: 28px; }
.brand-lockup--compact img:last-child { width: 26%; max-height: 22px; }
.brand-lockup--compact .brand-cross { font-size: 12px; }
.brand-lockup--queue { gap: 10px; width: min(76vw, 380px); }
.brand-lockup--queue img:first-child { width: 62%; max-height: 40px; }
.brand-lockup--queue img:last-child { width: 25%; max-height: 31px; }
.brand-lockup--code { gap: 8px; width: min(74vw, 330px); margin: 0 auto; }
.brand-lockup--code img:first-child { width: 61%; max-height: 35px; }
.brand-lockup--code img:last-child { width: 25%; max-height: 28px; }

.primary-button, .secondary-button, .quiet-button, .icon-button, .text-button,
.danger-text-button, .refresh-button, .back-button, .close-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 54px;
  width: 100%;
  border-radius: 13px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  transition: transform .12s ease, background .16s ease, opacity .16s ease;
}
.primary-button:active { transform: scale(.985); }
.primary-button:disabled { opacity: .38; cursor: not-allowed; }
.secondary-button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-weight: 700;
}
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--red); font-size: 13px; }

/* Login */
.login-screen {
  min-height: 100svh;
  padding: calc(44px + var(--safe-top)) 24px calc(36px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.login-screen::after {
  content: "";
  display: block;
  width: 100%;
  height: 8px;
  margin-top: auto;
  background: var(--accent);
}
.login-copy { margin-top: clamp(70px, 18vh, 160px); max-width: 520px; }
.login-copy h1 { margin: 0; max-width: none; font-size: clamp(32px, 9.4vw, 60px); line-height: 1.04; letter-spacing: -0.04em; white-space: nowrap; }
.login-copy > p:last-child { margin: 18px 0 0; color: var(--muted); line-height: 1.65; }
.login-form { margin-top: 42px; max-width: 430px; }
.login-form label, .field-label, .sheet-panel--form label { display: block; font-size: 13px; color: var(--muted); }
.login-form input, .sheet-panel input, .sheet-panel textarea {
  width: 100%;
  margin: 8px 0 14px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-size: 16px;
}
.login-form input:focus, .sheet-panel input:focus, .sheet-panel textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,74,50,.1); }

/* POS shell */
.pos-body { overflow: hidden; }
.app-shell { min-height: 100svh; max-width: 980px; margin: 0 auto; background: var(--paper); }
.pos-header {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 50%;
  width: min(100%, 980px);
  transform: translateX(-50%);
  height: calc(63px + var(--safe-top));
  padding: calc(13px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(244,239,229,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.header-actions { display: flex; align-items: center; gap: 7px; }
.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.connection-chip i, .live-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connection-chip.is-live { color: var(--green); }
.connection-chip.is-offline { color: var(--red); }
.quiet-button { min-height: 36px; padding: 0 10px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 12px; }
.quiet-button strong { color: #f7b5a7; }
.pos-main {
  height: 100svh;
  padding: calc(84px + var(--safe-top)) 16px calc(150px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
.app-view { display: none; animation: reveal .18s ease both; }
.app-view.is-active { display: block; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 0 0 22px; }
.section-heading h1 { margin: 0; font-size: clamp(30px, 8vw, 44px); line-height: 1; letter-spacing: -.04em; }
.muted-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); font-size: 24px; }

.category-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 20px;
  padding: 0 16px 4px;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }
.category-nav button, .filter-row button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-weight: 700;
}
.category-nav button.is-active, .filter-row button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.menu-item {
  min-height: 126px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.menu-item:active { border-color: var(--accent); transform: scale(.985); }
.menu-item h3 { margin: 0; font-size: 17px; line-height: 1.25; }
.menu-item p { margin: 7px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.menu-item strong { margin-top: auto; font-size: 18px; }
.menu-item.is-sold-out { opacity: .52; }
.menu-item.is-sold-out::after { content: "已售罄"; margin-top: 7px; color: var(--red); font-size: 12px; font-weight: 700; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.text-button { padding: 8px; background: transparent; color: var(--accent); font-weight: 750; }

.cart-bar {
  position: fixed;
  z-index: 18;
  bottom: calc(65px + var(--safe-bottom));
  left: 50%;
  width: min(calc(100% - 24px), 720px);
  min-height: 62px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 128px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 35px rgba(29,27,24,.2);
  transition: opacity .16s ease, transform .16s ease;
}
.cart-bar.is-empty { opacity: 0; pointer-events: none; transform: translate(-50%,12px); }
.cart-summary, .cart-checkout { border: 0; background: transparent; color: inherit; font-weight: 750; }
.cart-summary { padding: 0 18px; display: flex; justify-content: space-between; align-items: center; text-align: left; }
.cart-checkout { background: var(--accent); font-size: 16px; }
.cart-checkout:disabled { opacity: .55; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 50%;
  width: min(100%, 980px);
  height: calc(65px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 0 18px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3,1fr);
  background: rgba(255,253,248,.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.bottom-nav button { position: relative; border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.bottom-nav button.is-active { color: var(--accent); }
.bottom-nav button b { position: absolute; top: 8px; left: calc(50% + 18px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10px; line-height: 18px; }

/* Orders */
.filter-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 18px; padding: 0 16px 4px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row button { min-height: 37px; padding: 0 14px; font-size: 13px; }
.order-list { display: grid; gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.order-row { background: var(--paper); padding: 17px 2px; }
.order-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.order-code { display: block; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.order-state { font-size: 12px; font-weight: 750; color: var(--accent); }
.order-items { margin: 13px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.order-actions { display: flex; gap: 8px; margin-top: 15px; }
.order-actions button { min-height: 43px; flex: 1; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-weight: 750; }
.order-actions button.is-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.order-actions button.is-call { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Settings */
.settings-section { padding: 22px 0; border-top: 1px solid var(--line); }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.settings-section h2 { margin: 0; font-size: 19px; }
.settings-section p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.settings-title-row, .settings-section--split { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-menu-list { margin-top: 18px; border-top: 1px solid var(--line); }
.settings-menu-row { padding: 14px 0; display: grid; grid-template-columns: 1fr auto; gap: 12px; border-bottom: 1px solid var(--line); }
.settings-menu-row h3 { margin: 0; font-size: 15px; }
.settings-menu-row p { margin: 4px 0 0; }
.settings-menu-actions { display: flex; align-items: center; gap: 7px; }
.settings-menu-actions button { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: transparent; font-size: 12px; font-weight: 700; }
.settings-menu-actions button.is-sold-out { color: var(--red); border-color: rgba(167,47,39,.35); }
.public-url { color: var(--ink) !important; font-weight: 750; word-break: break-all; }
.danger-text-button { padding: 10px 0; background: transparent; color: var(--red); font-weight: 750; }

/* Dialogs */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(20,18,16,.45); backdrop-filter: blur(3px); }
.sheet-dialog { width: min(100%, 720px); max-height: 92svh; margin: auto auto 0; border-radius: 22px 22px 0 0; background: transparent; }
.sheet-dialog[open] { animation: sheet-up .22s ease both; }
.sheet-panel { max-height: 92svh; overflow-y: auto; padding: 10px 20px calc(24px + var(--safe-bottom)); background: var(--surface); overscroll-behavior: contain; }
.sheet-handle { width: 38px; height: 4px; margin: 1px auto 18px; border-radius: 2px; background: var(--line); }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.sheet-header h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.close-button { width: 42px; height: 42px; border-radius: 50%; background: var(--paper); font-size: 25px; line-height: 1; }
.modifier-options { display: grid; gap: 8px; }
.modifier-option { min-height: 52px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: transparent; }
.modifier-option.is-selected { border-color: var(--accent); background: rgba(200,74,50,.06); }
.modifier-option span:last-child { color: var(--muted); }
.quantity-row { margin: 20px 0; display: flex; align-items: center; justify-content: space-between; }
.stepper { display: flex; align-items: center; gap: 16px; }
.stepper button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 22px; }
.cart-lines { display: grid; gap: 13px; margin-bottom: 20px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.cart-line h3 { margin: 0; font-size: 15px; }
.cart-line p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.cart-line button { margin-top: 7px; padding: 0; border: 0; background: transparent; color: var(--red); font-size: 12px; }
.cart-dialog-total { margin: 4px 0 20px; display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
.cart-dialog-total strong { font-size: 28px; }
.quick-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 14px; }
.quick-notes button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; font-weight: 700; }
.quick-notes button.is-selected { border-color: var(--accent); color: var(--accent); background: rgba(200,74,50,.08); }
.field-label--optional { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.toggle-label { margin: 2px 0 20px; display: flex !important; align-items: center; gap: 10px; color: var(--ink) !important; }
.toggle-label input { width: 20px; height: 20px; margin: 0; }

.payment-dialog { width: 100%; max-width: none; height: 100%; max-height: none; background: var(--surface); }
.payment-panel { min-height: 100svh; max-width: 620px; margin: 0 auto; padding: calc(12px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; }
.payment-topbar { min-height: 46px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; font-size: 13px; font-weight: 750; }
.back-button { justify-self: start; padding: 9px 0; background: transparent; color: var(--accent); }
.payment-amount { margin: 22px 0 18px; text-align: center; }
.payment-amount span { display: block; color: var(--muted); font-size: 13px; }
.payment-amount strong { display: block; margin-top: 6px; font-size: clamp(48px, 14vw, 76px); line-height: 1; letter-spacing: -.05em; }
.payment-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.payment-tabs button { min-height: 45px; border: 1px solid var(--line); border-radius: 11px; background: transparent; font-weight: 750; }
.payment-tabs button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.qr-frame { flex: 1; min-height: 0; padding: 18px 0 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qr-crop { position: relative; width: min(72vw, 320px); aspect-ratio: 1; overflow: hidden; border: 12px solid #fff; border-radius: 15px; box-shadow: 0 4px 22px rgba(29,27,24,.08); background: #fff; }
.qr-crop img { position: absolute; max-width: none; border-radius: 0; }
.qr-crop[data-method="wechat"] img { width: 244%; left: -72%; top: -88%; }
.qr-crop[data-method="alipay"] img { width: 207%; left: -53%; top: -119%; }
.payment-payee { margin: 0 0 7px; text-align: center; color: var(--muted); font-size: 12px; }
.payment-warning { margin: 4px auto 15px; max-width: 32em; color: var(--red); text-align: center; font-size: 12px; line-height: 1.5; }
.primary-button--payment { background: var(--accent); }

.code-dialog { width: 100%; max-width: none; height: 100%; max-height: none; background: var(--surface); }
.code-panel { min-height: 100svh; padding: calc(50px + var(--safe-top)) 24px calc(30px + var(--safe-bottom)); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.code-panel > p { margin: 90px 0 0; color: var(--muted); }
.code-panel > strong { display: block; margin: 10px 0; color: var(--accent); font-size: clamp(92px, 30vw, 150px); line-height: 1; letter-spacing: -.07em; }
.code-panel > span { color: var(--muted); }
.code-panel .primary-button { margin-top: auto; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(88px + var(--safe-bottom)); max-width: calc(100% - 40px); transform: translate(-50%,20px); padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }

/* Customer queue */
.queue-body { min-height: 100svh; background: var(--surface); }
.queue-page { min-height: 100svh; max-width: 660px; margin: 0 auto; padding: calc(22px + var(--safe-top)) 20px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; }
.queue-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.official-mark { flex: 0 0 auto; padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; font-weight: 750; }
.lookup-panel { padding-top: clamp(45px, 9vh, 88px); }
.lookup-copy h1 { margin: 0; font-size: clamp(38px, 11vw, 62px); line-height: 1.03; letter-spacing: -.055em; }
.lookup-copy > p:last-child { max-width: 30em; margin: 17px 0 0; color: var(--muted); line-height: 1.55; }
.code-input { margin: 34px 0 17px; display: flex; align-items: center; justify-content: center; gap: 13px; font-size: 44px; font-weight: 800; }
.code-input > span { color: var(--accent); }
.code-input strong { display: flex; gap: 8px; }
.code-input i { width: 42px; height: 59px; display: flex; align-items: center; justify-content: center; border-bottom: 3px solid var(--ink); font-style: normal; }
.lookup-error { min-height: 22px; margin: 0 0 8px; color: var(--red); text-align: center; font-size: 13px; }
.keypad { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.keypad button { min-height: clamp(57px, 8.5vh, 76px); border: 1px solid var(--line); border-radius: 13px; background: var(--paper); font-size: 25px; font-weight: 650; }
.keypad button:active { background: var(--paper-deep); transform: scale(.97); }
.keypad .keypad-action { color: var(--muted); font-size: 13px; }
.queue-query-button { margin-top: 12px; background: var(--accent); }

.result-panel { padding-top: 32px; animation: reveal .24s ease both; }
.result-meta { display: flex; align-items: center; justify-content: space-between; }
.live-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.live-state.is-live { color: var(--green); }
.live-state.is-polling, .live-state.is-connecting { color: var(--amber); }
.live-state.is-stale { color: var(--red); }
.refresh-button { min-height: 38px; padding: 0 12px; border-radius: 9px; background: var(--paper); font-size: 12px; font-weight: 700; }
.result-code { padding: clamp(36px, 8vh, 72px) 0 24px; text-align: center; }
.result-code span { display: block; color: var(--muted); font-size: 13px; }
.result-code strong { display: block; margin-top: 6px; color: var(--accent); font-size: clamp(88px, 28vw, 140px); line-height: 1; letter-spacing: -.07em; }
.result-status { padding: 22px 0; display: flex; align-items: center; gap: 15px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.status-symbol { width: 16px; height: 16px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px rgba(200,74,50,.1); }
.result-status p { margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.result-status h2 { margin: 0; font-size: 22px; }
.progress-line { margin: 24px 0 28px; display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.progress-line i { height: 4px; border-radius: 2px; background: var(--paper-deep); }
.progress-line i.is-complete { background: var(--accent); }
.detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.detail-heading h3 { margin: 0; font-size: 16px; }
.detail-heading span { color: var(--muted); font-size: 11px; }
.public-items { margin-top: 10px; border-top: 1px solid var(--line); }
.public-item { padding: 13px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.public-item strong { font-size: 15px; }
.public-item p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.public-item > span { flex: 0 0 auto; font-weight: 750; }
.stale-message { padding: 12px; border-left: 3px solid var(--red); background: rgba(167,47,39,.07); color: var(--red); font-size: 13px; line-height: 1.5; }
.switch-code { width: 100%; margin-top: 28px; }
.queue-footer { margin-top: auto; padding-top: 46px; color: var(--muted); font-size: 11px; line-height: 1.65; text-align: center; }
.queue-footer p { margin: 0; }

@keyframes sheet-up { from { transform: translateY(30px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 700px) {
  .pos-main { padding-left: 28px; padding-right: 28px; }
  .menu-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .queue-page { padding-left: 34px; padding-right: 34px; }
}

@media (max-width: 370px) {
  .connection-chip { display: none; }
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .menu-item { min-height: 112px; padding: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .official-mark { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
