:root {
  --brand: #c8442e;
  --brand-dark: #a93522;
  --brand-soft: #fbeee9;
  --ink: #1c1a17;
  --ink-2: #6b6560;
  --ink-3: #9c9590;
  --line: #ece7e2;
  --bg: #f6f3f0;
  --card: #ffffff;
  --ok: #2f7a52;
  --warn: #b4632c;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.04), 0 6px 18px rgba(28, 26, 23, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior: none;
}

#app {
  max-width: 440px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
}

.view {
  display: none;
  height: 100%;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* ---------------------------------------------------------- 登录 */

.login-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 32px 80px;
  background: var(--card);
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 20px;
  flex: none;
}

.login-wrap h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 6px;
}

.login-wrap .sub {
  color: var(--ink-3);
  font-size: 13px;
  margin-bottom: 32px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}

.input:focus {
  border-color: var(--brand);
  background: #fff;
}

textarea.input {
  height: auto;
  min-height: 88px;
  padding: 12px 14px;
  resize: none;
  line-height: 1.6;
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.btn {
  height: 46px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.75;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
}

.btn-ghost {
  background: var(--bg);
  color: var(--ink-2);
}

.btn-outline {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.btn-sm {
  height: 32px;
  font-size: 13px;
  border-radius: 8px;
  padding: 0 12px;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.login-hint {
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.8;
}

/* ---------------------------------------------------------- 顶栏 */

.topbar {
  flex: none;
  background: var(--card);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 5;
}

.topbar.hide {
  transform: translateY(-100%);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  pointer-events: none;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 10px;
  padding: 0 12px;
  height: 38px;
}

.search-box svg {
  flex: none;
  color: var(--ink-3);
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
}

/* ---------------------------------------------------------- 首页主体 */

.home-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.catbar {
  flex: none;
  width: 84px;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 120px;
}

.cat-item {
  padding: 14px 8px;
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  position: relative;
  cursor: pointer;
  line-height: 1.35;
}

.cat-item.active {
  background: var(--card);
  color: var(--brand);
  font-weight: 500;
}

.cat-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.product-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 140px;
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pcard {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.pcard .thumb {
  width: 100%;
  aspect-ratio: 1 / 0.76;
}

.thumb.detail-hero {
  width: 100%;
  aspect-ratio: 1 / 0.66;
  border-radius: 12px;
  font-size: 30px;
  margin-bottom: 10px;
}

/* 订单状态筛选 */
.tabs-scroll {
  flex: none;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tabs-inner {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  width: max-content;
}

.tab-chip {
  font-size: 13px;
  padding: 6px 15px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.tab-chip.active {
  background: var(--brand);
  color: #fff;
}

/* 订单卡片 */
.order-brief {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.order-brief .ob-time {
  color: var(--ink-3);
  font-size: 11px;
  margin-top: 2px;
}

.order-items-brief {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.75;
  margin: 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.ob-qty {
  font-size: 12px;
  color: var(--ink-3);
}

.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 2px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pcard-body {
  padding: 7px 9px 9px;
}

.pcard-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  height: 34px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pcard-sup {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcard-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 5px;
  gap: 4px;
}

.price {
  color: var(--brand);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.price small {
  font-size: 11px;
  margin-right: 1px;
  font-weight: 400;
}

.price-unit {
  font-size: 10px;
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 2px;
}

.pcard-sales {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 4px;
}

.add-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  padding: 0 0 2px;
}

.add-btn:active {
  transform: scale(0.9);
}

.tag-top {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(200, 68, 46, 0.94);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.tag-low {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--warn);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(180, 99, 44, 0.3);
}

.empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  padding: 60px 20px;
  line-height: 1.8;
}

/* ---------------------------------------------------------- 购物车条 */

.cartbar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 66px;
  height: 50px;
  background: #2b2723;
  border-radius: 25px;
  display: flex;
  align-items: center;
  padding: 0 6px 0 16px;
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transform: translateY(120px);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 8;
}

.cartbar.show {
  transform: translateY(0);
}

.cartbar .num {
  font-size: 12px;
  background: var(--brand);
  border-radius: 10px;
  padding: 1px 7px;
  margin-right: 8px;
}

.cartbar .total {
  font-size: 16px;
  font-weight: 500;
}

.cartbar .go {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border: none;
  height: 38px;
  padding: 0 20px;
  border-radius: 19px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

/* ---------------------------------------------------------- 底部导航 */

.tabbar {
  flex: none;
  height: 56px;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
}

.tab-item.active {
  color: var(--brand);
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

/* ---------------------------------------------------------- 通用页面容器 */

.page {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.navbar {
  flex: none;
  height: 48px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 6px;
  position: relative;
}

.navbar h2 {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.nav-back {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  z-index: 2;
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

.page-foot {
  flex: none;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------------------------------------------------------- 商品详情 */

.detail-hero {
  width: 100%;
  aspect-ratio: 1 / 0.7;
  background: var(--card);
}

.detail-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.detail-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
}

.detail-price {
  color: var(--brand);
  font-size: 26px;
  font-weight: 500;
  margin: 8px 0 4px;
}

.detail-meta {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.9;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.row:last-child {
  border-bottom: none;
}

.row .k {
  color: var(--ink-2);
}

.row .v {
  color: var(--ink);
  text-align: right;
  max-width: 65%;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  height: 32px;
}

.stepper button {
  width: 32px;
  height: 100%;
  border: none;
  background: var(--bg);
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}

.stepper button:disabled {
  color: var(--ink-3);
}

.stepper span {
  min-width: 38px;
  text-align: center;
  font-size: 14px;
}

/* ---------------------------------------------------------- 列表项 */

.list-card {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.status-pill {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
}

.status-pill.s-pending { background: #fdf0e6; color: #b4632c; }
.status-pill.s-preparing { background: #eaf1fb; color: #2c5f9c; }
.status-pill.s-shipped { background: #e9f4ee; color: #2f7a52; }
.status-pill.s-completed { background: #efeeec; color: #6b6560; }
.status-pill.s-cancelled { background: #f4f2f0; color: #9c9590; }

.item-line {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  align-items: center;
}

.item-line .thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  flex: none;
  font-size: 14px;
}

.item-line .nm {
  flex: 1;
  font-size: 13px;
  min-width: 0;
}

.item-line .nm small {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  margin-top: 2px;
}

.item-line .qty {
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------------------------------------------------------- 订单进度 */

.steps {
  display: flex;
  align-items: flex-start;
  padding: 16px 4px 6px;
}

.step {
  flex: 1;
  text-align: center;
  position: relative;
  font-size: 11px;
  color: var(--ink-3);
}

.step .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--line);
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  position: relative;
  z-index: 2;
}

.step.done .dot {
  background: var(--brand);
}

.step.done {
  color: var(--brand);
}

.step::after {
  content: '';
  position: absolute;
  top: 9px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
  z-index: 1;
}

.step:last-child::after {
  display: none;
}

.step.done::after {
  background: var(--brand);
}

/* ---------------------------------------------------------- 评价 */

.stars {
  display: flex;
  gap: 10px;
  font-size: 30px;
  color: var(--line);
  padding: 6px 0 14px;
}

.stars span {
  cursor: pointer;
  transition: transform 0.1s;
  line-height: 1;
}

.stars span.on {
  color: #e8a33d;
}

.stars span:active {
  transform: scale(1.15);
}

.review-view {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-top: 8px;
}

/* ---------------------------------------------------------- 购物车页 */

.cart-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.cart-row .thumb {
  width: 56px;
  height: 56px;
  border-radius: 9px;
  flex: none;
  font-size: 15px;
}

.cart-row .info {
  flex: 1;
  min-width: 0;
}

.cart-row .nm {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-row .sub {
  font-size: 11px;
  color: var(--ink-3);
  margin: 2px 0 6px;
}

/* ---------------------------------------------------------- 我的 */

.profile-head {
  background: var(--card);
  padding: 26px 16px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
}

.profile-head .nm {
  font-size: 17px;
  font-weight: 500;
}

.profile-head .rl {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
}

.menu-list {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

.menu-item {
  padding: 15px 16px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item .arrow {
  color: var(--ink-3);
}

/* ---------------------------------------------------------- 状态页 */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 0;
  color: var(--ink-3);
  font-size: 13px;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------- 提示与弹窗 */

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translate(-50%, 20px);
  background: rgba(28, 26, 23, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s;
  z-index: 999;
  max-width: 80vw;
  text-align: center;
  line-height: 1.5;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 30px;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 300px;
}

.modal-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.modal-box p {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
  height: 40px;
  font-size: 14px;
}
