/* Dragon Court manager (/admin). This stylesheet and ui.css are loaded by the manager, and the public website never loads it, so neither can change the
   other. Every rule is written for the manager's own markup.

   Layout: a green rail and a main area fill the window. Each section scrolls
   inside the main area; the Orders board, the Menu lists and the Promotions
   panes each scroll on their own. Below 1280px the rail becomes an icon rail
   with larger text and touch targets; below 768px it becomes a bottom tab
   bar with More. */

:root {
  --paper: #f8f5ee;
  --ink: #292e2a;
  --red: #852e2d;
  --red-dark: #6a2322;
  --green: #283d32;
  --green-dark: #1f3027;
  --ok: var(--green);
  --surface: #fffdf8;
  --sunk: #efe9dc;
  --tint: #f5efe0;
  --line: #e0d8c6;
  --line-soft: #ece5d5;
  --line-strong: #d3cab6;
  --muted: #55594f;
  --faint: #6b6f68;
  --placeholder: var(--faint);
  --font: "DM Sans", "Noto Serif SC", system-ui, -apple-system, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-time: 22px;
  --fs-h1: 26px;
  --ctl: 40px;
  --btn: 40px;
  --btn-sm: 32px;
  --rail: 232px;
  --pad: 32px;
  --gap: 20px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 8px 24px rgba(41, 46, 42, 0.16);
  color-scheme: light;
}

/* Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body.admin-body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-md) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.admin-body:has(> .admin[data-signed-in]) {
  overflow: hidden;
}
h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}
ul {
  padding: 0;
  list-style: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
a {
  color: var(--green);
}
img {
  display: block;
  max-width: 100%;
}
svg {
  flex-shrink: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}
.skip-link:focus {
  top: 12px;
}

/* One language at a time: server-rendered labels carry both. */
html[data-lang="zh"] .l-en,
html:not([data-lang="zh"]) .l-zh {
  display: none;
}

/* Focus. Text fields never draw a highlight; the caret shows where typing
   goes. Buttons, links and toggles show a ring only for keyboard focus. */
:focus {
  outline: none;
}
html[data-keyboard] :is(a, button, summary, :where([tabindex]:not([tabindex="-1"], input, textarea, select))):focus-visible,
html[data-keyboard] input:is([type="checkbox"], [type="radio"]):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
html[data-keyboard] :is(.segment, .file-button, .day):has(input:focus-visible) {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
/* The hidden control inside such a label covers it, so focus scrolled into
   view brings the whole label and its ring along. */
:is(.file-button, .day) {
  position: relative;
}
:is(.segment, .file-button, .day) > input {
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}
/* Full-width list items and radio labels keep their rings inside scrollers. */
html[data-keyboard] :is(.menu-group, .dish-row, .promo-item):focus-visible,
html[data-keyboard] .segment:has(input:focus-visible) {
  outline-offset: -2px;
}
/* A clicked select counts as :focus-visible too, so selects show the ring
   only while the shared modality tracker marks keyboard use. */
html[data-keyboard] select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
/* Focus scrolled into a list keeps room for its ring at the edges. */
:is(.sheet-body, .dialog.reauth, .page, .rail, .board-list, .menu-groups, .menu-list, .promo-list, .promo-editor, .segmented) {
  scroll-padding: 8px;
}
input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"]):focus,
textarea:focus {
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

/* Buttons and links */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  border-color: var(--green);
  background: var(--green);
  color: var(--paper);
}
.btn-green {
  border-color: var(--green);
  background: var(--green);
  color: var(--paper);
}
.btn-danger {
  border-color: var(--red);
  background: var(--red);
  color: var(--paper);
}
.btn-outline {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.btn-quiet {
  color: var(--muted);
}
.btn-danger-text {
  color: var(--green);
}
.btn-outline.btn-danger-text {
  border-color: var(--line-strong);
}
@media (hover: hover) {
  .btn-danger:hover:not(:disabled) {
    border-color: var(--red-dark);
    background: var(--red-dark);
  }
  .btn-primary:hover:not(:disabled),
  .btn-green:hover:not(:disabled) {
    border-color: var(--green-dark);
    background: var(--green-dark);
  }
  .btn-outline:hover:not(:disabled) {
    border-color: var(--muted);
  }
  .btn-quiet:hover:not(:disabled) {
    background: var(--sunk);
    color: var(--ink);
  }
}
.btn-sm {
  min-height: var(--btn-sm);
  padding: 0 12px;
  font-size: var(--fs-sm);
}
.btn-square {
  width: var(--btn);
  padding: 0;
}
.btn-sm.btn-square {
  width: var(--btn-sm);
}
.btn-block {
  width: 100%;
}
.file-button {
  cursor: pointer;
}
.link {
  color: var(--green);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-quiet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
}
.link-danger {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-label {
  font-size: var(--fs-sm);
  font-weight: 500;
}
.field-hint,
.section-hint {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 16px;
}
.field-row-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}
.input,
.select,
.search-input {
  -webkit-appearance: none;
  appearance: none;
}
.input,
.select {
  width: 100%;
  min-width: 0;
  min-height: var(--ctl);
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-md);
  line-height: 1.4;
}
textarea.input {
  min-height: 72px;
  resize: vertical;
}
.select {
  padding-right: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2355594f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  cursor: pointer;
}
.input::placeholder,
.search-input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}
.input:disabled {
  background: var(--tint);
  color: var(--faint);
}
.input-sm,
.select-sm {
  width: auto;
  min-height: var(--btn-sm);
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: var(--fs-sm);
}
.input-sm {
  width: 120px;
}
.input-auto {
  width: auto;
  max-width: 100%;
}
.input-code {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.money-input {
  position: relative;
  display: flex;
}
.money-input > span {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.money-input .input {
  padding-left: 26px;
}
.check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: var(--ctl);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--faint);
}
.search-input {
  flex: 1;
  min-width: 0;
  height: calc(var(--ctl) - 2px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-md);
}
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
}

