:root {
  --wx: #07c160;
  --wx-dark: #06a04f;
  --wx-light: #e8f8ef;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d1d1f;
  --sub: #8a8f99;
  --line: #e8ebef;
  --red: #fa5151;
  --orange: #ff9500;
  --blue: #2f7af7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(22, 34, 45, .06), 0 8px 24px rgba(22, 34, 45, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--wx); text-decoration: none; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 10% 0%, #d8f5e5 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 100%, #e6f2ff 0%, transparent 55%),
              #f4f6f8;
  padding: 24px;
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 18px 60px rgba(16, 61, 40, .12);
  padding: 36px 32px 28px;
}
.login-logo { font-size: 40px; line-height: 1; }
.login-title { font-size: 22px; font-weight: 700; margin: 12px 0 4px; }
.login-sub { color: var(--sub); font-size: 13px; margin-bottom: 26px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; height: 44px; font-size: 15px; margin-top: 6px; }
.login-tip { margin-top: 16px; color: var(--sub); font-size: 12px; text-align: center; }

/* ---------------- 布局 ---------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--wx), #04a34f);
  color: #fff; font-size: 20px; display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--sub); margin-top: 1px; }
.nav { padding: 6px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: 10px; cursor: pointer; color: #4a4f57; font-size: 14px;
  user-select: none;
}
.nav-item:hover { background: #f5f6f8; }
.nav-item.on { background: var(--wx-light); color: var(--wx-dark); font-weight: 600; }
.nav-ic { width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--red); color: #fff;
  font-size: 11px; display: grid; place-items: center;
}
.side-foot { padding: 14px 18px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--sub); }
.side-foot .who { color: var(--text); font-weight: 600; margin-bottom: 6px; }

.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-desc { color: var(--sub); font-size: 13px; margin-top: 2px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------- 通用组件 ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
}

.stat { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--sub); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-value small { font-size: 13px; font-weight: 400; color: var(--sub); margin-left: 4px; }
.stat-foot { font-size: 12px; color: var(--sub); margin-top: 4px; }
.stat.hl { background: linear-gradient(135deg, #07c160, #04a34f); color: #fff; }
.stat.hl .stat-label, .stat.hl .stat-foot { color: rgba(255, 255, 255, .82); }

.btn {
  height: 34px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; transition: .15s;
}
.btn:hover { border-color: #d3d8de; background: #fafbfc; }
.btn-primary { background: var(--wx); border-color: var(--wx); color: #fff; }
.btn-primary:hover { background: var(--wx-dark); border-color: var(--wx-dark); }
.btn-danger { color: var(--red); border-color: #ffd9d9; background: #fff7f7; }
.btn-danger:hover { background: #ffecec; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--wx); cursor: pointer; padding: 0 4px; font-size: 13px; }
.link-btn.red { color: var(--red); }
.link-btn.gray { color: var(--sub); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none;
  transition: .15s;
}
textarea { height: auto; min-height: 78px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--wx); box-shadow: 0 0 0 3px rgba(7, 193, 96, .12); }
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }
.hint { font-size: 12px; color: var(--sub); }

.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px;
  border-radius: 12px; font-size: 12px; background: #f2f4f6; color: #5b616b;
}
.chip.green { background: var(--wx-light); color: var(--wx-dark); }
.chip.red { background: #fff0f0; color: var(--red); }
.chip.orange { background: #fff6e6; color: #b87400; }
.chip.blue { background: #eef4ff; color: var(--blue); }
.chip.gray { background: #f3f4f6; color: var(--sub); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--sub); font-weight: 500; background: #fafbfc; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #fafefb; }
td.name { font-weight: 600; }
td.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
.empty { padding: 40px 0; text-align: center; color: var(--sub); font-size: 13px; }
.empty-ic { font-size: 30px; display: block; margin-bottom: 8px; }

.code-badge {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 1px;
  background: #0f2f22; color: #5ef0a8; padding: 2px 8px; border-radius: 6px; font-size: 12.5px;
}

/* 概览趋势条 */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trend-bar { width: 100%; max-width: 36px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #34d27f, #07c160); min-height: 3px; }
.trend-bar.zero { background: #e9edf1; }
.trend-n { font-size: 11px; color: var(--sub); }
.trend-d { font-size: 11px; color: var(--sub); }

.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 礼品卡 */
.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.gift-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; position: relative; }
.gift-card.off { opacity: .6; }
.gift-ic { font-size: 26px; }
.gift-name { font-weight: 600; margin: 6px 0 2px; }
.gift-pts { color: var(--orange); font-weight: 700; font-size: 13px; }
.gift-desc { color: var(--sub); font-size: 12px; margin-top: 4px; min-height: 32px; }
.gift-acts { display: flex; gap: 6px; margin-top: 10px; }
.ribbon {
  position: absolute; right: 10px; top: 10px; font-size: 11px;
  background: #fff1e6; color: #d15b00; border-radius: 8px; padding: 1px 6px;
}

/* 价格录入 */
.price-input {
  width: 92px; height: 30px; text-align: right; padding-right: 8px;
  border: 1px solid var(--line); border-radius: 7px;
}
.price-input.changed { border-color: var(--wx); background: #f2fff9; }
.price-input.empty { border-color: #ffd9a8; background: #fffbf3; }
.matrix td, .matrix th { padding: 9px 10px; font-size: 13px; }
.matrix .price { font-family: ui-monospace, Menlo, Consolas, monospace; }
.matrix .lowest { color: var(--wx-dark); font-weight: 700; background: #f1fdf7; }

/* 弹层 */
.mask {
  position: fixed; inset: 0; background: rgba(20, 28, 34, .45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(2px);
}
.mask.show { display: flex; }
.modal {
  width: 520px; max-width: 100%; max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { padding: 18px 20px 0; font-weight: 700; font-size: 16px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.modal.wide { width: 760px; }

.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  background: #1f2b26; color: #fff; padding: 9px 18px; border-radius: 10px;
  font-size: 13px; z-index: 80; opacity: 0; pointer-events: none; transition: .2s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(2px); }
.toast.ok { background: #0b7f45; }
.toast.err { background: #b02a2a; }

.loading { padding: 36px; text-align: center; color: var(--sub); font-size: 13px; }

@media (max-width: 720px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .modal { width: 100%; }
}
