:root {
  --brand: #c8102e;
  --brand-2: #ff5a3c;
  --ink: #1f2329;
  --ink-2: #5a6270;
  --ink-3: #8c939e;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e8eb;
  --ok: #12845a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 24, 32, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { max-width: 480px; margin: 0 auto; padding: 0 0 90px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 20px 20px 60px; }

.topbar {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; padding: 18px 18px 22px; border-radius: 0 0 20px 20px;
  box-shadow: 0 4px 16px rgba(200,16,46,.18);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.topbar p { margin: 6px 0 0; font-size: 13px; opacity: .92; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin: 14px 14px 0; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card.flat { margin: 14px; }
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card .sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 12px; }

label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 6px; font-weight: 500; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fbfbfc; color: var(--ink); font-family: inherit; outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); background: #fff; }
textarea { min-height: 74px; resize: vertical; }

.btn {
  display: block; width: 100%; padding: 13px; border: none; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 16px;
  font-family: inherit; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.985); opacity: .92; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.gray { background: #eef0f3; color: var(--ink-2); }
.btn.sm { width: auto; padding: 8px 15px; font-size: 13.5px; margin: 0; border-radius: 9px; display: inline-block; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row.tight { gap: 8px; }

.seg { display: flex; background: #eef0f3; border-radius: 10px; padding: 3px; margin-top: 4px; }
.seg button {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 8px;
  font-size: 14px; color: var(--ink-2); cursor: pointer; font-family: inherit; font-weight: 500;
}
.seg button.on { background: #fff; color: var(--brand); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.prod {
  display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px; align-items: center; background: #fff;
}
.prod .thumb {
  width: 58px; height: 58px; border-radius: 10px; flex: 0 0 58px;
  background: linear-gradient(135deg, #ffe9e5, #ffd6ce); display: flex; align-items: center;
  justify-content: center; font-size: 24px;
}
.prod .info { flex: 1; min-width: 0; }
.prod .info .nm { font-weight: 600; font-size: 14.5px; }
.prod .info .sp { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.prod .info .pr { color: var(--brand); font-weight: 700; font-size: 15px; margin-top: 4px; }
.prod .info .pr small { color: var(--ink-3); font-weight: 400; font-size: 11.5px; }
.qty { display: flex; align-items: center; gap: 0; flex: 0 0 auto; }
.qty button {
  width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 17px; cursor: pointer; border-radius: 8px; line-height: 1; font-family: inherit;
}
.qty button:first-child { border-radius: 8px; }
.qty .n { width: 34px; text-align: center; font-weight: 600; font-size: 15px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); display: flex; align-items: center;
  gap: 12px; box-shadow: 0 -2px 14px rgba(0,0,0,.06); max-width: 480px; margin: 0 auto;
}
.bar .total { flex: 1; }
.bar .total .t1 { font-size: 12px; color: var(--ink-3); }
.bar .total .t2 { font-size: 20px; font-weight: 700; color: var(--brand); }
.bar .btn { width: auto; padding: 12px 26px; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px;
}
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v { font-size: 21px; font-weight: 700; margin-top: 3px; letter-spacing: -.3px; }
.stat .v.red { color: var(--brand); }
.stat .v.green { color: var(--ok); }

.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.list-item:last-child { border-bottom: none; }
.list-item .l { min-width: 0; }
.list-item .l .a { font-weight: 600; }
.list-item .l .b { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.list-item .r { text-align: right; flex: 0 0 auto; }
.list-item .r .m { font-weight: 700; color: var(--brand); }
.list-item .r .t { font-size: 11.5px; color: var(--ink-3); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: #eef7f2; color: var(--ok); font-weight: 600;
}
.tag.gray { background: #f0f1f3; color: var(--ink-3); }
.tag.red { background: #fdeceb; color: var(--brand); }
.tag.orange { background: #fff4e5; color: var(--warn); }
.tag.green { background: #eef7f2; color: var(--ok); }
.tag.blue { background: #eff6ff; color: #1d4ed8; }

.toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: rgba(28,32,40,.9); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 80vw; text-align: center;
}
.toast.on { opacity: 1; }

/* 自建确认框（替代原生 confirm，避免被浏览器拦截） */
.ask-mask {
  position: fixed; inset: 0; background: rgba(20,24,32,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .16s;
}
.ask-mask.on { opacity: 1; }
.ask-box {
  background: #fff; border-radius: 14px; padding: 22px 20px 16px; width: 300px; max-width: 86vw;
  box-shadow: 0 18px 50px rgba(0,0,0,.22); transform: translateY(8px); transition: transform .16s;
}
.ask-mask.on .ask-box { transform: translateY(0); }
.ask-msg { font-size: 14.5px; line-height: 1.6; color: var(--ink); text-align: center; }
.ask-btns { display: flex; gap: 10px; margin-top: 18px; }
.ask-btn {
  flex: 1; border: 0; border-radius: 9px; padding: 10px 0; font-size: 14px; font-weight: 600;
  cursor: pointer; color: #fff;
}
.ask-btn.cancel { background: #eef0f3; color: var(--ink-2); }

.mask {
  position: fixed; inset: 0; background: rgba(20,24,32,.45); z-index: 900;
  display: none; align-items: flex-end; justify-content: center;
}
.mask.on { display: flex; }
.sheet {
  background: #fff; width: 100%; max-width: 480px; border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 86vh; overflow: auto;
}
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.empty { text-align: center; color: var(--ink-3); font-size: 13.5px; padding: 28px 0; }

/* ------- 后台 ------- */
.admin-head {
  background: #fff; border-bottom: 1px solid var(--line); padding: 0 22px;
  display: flex; align-items: center; gap: 22px; position: sticky; top: 0; z-index: 50;
}
.admin-head .logo { font-weight: 800; color: var(--brand); font-size: 16px; padding: 16px 0; }
.admin-head nav { display: flex; gap: 4px; flex: 1; }
.admin-head nav a {
  padding: 16px 14px; color: var(--ink-2); font-size: 14px; font-weight: 500;
  border-bottom: 2.5px solid transparent; cursor: pointer;
}
.admin-head nav a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.admin-body { padding: 20px 22px 60px; }
.panel { display: none; }
.panel.on { display: block; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.panel-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow);
}
.panel-card h3 { margin: 0 0 14px; font-size: 15px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-3); font-weight: 600; font-size: 12.5px; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.section-title { font-size: 18px; font-weight: 700; margin: 4px 0 16px; }
.hint {
  background: #fff8e6; border: 1px solid #ffe2a8; color: #8a5a00; border-radius: 10px;
  padding: 11px 14px; font-size: 13px; margin-bottom: 16px; line-height: 1.6;
}
.hint b { color: #6b4400; }
.code-pill {
  font-family: ui-monospace, Menlo, Consolas, monospace; background: #f4f5f7;
  border: 1px solid var(--line); border-radius: 7px; padding: 2px 8px; font-size: 12.5px;
  letter-spacing: 1px; font-weight: 600;
}
@media (max-width: 900px) {
  .grid4, .grid3 { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  /* 第一排：logo 靠左撑开 + 刷新按钮靠右；不吸顶，给内容留视野 */
  .admin-head { flex-wrap: wrap; gap: 6px 10px; padding: 10px 14px; position: static; }
  .admin-head .logo { flex: 1; font-size: 15px; padding: 4px 0; }
  /* 第二排：9 个标签 3×3 网格全部铺开，不用滑动，拇指随手点 */
  .admin-head nav {
    flex-basis: 100%;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    overflow: visible;
  }
  .admin-head nav a {
    text-align: center; padding: 11px 4px; font-size: 13.5px; white-space: nowrap;
    border: 1px solid var(--line); border-radius: 10px; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  .admin-head nav a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
  .admin-body { padding: 16px 14px 60px; }
}