/* Switch: a checkbox with role="switch" */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: #b3ac9b;
  cursor: pointer;
  transition: background-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.switch:checked {
  background: var(--ok);
}
.switch:checked::after {
  transform: translateX(18px);
}
.switch:disabled {
  opacity: 0.5;
  cursor: default;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}
.switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.switch-text strong {
  font-weight: 500;
}
.switch-text small {
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* Segmented control: a radio group drawn as one row */
.segmented {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border-radius: 10px;
  background: var(--sunk);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar {
  display: none;
}
.segment {
  position: relative;
  flex-shrink: 0;
  border-radius: 7px;
  isolation: isolate;
}
/* A tap on the control's rim or the gap beside a segment still chooses it, so
   each segment takes taps across the control's full height. The rim lies
   under the label's text, which keeps its own hover and cursor. */
.segment::before {
  position: absolute;
  z-index: -1;
  inset: -3px -1px;
  content: "";
  cursor: pointer;
}
.segment input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.segment span {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--ctl) - 6px);
  padding: 0 14px;
  border-radius: 7px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.segment small {
  color: var(--faint);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.segment input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(41, 46, 42, 0.12);
}

/* Language switch */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--sunk);
}
.lang-switch button {
  min-width: 40px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
html:not([data-lang="zh"]) .lang-switch [data-set-language="en"],
html[data-lang="zh"] .lang-switch [data-set-language="zh"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(41, 46, 42, 0.12);
}

/* Badges, notices, cards */
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-off,
.tag-birthday {
  background: var(--sunk);
  color: var(--green);
}
.badge-promo,
.tag-new {
  background: var(--sunk);
  color: var(--green);
}
.badge-points,
.badge-ok,
.tag-member {
  background: #e3ece4;
  color: var(--green);
}
.badge-soft,
.tag-guest {
  background: var(--sunk);
  color: var(--muted);
}
.tag-returning {
  background: var(--sunk);
  color: var(--muted);
}
.notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.notice .btn {
  margin-left: auto;
}
.notice-error {
  background: #852e2d14;
  color: var(--red);
}
.notice-warn {
  background: var(--sunk);
  color: var(--ink);
}
.notice-ok {
  background: #e3ece4;
  color: var(--green);
}
.muted {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.card-title {
  padding: 16px 20px 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}
.card-title .badge {
  margin-left: 6px;
  vertical-align: 2px;
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 16px 20px 20px;
}
.card-title + .card-body {
  padding-top: 12px;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
}
.empty p {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.empty .btn {
  margin-top: 8px;
}
.empty-inline {
  padding: 24px 12px;
  color: var(--faint);
  font-size: var(--fs-sm);
  text-align: center;
}
.disclosure summary {
  padding: 4px 0;
  font-weight: 500;
  cursor: pointer;
}
.disclosure-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 12px;
}

/* Save bar: quiet until the form has unsaved changes */
.savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px 10px 18px;
  border-radius: var(--radius-lg);
  background: var(--sunk);
  color: var(--muted);
}
.savebar-status {
  margin-right: auto;
}
[data-dirty] .savebar {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}
[data-dirty] .savebar-status {
  font-weight: 600;
}
[data-dirty] .savebar .btn-quiet {
  color: #dfe6e0;
}
[data-dirty] .savebar .btn-primary {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink);
}

