/* ===================== 卡网电商 - 通用样式 ===================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1c2230;
  --text-soft: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #ef4444;
  --danger-soft: #fdeaea;
  --success: #16a34a;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 24, 40, 0.08);
  --shadow-sm: 0 2px 8px rgba(20, 24, 40, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; gap: 18px;
  height: 64px;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }
.nav-links { display: flex; gap: 22px; margin-left: 8px; }
.nav-links a { color: var(--text-soft); font-weight: 600; font-size: 14px; }
.nav-links a:hover { color: var(--primary); }
.nav-spacer { flex: 1; }
.cart-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--primary-dark);
  border: none; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.cart-btn:hover { background: #e3e6ff; }
.cart-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 12px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px; font-weight: 800;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff; border-radius: 18px; padding: 40px 36px; margin: 26px 0 18px;
  position: relative; overflow: hidden;
}
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero p { opacity: .92; max-width: 560px; }
.hero .hint { margin-top: 14px; font-size: 13px; opacity: .8; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 8px 0 22px; }
.search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px;
}
.search input { border: none; outline: none; flex: 1; font-size: 15px; background: transparent; color: var(--text); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.chip.active, .chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 商品网格 ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px; padding-bottom: 40px;
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card .thumb {
  height: 180px; background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: 13px; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .cat { font-size: 12px; color: var(--primary); font-weight: 700; }
.card .name { font-size: 16px; font-weight: 700; }
.card .desc { font-size: 13px; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.price { color: var(--danger); font-weight: 800; font-size: 18px; }
.price small { font-size: 12px; font-weight: 600; }
.stock { font-size: 12px; color: var(--text-soft); }
.add-btn {
  background: var(--primary); color: #fff; border: none; border-radius: 10px;
  padding: 9px 14px; font-weight: 700; font-size: 14px;
}
.add-btn:hover { background: var(--primary-dark); }
.add-btn:disabled { background: #c7c9d9; cursor: not-allowed; }
.sold-out { color: var(--danger); font-weight: 700; font-size: 13px; }

.empty { text-align: center; color: var(--text-soft); padding: 60px 0; grid-column: 1 / -1; }

/* ---------- 购物车抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 18, 30, .45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 92vw;
  background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.15); transform: translateX(100%);
  transition: transform .25s ease; z-index: 51; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { font-size: 18px; }
.close-x { border: none; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--text-soft); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 20px; }
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item img, .cart-item .ci-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: contain; background: var(--surface-2); flex-shrink: 0; }
.cart-item .ci-info { flex: 1; min-width: 0; }
.cart-item .ci-name { font-weight: 700; font-size: 14px; }
.cart-item .ci-price { color: var(--danger); font-weight: 700; font-size: 14px; }
.qty { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; }
.qty button { width: 26px; height: 26px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; font-size: 16px; line-height: 1; color: var(--text); }
.qty span { min-width: 22px; text-align: center; font-weight: 700; }
.ci-del { border: none; background: transparent; color: var(--text-soft); font-size: 12px; text-decoration: underline; }
.drawer-foot { border-top: 1px solid var(--border); padding: 16px 20px; }
.total-row { display: flex; justify-content: space-between; font-size: 17px; font-weight: 800; margin-bottom: 12px; }
.total-row .price { font-size: 19px; }
.checkout-btn { width: 100%; background: var(--success); color: #fff; border: none; border-radius: 12px; padding: 13px; font-weight: 800; font-size: 15px; }
.checkout-btn:hover { filter: brightness(.96); }
.cart-empty { text-align: center; color: var(--text-soft); padding: 50px 0; }

/* ---------- 客服二维码弹窗 ---------- */
.kf-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--success); color: #fff; border: none; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.kf-btn:hover { filter: brightness(.96); }
.kf-mask { position: fixed; inset: 0; background: rgba(15, 18, 30, .5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.kf-mask.open { opacity: 1; pointer-events: auto; }
.kf-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.95);
  width: 300px; max-width: 92vw; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow); padding: 18px; z-index: 61; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; text-align: center;
}
.kf-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.kf-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kf-head h3 { font-size: 18px; }
.kf-body { display: flex; justify-content: center; padding: 6px 0 12px; }
.kf-body img { width: 240px; height: 240px; object-fit: contain; background: #fff; border-radius: 12px; }
.kf-tip { font-size: 13px; color: var(--text-soft); }

/* ---------- 后台 ---------- */
.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.login-box { max-width: 360px; margin: 90px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.login-box h2 { margin-bottom: 6px; }
.login-box p { color: var(--text-soft); font-size: 13px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text-soft); }
.input, .textarea, select.input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px;
  font-size: 14px; background: var(--surface); color: var(--text); outline: none;
}
.input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 72px; }
.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 10px;
  padding: 11px 18px; font-weight: 700; font-size: 14px;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost:hover { background: #e6e9f2; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(.95); }
.btn.block { width: 100%; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.panel h3 { margin-bottom: 16px; font-size: 17px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 16px; }
.stat .num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat .lbl { font-size: 13px; color: var(--text-soft); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table th { color: var(--text-soft); font-weight: 700; font-size: 13px; }
.table img { width: 46px; height: 46px; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.row-actions { display: flex; gap: 8px; }
.mini { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.tag { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }

/* 表单两列 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-note { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1c2230; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 80; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.back-link { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.back-link:hover { color: var(--primary); }

.footer { text-align: center; color: var(--text-soft); font-size: 13px; padding: 26px 0 40px; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 24px; }
}
