/* 仓库管理系统 - 样式（手机/电脑自适应） */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
:root{
  --primary:#2F5597; --primary-l:#eaf0fa;
  --green:#1a7f4b; --green-l:#e6f5ec;
  --red:#c0392b; --red-l:#fdecea;
  --amber:#b7791f; --amber-l:#fdf5e6;
  --gray:#6b7280; --line:#e6e8ec; --bg:#f4f6f9;
}
html,body{height:100%;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei","Helvetica Neue",Arial,sans-serif;
  background:var(--bg); color:#1f2430; font-size:15px; line-height:1.5;
  -webkit-text-size-adjust:100%;
}
.hidden{display:none !important;}

/* ---------- 登录 ---------- */
.login-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(160deg,#2F5597,#1a3a6b); padding:20px;
}
.login-box{
  background:#fff; border-radius:18px; padding:36px 28px; width:100%; max-width:360px;
  box-shadow:0 18px 50px rgba(0,0,0,.25); text-align:center;
}
.login-logo{font-size:48px; line-height:1;}
.login-box h1{font-size:22px; margin:10px 0 4px;}
.login-sub{color:var(--gray); font-size:13px; margin-bottom:22px;}
.login-box input{
  width:100%; padding:13px 14px; margin-bottom:12px; border:1px solid var(--line);
  border-radius:10px; font-size:16px; outline:none; background:#fafbfc;
}
.login-box input:focus{border-color:var(--primary); background:#fff;}
.login-err{color:var(--red); font-size:13px; margin-top:10px; min-height:18px;}

/* ---------- 按钮 ---------- */
.btn{
  border:none; border-radius:10px; padding:11px 16px; font-size:15px; font-weight:600;
  cursor:pointer; font-family:inherit; transition:filter .12s, transform .08s;
}
.btn:active{transform:scale(.97);}
.btn-primary{background:var(--primary); color:#fff;}
.btn-out{background:var(--red); color:#fff;}
.btn-in{background:var(--green); color:#fff;}
.btn-ghost{background:#fff; color:var(--primary); border:1px solid var(--primary);}
.btn-block{width:100%; display:block; margin-top:8px;}
.btn-mini{padding:2px 9px; font-size:12px; border-radius:8px; line-height:1.6;}
/* 列表行里的小按钮：单独一行，不挤名称 */
.acts{
  flex:0 0 100%; display:flex; gap:5px; justify-content:flex-end;
  flex-wrap:wrap; margin-top:1px;
}
.btn-act{
  padding:0 7px; font-size:11.5px; border-radius:7px; line-height:1.6;
  border-color:#dde2e8; color:#5c636a; background:#fff; font-weight:500;
}
.btn-act:active{background:#f1f3f5;}
.btn-arrow{padding:0 6px; font-size:10px; color:#adb5bd; line-height:1.9;}
.btn-row{display:flex; gap:8px; margin-bottom:12px; flex-wrap:wrap;}
.btn-row .btn{flex:1; min-width:110px;}
.icon-btn{
  background:transparent; border:none; font-size:20px; cursor:pointer;
  color:inherit; padding:4px 8px; border-radius:8px;
}
.icon-btn:active{background:rgba(0,0,0,.06);}

/* ---------- 顶栏 ---------- */
.topbar{
  position:sticky; top:0; z-index:50; display:flex; align-items:center; justify-content:space-between;
  background:var(--primary); color:#fff; padding:10px 14px; box-shadow:0 2px 8px rgba(0,0,0,.12);
}
.topbar-left{display:flex; align-items:center; gap:8px;}
.logo{font-size:22px;}
.topbar-title{font-weight:700; font-size:17px;}
.topbar-right{display:flex; align-items:center; gap:6px;}
.user-chip{
  background:rgba(255,255,255,.2); padding:4px 10px; border-radius:20px;
  font-size:13px; font-weight:600;
}
.sync-bar{
  background:#e8f5ec; color:#1a7f4b; font-size:12px; text-align:center;
  padding:3px; font-weight:600;
}
.sync-bar.off{background:#fdecea; color:var(--red);}

/* ---------- 页面 ---------- */
.page{
  padding:12px 12px 78px; max-width:900px; margin:0 auto;
}
.stat-grid{
  display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:12px;
}
.stat{
  background:#fff; border-radius:12px; padding:12px 6px; text-align:center;
  box-shadow:0 1px 3px rgba(0,0,0,.07);
}
.stat-num{font-size:20px; font-weight:800; color:var(--primary);}
.stat-label{font-size:11px; color:var(--gray); margin-top:2px;}
.stat-warn .stat-num{color:var(--red);}

.card{
  background:#fff; border-radius:12px; padding:12px; margin-bottom:12px;
  box-shadow:0 1px 3px rgba(0,0,0,.07);
}
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:10px; gap:8px;
}
.card-head h2{font-size:15px; font-weight:700;}
.badge{
  background:var(--primary-l); color:var(--primary); font-size:12px; font-weight:700;
  padding:3px 9px; border-radius:12px; white-space:nowrap;
}
.badge-red{background:var(--red-l); color:var(--red);}
.badge-green{background:var(--green-l); color:var(--green);}
.badge-amber{background:var(--amber-l); color:var(--amber);}

/* ---------- 列表 ---------- */
.list{display:flex; flex-direction:column; gap:8px;}
.item{
  background:#fff; border-radius:10px; padding:10px 12px; border:1px solid var(--line);
  display:flex; align-items:center; gap:2px 10px; flex-wrap:wrap;
}
.item.click:active{background:#f2f4f7;}
.item-main{flex:1; min-width:0;}
.item-title{
  font-weight:700; font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.item-sub{font-size:12px; color:var(--gray); margin-top:2px;}
.item-right{text-align:right; white-space:nowrap; margin-left:auto;}
.item-qty{font-size:17px; font-weight:800;}
.item-qty.low{color:var(--red);}
.item-qty.ok{color:var(--green);}
.tag{
  display:inline-block; font-size:11px; padding:1px 7px; border-radius:8px;
  background:#eef1f5; color:var(--gray); margin-left:4px;
}
.tag-in{background:var(--green-l); color:var(--green);}
.tag-plain{background:#f1f3f5; color:#868e96;}
.tag-out{background:var(--red-l); color:var(--red);}
.empty{text-align:center; color:var(--gray); padding:26px 10px; font-size:14px;}

/* ---------- 表单 ---------- */
.toolbar{display:flex; gap:8px; margin-bottom:12px; flex-wrap:wrap;}
.search{
  flex:1; min-width:160px; padding:11px 13px; border:1px solid var(--line);
  border-radius:10px; font-size:15px; outline:none; background:#fff;
}
.search:focus{border-color:var(--primary);}
.select{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px;
  font-size:15px; background:#fff; margin-bottom:12px; outline:none;
}
.seg{display:flex; background:#fff; border-radius:10px; padding:3px; border:1px solid var(--line);}
.seg-btn{
  border:none; background:transparent; padding:7px 13px; border-radius:8px;
  font-size:13px; cursor:pointer; color:var(--gray); font-family:inherit; font-weight:600;
}
.seg-btn.active{background:var(--primary); color:#fff;}

/* ---------- 分组 chips ---------- */
.chips{
  display:flex; gap:8px; overflow-x:auto; padding:2px 2px 12px;
  -webkit-overflow-scrolling:touch; scrollbar-width:none;
}
.chips::-webkit-scrollbar{display:none;}
.chip{
  flex:0 0 auto; border:1px solid var(--line); background:#fff; color:var(--gray);
  padding:7px 14px; border-radius:20px; font-size:13px; font-weight:600;
  cursor:pointer; font-family:inherit; white-space:nowrap;
}
.chip.active{background:var(--primary); border-color:var(--primary); color:#fff;}
.chip .chip-n{opacity:.7; font-size:11px; margin-left:4px; font-weight:700;}
.chip-gear{border-style:dashed; color:var(--primary);}

/* 分组标题（列表内） */
.group-head{
  display:flex; align-items:center; gap:8px; margin:14px 2px 0;
  font-size:13px; font-weight:800; color:var(--primary);
}
.group-head:first-child{margin-top:0;}
.group-head .gh-n{color:var(--gray); font-weight:600; font-size:12px;}
.group-head .gh-line{flex:1; height:1px; background:var(--line);}
.group-head.gh-click{cursor:pointer; user-select:none; padding:6px 2px; margin:8px 0 0; border-radius:8px;}
.group-head.gh-click:active{background:var(--bg, #f3f4f6);}
.group-head .gh-arrow{font-size:12px; color:var(--gray); width:14px; display:inline-block;}

/* 分组管理弹窗里的名称输入框 */
.mg-name{
  width:100%; padding:8px 10px; border:1px solid var(--line); border-radius:8px;
  font-size:14px; font-weight:600; outline:none; background:#fafbfc; font-family:inherit;
}
.mg-name:focus{border-color:var(--primary); background:#fff;}

.field{margin-bottom:12px;}
.field label{display:block; font-size:13px; font-weight:600; margin-bottom:5px; color:#404756;}
.field input,.field select,.field textarea{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px;
  font-size:15px; outline:none; background:#fafbfc; font-family:inherit;
}
.field input:focus,.field select:focus{border-color:var(--primary); background:#fff;}
.field-row{display:flex; gap:10px;}
.field-row .field{flex:1;}
.hint{font-size:12px; color:var(--gray); margin-top:4px;}
.hint-red{color:var(--red); font-weight:600;}

.kv{
  display:flex; justify-content:space-between; padding:9px 0;
  border-bottom:1px solid var(--line); font-size:14px;
}
.kv:last-child{border-bottom:none;}
.kv span{color:var(--gray);}
.kv b{font-weight:600;}

/* ---------- 底部导航 ---------- */
.tabbar{
  position:fixed; bottom:0; left:0; right:0; z-index:50;
  background:#fff; display:flex; border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.tab{
  flex:1; border:none; background:transparent; padding:8px 0 7px; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  font-size:11px; color:var(--gray); font-family:inherit; font-weight:600;
}
.tab span{font-size:19px;}
.tab.active{color:var(--primary);}

/* ---------- 弹窗 ---------- */
.modal{
  position:fixed; inset:0; background:rgba(15,20,30,.5); z-index:100;
  display:flex; align-items:center; justify-content:center; padding:16px;
}
.modal-card{
  background:#fff; border-radius:16px; width:100%; max-width:440px;
  max-height:88vh; display:flex; flex-direction:column;
  box-shadow:0 20px 60px rgba(0,0,0,.3);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; border-bottom:1px solid var(--line);
}
.modal-head h3{font-size:16px;}
.modal-body{padding:16px; overflow-y:auto; flex:1;}
.modal-foot{padding:12px 16px; border-top:1px solid var(--line); display:flex; gap:8px;}
.modal-foot .btn{flex:1;}

/* ---------- Toast ---------- */
.toast{
  position:fixed; left:50%; bottom:90px; transform:translateX(-50%);
  background:rgba(25,30,40,.93); color:#fff; padding:11px 20px; border-radius:24px;
  font-size:14px; z-index:200; max-width:86vw; text-align:center; font-weight:600;
}
.toast.err{background:var(--red);}
.toast.ok{background:var(--green);}

/* ---------- 电脑端 ---------- */
@media (min-width:768px){
  .page{padding:16px 16px 24px;}
  .tabbar{
    position:sticky; top:56px; border-radius:12px; margin:12px auto; max-width:900px;
    border:1px solid var(--line); box-shadow:0 2px 8px rgba(0,0,0,.07);
  }
  .stat-num{font-size:26px;}
  .stat-grid{gap:12px;}
  .card{padding:16px;}
}

/* ---------- 勾选框 ---------- */
.chk{
  display:flex; gap:8px; align-items:flex-start; font-size:13px; color:#495057;
  line-height:1.45; background:#f8f9fa; border:1px solid var(--line);
  padding:10px 12px; border-radius:10px;
}
.chk input{width:18px; height:18px; margin:1px 0 0; flex:0 0 auto; accent-color:var(--primary);}

/* ---------- 加工：当前配方摘要 ---------- */
.recipe-box{padding:0 12px 6px;}
.recipe-head{font-size:12px; color:var(--gray); font-weight:700; margin:6px 0;}
.recipe-row{
  display:flex; align-items:baseline; gap:8px; flex-wrap:wrap;
  background:#f8f9fb; border:1px solid var(--line); border-radius:9px;
  padding:7px 10px; margin-bottom:5px;
}
.rr-name{font-size:13px; font-weight:700; color:#212529;}
.rr-qty{font-size:13px; font-weight:800; color:var(--primary);}
.rr-stock{font-size:11.5px; color:var(--gray); margin-left:auto;}
.recipe-empty{font-size:12.5px; color:var(--gray); background:#fff8e6; border:1px solid #ffe3a3; border-radius:9px; padding:9px 11px; margin:6px 0;}