/* Toasts */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 10px 10px 10px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: var(--fs-md);
  line-height: 1.45;
  pointer-events: auto;
  animation: rise 0.18s ease-out;
}
.toast-error {
  background: var(--red);
}
.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Confirm dialog and the dish editor sheet */
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 48px rgba(41, 46, 42, 0.25);
}
.dialog::backdrop,
.sheet::backdrop {
  background: rgba(41, 46, 42, 0.4);
}
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
}
.dialog-body h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.dialog-body p {
  color: var(--muted);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: -12px 0 32px rgba(41, 46, 42, 0.12);
}
.sheet[open] {
  animation: slide 0.2s ease-out;
}
@keyframes slide {
  from {
    opacity: 0.6;
    transform: translateX(24px);
  }
}
.sheet-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sheet-kicker {
  margin-bottom: 4px;
  color: var(--faint);
  font-size: var(--fs-xs);
}
.sheet-head h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.sheet-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 22px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.sheet-section h3 {
  font-size: var(--fs-md);
  font-weight: 600;
}
.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.photo-field {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.photo-preview {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  background: var(--sunk);
  color: var(--faint);
  overflow: hidden;
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-preview-wide {
  width: 160px;
  height: 104px;
}
.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.photo-source {
  font-size: var(--fs-sm);
  font-weight: 500;
}
.photo-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mini-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Sign-in */
.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 32px 16px;
}
.login-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.login-mark {
  width: 56px;
  height: 56px;
}
.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dialog.reauth {
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.reauth .login-card {
  width: 100%;
  border: 0;
  border-radius: inherit;
  box-shadow: none;
}
.login-form .btn {
  margin-top: 6px;
}
.login-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-sm);
}

/* Shell */
.admin {
  min-height: 100dvh;
}
.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: 100dvh;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.offline {
  padding: 8px var(--pad);
  background: var(--sunk);
  color: var(--green);
  font-size: var(--fs-sm);
}
.sound-needed {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px var(--pad);
  background: var(--sunk);
  color: var(--ink);
  font-size: var(--fs-sm);
}
.sound-needed .btn {
  margin-left: auto;
  min-height: 44px;
  min-width: 44px;
}
.view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.page {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  padding: 24px var(--pad) 40px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
.page-fill {
  padding-bottom: 24px;
  overflow: hidden;
}
.view-head {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.view-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.view-title h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.3px;
}
.view-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.view-tools .search {
  width: 300px;
  max-width: 100%;
}
.view-note {
  flex-shrink: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.live[data-state="connecting"] {
  color: var(--muted);
}
.live[data-state="offline"] {
  color: var(--green);
}

/* Rail */
.rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  padding: 22px 14px 18px;
  overflow-y: auto;
  background: var(--green);
  color: #e6ece7;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--paper);
  text-decoration: none;
}
.rail-brand img {
  width: 40px;
  height: 40px;
}
.rail-brand-text {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 1.5px;
}
.rail-brand-text small {
  color: #a9b8ad;
  font-size: 11px;
  font-weight: 400;
}
.rail-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #dfe6e0;
  font-size: var(--fs-md);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rail-item svg,
.rail-sheet-item svg {
  stroke-width: 1.75;
}
@media (hover: hover) and (min-width: 768px) {
  .rail-item:hover:not([aria-current]) {
    background: rgba(248, 245, 238, 0.08);
    color: var(--paper);
  }
}
.rail-item[aria-current] {
  background: var(--paper);
  color: var(--green);
  font-weight: 600;
}
.rail-badge {
  min-width: 22px;
  height: 22px;
  margin-left: auto;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--paper);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 22px;
  text-align: center;
}
/* The selected item is paper on the green rail, so its badge turns green. */
.rail-item[aria-current] .rail-badge {
  background: var(--green);
  color: var(--paper);
}
.rail-more-slot {
  display: none;
}
.rail-foot {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}
.rail-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(248, 245, 238, 0.08);
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
}
.rail .lang-switch {
  align-self: flex-start;
  margin-left: 8px;
  background: rgba(248, 245, 238, 0.1);
}
.rail .lang-switch button {
  color: #c9d3cb;
}
html:not([data-lang="zh"]) .rail .lang-switch [data-set-language="en"],
html[data-lang="zh"] .rail .lang-switch [data-set-language="zh"] {
  background: var(--paper);
  color: var(--green);
}
.rail-foot-links {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
}
.rail-foot-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: #c9d3cb;
  font-size: var(--fs-sm);
  text-decoration: none;
  cursor: pointer;
}
@media (hover: hover) {
  .rail-foot-link:hover {
    color: var(--paper);
  }
}
.rail-sheet {
  display: none;
}
html[data-keyboard] .rail :is(a, button, input):focus-visible {
  outline-color: var(--paper);
}

