/* ============ 商家后台样式 ============ */
:root {
  --primary: #4f46e5;
  --grad: linear-gradient(135deg, #4f46e5, #7c3aed);
  --bg: #f1f3f9;
  --card: #fff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e8ebf3;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ---------- 登录页 ---------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; background:
    radial-gradient(800px 400px at 20% 0%, rgba(124, 58, 237, .18), transparent),
    radial-gradient(700px 400px at 90% 100%, rgba(79, 70, 229, .22), transparent), var(--bg);
}
.login-box { width: 380px; background: var(--card); border-radius: 18px; padding: 34px; box-shadow: 0 24px 60px -24px rgba(23,30,60,.25); }
.login-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 6px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ---------- 布局 ---------- */
.layout { display: none; min-height: 100vh; }
.layout.show { display: flex; }
.sidebar {
  width: 220px; flex: none; background: #171c2e; color: #aab0c5;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 6px 10px 20px; }
.side-item {
  padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px; transition: background .15s;
}
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.on { background: var(--grad); color: #fff; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.shop-chip { background: rgba(255,255,255,.08); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: #d0d5e8; margin-bottom: 10px; }
.side-logout { cursor: pointer; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; }
.side-logout:hover { background: rgba(220,38,38,.18); color: #fca5a5; }

.content { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.page { display: none; }
.page.on { display: block; }
.page-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- 卡片 & 统计 ---------- */
.card { background: var(--card); border-radius: 14px; padding: 22px; box-shadow: 0 1px 2px rgba(23,30,60,.04), 0 10px 28px -18px rgba(23,30,60,.15); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat .k { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-hl .v { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f0f2f8; font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }
.td-actions { white-space: nowrap; text-align: right; }
.mini-btn {
  border: none; cursor: pointer; font-size: 12.5px; padding: 6px 12px; border-radius: 8px;
  background: #eef0f8; color: #374151; font-weight: 600; margin-left: 6px;
}
.mini-btn:hover { background: #e3e6f2; }
.mini-btn.warn { background: #fff7ed; color: var(--orange); }
.mini-btn.danger { background: #fee2e2; color: var(--red); }
.mini-btn.primary { background: var(--grad); color: #fff; }

.chip { font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; display: inline-block; }
.chip.paid, .chip.on { background: #ecfdf5; color: var(--green); }
.chip.pending, .chip.sold { background: #fff7ed; color: var(--orange); }
.chip.cancelled, .chip.used, .chip.off { background: #f3f4f6; color: #9ca3af; }
.chip.unsold { background: #eef0f8; color: #6366f1; }
.mono { font-family: Consolas, monospace; font-size: 12.5px; color: #4b5563; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fbfcfe; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); background: #fff; }
textarea.input { resize: vertical; min-height: 130px; line-height: 1.7; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none;
  cursor: pointer; font-size: 14px; font-weight: 600; padding: 10px 20px; border-radius: 10px;
}
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: #eef0f8; color: var(--text); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 工具条 / 弹窗 ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select, .toolbar .input { width: auto; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 20, 40, .45); z-index: 100;
  display: none; place-items: center; backdrop-filter: blur(2px);
}
.modal-mask.show { display: grid; }
.modal { width: 480px; max-width: 92vw; background: #fff; border-radius: 16px; padding: 26px; max-height: 88vh; overflow: auto; }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

#toast {
  position: fixed; top: 30px; left: 50%; transform: translateX(-50%) translateY(-12px);
  background: #111827; color: #fff; font-size: 14px; padding: 11px 20px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 999; max-width: 86vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; }

/* 商品图片 */
.img-preview {
  width: 130px; height: 80px; border-radius: 10px; background: #eef0f8; color: #9ca3af;
  display: grid; place-items: center; font-size: 22px; cursor: pointer; flex: none;
  background-size: cover; background-position: center; border: 1.5px dashed var(--line);
}
.img-preview.has { border-style: solid; }
.thumb {
  width: 64px; height: 40px; border-radius: 7px; object-fit: cover; vertical-align: middle;
  background: #eef0f8; margin-right: 8px; flex: none;
}
.thumb-ph {
  width: 64px; height: 40px; border-radius: 7px; background: var(--grad); color: #fff;
  display: inline-grid; place-items: center; font-size: 14px; font-weight: 700;
  vertical-align: middle; margin-right: 8px; flex: none;
}

@media (max-width: 760px) {
  .layout.show { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { padding: 6px 10px; }
  .sidebar .spacer { display: none; }
  .content { padding: 18px 14px 60px; }
}
