/* ===== 生意专家 · 库存管理 ===== */
:root {
  --primary: #f25022;
  --primary-dark: #d63c12;
  --primary-light: #fff1ec;
  --orange: #e8a86a;
  --text: #1f2329;
  --text-sub: #646a73;
  --text-mute: #8f959e;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #ebedf0;
  --green: #2ea867;
  --red: #e54848;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0,0,0,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; outline: none; }
button { cursor: pointer; border: none; background: none; }

/* ===== 顶部导航 ===== */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; min-height: 52px; flex-wrap: wrap; gap: 6px;
}
.navbar .brand { font-weight: 800; font-size: 18px; color: var(--primary); white-space: nowrap; }
.navbar .nav-right { display: flex; gap: 10px; font-size: 11px; color: var(--text-sub); flex-wrap: wrap; }
.navbar .nav-right a:hover { color: var(--primary); }
.navbar .nav-right .logout { font-size: 10px; color: var(--red); }

/* ===== 进价脱敏 ===== */
.cost-masked {
  cursor: pointer; user-select: none;
  letter-spacing: 1px; color: var(--text-mute);
  border-bottom: 1px dashed var(--text-mute);
  padding-bottom: 1px;
}
.cost-masked:hover { color: var(--primary); border-bottom-color: var(--primary); }
.cost-masked::before { content: "🔒 "; font-size: 11px; }
.cost-revealed { color: var(--text); font-weight: 600; }

/* ===== 布局容器 ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 12px; }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  background: linear-gradient(135deg, #2b2f36 0%, #4a5058 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 24px;
  padding: 36px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card .logo { text-align: center; font-size: 30px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.login-card .logo sup { font-size: 12px; color: var(--text-mute); }
.login-card .slogan { text-align: center; color: var(--text-sub); font-size: 13px; margin-bottom: 28px; }
.login-card .field {
  display: flex; align-items: center; background: #f5f6f8; border-radius: 12px;
  padding: 0 14px; margin-bottom: 14px; height: 50px;
}
.login-card .field input { flex: 1; border: none; background: transparent; height: 100%; font-size: 16px; }
.login-card .row-between { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 18px; font-size: 13px; color: var(--text-sub); }
.login-card .row-between label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.login-foot { text-align: center; font-size: 12px; color: rgba(255,255,255,.6); margin-top: 20px; }

/* ===== 通用按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 46px; padding: 0 22px; border-radius: 23px; font-size: 15px; font-weight: 500;
  transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--text-sub); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 999px; padding: 0 14px; height: 44px;
  box-shadow: var(--shadow);
}
.search-bar input { flex: 1; border: none; background: transparent; height: 100%; }
.search-bar .icon-btn { color: var(--text-sub); padding: 6px; }
.search-bar .filter-link { color: var(--text-sub); font-size: 13px; white-space: nowrap; }

/* ===== 统计卡片 ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: var(--card); border-radius: var(--radius); padding: 16px 10px;
  margin: 12px 0; box-shadow: var(--shadow);
}
.stats-row .stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px; min-width: 0;
}
.stats-row .stat .label { font-size: 12px; color: var(--text-sub); white-space: nowrap; flex-shrink: 0; }
.stats-row .stat .value { font-size: 18px; font-weight: 700; white-space: nowrap; }
.stats-row .stat .value.cost-masked { font-size: 14px; }

/* ===== 排序 tab ===== */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; color: var(--text-sub); font-size: 13px;
}
.toolbar .tabs { display: flex; gap: 16px; }
.toolbar .tabs a.active { color: var(--primary); font-weight: 600; }

/* ===== 主布局：手机单列 / 电脑侧栏+列表 ===== */
.layout { display: flex; gap: 12px; align-items: flex-start; }
.sidebar {
  width: 110px; flex-shrink: 0;
  background: var(--card); border-radius: var(--radius); padding: 8px 0;
  max-height: 70vh; overflow-y: auto;
}
.sidebar a {
  display: block; padding: 11px 14px; color: var(--text-sub); font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar a.active { color: var(--primary); background: var(--primary-light); border-left-color: var(--primary); font-weight: 600; }
.product-list { flex: 1; min-width: 0; }

/* ===== 商品卡片 ===== */
.product-card {
  display: flex; gap: 12px; background: var(--card); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow);
  transition: transform .1s;
}
.product-card:hover { transform: translateY(-1px); }
.product-card .thumb {
  width: 80px; height: 80px; border-radius: 10px; background: #f0f2f5;
  flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--text-mute); font-size: 11px;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .info { flex: 1; min-width: 0; }
