:root {
  --bg: #f6f4ef;
  --surface: #fffdf9;
  --ink: #22201c;
  --muted: #7b756c;
  --line: #e4dfd5;
  --accent: #a8492a;
  --accent-ink: #fff6f1;
  --ok: #2f6b4f;
  --warn: #a06a1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 25, 20, .05), 0 8px 24px -12px rgba(30, 25, 20, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main.container { flex: 1 0 auto; width: 100%; }
.foot { margin-top: auto; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(246, 244, 239, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .02em;
}
.nav { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--accent); }

.notice {
  margin: 14px auto 0;
  max-width: 1080px;
  padding: 10px 16px;
  border: 1px solid #ecdfc4;
  background: #fdf6e7;
  color: var(--warn);
  border-radius: 10px;
  font-size: 13.5px;
}

/* ---------- 布局 ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 20px 80px;
}
.page-title {
  margin: 4px 0 18px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .01em;
}
.sub { color: var(--muted); font-size: 13.5px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(30,25,20,.06), 0 16px 32px -16px rgba(30,25,20,.28); }
.card .thumb {
  aspect-ratio: 4 / 3;
  background: #efece5 center/cover no-repeat;
}
.card .body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .title { font-weight: 600; line-height: 1.5; }
.card .desc { color: var(--muted); font-size: 13px; min-height: 1.4em; }
.price { color: var(--accent); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.price small { font-size: 12px; font-weight: 600; margin-right: 1px; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- 详情 ---------- */
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 26px;
  align-items: start;
}
.detail .hero {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #efece5 center/cover no-repeat;
  box-shadow: var(--shadow);
}
.detail h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.4; }
.detail .body-text { color: #4a453d; white-space: pre-wrap; margin: 14px 0 0; font-size: 14.5px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 73, 42, .12);
}
.field textarea { resize: vertical; min-height: 78px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #963f23; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

.amount-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
}
.amount-line .big { font-size: 26px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 订单 ---------- */
.order-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: #ece7dd;
  color: #5c564d;
}
.badge.review { background: #fdf3e0; color: var(--warn); }
.badge.paid, .badge.done { background: #e6f1ea; color: var(--ok); }
.badge.canceled { background: #f4e8e6; color: #9a4a3a; }

.qr-box {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px;
  max-width: 340px;
  margin: 0 auto;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
}
.qr-box img { width: 220px; height: 220px; object-fit: contain; border-radius: 8px; }
.qr-hint { color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.6; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.list-item:last-child { border-bottom: 0; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 20px 32px;
}
.foot .sep { margin: 0 6px; }

/* ---------- 聊天 ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(168, 73, 42, .7);
  z-index: 40;
}
.fab .dot {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffd166;
  border: 2px solid var(--accent);
}

.chat {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: min(370px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(30, 25, 20, .5);
  overflow: hidden;
  z-index: 45;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fffaf4;
}
.chat-tip {
  margin: 0;
  padding: 7px 14px;
  font-size: 11.5px;
  color: var(--muted);
  background: #faf7f1;
  border-bottom: 1px solid var(--line);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: #fdfbf7;
}
.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.admin { align-self: flex-start; background: #efece4; color: var(--ink); border-bottom-left-radius: 4px; }
.msg time { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.chat-input input:focus { border-color: var(--accent); }
.icon-btn { background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #22201c;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 后台 ---------- */
.admin-body { background: #f2f0ea; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(380px, 100%); padding: 28px; }
.err { color: #a8492a; font-size: 13.5px; min-height: 1.4em; margin: 10px 0 0; }

.nav a.active { color: var(--accent); font-weight: 600; }
.nav a { padding: 2px 0; }

.chat-admin {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.chat-list { padding: 0; max-height: 560px; overflow-y: auto; }
.chat-row {
  position: relative;
  display: block;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.chat-row:last-child { border-bottom: 0; }
.chat-row:hover { background: #f7f4ee; }
.chat-row.active { background: #fdf1ea; box-shadow: inset 3px 0 0 var(--accent); }
.chat-row-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.chat-row-text { font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.chat-detail { padding: 0; overflow: hidden; }
.chat-detail .chat-log { max-height: 420px; }
.chat-detail .chat-input { border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; }
  .container { padding: 18px 14px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .topbar { padding: 12px 14px; }
  .chat-admin { grid-template-columns: 1fr; }
}
