/* ============================================================
   点菜 · 设计系统
   视觉语言参考 LeiBox（齿孔票根、按压按钮、磨砂玻璃、点阵加载）
   全部手写实现，不依赖第三方框架
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  --paper:      #f4efe6;
  --paper-2:    #ebe4d8;
  --surface:    #fffdf9;
  --ink:        #1b1917;
  --ink-2:      #55504a;
  --muted:      #8a8378;
  --line:       rgba(27, 25, 23, .12);
  --line-soft:  rgba(27, 25, 23, .07);
  --accent:     #d1461f;
  --accent-ink: #fff;
  --ok:         #2f7d4f;
  --warn:       #b4731a;
  --shadow-sm:  0 1px 2px rgba(27,25,23,.05), 0 4px 14px rgba(27,25,23,.05);
  --shadow-md:  0 2px 6px rgba(27,25,23,.06), 0 14px 40px rgba(27,25,23,.09);
  --radius:     20px;
  --radius-sm:  12px;
  --font-sans:  -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
                "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "STSong", "Source Han Serif SC", serif;
  --tab-h:      64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0c0c0d;
    --paper-2:    #141416;
    --surface:    #17171a;
    --ink:        #ecebe7;
    --ink-2:      #b9b6ae;
    --muted:      #7e7a73;
    --line:       rgba(255,255,255,.13);
    --line-soft:  rgba(255,255,255,.07);
    --accent:     #ff6b3d;
    --accent-ink: #1a0c07;
    --ok:         #57c98a;
    --warn:       #e0a44a;
    --shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
    --shadow-md:  0 2px 8px rgba(0,0,0,.45), 0 18px 44px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 20px);
  overflow-x: hidden;
}

/* 纸张质感：极淡的斑点，增加温度 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 45%),
    radial-gradient(circle at 85% 0%, color-mix(in srgb, var(--ok) 4%, transparent), transparent 40%);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 14px;
  gap: 12px;
}
.topbar h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
}
.topbar .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .02em;
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

/* ---------- 齿孔票根卡片 ---------- */
.stamp {
  --perf: 7px;
  --gap: 18px;
  position: relative;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-mask:
    radial-gradient(circle var(--perf) at 50% 0, #0000 97%, #000) 0 0 / var(--gap) var(--perf) repeat-x,
    radial-gradient(circle var(--perf) at 50% 100%, #0000 97%, #000) 0 100% / var(--gap) var(--perf) repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - var(--perf) * 2) no-repeat;
  mask:
    radial-gradient(circle var(--perf) at 50% 0, #0000 97%, #000) 0 0 / var(--gap) var(--perf) repeat-x,
    radial-gradient(circle var(--perf) at 50% 100%, #0000 97%, #000) 0 100% / var(--gap) var(--perf) repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - var(--perf) * 2) no-repeat;
}

/* ---------- 菜品大图卡 ---------- */
.dish {
  display: block;
  margin: 0 0 20px;
  border-radius: 0;
  overflow: hidden;
  animation: rise .5s cubic-bezier(.22,1,.36,1) both;
  transition: transform .35s cubic-bezier(.22,1,.36,1), box-shadow .35s;
}
.dish:active { transform: scale(.985); }

.dish__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--paper-2);
  overflow: hidden;
}
.dish__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .6s cubic-bezier(.22,1,.36,1);
}
.dish:hover .dish__media img { transform: scale(1.04); }
.dish__media .ph {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 44px;
  color: var(--muted);
  opacity: .45;
}

.dish__body {
  padding: 16px 18px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.dish__text { flex: 1 1 auto; min-width: 0; }
.dish__name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0 0 5px;
}
.dish__desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish__cat {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

/* 加号按钮 */
.add-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.22,1,.36,1), background .2s, color .2s;
}
.add-btn:active { transform: scale(.88); }
.add-btn.on {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.add-btn .qty { font-size: 14px; font-weight: 600; font-family: var(--font-sans); }

/* ---------- 立体按压按钮 ---------- */
.tactile {
  --btn-bg-1: color-mix(in srgb, var(--accent) 88%, #fff);
  --btn-bg-2: color-mix(in srgb, var(--accent) 74%, #000);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 22px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--btn-bg-1), var(--btn-bg-2));
  box-shadow:
    0 1px 0 rgba(255,255,255,.28) inset,
    0 -2px 6px rgba(0,0,0,.18) inset,
    0 2px 4px rgba(0,0,0,.12),
    0 10px 22px color-mix(in srgb, var(--accent) 32%, transparent);
  cursor: pointer;
  transition: transform .16s cubic-bezier(.22,1,.36,1), box-shadow .24s, filter .2s;
  -webkit-user-select: none; user-select: none;
}
.tactile:hover { filter: brightness(1.04); }
.tactile:active {
  transform: translateY(1px) scale(.978);
  box-shadow:
    0 1px 0 rgba(255,255,255,.18) inset,
    0 4px 10px rgba(0,0,0,.2) inset,
    0 1px 2px rgba(0,0,0,.1);
}
.tactile[disabled] { opacity: .45; pointer-events: none; }

.tactile--ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.tactile--ghost:active { box-shadow: 0 2px 6px rgba(0,0,0,.08) inset; }
.tactile--sm { width: auto; padding: 10px 16px; font-size: 14px; }

/* ---------- 底部下单栏 ---------- */
.checkout {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 30;
  padding: 0 16px;
  pointer-events: none;
}
.checkout__inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  transform: translateY(120%);
  opacity: 0;
  transition: transform .4s cubic-bezier(.22,1,.36,1), opacity .3s;
}
.checkout.show .checkout__inner { transform: none; opacity: 1; }
.checkout__row { display: flex; align-items: center; gap: 10px; }
.checkout__row:first-child { justify-content: space-between; padding: 0 4px; }
.checkout__count { font-size: 13.5px; color: var(--ink-2); flex: 1 1 auto; }
.checkout__count b { color: var(--ink); font-size: 15px; }
.checkout .tactile { width: auto; padding: 12px 26px; font-size: 15px; flex: 0 0 auto; }

.note-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.note-input::placeholder { color: var(--muted); }
.note-input:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px;
  cursor: pointer;
  transition: color .2s;
}
.link-btn:hover { color: var(--ink); }

/* ---------- 磨砂玻璃标签栏 ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.tabbar a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
  transition: background .3s cubic-bezier(.22,1,.36,1), color .25s;
  white-space: nowrap;
}
.tabbar a.active {
  background: var(--ink);
  color: var(--paper);
}
.tabbar svg { width: 17px; height: 17px; }

/* ---------- 状态标签 ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--paper-2);
}
.pill--pending  { color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.pill--cooking  { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.pill--ready    { color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pill--done     { color: var(--muted); }
.pill--cancelled{ color: var(--muted); text-decoration: line-through; }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill--pending .dot,
.pill--cooking .dot { animation: pulse 1.6s ease-in-out infinite; }

/* ---------- 订单卡片 ---------- */
.order-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  animation: rise .45s cubic-bezier(.22,1,.36,1) both;
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.order-card:active { transform: scale(.99); }
.order-card__top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.order-card__id {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
}
.order-card__time { font-size: 12px; color: var(--muted); }
.order-card__items {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.7;
}

/* 新订单流光 */
.beam { position: relative; }
.beam::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  padding: 1px;
  background: conic-gradient(from var(--a, 0deg),
      transparent 0 62%, color-mix(in srgb, var(--accent) 80%, transparent) 76%, transparent 88%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: beam-spin 3.2s linear infinite;
  pointer-events: none;
}
@property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes beam-spin { to { --a: 360deg; } }

/* ---------- 订单详情 ---------- */
.hero {
  padding: 26px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.hero__status {
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  margin: 10px 0 6px;
}
.hero__meta { font-size: 13px; color: var(--muted); }

.timeline { margin: 22px 0 0; padding: 0; list-style: none; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--line);
}
.timeline li {
  position: relative;
  padding: 0 0 18px 24px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 0; top: 4px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
}
.timeline li.on::before { border-color: var(--accent); background: var(--accent); }
.timeline time { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.item-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
}
.item-row:last-child { border-bottom: 0; }
.item-row .q { color: var(--muted); font-variant-numeric: tabular-nums; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .02em;
}
.input, .textarea, select.input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.switch input { appearance: none; width: 42px; height: 25px; border-radius: 999px;
  background: var(--line); position: relative; transition: background .25s; cursor: pointer; }
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .25s cubic-bezier(.22,1,.36,1);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(17px); }

