/* ==========================================================
   独角数卡 Python 版 · 设计系统
   深色侧栏 + 浅色内容区，强调色用青蓝，状态色用琥珀/玫红
   ========================================================== */

:root {
  --bg: #f4f6fa;
  --bg-deep: #eef1f7;
  --panel: #ffffff;
  --ink: #10141c;
  --ink-2: #4a5568;
  --ink-3: #8a94a6;
  --line: #e4e8f0;
  --line-soft: #eef1f6;

  --brand: #2563eb;
  --brand-2: #06b6d4;
  --brand-soft: #eaf1ff;
  --brand-ink: #ffffff;

  --ok: #0d9488;
  --ok-soft: #e6f7f4;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --err: #dc2626;
  --err-soft: #fdeaea;
  --violet: #7c3aed;
  --violet-soft: #f2ecff;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16, 20, 28, .06);
  --shadow-2: 0 4px 16px rgba(16, 20, 28, .08);
  --shadow-3: 0 12px 40px rgba(16, 20, 28, .14);
  --t: .18s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Inter", "Segoe UI", "Microsoft YaHei", -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ---------------------------------------------------------
   公共容器
   --------------------------------------------------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.page-head { margin: 26px 0 18px; }
.page-head h1 { font-size: 21px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }

/* ---------------------------------------------------------
   前台顶栏
   --------------------------------------------------------- */
.topbar {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 56px; }

.brand {
  font-weight: 800; font-size: 16px; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.brand::before {
  content: ""; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.brand:hover { text-decoration: none; }

.topbar nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--ink-2);
  font-size: 13px; white-space: nowrap; transition: var(--t);
}
.topbar nav a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.topbar nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------
   公告 / 提示
   --------------------------------------------------------- */
.notice {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a; color: #78350f;
  border-radius: var(--r); padding: 12px 16px; margin: 18px 0;
  word-break: break-word; font-size: 13px;
}
.notice b { display: block; margin-bottom: 4px; font-size: 13px; }

.alert { padding: 11px 15px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 13px; }
.alert.err  { background: var(--err-soft);  color: #991b1b; border: 1px solid #fecaca; }
.alert.ok   { background: var(--ok-soft);   color: #115e59; border: 1px solid #ccfbf1; }
.alert.info { background: var(--brand-soft); color: #1e40af; border: 1px solid #dbeafe; }
.alert.warn { background: var(--warn-soft); color: #92400e; border: 1px solid #fde68a; }

/* ---------------------------------------------------------
   分类 pill
   --------------------------------------------------------- */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.pills a {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink-2); font-size: 13px;
  transition: var(--t);
}
.pills a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pills a.on {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .28);
}

/* ---------------------------------------------------------
   商品网格（前台）
   --------------------------------------------------------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.goods {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; display: flex; flex-direction: column;
  transition: var(--t); box-shadow: var(--shadow-1);
}
.goods:hover {
  border-color: #c7d7f5; box-shadow: var(--shadow-2); transform: translateY(-2px);
}
.goods .thumb {
  height: 118px; background: linear-gradient(135deg, #eef2f9, #e3e9f4);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 12px; overflow: hidden;
}
.goods .thumb img { width: 100%; height: 118px; object-fit: cover; }
.goods .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.goods .name {
  font-weight: 600; font-size: 13.5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 38px;
}
.goods .meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

.price { color: var(--err); font-weight: 800; font-size: 16px; white-space: nowrap; }
.stock { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------
   标签 / 徽章
   --------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; line-height: 19px; font-weight: 600; white-space: nowrap;
  background: var(--line-soft); color: var(--ink-2);
}
.tag.ok   { background: var(--ok-soft);     color: var(--ok); }
.tag.warn { background: var(--warn-soft);   color: var(--warn); }
.tag.err  { background: var(--err-soft);    color: var(--err); }
.tag.info { background: var(--brand-soft);  color: var(--brand); }
.tag.violet { background: var(--violet-soft); color: var(--violet); }

.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------
   按钮
   --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
  white-space: nowrap; transition: var(--t); box-shadow: var(--shadow-1);
}
.btn:hover { background: #f7f9fc; border-color: #cfd8e6; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), #3b82f6);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(37, 99, 235, .3);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 4px 16px rgba(37, 99, 235, .38); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--err); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------
   表单
   --------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; font: inherit; font-size: 13px; color: var(--ink);
  transition: var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input[type=file] { padding: 6px 8px; background: #fafbfd; }

/* 自定义复选框 */
input[type=checkbox] {
  width: 16px; height: 16px; accent-color: var(--brand);
  cursor: pointer; margin: 0; vertical-align: middle;
}

/* ---------------------------------------------------------
   面板 / 卡片
   --------------------------------------------------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: 14px; }
.panel h2 { font-size: 14.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel h2::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

.split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------
   表格
   --------------------------------------------------------- */
.table-wrap {
  overflow: auto; border-radius: var(--r); border: 1px solid var(--line);
  max-height: 70vh;
}
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f8fafc; color: var(--ink-2); font-weight: 600;
  font-size: 12px; text-transform: none; letter-spacing: .02em;
  padding: 10px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.tbl tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background var(--t); }
table.tbl tbody tr:hover { background: #fafbfe; }
table.tbl tbody tr.sel { background: var(--brand-soft); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.wrap-cell { word-break: break-all; max-width: 300px; }
table.tbl th.check, table.tbl td.check { width: 38px; text-align: center; padding-left: 14px; }

/* ---------------------------------------------------------
   统计卡
   --------------------------------------------------------- */
.stat-grid {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.stat {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; box-shadow: var(--shadow-1);
}
.stat::after {
  content: ""; position: absolute; right: -26px; top: -26px;
  width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, .1), transparent 70%);
}
.stat .lb { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.stat .vl {
  font-size: 23px; font-weight: 800; margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat.accent  .vl { color: var(--brand); }
.stat.ok      .vl { color: var(--ok); }
.stat.warn    .vl { color: var(--warn); }
.stat.err     .vl { color: var(--err); }
.stat.violet  .vl { color: var(--violet); }

/* ---------------------------------------------------------
   工具栏
   --------------------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; }
.toolbar input[type=search], .toolbar select {
  width: auto; min-width: 150px; height: 34px; padding: 0 11px;
}
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* 批量操作条 */
.bulkbar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px; border-radius: var(--r);
  background: linear-gradient(135deg, #eef4ff, #e6f7fd);
  border: 1px solid #cfe0ff; font-size: 13px;
}
.bulkbar.show { display: flex; }
.bulkbar .cnt { font-weight: 700; color: var(--brand); }

/* ---------------------------------------------------------
   分页
   --------------------------------------------------------- */
.pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 14px; font-size: 12.5px; color: var(--ink-2);
}
.pager a, .pager span.pg {
  min-width: 32px; height: 32px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink-2); transition: var(--t);
}
.pager a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager span.pg.cur {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff; font-weight: 600;
}
.pager .info { margin-left: auto; color: var(--ink-3); }

/* ---------------------------------------------------------
   空状态
   --------------------------------------------------------- */
.empty { text-align: center; color: var(--ink-3); padding: 46px 18px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 10px; opacity: .8; }
.empty .sub { font-size: 12.5px; margin-top: 6px; }

/* ---------------------------------------------------------
   结算页
   --------------------------------------------------------- */
.summary-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .k { color: var(--ink-2); }
.summary-row.total { font-size: 15.5px; font-weight: 800; padding-top: 11px; }
.summary-row.total .v { color: var(--err); }

.payways { display: grid; gap: 9px; }
.payway {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r); cursor: pointer;
  background: #fff; transition: var(--t);
}
.payway:hover { border-color: #c7d7f5; background: #fafbff; box-shadow: var(--shadow-1); }
.payway:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.payway .nm { font-size: 13px; font-weight: 500; }

/* ---------------------------------------------------------
   订单卡
   --------------------------------------------------------- */
.order-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-1);
}
.order-card .hd {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft);
}
.order-card .sn { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--ink-2); }
.kv .v { word-break: break-word; }

