/* ============================================================
   药房采购系统 · 门店端 UI 框架（手机 H5）
   风格：高级黑白灰 + 价格橙红点缀
   ============================================================ */

:root {
  --primary: #1A1A1A;
  --primary-dark: #000000;
  --primary-light: #F1F1F1;
  --price: #FF4D24;
  --danger: #FF4D24;
  --danger-light: #FFEEEE;
  --bg: #F6F6F6;
  --card: #FFFFFF;
  --border: #EFEFEF;
  --text: #1F2329;
  --text-2: #858B95;
  --text-3: #B5BAC2;
  --dark: #22252A;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  max-width: 750px;
  margin: 0 auto;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 顶部搜索区 ---------------- */
.top-search {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--card);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 20px;
  height: 38px;
  padding: 0 14px;
}
.search-box svg { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.top-store {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  padding: 8px 4px 0;
}
.top-store .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* ---------------- 下单页：左分类右商品 ---------------- */
.shop-layout {
  display: flex;
  align-items: stretch;
  /* 高度 = 屏幕 - 搜索区 - 底部导航（购物车条是悬浮层，不占空间） */
  height: calc(100vh - 57px - 54px);
  height: calc(100dvh - 57px - 54px);
}

.cat-side {
  width: 86px;
  flex-shrink: 0;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cat-side .cat-item {
  padding: 14px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  border-left: 3px solid transparent;
  word-break: break-all;
  line-height: 1.3;
}
.cat-side .cat-item.active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--primary);
}

.goods-main {
  flex: 1;
  background: var(--card);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  position: relative; /* 作为子元素 offsetTop 的定位基准 */
}
.goods-cat-title {
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px 4px;
  color: var(--text);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 5;
}

