/* ============ 风融库存 全局样式 ============ */
:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --line: #e5ddce;
  --text: #2b2620;
  --text2: #7a746a;
  --text3: #a8a296;
  --primary: #e2582b;
  --primary-deep: #c74a22;
  --primary-weak: #fdeee5;
  --danger: #d9442c;
  --danger-weak: #fdecea;
  --success: #2e9e5b;
  --success-weak: #e7f4ec;
  --warn: #c9861c;
  --warn-weak: #faf1dc;
  --gray-weak: #f3f0e9;
  --radius: 14px;
  --radius-sm: 9px;
  --tabbar-h: 58px;
  --shadow: 0 1px 4px rgba(74, 60, 38, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
}
html {
  background: #e7e2d8;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue',
    'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  box-shadow: 0 0 24px rgba(74, 60, 38, 0.1);
}
input,
button,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}
button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- 页面骨架 ---------- */
.page {
  padding: 12px 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}
.page--sub {
  padding-bottom: 110px;
}
.page--tab {
  padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
}
.page-head-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 8px;
  background: rgba(244, 245, 247, 0.92);
  backdrop-filter: blur(8px);
}
.page-head-bar .phb-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 600;
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phb-back {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 15px;
}
.phb-back svg {
  width: 20px;
  height: 20px;
}
.phb-right {
  margin-left: auto;
  padding: 6px 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- 主 Tab 页头（标题 + 右上角设置齿轮） ---------- */
.tab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 12px;
}
.tab-head .th-title {
  font-size: 22px;
  font-weight: 700;
}
.tab-head .th-sub {
  font-size: 12px;
  color: var(--text3);
  font-weight: 400;
  margin-left: 6px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
}
.icon-btn:active {
  background: var(--gray-weak);
}

/* ---------- 商品卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.gcard {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.gcard:active {
  background: #f7f8fa;
}
.gcard .gc-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--gray-weak);
}
.gcard .gc-season {
  position: absolute;
  top: 8px;
  left: 8px;
}
.gcard .gc-status {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(28, 30, 33, 0.6);
  color: #fff;
}
.gcard.is-disabled .gc-img {
  opacity: 0.45;
}
.gcard .gc-body {
  padding: 6px 8px 8px;
}
.gcard .gc-sku {
  font-size: 11px;
  font-weight: 600;
  min-width: 0;
  display: flex;
}
.gcard .gc-sku .sku-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gcard .gc-name {
  font-size: 10.5px;
  color: var(--text2);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 17px;
}
.gcard .gc-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 5px;
  gap: 6px;
}
.gcard .gc-cost {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}
.gcard .gc-stock {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- 详情页一键销售 ---------- */
.sell-now {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #f0763a, #dd5327);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(226, 88, 43, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}
.sell-now:active {
  opacity: 0.85;
}
.sell-now svg {
  width: 18px;
  height: 18px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(74, 60, 38, 0.04), 0 4px 14px rgba(74, 60, 38, 0.05);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title .extra {
  font-size: 12px;
  color: var(--text3);
  font-weight: 400;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  padding: 10px 16px;
  transition: opacity 0.15s;
  user-select: none;
}
.btn:active {
  opacity: 0.75;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-ghost {
  background: var(--gray-weak);
  color: var(--text);
}
.btn-ghost-danger {
  background: var(--danger-weak);
  color: var(--danger);
}
.btn-ghost-primary {
  background: var(--primary-weak);
  color: var(--primary-deep);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 7px;
}
.btn-block {
  display: flex;
  width: 100%;
}
.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  z-index: 40;
}
.action-bar .btn {
  flex: 1;
}

/* ---------- 表单 ---------- */
.field {
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
}
.field-label .req {
  color: var(--danger);
  margin-left: 2px;
}
.input,
.textarea {
  width: 100%;
  border: 1px solid #e0d8c8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  transition: border-color 0.15s;
}
.input:focus,
.textarea:focus {
  border-color: var(--primary);
  background: #fff;
}
.textarea {
  min-height: 64px;
  resize: none;
}
.input-inline {
  display: flex;
  align-items: center;
  border: 1px solid #e0d8c8;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0 12px;
}
.input-inline:focus-within {
  border-color: var(--primary);
  background: #fff;
}
.input-inline .input {
  border: none;
  background: none;
  padding: 10px 0;
  flex: 1;
  min-width: 0;
}
.input-inline .suffix {
  color: var(--text3);
  font-size: 13px;
}
.hint {
  font-size: 12px;
  color: var(--text3);
  margin-top: 5px;
  line-height: 1.5;
}
.hint-warn {
  color: var(--warn);
}

/* ---------- 分段控件 ---------- */
.seg {
  display: flex;
  background: var(--gray-weak);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-item {
  flex: 1;
  text-align: center;
  padding: 7px 4px;
  font-size: 14px;
  color: var(--text2);
  border-radius: 6px;
  font-weight: 500;
}
.seg-item.on {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.1);
}

/* ---------- 徽标 / 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--gray-weak);
  color: var(--text2);
  line-height: 1.7;
  white-space: nowrap;
}
.tag-spring {
  background: #e8f7ef;
  color: #15803d;
}
.tag-autumn {
  background: #fdf3e3;
  color: #b45309;
}
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 1.5px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-paid {
  background: var(--success-weak);
  color: var(--success);
}
.badge-unpaid {
  background: var(--danger-weak);
  color: var(--danger);
}
.badge-void {
  background: #ececec;
  color: #8a8f99;
}
.badge-info {
  background: var(--primary-weak);
  color: var(--primary);
}
.badge-warn {
  background: var(--warn-weak);
  color: var(--warn);
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 48px 0 40px;
  color: var(--text3);
  font-size: 13px;
}
.empty .empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.6;
}

/* ---------- 顶部警示条 ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}
.banner-warn {
  background: var(--warn-weak);
  color: var(--warn);
}
.banner-warn a,
.banner-warn .link {
  color: var(--warn);
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  position: relative;
}
.stat-card .sc-label {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-card .sc-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.stat-card .sc-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.stat-card.clickable:active {
  background: #faf6ee;
}
.sc-value.danger {
  color: var(--danger);
}
.sc-value.success {
  color: var(--success);
}
.sc-arrow {
  position: absolute;
  right: 10px;
  top: 12px;
  color: var(--text3);
  font-size: 14px;
}

/* ---------- 列表行 ---------- */
.cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.cell:last-child {
  border-bottom: none;
}
.cell-main {
  flex: 1;
  min-width: 0;
}
.cell-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-right {
  text-align: right;
  flex-shrink: 0;
}
.cell-amount {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.amount-in {
  color: var(--success);
}
.amount-out {
  color: var(--danger);
}

/* ---------- 商品图（行内小图） ---------- */
.goods-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--gray-weak);
  flex-shrink: 0;
}
.img-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-weak);
  color: var(--text3);
  font-size: 11px;
}

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s;
}
.modal-mask[hidden] {
  display: none;
}
.modal-body {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: slideUp 0.22s;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  color: var(--text3);
  font-size: 20px;
  padding: 2px 6px;
  line-height: 1;
}
.modal-center {
  align-items: center;
  padding: 24px;
}
.modal-center .modal-body {
  border-radius: 16px;
  animation: zoomIn 0.18s;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(40%);
    opacity: 0.5;
  }
}
@keyframes zoomIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
}

