/* 砖老二 手机后台（网页版）· 移动端优先 */
:root {
  --g: #1f6f54;
  --g2: #2c8a68;
  --gd: #14503d;
  --bg: #f2f4f3;
  --card: #fff;
  --tx: #1c2723;
  --mut: #7b8a83;
  --ln: #e3e8e5;
  --warn: #b45309;
  --bad: #b3261e;
  --ok: #166534;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--tx); }
body {
  font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
#app { max-width: 860px; margin: 0 auto; }
button, input, select, textarea, a { font: inherit; color: inherit; }
a { text-decoration: none; }

/* 顶栏 */
#top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(135deg, var(--gd), var(--g));
  color: #fff;
}
.brand b { font-size: 17px; letter-spacing: .5px; }
.brand span { font-size: 12px; opacity: .82; margin-left: 8px; }
.topright { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 11px; background: rgba(255,255,255,.16); padding: 3px 8px; border-radius: 999px; }
.ghost {
  background: #fff; border: 1px solid var(--ln); border-radius: 10px;
  padding: 9px 12px; cursor: pointer;
}
.ghost.sm { padding: 6px 10px; font-size: 13px; }
.ghost.on { border-color: var(--g); color: var(--g); background: #eef6f2; }
.ghost.danger { color: var(--bad); }
.primary {
  background: var(--g); border: 0; color: #fff; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; font-weight: 600;
}
.primary.sm { padding: 7px 11px; font-size: 13px; }
.primary:active, .ghost:active { transform: translateY(1px); }
.big { display: block; width: 100%; padding: 13px; font-size: 16px; }
button:disabled { opacity: .5; }

/* 视图 */
.view { display: none; padding: 12px 12px 20px; }
.view.on { display: block; }
.card {
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 6px 16px rgba(20,80,61,.06);
  margin-bottom: 12px;
}
.card.center { text-align: center; padding: 26px 18px; margin-top: 12vh; }
.card h2 { margin: 0 0 4px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.gap8 { gap: 8px; }
.flex { flex: 1; }
.muted { color: var(--mut); }
.small { font-size: 12px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* 表单 */
label { display: block; margin: 10px 0; font-size: 13px; color: #45514b; }
label > span { display: inline; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  border: 1px solid var(--ln); border-radius: 10px; background: #fbfcfb;
}
/* 横排里的输入框（搜索条 / 底部输入条 / 规格行 / 加分类行）：
   不能被上面那条 width:100% 挤走右边的按钮——窄屏手机上就点不到了 */
.searchbar > input, .composer > input, .row > input, .spec > input, .chips > input {
  width: auto; flex: 1 1 auto; min-width: 0; margin-top: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe6dc; border-color: var(--g); }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.form label:first-child { margin-top: 0; }
.savebar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 20; }
.switch { position: relative; display: inline-block; width: 44px; height: 25px; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i { position: absolute; inset: 0; background: #d7ded9; border-radius: 999px; transition: .2s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--g); }
.switch input:checked + i::after { transform: translateX(19px); }

/* 概览数字 */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.stat b { display: block; font-size: 20px; color: var(--gd); }
.stat span { font-size: 11px; color: var(--mut); }

/* 列表 */
.list > .li {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.li .th { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: #eef2ef; flex: 0 0 auto; }
.li .g { flex: 1; min-width: 0; }
.li .g b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .g p { margin: 3px 0 0; font-size: 12px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .r { text-align: right; font-size: 13px; flex: 0 0 auto; }
.li .r b { color: var(--gd); font-size: 15px; }
.li .st { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #eef2ef; color: #46534d; }
.li .st.pending { background: #fff4e5; color: var(--warn); }
.li .st.confirmed { background: #e9f3ff; color: #1d4ed8; }
.li .st.picked { background: #e7f5ec; color: var(--ok); }
.li .st.cancelled { background: #f6e9e8; color: var(--bad); }
.li .dot { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; }
.empty { text-align: center; color: var(--mut); font-size: 13px; padding: 22px 10px; }

/* 搜索/筛选 */
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input { flex: 1; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--ln); background: #fff; border-radius: 999px;
  padding: 6px 11px; font-size: 13px; cursor: pointer; position: relative;
}
.chip.on { border-color: var(--g); background: var(--g); color: #fff; }
.subhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

/* 聊天 */
.msgs { background: var(--bg); border-radius: 12px; padding: 10px; min-height: 45vh; }
.msg { max-width: 78%; margin: 0 0 10px; padding: 9px 11px; border-radius: 12px; background: #fff; font-size: 14px; clear: both; }
.msg time { display: block; font-size: 10px; color: var(--mut); margin-top: 4px; }
.msg.me { float: right; background: #dcf0e5; }
.msg.im { float: right; background: #fff2d9; }
.msg img { display: block; width: 170px; max-width: 100%; border-radius: 8px; margin-top: 4px; }
.composer { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; gap: 7px; padding: 8px; background: var(--bg); }
.composer input[type=text], #chatText { flex: 1; margin: 0; }
/* 常用语条：输入框上方，横向滑，点一下填进输入框 */
.quick { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.quick::-webkit-scrollbar { display: none; }
.quick .chip { flex: 0 0 auto; max-width: 62%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; }
.quick .chip[data-qt] { border-style: dashed; color: var(--mut); }
.q { font-size: 12px; color: var(--mut); }

/* 商品图片管理 */
.imgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.imc { position: relative; }
.imc img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 9px; background: #eef2ef; display: block; }
.imc .cov { position: absolute; left: 4px; top: 4px; background: rgba(31,111,84,.9); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 999px; }
.imc .del { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; line-height: 20px; text-align: center; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; font-size: 14px; }
.imc .cov2 { display: block; width: 100%; border: 1px solid var(--ln); border-radius: 8px; background: #fff; font-size: 11px; padding: 4px 0; margin-top: 4px; cursor: pointer; }
.imc.add img { border: 2px dashed var(--ln); }
.spec { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.spec input { margin: 0; }

/* 抽屉 */
.sheet { position: fixed; inset: 0; background: rgba(12,26,20,.5); z-index: 60; display: flex; align-items: flex-end; }
.sheet.hidden { display: none; }
.sheet-in {
  background: var(--bg); width: 100%; max-width: 860px; max-height: 88vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
}
.sheet-in h3 { margin: 0; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 14px; margin: 10px 0; }
.kv span { color: var(--mut); font-size: 13px; }
.act { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.his { font-size: 12px; color: var(--mut); border-top: 1px dashed var(--ln); padding-top: 8px; margin-top: 10px; }

/* 页签 */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: #fff; border-top: 1px solid var(--ln);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; border: 0; background: none; padding: 7px 0 6px; font-size: 11px; color: #6d7a74; position: relative; cursor: pointer; }
.tab .ico { display: block; font-size: 19px; line-height: 1.25; filter: grayscale(1) opacity(.75); }
.tab.on { color: var(--g); font-weight: 700; }
.tab.on .ico { filter: none; }
.badge { position: absolute; left: 58%; top: 4px; background: var(--bad); color: #fff; font-size: 10px; font-style: normal; padding: 1px 5px; border-radius: 999px; }
.badge.hidden, .hidden { display: none; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 90;
  background: rgba(20,40,32,.94); color: #fff; padding: 11px 16px; border-radius: 12px;
  font-size: 14px; max-width: 88%; text-align: center;
}
.toast.hidden { display: none; }
.toast.bad { background: rgba(150,32,26,.95); }

/* 大图预览 */
.lb { position: fixed; inset: 0; background: #0b1512; z-index: 80; display: flex; flex-direction: column; }
.lb.hidden { display: none; }
.lb img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.lbbar { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 12px; color: #cfd8d3; }
.lbbar .ghost { background: #1d2b25; border-color: #2c3a34; color: #e7efeb; }

/* 悬浮"新增商品"大按钮：窄屏手机右上角被输入框挤到时，这个一定点得到 */
.fab {
  display: none; position: fixed; right: 14px; z-index: 35;
  bottom: calc(76px + env(safe-area-inset-bottom));
  background: var(--g); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 18px; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(20,80,61,.4); cursor: pointer;
}
body.v-goods .fab { display: block; }
.fab.busy { opacity: .6; }
.busy2 { opacity: .6; pointer-events: none; }

/* 桌面/宽屏：两列 */
@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(6, 1fr); }
  .imgs { grid-template-columns: repeat(8, 1fr); }
  #tabbar { max-width: 860px; margin: 0 auto; border-radius: 14px 14px 0 0; border: 1px solid var(--ln); border-bottom: 0; }
}
