/* =========================================================
   自动发卡系统 · 后台样式
   ========================================================= */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --sidebar: #101014;
  --sidebar-2: #17171c;
  --text: #1d1d1f;
  --text-2: #3a3a3d;
  --muted: #6e6e73;
  --border: rgba(0, 0, 0, 0.09);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --success: #1a7f43;
  --success-soft: rgba(48, 209, 88, 0.14);
  --warning: #a15c00;
  --warning-soft: rgba(255, 159, 10, 0.16);
  --danger: #c9342f;
  --danger-soft: rgba(255, 69, 58, 0.12);
  --radius: 14px;
  --shadow: 0 16px 38px -30px rgba(0, 0, 0, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Microsoft YaHei", Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warning); }
.text-ok { color: var(--success); }

/* ---------------- 布局 ---------------- */
.admin { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #e7e7ea;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.side-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0071e3, #30d158);
  display: grid; place-items: center;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}
.side-brand b { display: block; font-size: 14px; }
.side-brand small { display: block; font-size: 11px; color: #8e8e93; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: #c7c7cc;
  transition: 0.16s;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-link.active { background: rgba(10, 132, 255, 0.18); color: #fff; font-weight: 600; }
.side-icon svg { width: 17px; height: 17px; display: block; }
.side-badge {
  margin-left: auto;
  background: #ff453a;
  color: #fff;
  font-size: 10.5px;
  font-style: normal;
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 700;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 3px; }
.side-version { font-size: 11px; color: #5f5f66; padding: 12px 12px 0; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-user { font-size: 13px; color: var(--muted); }
.admin-content { padding: 24px 26px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------------- 组件 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: 0.16s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0067d2; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: rgba(0, 0, 0, 0.2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn-block { width: 100%; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h3 { font-size: 15px; letter-spacing: -0.01em; }
.panel-sub { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.panel-sub h4 { font-size: 13.5px; margin-bottom: 10px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.link { color: var(--accent); font-size: 13px; }
.link:hover { text-decoration: underline; }
.inline { display: inline; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}
.stat-card.accent { background: linear-gradient(135deg, #0071e3, #0a84ff); color: #fff; border-color: transparent; }
.stat-card.accent .stat-label, .stat-card.accent .stat-foot { color: rgba(255, 255, 255, 0.8); }
.stat-card.warn { border-color: rgba(255, 159, 10, 0.4); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 25px; letter-spacing: -0.02em; font-weight: 700; }
.stat-foot { font-size: 11.5px; color: var(--muted); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table-foot { display: flex; align-items: center; gap: 12px; padding-top: 14px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions .link { font-size: 12.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn, .pill.pending { background: var(--warning-soft); color: var(--warning); }
.pill.muted { background: rgba(0, 0, 0, 0.05); color: var(--muted); }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field label em { color: var(--danger); font-style: normal; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: 0.16s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; line-height: 1.6; }
.input-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; width: auto; }
.w-40 { width: 40px; }
.w-70 { width: 70px; }
.w-90 { width: 90px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-grid { display: flex; flex-direction: column; gap: 18px; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-all;
}

/* 提示 */
.alert {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13px;
  border: 1px solid transparent;
  line-height: 1.7;
  margin-bottom: 4px;
}
.alert a { color: inherit; text-decoration: underline; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: rgba(255, 69, 58, 0.24); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(48, 209, 88, 0.26); }
.alert-info { background: var(--accent-soft); color: var(--accent); border-color: rgba(0, 113, 227, 0.22); }
.alert-warn { background: var(--warning-soft); color: var(--warning); border-color: rgba(255, 159, 10, 0.28); }

/* 工具条 */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input { width: auto; }

/* 商品单元格 */
.prod-cell { display: flex; align-items: center; gap: 10px; }
.mini-cover {
  width: 42px; height: 42px;
  border-radius: 9px;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--surface-2);
}
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.mini-cover.cover-text span { font-size: 16px; }

/* 卡密列表 */
.card-list { display: flex; flex-direction: column; gap: 7px; max-height: 420px; overflow: auto; }
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.card-main { display: flex; gap: 8px; align-items: center; min-width: 0; }
.copy-btn {
  font-size: 11.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 9px;
  border-radius: 6px;
  font-weight: 600;
}
.copy-btn:hover { background: var(--accent); color: #fff; }

/* 快捷入口 */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  transition: 0.16s;
}
.quick:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick b { font-size: 13.5px; }
.quick span { font-size: 11.5px; color: var(--muted); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pager-item {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
}
.pager-item.active { background: var(--accent); color: #fff; border-color: transparent; }
.pager-item.disabled { opacity: 0.45; }
.pager-info { font-size: 12px; color: var(--muted); margin-left: 4px; }

/* 登录页 */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(0, 113, 227, 0.18), transparent),
    radial-gradient(700px 500px at 90% 110%, rgba(48, 209, 88, 0.14), transparent),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px 26px;
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.5);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { font-size: 18px; letter-spacing: -0.01em; }
.login-brand p { font-size: 12px; color: var(--muted); }
.login-back { display: block; text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 16px; }
.login-back:hover { color: var(--accent); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .admin-content { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .ellipsis { max-width: 160px; }
}