.card-secret {
  margin-top: 12px; background: #0b1220; color: #cfe3ff; border-radius: var(--r);
  padding: 13px 15px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all;
  max-height: 340px; overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ---------------------------------------------------------
   后台布局
   --------------------------------------------------------- */
.admin-body { display: flex; min-height: 100vh; background: var(--bg); }

.side {
  width: 216px; flex: 0 0 216px;
  background: linear-gradient(180deg, #141a26 0%, #0d1219 100%);
  color: #a9b4c6; padding: 16px 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  box-shadow: 2px 0 16px rgba(10, 14, 22, .1);
}
.side .logo {
  padding: 0 18px 16px; font-weight: 800; color: #fff; font-size: 15px;
  display: flex; align-items: center; gap: 9px;
}
.side .logo::before {
  content: ""; width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 2px 10px rgba(37, 99, 235, .5);
}
.side .navwrap { flex: 1; overflow-y: auto; }
.side a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; color: #a9b4c6; font-size: 13px;
  transition: var(--t); border-left: 2px solid transparent;
}
.side a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.side a.on {
  background: linear-gradient(90deg, rgba(37, 99, 235, .22), transparent);
  color: #fff; border-left-color: var(--brand-2); font-weight: 600;
}
.side .sep { height: 1px; background: rgba(255, 255, 255, .07); margin: 10px 16px; }
.side .foot { padding: 10px 18px 0; font-size: 11px; color: #5b6678; }

.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }
.main h1 { font-size: 19px; margin-bottom: 16px; }

/* ---------------------------------------------------------
   模态框
   --------------------------------------------------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(10, 14, 22, .5);
  backdrop-filter: blur(3px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; box-shadow: var(--shadow-3);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal .hd h3 { font-size: 15px; }
.modal .hd .x {
  cursor: pointer; color: var(--ink-3); font-size: 20px; line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); transition: var(--t);
}
.modal .hd .x:hover { background: var(--line-soft); color: var(--ink); }
.modal .bd { padding: 18px 20px; }
.modal .ft {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 9px; justify-content: flex-end;
}

/* ---------------------------------------------------------
   进度条 / 加载
   --------------------------------------------------------- */
.progress {
  height: 8px; border-radius: 999px; background: var(--line-soft);
  overflow: hidden;
}
.progress .bar {
  height: 100%; border-radius: 999px; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .3s ease;
}
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
.spin.dark { border-color: rgba(37, 99, 235, .25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
   页脚
   --------------------------------------------------------- */
.foot {
  margin: 44px 0 26px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---------------------------------------------------------
   工具类
   --------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.flex1 { flex: 1; }
.hidden { display: none !important; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #10141c; color: #fff; padding: 11px 20px; border-radius: var(--r);
  font-size: 13px; box-shadow: var(--shadow-3); z-index: 200;
  opacity: 0; pointer-events: none; transition: all .25s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); }
#toast.ok { background: var(--ok); }

/* 响应式 */
@media (max-width: 900px) {
  .side { position: fixed; left: -220px; z-index: 50; transition: left .25s; }
  .side.open { left: 0; }
  .main { padding: 16px 14px 40px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}