.product-card .name { font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .spec { color: var(--text-mute); font-size: 12px; margin-top: 2px; }
.product-card .bottom { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.product-card .price { color: var(--primary); font-weight: 700; font-size: 17px; }
.product-card .price::before { content: "¥"; font-size: 12px; margin-right: 1px; }
.product-card .stock { color: var(--text-sub); font-size: 13px; }
.product-card .stock.zero { color: var(--red); }

/* ===== 浮动按钮 ===== */
.fab-group { position: fixed; right: 18px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 40; }
.fab {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  box-shadow: 0 6px 16px rgba(242,80,34,.4);
}
.fab.secondary { background: #333; }

/* ===== 详情页 ===== */
.detail-hero { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.detail-hero .top { display: flex; justify-content: space-between; align-items: flex-start; }
.detail-hero .thumb { width: 100px; height: 100px; border-radius: 10px; background: #f0f2f5; overflow: hidden; }
.detail-hero .thumb img { width: 100%; height: 100%; object-fit: cover; }
.share-pill { background: var(--primary-light); color: var(--primary); padding: 6px 14px; border-radius: 999px; font-size: 13px; }
.detail-title { font-size: 20px; font-weight: 700; margin: 14px 0 4px; }
.detail-cat { color: var(--text-sub); font-size: 13px; }
.detail-price { color: var(--primary); font-weight: 700; font-size: 22px; text-align: right; }
.detail-price::before { content: "¥"; font-size: 14px; margin-right: 2px; }

.detail-list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.detail-list .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 16px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.detail-list .row:last-child { border-bottom: none; }
.detail-list .row .k { color: var(--text-sub); }
.detail-list .row .v { color: var(--text); font-weight: 500; }
.detail-list .row .v.link { color: #3370ff; }

.bottom-actions {
  position: sticky; bottom: 0; background: var(--card); padding: 12px;
  display: flex; gap: 12px; border-top: 1px solid var(--border); margin: 16px -12px -12px;
}
.bottom-actions .btn { flex: 1; height: 48px; }

/* ===== 表单 ===== */
.form-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.form-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.form-row:last-child { border-bottom: none; }
.form-row label { width: 90px; color: var(--text-sub); flex-shrink: 0; }
.form-row label .req { color: var(--red); margin-left: 2px; }
.form-row input, .form-row select, .form-row textarea {
  flex: 1; border: none; background: transparent; padding: 6px 0; font-size: 15px;
}
.form-row textarea { min-height: 60px; resize: vertical; }
.form-row input::placeholder, .form-row textarea::placeholder { color: #c0c4cc; }
.form-row .side-action { color: var(--primary); font-size: 13px; cursor: pointer; }

.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.price-grid .p-cell { background: #f8f9fb; border-radius: 10px; padding: 12px; text-align: center; }
.price-grid .p-cell input { width: 100%; border: none; background: transparent; text-align: center; font-size: 18px; font-weight: 600; }
.price-grid .p-cell .lbl { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.price-grid .p-cell .lbl .req { color: var(--red); }

.image-picker { display: flex; gap: 10px; margin-bottom: 12px; }
.image-picker .img-box {
  width: 80px; height: 80px; border-radius: 10px; background: #f5f6f8;
  display: flex; align-items: center; justify-content: center; color: var(--text-mute);
  font-size: 28px; overflow: hidden; position: relative;
}
.image-picker .img-box img { width: 100%; height: 100%; object-fit: cover; }
.image-picker input[type=file] { display: none; }

/* ===== 出入库页 ===== */
.seg-tabs { display: flex; background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.seg-tabs a { flex: 1; text-align: center; padding: 14px; color: var(--text-sub); font-weight: 500; border-bottom: 2px solid transparent; }
.seg-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.context-bar { background: var(--primary-light); color: var(--primary); padding: 10px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }

.qty-stepper { display: flex; align-items: center; gap: 14px; }
.qty-stepper button { width: 36px; height: 36px; border-radius: 50%; background: #f0f2f5; font-size: 18px; color: var(--text); }
.qty-stepper input { width: 80px; text-align: center; font-size: 20px; font-weight: 600; border: none; }

/* ===== 表格（记录/管理页） ===== */
.table-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-card th, .table-card td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table-card th { background: #fafbfc; color: var(--text-sub); font-weight: 500; }
.table-card tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tag.in { background: #e8f7ef; color: var(--green); }
.tag.out { background: #fdecec; color: var(--red); }

/* ===== flash 提示 ===== */
.flash {
  background: #fff7e6; color: #d46b08; padding: 10px 14px; border-radius: 10px;
  margin-bottom: 10px; font-size: 13px;
}
.flash.error { background: #fdecec; color: var(--red); }

/* ===== 空状态 ===== */
.empty { text-align: center; color: var(--text-mute); padding: 40px 0; font-size: 13px; }

/* ===== 页头 ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 12px; }
.page-header h2 { font-size: 18px; font-weight: 700; }
.page-header .back { color: var(--text-sub); }

/* ===== 响应式：电脑端 ===== */
@media (min-width: 768px) {
  body { font-size: 14px; }
  .container { padding: 20px; }
  .sidebar { width: 160px; }
  .product-card .thumb { width: 100px; height: 100px; }
  .product-card .name { font-size: 16px; }
  .stats-row .stat .value { font-size: 28px; }
  .price-grid { max-width: 560px; }
  .detail-wrap { max-width: 720px; margin: 0 auto; }
  .navbar { padding: 10px 16px; }
  .navbar .brand { font-size: 21px; }
  .navbar .nav-right { font-size: 12px; gap: 14px; }
  .navbar .nav-right .logout { font-size: 11px; }
}

/* ===== 响应式：手机端微调 ===== */
@media (max-width: 480px) {
  .stats-row .stat .value { font-size: 18px; }
  .form-row label { width: 80px; font-size: 13px; }
}