/* Orders. The toolbar is one grid whose areas move per screen size. */
.orders-top {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "title . search"
    "today filters filters";
  align-items: center;
  gap: 16px 12px;
}
.orders-title {
  grid-area: title;
}
.orders-search {
  grid-area: search;
  width: 320px;
  max-width: 100%;
}
.orders-today {
  grid-area: today;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.orders-today strong {
  color: var(--ink);
  font-weight: 600;
}
.orders-filters {
  grid-area: filters;
  justify-self: end;
  min-width: 0;
}
.orders-filters .segment span,
.orders-tabs .segment span {
  min-height: calc(var(--btn-sm) - 6px);
}
.orders-tabs {
  display: none;
  grid-area: tabs;
}
.batch {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.batch-count {
  font-size: var(--fs-sm);
  font-weight: 600;
}
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.orders-nomatch {
  flex-shrink: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.board {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}
.board:not([data-filter="current"]) {
  grid-template-columns: minmax(0, 1fr);
}
.board-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: var(--sunk);
}
.board-column-head {
  display: flex;
  flex-shrink: 0;
  align-items: baseline;
  gap: 8px;
  padding: 14px 18px 10px;
}
.board-column-head h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
}
.board-count {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.board-empty {
  flex-shrink: 0;
  padding: 20px 16px;
  color: var(--faint);
  font-size: var(--fs-sm);
  text-align: center;
}
.board-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 0 12px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  align-content: start;
  align-items: start;
}
.order {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.order.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}
.order[data-status="rejected"] {
  opacity: 0.85;
}
.order-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
/* The time and its countdown wrap together; the number and the menu keep
   their place on the right however narrow the card is. */
.order-when {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
}
/* The checkbox draws 18px but takes taps across 44px. */
.order-select {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  align-self: center;
  width: 44px;
  height: 44px;
  margin: -13px -5px -13px -13px;
  cursor: pointer;
}
.order-time {
  font-size: var(--fs-time);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.order-time small {
  display: block;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
}
.order-time-missing {
  color: var(--muted);
  font-size: var(--fs-md);
}
.order-due {
  color: var(--faint);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.order-due.is-due {
  color: var(--green);
  font-weight: 600;
}
.order-number {
  color: var(--faint);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-guest {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.order-guest strong {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.order-party {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}
.order-phone {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}
.order-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.4;
}
.order-lines li {
  display: flex;
  gap: 8px;
}
.order-qty {
  flex-shrink: 0;
  min-width: 1.9em;
  color: var(--green);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.order-line {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.order-line small {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.order-line em {
  display: block;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-style: normal;
}
.order-line-price {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-more,
.order-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.order-more {
  min-height: 0;
  font-size: var(--fs-xs);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.order-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--tint);
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.order-note svg {
  margin-top: 2px;
}
.order-note-message {
  flex-direction: column;
  gap: 2px;
  background: #283d320d;
}
.order-note-message strong {
  color: var(--green);
  font-weight: 600;
}
.order-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.order-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.order-estimate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ok);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.order-total {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-actions {
  display: flex;
  gap: 8px;
}
.order-actions-stack {
  flex-direction: column;
}
.order-main {
  flex: 1;
  min-height: calc(var(--btn) + 6px);
  font-size: var(--fs-lg);
}
.order-actions .btn-square {
  width: calc(var(--btn) + 6px);
  min-height: calc(var(--btn) + 6px);
}
.ready-in {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.ready-in-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.ready-in-label small {
  color: var(--faint);
  font-size: inherit;
}
.chip {
  min-width: 0;
  min-height: var(--btn-sm);
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: var(--paper);
}
.order-done {
  color: var(--ok);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.order-done-rejected {
  color: var(--green);
}
.order-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
}
.order-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  font-size: var(--fs-sm);
}
.order-facts div {
  display: contents;
}
.order-facts dt {
  color: var(--muted);
}
.order-estimate-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--fs-sm);
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.order-message-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.order-message-form .field {
  width: 100%;
}

/* Menu */
.menu-tabs {
  flex-shrink: 0;
  min-width: 0;
}
.menu-tabs .segmented {
  display: flex;
  width: max-content;
}
.menu-tabs .segment input:checked + span {
  background: var(--green);
  color: var(--paper);
}
.menu-tabs .segment input:checked + span small {
  color: var(--paper);
  opacity: 0.8;
}
html[data-keyboard] .menu-tabs .segment:has(input:checked:focus-visible) {
  outline-color: var(--paper);
}
.menu-body {
  display: grid;
  flex: 1;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  min-height: 0;
}
.menu-groups {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding-bottom: 8px;
  overflow-y: auto;
}
.menu-group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3d423c;
  text-align: left;
  cursor: pointer;
}
.menu-group small {
  color: var(--faint);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.menu-group[aria-pressed="true"] {
  background: var(--sunk);
  color: var(--ink);
  font-weight: 600;
}
.menu-list {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dish-list {
  display: flex;
  flex-direction: column;
}
.dish-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--tint);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.dish-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 190px) 180px auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  scroll-margin-top: calc(var(--fs-xs) * 1.5 + 20px);
  -webkit-tap-highlight-color: transparent;
}
.dish-row:last-child {
  border-bottom: 0;
}
@media (hover: hover) {
  .dish-row:hover {
    background: #fbf6ec;
  }
}
.dish-row.is-off .dish-row-name,
.dish-row.is-off .dish-row-price {
  opacity: 0.55;
}
.dish-row-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dish-row-name strong {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.dish-row-name small {
  color: var(--faint);
  font-size: var(--fs-xs);
}
.dish-row-price {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.dish-row-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}
.dish-row-edit {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* Promotions */
.promo-layout {
  display: grid;
  flex: 1;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  min-height: 0;
}
.promo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
}
.promo-item {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.promo-item[aria-pressed="true"] {
  border-color: var(--green);
  background: #e9ede5;
}
.promo-item-title {
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.promo-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.promo-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.promo-editor-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.promo-editor-head h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.pick-list,
.pick-results {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.pick-list li,
.pick-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.pick-list li:last-child,
.pick-results li:last-child {
  border-bottom: 0;
}
.pick-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pick-name strong {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.pick-name small {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
}
.preview-head .card-title {
  padding: 0;
}
.preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preview-controls .segment span {
  min-height: calc(var(--btn-sm) - 6px);
}
/* The frame is positioned out of the layout flow: its page width is scaled
   to fit and can never widen the form. */
.preview-stage {
  position: relative;
  width: 100%;
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
}
.preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  background: var(--paper);
  transform-origin: 0 0;
}

/* Restaurant */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1120px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 20px;
}
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 6px 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.day-name {
  font-weight: 600;
}
.day-state {
  color: var(--ok);
  font-size: 11px;
  font-weight: 500;
}
.day:has(input:checked) {
  border-color: var(--green);
  background: var(--green);
  color: var(--paper);
}
.day:has(input:checked) .day-state {
  color: var(--paper);
}

/* Rewards */
.reward-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--fs-lg);
  font-weight: 600;
}
.section-count {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.reward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  align-items: start;
  gap: 12px;
}
.reward {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.reward-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.reward-head strong {
  font-size: var(--fs-lg);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.reward-meta,
.reward-member,
.reward-notes,
.reward-time {
  color: var(--muted);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.reward-code {
  display: flex;
  flex-direction: column;
  margin: 4px 0;
}
.reward-code span {
  color: var(--faint);
  font-size: var(--fs-xs);
}
.reward-code strong {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  overflow-wrap: anywhere;
}
.reward-section .empty-inline {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.reward-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

/* Members */
.members-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 20px;
  max-width: 1200px;
}
.members-main,
.members-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.lookup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lookup-row .input-code {
  flex: 1 1 200px;
  width: auto;
}
.scanner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scanner video {
  width: 100%;
  border-radius: var(--radius-lg);
  background: #1f2a24;
}
.member-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.member-name h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.member-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.member-points div {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--sunk);
}
.member-points dt {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.member-points dd {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.member-summary .btn-quiet {
  align-self: flex-start;
}
.member-summary .muted {
  overflow-wrap: anywhere;
}
.member-empty .card-body {
  align-items: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}
.member-empty h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
}
.member-empty p {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.member-empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sunk);
  color: var(--muted);
}
.credit-preview {
  min-height: 1.5em;
  color: var(--ok);
  font-size: var(--fs-sm);
  font-weight: 600;
}
[data-credit] .btn-primary {
  align-self: flex-start;
}
.row-list {
  display: flex;
  flex-direction: column;
}
.row-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.row-list li:last-child {
  border-bottom: 0;
}
.row-list li > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row-list li.is-void {
  opacity: 0.55;
}

/* Account: each setting's explanation sits beside its control */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 880px;
}
.setting {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 24px 32px;
  padding: 24px;
}
.setting-text h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
}
.setting-text p {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.setting-control {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.setting-control > .segmented {
  align-self: flex-start;
}
.setting-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setting-form {
  max-width: 400px;
}
.account-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Touch screens: 16px text in fields keeps iOS from zooming in */
@media (pointer: coarse) {
  .input,
  .select,
  .search-input {
    font-size: max(16px, var(--fs-md));
  }
}

/* Tablets: icon rail, larger text and touch targets */
@media (max-width: 1279px) {
  :root {
    --fs-xs: 13px;
    --fs-sm: 14px;
    --fs-md: 16px;
    --fs-lg: 18px;
    --fs-xl: 22px;
    --fs-time: 25px;
    --fs-h1: 28px;
    --ctl: 46px;
    --btn: 48px;
    --btn-sm: 44px;
    --rail: 104px;
    --pad: 24px;
  }
  .rail {
    gap: 18px;
    padding: 18px 4px;
  }
  .rail-brand {
    justify-content: center;
    padding: 0;
  }
  .rail-brand img {
    width: 52px;
    height: 52px;
  }
  .rail-brand-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  .rail-links {
    gap: 4px;
  }
  .rail-item {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 64px;
    padding: 6px 2px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
  }
  .rail-item svg {
    width: 24px;
    height: 24px;
  }
  .rail-badge {
    position: absolute;
    top: 6px;
    right: 12px;
    min-width: 20px;
    height: 20px;
    margin: 0;
    padding: 0 6px;
    font-size: 12px;
    line-height: 20px;
  }
  .rail-switch {
    flex-direction: column;
    gap: 8px;
    padding: 12px 4px;
    font-size: 12px;
    text-align: center;
  }
  .rail .lang-switch {
    align-self: center;
    margin: 0;
  }
  .rail .lang-switch button {
    min-width: 44px;
    padding: 0 6px;
  }
  .rail-foot-links {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0;
  }
  .rail-foot-link {
    min-height: 44px;
    font-size: 12px;
  }
  .menu-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
  }
  .menu-groups {
    flex-direction: row;
    gap: 6px;
    padding-bottom: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .menu-group {
    min-height: 44px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    white-space: nowrap;
  }
  .menu-group[aria-pressed="true"] {
    border-color: var(--green);
    background: #e9ede5;
  }
  .promo-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
  }
  .promo-list {
    flex-direction: row;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .promo-item {
    width: auto;
    max-width: 280px;
  }
  /* Touch screens: every control is at least 44px each way. Segments reach
     it with the control's rim; see .segment::before. */
  .lang-switch button,
  .link-danger,
  .order-toggle,
  .order-more,
  .toast-close,
  .switch-row,
  .check-row,
  .disclosure summary,
  .login-foot .link-quiet {
    min-height: 44px;
  }
  .order-phone {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .segment span {
    justify-content: center;
    min-width: 44px;
  }
  .lang-switch button,
  .toast-close {
    min-width: 44px;
  }
}

/* Short tablets keep every rail control in view. */
@media (min-width: 768px) and (max-width: 1279px) and (max-height: 860px) {
  .rail {
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .rail-brand {
    min-height: 44px;
  }
  .rail-brand img {
    width: 40px;
    height: 40px;
  }
  .rail-item {
    min-height: 54px;
  }
  .rail-foot {
    gap: 10px;
  }
  .rail-switch {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* Narrow workspaces give the toolbar and forms fewer columns. */
@media (max-width: 1099px) {
  .orders-top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title search"
      "today today"
      "filters filters";
  }
  .settings-grid,
  .members-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .dish-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 170px) auto;
  }
  .dish-row-badges {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }
  .dish-row-badges:empty {
    display: none;
  }
}

/* Portrait tablets: Pending and Accepted side by side, Ready below. */
@media (min-width: 768px) and (max-width: 1099px) and (orientation: portrait) {
  .board[data-filter="current"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .board[data-filter="current"] .board-column[data-status="ready"] {
    grid-column: 1 / -1;
    max-height: 300px;
  }
  .board[data-filter="current"] .board-column[data-status="ready"] .board-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    align-items: start;
  }
}

/* Phones: bottom tab bar, one order column at a time */
@media (max-width: 767px) {
  :root {
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 15px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-time: 22px;
    --fs-h1: 24px;
    --ctl: 44px;
    --btn: 46px;
    --btn-sm: 44px;
    --pad: 16px;
    --gap: 16px;
    --tabbar: calc(58px + env(safe-area-inset-bottom));
  }
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .main {
    grid-row: 1;
  }
  .page {
    padding-top: 16px;
  }
  .page-fill {
    padding-bottom: 16px;
  }
  .rail {
    grid-row: 2;
    gap: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    overflow: visible;
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .rail-brand,
  .rail-foot,
  .rail-links > .rail-slot-secondary {
    display: none;
  }
  .rail-links {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 0;
  }
  .rail-more-slot {
    display: block;
  }
  .rail-item {
    min-height: 58px;
    padding: 6px 2px;
    border-radius: 0;
    background: none;
    color: var(--faint);
    font-size: 11px;
  }
  .rail-item svg {
    width: 22px;
    height: 22px;
  }
  .rail-item[aria-current],
  .rail[data-more-open] [data-rail-more] {
    background: none;
    color: var(--green);
  }
  .rail-item:hover:not([aria-current]) {
    background: none;
    color: var(--ink);
  }
  html[data-keyboard] .rail :is(a, button, input):focus-visible {
    outline-color: var(--green);
  }
  /* The tab bar meets the screen's edges: rings stay inside each tab. */
  html[data-keyboard] .rail-item:focus-visible {
    outline-offset: -3px;
  }
  .rail-badge {
    top: 4px;
    right: calc(50% - 24px);
    min-width: 18px;
    height: 18px;
    background: var(--green);
    color: var(--paper);
    font-size: 11px;
    line-height: 18px;
  }
  .rail[data-more-open]::before {
    content: "";
    position: fixed;
    inset: 0 0 var(--tabbar) 0;
    z-index: 29;
    background: rgba(41, 46, 42, 0.35);
  }
  .rail-sheet:not([hidden]) {
    position: fixed;
    right: 0;
    bottom: var(--tabbar);
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: calc(100dvh - var(--tabbar) - 40px);
    padding: 12px 16px 16px;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 -8px 24px rgba(41, 46, 42, 0.12);
  }
  .rail-sheet-links {
    display: flex;
    flex-direction: column;
  }
  .rail-sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 50px;
    padding: 0 4px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
  }
  .rail-sheet-item[aria-current] {
    color: var(--green);
    font-weight: 600;
  }
  .rail-sheet .rail-switch {
    flex-direction: row;
    padding: 12px 14px;
    background: var(--sunk);
    color: var(--ink);
    font-size: var(--fs-md);
    text-align: left;
  }
  .rail-sheet .lang-switch {
    align-self: flex-start;
    margin: 0;
    background: var(--sunk);
  }
  .rail-sheet .lang-switch button {
    min-width: 48px;
    min-height: 44px;
    color: var(--muted);
  }
  html:not([data-lang="zh"]) .rail-sheet .lang-switch [data-set-language="en"],
  html[data-lang="zh"] .rail-sheet .lang-switch [data-set-language="zh"] {
    background: var(--surface);
    color: var(--ink);
  }
  .rail-sheet .rail-foot-links {
    flex-direction: row;
    justify-content: space-between;
    padding: 0 4px;
  }
  .rail-sheet .rail-foot-link {
    color: var(--muted);
    font-size: var(--fs-md);
  }
  .toasts {
    right: 16px;
    bottom: calc(var(--tabbar) + 12px);
    left: 16px;
    align-items: stretch;
  }
  .admin:not([data-signed-in]) ~ .toasts {
    bottom: 16px;
  }
  .view-tools,
  .view-tools .search {
    width: 100%;
  }
  .view-tools .search {
    flex: 1;
  }
  .orders-top {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "search"
      "tabs";
    gap: 12px 8px;
  }
  .orders-search {
    width: 100%;
  }
  .orders-today,
  .orders-filters {
    display: none;
  }
  .orders-title .live-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .orders-tabs {
    display: block;
  }
  .orders-tabs .segmented {
    display: flex;
  }
  .orders-tabs .segment {
    flex: 1;
  }
  .orders-tabs .segment span {
    justify-content: center;
    padding: 0 6px;
  }
  .board[data-filter="current"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .board[data-filter="current"] .board-column[data-status="ready"] {
    max-height: none;
  }
  .board[data-filter="current"] .board-column[data-status="ready"] .board-list {
    display: flex;
  }
  /* The board shows the chosen column; All ready and Rejected are one list. */
  .board[data-filter="current"][data-column="pending"] .board-column:not([data-status="pending"]),
  .board[data-filter="current"][data-column="accepted"] .board-column:not([data-status="accepted"]),
  .board[data-filter="current"][data-column="ready"] .board-column:not([data-status="ready"]) {
    display: none;
  }
  .board-column-head {
    display: none;
  }
  .board-list {
    padding-top: 12px;
  }
  .board:not([data-filter="current"]) .board-column {
    background: none;
  }
  .board:not([data-filter="current"]) .board-list {
    padding: 0;
  }
  .dish-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 12px 12px 14px;
  }
  .dish-row-price {
    grid-column: 1;
    grid-row: 2;
    text-align: left;
  }
  .dish-row-badges {
    grid-row: 3;
  }
  .dish-row-edit {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .sheet {
    width: 100vw;
    border-left: 0;
  }
  .sheet-head {
    padding: 14px 10px 12px 16px;
  }
  .sheet-body {
    padding: 12px 12px 20px;
  }
  .sheet-section {
    padding: 14px;
  }
  .sheet-foot {
    padding-right: 16px;
    padding-left: 16px;
  }
  .sheet-foot .btn {
    flex: 1;
  }
  .photo-field {
    flex-direction: column;
  }
  .days {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
    gap: 2px;
  }
  .day {
    min-height: 54px;
  }
  .setting {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 20px;
  }
  .card-title {
    padding: 14px 16px 0;
  }
  .card-body {
    padding: 14px 16px 16px;
  }
  /* Phones show the save bar only while there are unsaved changes. */
  form:not([data-dirty]) .savebar,
  .savebar-status {
    display: none;
  }
  .savebar {
    flex-wrap: nowrap;
    padding: 8px;
  }
  .savebar .btn {
    flex: 1;
  }
}

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

/* Stored Chinese is applied before the shell becomes visible. */
html[data-zh-pending] .admin-body { visibility: hidden; }
.order-menu {
  width: 44px;
  min-height: 44px;
  margin: -10px -12px -10px -4px;
  padding: 0;
  flex-shrink: 0;
}
.ordering-status { color: var(--green); font-weight: 600; }
.rewards-setting { margin-bottom: 16px; }
.rewards-content.is-readonly { background: var(--sunk); border-radius: var(--radius); padding: 16px; color: var(--muted); }
.member-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}
.member-tools .field {
  flex: 0 0 auto;
}
.member-tools .input[type="date"] {
  width: auto;
}
.member-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.member-result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.member-result:hover {
  border-color: var(--line-strong);
}
.member-result span {
  color: var(--muted);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.member-result-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.member-result-name strong {
  overflow-wrap: anywhere;
}
.member-result[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--sunk);
}
.member-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.member-panel [data-member-adjust] .btn-primary {
  align-self: flex-start;
}

:lang(zh-Hant) {
  --font: "DM Sans", "Noto Serif TC", system-ui, -apple-system, sans-serif;
}