/* ---------- 管理页 ---------- */
.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.admin-row img, .admin-row .thumb {
  width: 52px; height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--paper-2);
  flex: 0 0 auto;
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 18px;
}
.admin-row__main { flex: 1 1 auto; min-width: 0; }
.admin-row__name { font-size: 15px; font-weight: 600; font-family: var(--font-serif); }
.admin-row__meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, color .2s, transform .2s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn--danger { color: #c0392b; }

/* ---------- 统计 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-tile b {
  display: block;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.stat-tile span { font-size: 11.5px; color: var(--muted); }

.bar-row { margin-bottom: 12px; }
.bar-row__head {
  display: flex; justify-content: space-between;
  font-size: 13.5px; margin-bottom: 6px;
}
.bar-row__head .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar {
  height: 7px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 75%, #fff), var(--accent));
  transform-origin: left;
  animation: grow .7s cubic-bezier(.22,1,.36,1) both;
}

/* ---------- 点阵加载 ---------- */
.loader {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 3px;
  width: 100%;
  max-width: 240px;
  margin: 18px auto;
  aspect-ratio: 1;
  padding: 12px;
}
.loader i {
  border-radius: 50%;
  background: var(--ink);
  opacity: .08;
  animation: dot 2.6s ease-in-out infinite;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty__mark {
  font-family: var(--font-serif);
  font-size: 40px;
  opacity: .28;
  margin-bottom: 12px;
}
.empty p { font-size: 14px; margin: 0; line-height: 1.7; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 84px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px);
  z-index: 90;
  padding: 11px 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: var(--paper);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .3s cubic-bezier(.22,1,.36,1);
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 动画 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
@keyframes grow { from { transform: scaleX(0); } }
@keyframes dot {
  0%, 100% { opacity: .07; }
  50%      { opacity: .28; }
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 34px 28px 28px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-md);
  animation: rise .6s cubic-bezier(.22,1,.36,1) both;
}
.login-card h1 {
  font-family: var(--font-serif);
  font-size: 27px;
  margin: 0 0 6px;
  letter-spacing: -.01em;
}
.login-card p.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 24px;
}