/* 商品条目 */
.goods-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.goods-item:last-child { border-bottom: none; }
.goods-thumb {
  width: 78px;
  height: 78px;
  border-radius: 10px;
  background: var(--primary-light);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.goods-thumb img { width: 100%; height: 100%; object-fit: cover; }
.goods-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.goods-name {
  font-size: 14px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.goods-meta {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goods-tags { display: flex; gap: 4px; margin-top: 4px; }
.tag {
  font-size: 12px;
  height: 20px;
  line-height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 600;
}
.tag-control { color: #B45309; border: 1px solid #F0D9B5; background: #FDF6E9; }
.tag-nostock { color: var(--text-2); background: #F0F0F0; }
/* 类型标签颜色由内联样式按类型动态指定 */
.goods-bottom {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 6px;
}
.goods-price { color: var(--price); font-weight: 700; font-size: 16px; }
.goods-price small { font-size: 11px; font-weight: 400; }
.goods-price .unit { color: var(--text-2); font-size: 11px; font-weight: 400; }

/* 数量步进器 */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .st-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.stepper .st-plus { background: var(--primary); color: #fff; }
.stepper .st-minus { background: #fff; border: 1px solid #D8DCE2; color: var(--text-2); }
.stepper .st-qty {
  min-width: 20px;
  text-align: center;
  font-size: 16px; /* 16px 以上避免 iOS 聚焦时页面放大 */
  font-variant-numeric: tabular-nums;
  width: 48px;
  height: 30px;
  border: 1px solid #D8DCE2;
  border-radius: 6px;
  background: #fff;
  outline: none;
  padding: 0 4px;
}
/* 去掉数字输入框自带的上下箭头，界面更干净 */
.stepper .st-qty::-webkit-outer-spin-button,
.stepper .st-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .st-qty { -moz-appearance: textfield; }

/* 售罄/不可买状态 */
.goods-item.disabled .goods-thumb { background: #F0F0F0; color: var(--text-3); }
.goods-item.disabled .goods-name,
.goods-item.disabled .goods-price { color: var(--text-3); }
.soldout-text { font-size: 12px; color: var(--text-3); }

/* ---------------- 购物车悬浮条 ---------------- */
.cart-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 54px;
  z-index: 70;
  max-width: 750px;
  margin: 0 auto;
  padding: 8px 12px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
}
.cart-bar-inner {
  background: var(--dark);
  border-radius: 26px;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 6px 0 16px;
  color: #fff;
}
.cart-icon { position: relative; display: flex; align-items: center; }
.cart-icon svg { width: 26px; height: 26px; }
.cart-badge {
  position: absolute;
  top: -6px; right: -10px;
  background: var(--price);
  color: #fff;
  font-size: 10px;
  height: 16px;
  min-width: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.cart-total { margin-left: 12px; font-size: 17px; font-weight: 700; flex: 1; }
.cart-total small { font-size: 11px; font-weight: 400; color: rgba(255,255,255,.6); margin-left: 4px; }
.cart-submit {
  background: #fff;
  color: #1A1A1A;
  border: 1px solid #1A1A1A;
  height: 40px;
  padding: 0 22px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.cart-submit[disabled] { background: #4A4E55; color: #9CA0A8; border-color: #4A4E55; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  max-width: 750px;
  margin: 0 auto;
  height: 54px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-2);
}
.tabbar a.active { color: var(--primary); }
.tabbar a svg { width: 21px; height: 21px; }

/* ---------------- 通用组件 ---------------- */
.page { padding-bottom: 70px; min-height: 100vh; }
.page-head {
  position: sticky; top: 0; z-index: 60;
  background: var(--card);
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 10px 12px;
  padding: 14px;
}

/* 订单卡片 */
.order-card .order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.order-status { font-weight: 600; }
.order-status.st-pending { color: #B45309; }
.order-status.st-shipped { color: var(--primary); }
.order-status.st-delivered { color: var(--primary); }
.order-status.st-finished { color: var(--text-2); }
.order-status.st-cancelled { color: var(--text-3); }
.order-goods { padding: 10px 0; font-size: 13px; color: var(--text-2); }
.order-goods .line { display: flex; justify-content: space-between; padding: 3px 0; }
.order-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.order-amount { color: var(--price); font-weight: 700; font-size: 16px; }
.order-amount small { color: var(--text-2); font-weight: 400; font-size: 12px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border-radius: 17px;
  border: 1px solid #D8DCE2;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-lg { height: 46px; border-radius: 23px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btn-n { display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 14px; border-radius: 15px; border: 1px solid #D8DCE2; background: #fff; color: var(--text); font-size: 12px; cursor: pointer; text-decoration: none; }
.btn-n.primary { color: var(--primary); border-color: var(--primary); }
.btn-n.danger { color: var(--danger); border-color: var(--danger); }

/* 统计看板 */
.stat-banner {
  background: linear-gradient(135deg, #2B2F36, #111214);
  border-radius: var(--radius);
  margin: 10px 12px;
  padding: 20px 16px;
  color: #fff;
}
.stat-banner .sb-label { font-size: 12px; opacity: .85; }
.stat-banner .sb-value { font-size: 30px; font-weight: 700; margin-top: 4px; }
.stat-banner .sb-row { display: flex; gap: 24px; margin-top: 14px; }
.stat-banner .sb-row .cell .n { font-size: 17px; font-weight: 600; }
.stat-banner .sb-row .cell .t { font-size: 11px; opacity: .85; }

/* 列表项（我的页面） */
.menu-list { background: var(--card); border-radius: var(--radius); margin: 10px 12px; overflow: hidden; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.menu-item:last-child { border-bottom: none; }
.menu-item .arrow { color: var(--text-3); }

/* 登录页 */
.login-page { min-height: 100vh; background: var(--card); padding: 60px 28px 0; }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.login-logo .logo-dot {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.login-sub { color: var(--text-2); font-size: 13px; margin: 10px 0 34px; }
.login-page .form-item { margin-bottom: 16px; }
.login-page input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0 18px;
  font-size: 15px;
  outline: none;
  background: var(--bg);
}
.login-page input:focus { border-color: var(--primary); background: #fff; }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); font-size: 13px; }
.empty .icon { font-size: 40px; margin-bottom: 10px; }

/* Toast */
.toast {
  position: fixed;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  max-width: 80vw;
}
.toast.show { opacity: 1; }

/* 自定义弹窗 */
.dlg-mask { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:999; display:flex; align-items:center; justify-content:center; animation:fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dlg-box { background:#fff; border-radius:14px; width:85%; max-width:360px; overflow:hidden; box-shadow:0 8px 40px rgba(0,0,0,.12); animation:dlgUp .2s ease; }
@keyframes dlgUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.dlg-msg { padding:28px 20px 16px; text-align:center; font-size:15px; line-height:1.6; color:var(--text); }
.dlg-input { display:block; width:calc(100% - 32px); margin:0 16px 16px; padding:10px 12px; border:1px solid var(--border); border-radius:8px; font-size:14px; outline:none; }
.dlg-input:focus { border-color:var(--primary); }
.dlg-btns { display:flex; border-top:1px solid var(--border); }
.dlg-btn { flex:1; padding:14px 0; border:none; background:transparent; font-size:15px; cursor:pointer; color:var(--text-2); transition:background .15s; }
.dlg-btn:hover { background:var(--bg); }
.dlg-btn.dlg-ok { color:var(--primary); font-weight:600; }
.dlg-btn.dlg-cancel { border-right:1px solid var(--border); }

.muted { color: var(--text-2); }
.small { font-size: 12px; }
.text-price { color: var(--price); }

/* 商品详情面板上滑动画 */
@keyframes detailUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