/* ---------- Toast / Dialog ---------- */
.toast-wrap {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 80vw;
}
.toast {
  background: rgba(28, 30, 33, 0.88);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  text-align: center;
  animation: zoomIn 0.2s;
  line-height: 1.5;
  word-break: break-all;
}
.toast-ok {
  background: rgba(24, 160, 88, 0.92);
}
.toast-err {
  background: rgba(229, 72, 77, 0.94);
}
.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.dialog-actions .btn {
  flex: 1;
  padding: 9px;
}

/* ---------- 联想下拉 ---------- */
.sugg-wrap {
  position: relative;
}
.sugg {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 24px rgba(17, 24, 39, 0.16);
  z-index: 60;
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.sugg[hidden] {
  display: none;
}
.sugg-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  cursor: pointer;
}
.sugg-item:last-child {
  border-bottom: none;
}
.sugg-item:active {
  background: var(--gray-weak);
}
.sugg-item img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--gray-weak);
}

/* ---------- 步进器 ---------- */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stepper button {
  width: 30px;
  height: 30px;
  font-size: 17px;
  color: var(--text2);
  background: var(--gray-weak);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper input {
  width: 40px;
  height: 30px;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  background: #fff;
}

/* ---------- 头像 ---------- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.gray {
  background: var(--gray-weak);
  color: var(--text3);
}

/* ---------- 口径说明 ---------- */
.note-box {
  background: var(--gray-weak);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.7;
}

/* ---------- 照片选择 ---------- */
.photo-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-item {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-del {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 0 8px;
}
.photo-add {
  width: 84px;
  height: 84px;
  border: 1.5px dashed #c8ccd4;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 11px;
  gap: 2px;
  background: #fafbfc;
  cursor: pointer;
}
.photo-add .plus {
  font-size: 22px;
  line-height: 1;
  color: #b6bac2;
}

/* ---------- 排行 ---------- */
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.rank-row:last-child {
  border-bottom: none;
}
.rank-no {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--gray-weak);
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rank-no.r1 {
  background: #fdeeee;
  color: var(--danger);
}
.rank-no.r2 {
  background: var(--warn-weak);
  color: var(--warn);
}
.rank-no.r3 {
  background: var(--success-weak);
  color: var(--success);
}

/* ---------- 详情键值 ---------- */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
}
.kv .k {
  color: var(--text2);
  flex-shrink: 0;
}
.kv .v {
  text-align: right;
  word-break: break-all;
}
.kv .v.money {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.divider {
  height: 1px;
  background: var(--line);
  margin: 8px 0;
}
.red {
  color: var(--danger);
}
.green {
  color: var(--success);
}
.gray {
  color: var(--text3);
}
.strong {
  font-weight: 600;
}
.small {
  font-size: 12px;
}

/* ---------- 底部导航（库存｜记账｜＋录销售｜顾客｜进货） ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #9298a3;
  font-size: 10.5px;
}
.tabbar .tab.on {
  color: var(--primary);
}
.tabbar .tab-icon {
  display: flex;
}
.tabbar .tab-sell {
  flex: 1.1;
}
.tabbar .sell-btn {
  width: 50px;
  height: 50px;
  margin-top: -14px;
  border-radius: 50%;
  background: linear-gradient(160deg, #f0763a, #dd5327);
  box-shadow: 0 6px 14px rgba(226, 88, 43, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 7px;
}
.tabbar .sell-btn svg {
  height: 17px;
  width: 17px;
}
.tabbar .sell-btn i {
  font-style: normal;
  color: #fff;
  font-size: 9px;
  line-height: 1.4;
  transform: scale(0.94);
}

/* 行内小图：充满外层固定尺寸容器（列表 46–52px 行高用） */
.goods-img-sm {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  background: var(--gray-weak);
  display: block;
}
.img-box {
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px;
}
