﻿/* ============ tokens ============ */
:root {
  --bg: #0e1116;
  --bg-soft: #12161d;
  --panel: #161b23;
  --panel-2: #1b222c;
  --panel-3: #222a36;
  --border: #262f3d;
  --border-soft: #1f2733;
  --text: #e7ebf2;
  --text-2: #aab4c5;
  --muted: #7d8798;
  --accent: #ff5b3a;
  --accent-2: #ff8a45;
  --green: #2fbe6e;
  --red: #f0553f;
  --amber: #e8a33d;
  --blue: #4b8bff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .38);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.error { color: var(--red); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.gap-14 { gap: 14px; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.right { margin-left: auto; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(255, 91, 58, .16), transparent 62%),
    radial-gradient(760px 480px at 100% 110%, rgba(75, 139, 255, .12), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card .brand { margin-bottom: 22px; }

/* ============ 品牌 ============ */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: 0 6px 18px rgba(255, 91, 58, .28);
}
.brand.small .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 16px; border-radius: 10px; }
.brand.small strong { font-size: 14px; display: block; }
.brand.small p { margin: 0; }

/* ============ 框架 ============ */
.app {
  display: grid;
  grid-template-columns: 228px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav a svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .78; }
.nav-short { display: none; }
.nav a:hover svg, .nav a.active svg { opacity: 1; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active {
  background: linear-gradient(90deg, rgba(255, 91, 58, .18), rgba(255, 91, 58, .04));
  color: #ffd9d0;
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--panel); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--text-2); font-weight: 700; font-size: 13px;
}
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
  position: relative;
  z-index: 40;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page { padding: 20px 22px 40px; overflow-y: auto; min-height: 0; }

/* ============ 状态 / 分段开关 ============ */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text-2);
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.pill.on { color: #b8f5d2; border-color: rgba(47, 190, 110, .35); background: rgba(47, 190, 110, .1); }
.pill.on::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.off { color: #ffc8c0; border-color: rgba(240, 85, 63, .35); background: rgba(240, 85, 63, .1); }
.pill.off::before { background: var(--red); }

.switch-group {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.seg {
  border: 0; background: transparent; color: var(--text-2);
  padding: 6px 13px; border-radius: 7px; font-size: 12.5px;
  cursor: pointer; transition: .12s;
  font-family: inherit;
}
.seg:hover { color: var(--text); background: var(--panel-3); }
.seg.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ============ 卡片 ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h3 { display: flex; align-items: center; gap: 8px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px 16px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: .5;
}
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px; font-family: inherit;
  cursor: pointer;
  transition: .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #33404f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #ff6b4d; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb3a8; border-color: rgba(240, 85, 63, .35); }
.btn.danger:hover { background: rgba(240, 85, 63, .12); }
.btn.tiny { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.link {
  border: 0; background: transparent; padding: 2px 4px;
  color: var(--blue); font-size: 12.5px;
}
.btn.link:hover { text-decoration: underline; background: transparent; }
.btn.link.red { color: #ff8f7d; }

/* ============ 表单 ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--text-2); }
.field > span em { color: var(--muted); font-style: normal; font-size: 11.5px; }

input[type="text"], input[type="password"], input[type="number"],
input[type="url"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 91, 58, .55);
  box-shadow: 0 0 0 3px rgba(255, 91, 58, .12);
}
input::placeholder, textarea::placeholder { color: #5d6778; }
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.check:hover { color: var(--text); }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.section-title {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0 -2px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

/* ============ 表格 ============ */
.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2);
  text-align: left;
  padding: 10px 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.selected { background: rgba(255, 91, 58, .08); box-shadow: inset 2px 0 0 var(--accent); }
td.actions { white-space: nowrap; text-align: right; }
.td-title { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 商品表：固定布局，标题省略号，「拉黑」按钮永远在可视区内 */
.products-table { table-layout: fixed; }
.products-table .td-title { max-width: none; }
.products-table .seller-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.products-table .seller-cell .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.products-table .seller-cell .btn { flex: none; padding: 2px 8px; font-size: 11.5px; }
.products-table .seller-cell .btn[data-block] { border-color: rgba(255, 91, 58, .45); color: var(--accent); background: transparent; }
.products-table .seller-cell .btn[data-block]:hover { background: rgba(255, 91, 58, .12); border-color: var(--accent); }
.products-table .td-pid {
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.thumb {
  width: 42px; height: 42px; border-radius: 8px; object-fit: cover;
  background: var(--panel-3); display: block;
}
.thumb-fallback { width: 42px; height: 42px; border-radius: 8px; background: var(--panel-3); display: grid; place-items: center; color: var(--muted); font-size: 11px; }

.price { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid transparent; white-space: nowrap;
}
.badge.green { color: #a8f0c6; background: rgba(47, 190, 110, .12); border-color: rgba(47, 190, 110, .28); }
.badge.red { color: #ffbeb4; background: rgba(240, 85, 63, .12); border-color: rgba(240, 85, 63, .28); }
.badge.blue { color: #bcd3ff; background: rgba(75, 139, 255, .12); border-color: rgba(75, 139, 255, .28); }
.badge.amber { color: #ffdca8; background: rgba(232, 163, 61, .12); border-color: rgba(232, 163, 61, .28); }
.badge.gray { color: var(--text-2); background: var(--panel-3); border-color: var(--border); }

.tag {
  display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0;
  border-radius: 5px; font-size: 11.5px;
  background: var(--panel-3); color: var(--text-2);
}

.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; opacity: .35; display: block; margin-bottom: 8px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: 220px; }
.toolbar select { width: auto; min-width: 140px; }
.toolbar .right { margin-left: auto; }

/* ============ 商品页分栏 ============ */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.detail { position: sticky; top: 0; }
.detail-img {
  width: 100%; height: 240px; border-radius: 10px; object-fit: cover;
  background: var(--panel-3); display: block; border: 1px solid var(--border-soft);
}
.detail-img-wrap { position: relative; }
.detail-img-ph {
  width: 100%; height: 240px; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted);
  background: repeating-linear-gradient(45deg, var(--panel-2), var(--panel-2) 10px, var(--panel) 10px, var(--panel) 20px);
  border: 1px solid var(--border-soft); font-size: 12px;
}
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  margin-top: 12px;
}
/* 二维码放大到 200px，方便直接拿手机扫 */
.qr-box img {
  width: 200px; height: 200px;
  border-radius: 8px; background: #fff; padding: 8px;
  cursor: zoom-in; transition: transform .12s;
}
.qr-box img:hover { transform: scale(1.02); }

/* 全屏扫码用的大二维码 */
.qr-large {
  width: min(420px, 78vw); height: auto;
  background: #fff; padding: 16px; border-radius: 12px;
}
/* 详情标题：最多 3 行，超长省略，避免长标题把二维码挤下去 */
.detail-title {
  font-size: 15px; font-weight: 650; line-height: 1.4; margin-bottom: 6px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow: hidden; word-break: break-all;
}
.kv { display: flex; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.kv .k { color: var(--muted); min-width: 54px; flex: 0 0 54px; }
.kv .v { color: var(--text-2); word-break: break-all; }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 8, 11, .68);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow: hidden;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop .14s ease-out;
  overflow: hidden;
}
@keyframes pop { from { transform: translateY(-6px) scale(.995); opacity: .6 } to { transform: none; opacity: 1 } }
.modal.wide { width: min(900px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border-soft);
  flex: 0 0 auto; background: var(--panel-2);
}
.x-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.x-btn:hover { color: var(--text); background: var(--panel-3); }

/* ============ toast ============ */
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 15px; border-radius: 10px; font-size: 13px;
  background: var(--panel-3); border: 1px solid var(--border);
  box-shadow: var(--shadow); max-width: 380px;
  animation: slide .16s ease-out;
}
@keyframes slide { from { transform: translateX(12px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.ok { border-color: rgba(47, 190, 110, .4); color: #b8f5d2; }
.toast.err { border-color: rgba(240, 85, 63, .4); color: #ffc8c0; }

/* ============ 杂项 ============ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px;
  background: var(--panel-3); color: var(--text-2); border: 1px solid var(--border);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }

.code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 12px; overflow-x: auto;
  color: #c8d3e4; white-space: pre; line-height: 1.6;
}

.log-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.log-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--panel-2);
  font-size: 12.5px;
}
.log-row .msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.divider { height: 1px; background: var(--border-soft); margin: 14px 0; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .detail { position: static; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .sidebar .nav { flex-direction: row; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .page { padding: 14px; }
  .form-grid, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}

/* ============ 二次规则卡片 / 批量设置 ============ */
.rule-card {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-soft);
  margin-bottom: 10px;
}
.rule-card + .rule-card { margin-top: 0; }
.rule-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-2); margin-bottom: 10px;
}
.rule-head b { color: var(--accent-2); }
.rule-card .form-grid { gap: 10px; }
.rule-card textarea { min-height: 56px; }

.batch-row {
  display: flex; align-items: center; gap: 12px;
}
.batch-row.top { align-items: flex-start; }
.batch-label {
  flex: 0 0 96px; font-size: 12.5px; color: var(--text-2); padding-top: 7px;
}
.batch-row select { width: auto; min-width: 120px; }

/* ============ 明亮主题 ============ */
html[data-theme="light"] {
  --bg: #f2f5fa;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --panel-3: #e9eef7;
  --border: #d7deea;
  --border-soft: #e6ebf3;
  --text: #141a23;
  --text-2: #45526a;
  --muted: #74808f;
  --shadow: 0 12px 30px rgba(16, 24, 40, .14);
}
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .login-wrap {
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(255, 91, 58, .12), transparent 62%),
    radial-gradient(760px 480px at 100% 110%, rgba(75, 139, 255, .10), transparent 60%),
    var(--bg);
}
html[data-theme="light"] .topbar { background: #fff; }
html[data-theme="light"] .sidebar { background: #fff; }
html[data-theme="light"] .nav a.active {
  color: #b3361c;
  background: linear-gradient(90deg, rgba(255, 91, 58, .14), rgba(255, 91, 58, .02));
}
html[data-theme="light"] .price { color: #cf4419; }
html[data-theme="light"] .badge.green { color: #0a7d32; background: rgba(47, 190, 110, .14); }
html[data-theme="light"] .badge.red { color: #b3261c; background: rgba(240, 85, 63, .12); }
html[data-theme="light"] .badge.blue { color: #1e56b8; background: rgba(75, 139, 255, .12); }
html[data-theme="light"] .badge.amber { color: #8a5a06; background: rgba(232, 163, 61, .16); }
html[data-theme="light"] .badge.gray { color: #55627a; background: var(--panel-3); }
html[data-theme="light"] .pill.on { color: #0a7d32; background: rgba(47, 190, 110, .12); }
html[data-theme="light"] .pill.off { color: #b3261c; background: rgba(240, 85, 63, .1); }
html[data-theme="light"] .toast { background: #fff; color: var(--text); }
html[data-theme="light"] .toast.ok { color: #0a7d32; }
html[data-theme="light"] .toast.err { color: #b3261c; }
html[data-theme="light"] .code { color: #2b3445; background: #f7f9fc; }
html[data-theme="light"] .detail-img-ph {
  background: repeating-linear-gradient(45deg, #f1f4fa, #f1f4fa 10px, #e9eef7 10px, #e9eef7 20px);
}
html[data-theme="light"] .rule-card { background: #f8fafd; }

/* ============ 顶栏图标按钮 ============ */
.icon-btn {
  position: relative;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  transition: .12s;
  padding: 0;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.active { border-color: var(--accent); color: var(--accent); }

.mini-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: var(--red); color: #fff;
  font-size: 10.5px; line-height: 16px; text-align: center;
  font-weight: 700;
}
html[data-theme="light"] .icon-moon { display: none; }
html:not([data-theme="light"]) .icon-sun { display: none; }

/* ============ 请求日志抽屉 ============ */
.drawer {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  width: min(560px, calc(100vw - 36px));
  max-height: 46vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px; color: var(--text-2);
}
.drawer-head b { color: var(--text); }
.drawer-head .spacer { flex: 1; }
.drawer-body { overflow-y: auto; padding: 6px 0; }
.log-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 5px 14px;
  font-size: 12px; line-height: 1.5;
  font-family: var(--mono);
  border-left: 2px solid transparent;
}
.log-item:hover { background: var(--panel-2); }
.log-item.ok { border-left-color: rgba(47, 190, 110, .6); }
.log-item.err { border-left-color: rgba(240, 85, 63, .8); }
.log-item.info { border-left-color: var(--border); }
.log-item .t { color: var(--muted); flex: 0 0 auto; }
.log-item .m { color: var(--text-2); word-break: break-all; }
.log-item.err .m { color: #e8664f; }
html[data-theme="light"] .log-item.err .m { color: #b3261c; }
.log-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ============ 通知面板 ============ */
.pop-wrap { position: relative; }
.pop-panel {
  position: absolute; right: 0; top: 38px; z-index: 75;
  width: min(380px, calc(100vw - 36px));
  max-height: 60vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
}
.pop-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px; color: var(--text-2);
}
.pop-head .spacer { flex: 1; }
.notice-item {
  padding: 9px 10px; border-radius: 8px; margin-bottom: 4px;
  background: var(--panel-2);
  border-left: 3px solid var(--border);
}
.notice-item.error { border-left-color: var(--red); }
.notice-item.warning { border-left-color: var(--amber); }
.notice-item.info { border-left-color: var(--blue); }
.notice-item .nt { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notice-item .nm { font-size: 12px; color: var(--text-2); white-space: pre-wrap; line-height: 1.6; }
.notice-item .nd { font-size: 11px; color: var(--muted); margin-top: 4px; }
.notice-item.unread { background: var(--panel-3); }

/* 管理后台：实时日志面板 */
.log-panel {
  height: calc(100vh - 176px); margin: 0;
  padding: 12px 14px;
  background: #0f1115;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px; line-height: 1.55;
  color: #cfd3dc;
  white-space: pre-wrap; word-break: break-all;
}


/* ============ 手机端（≤640px）：底部导航 + 商品卡片 ============ */
@media (max-width: 640px) {
  /* 手机上让整页滚动（浏览器原生惯性），底部导航 fixed */
  .app { display: block; height: auto; min-height: 100vh; min-height: 100dvh; }
  .main { min-height: 100vh; min-height: 100dvh; }
  .page { overflow: visible; padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }

  /* 侧边栏 == 底部固定导航 */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 55;
    flex-direction: row; align-items: stretch; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border-soft);
    background: var(--bg-soft);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .sidebar .nav { flex-direction: row; gap: 0; width: 100%; overflow: visible; }
  .nav a {
    flex: 0 0 auto; flex-direction: column; justify-content: center;
    gap: 2px; padding: 6px 9px 5px; font-size: 10.5px; border-radius: 8px;
  }
  .nav a span { font-size: 10.5px; white-space: nowrap; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .nav a svg { width: 18px; height: 18px; flex-basis: 18px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--accent); background: rgba(255, 91, 58, .1); }

  /* 顶栏：标题一行，开关一行 */
  .topbar { padding: 10px 12px; gap: 8px 10px; flex-wrap: wrap; align-items: center; }
  .topbar h2 { font-size: 16px; }
  #page-sub { display: none; }
  .topbar-right { flex: 1 1 100%; justify-content: space-between; gap: 8px; flex-wrap: wrap; row-gap: 8px; }
  .switch-group .seg { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  #state-pill { font-size: 11.5px; padding: 4px 8px; }
  .icon-btn { width: 34px; height: 34px; }

  /* 表单 / 工具条 */
  .toolbar { gap: 8px; }
  .toolbar .search { width: 100%; }
  .toolbar select { flex: 1 1 45%; min-width: 0; width: auto; }
  .form-grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .card { padding: 13px; border-radius: 12px; }
  .btn { min-height: 36px; }
  .btn.tiny { min-height: 30px; }
  .pager { justify-content: space-between; }
  .batch-row { flex-wrap: wrap; }
  .batch-label { flex-basis: 100%; padding-top: 0; }
  /* 黑名单添加行：手机上竖排 */
  .bl-add-row { flex-wrap: wrap; }
  .bl-add-row input { flex: 1 1 100%; }
  .bl-add-row .btn { flex: 1 1 100%; }

  /* 商品表 → 卡片列表（保留 图 / 标题 / 价格 / 卖家+拉黑 / 状态） */
  /* 只有商品表变成卡片；其他表格保留横向滚动 */
  .table-cards { border: 0; border-radius: 0; overflow: visible; background: transparent; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .products-table { display: block; table-layout: auto; }
  .products-table thead { display: none; }
  .products-table tbody { display: block; }
  .products-table tr {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb title status"
      "thumb meta price";
    gap: 4px 10px; align-items: start;
    padding: 10px; margin-bottom: 8px;
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
  }
  .products-table tr:hover { background: var(--panel); }
  .products-table tr.selected {
    background: rgba(255, 91, 58, .08);
    box-shadow: inset 0 0 0 1px var(--accent);
  }
  .products-table td { display: block; padding: 0; border: 0; }
  .products-table td:nth-child(1) { grid-area: thumb; }
  .products-table td:nth-child(2) { grid-area: title; }
  .products-table td:nth-child(4) { grid-area: price; text-align: right; }
  .products-table td:nth-child(6) { grid-area: meta; }
  .products-table td:nth-child(7) { grid-area: status; text-align: right; }
  /* 手机不显示 商品ID / 地区列（详情里都有） */
  .products-table td:nth-child(3), .products-table td:nth-child(5) { display: none; }
  .products-table .td-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal; line-height: 1.45; font-size: 13.5px;
  }
  .products-table .seller-cell { gap: 8px; }
  .products-table .seller-cell .name { font-size: 12px; color: var(--muted); }
  .thumb, .thumb-fallback { width: 52px; height: 52px; }
  .thumb-fallback { font-size: 11px; }
  .products-table .price { font-size: 13.5px; }

  /* 详情（手机用底部弹窗，隐藏右侧栏） */
  .split { gap: 10px; }
  .split .detail { display: none; }
  .detail-sheet .detail-title { margin-top: 10px; }
  .detail-img, .detail-img-ph { height: 200px; }
  .detail-title { font-size: 14.5px; }
  /* 手机不展示商品二维码（本机直接点「打开链接」） */
  .qr-box { display: none; }

  /* 弹窗铺满 / 底部弹出 */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; max-height: 88vh; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }

  /* 日志抽屉贴底，避开底部导航 */
  .drawer {
    left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto; max-height: 52vh;
  }
  .pop-panel { width: calc(100vw - 26px); right: -6px; }

  /* 登录页 / 提示 */
  .login-wrap { padding: 16px; }
  .login-card { padding: 22px 18px; }
  .toast-root { left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
}


/* 手机端：关键词 / 账号表只留关键列，操作按钮换行 */
@media (max-width: 640px) {
  .kw-table th:nth-child(3), .kw-table td:nth-child(3),
  .kw-table th:nth-child(4), .kw-table td:nth-child(4),
  .kw-table th:nth-child(5), .kw-table td:nth-child(5),
  .kw-table th:nth-child(6), .kw-table td:nth-child(6),
  .acc-table th:nth-child(3), .acc-table td:nth-child(3),
  .acc-table th:nth-child(4), .acc-table td:nth-child(4) { display: none; }

  .kw-table th:nth-child(7), .acc-table th:nth-child(2) { width: auto !important; }
  /* 黑名单表：手机只留 ID / 昵称 / 解除 */
  .bl-table th:nth-child(3), .bl-table td:nth-child(3) { display: none; }
  .bl-table th:nth-child(1) { width: 118px !important; }
  .bl-table td.nowrap { white-space: normal; word-break: break-all; }
  .kw-table td.actions, .acc-table td.actions { width: auto !important; white-space: normal; }
  .kw-table td.actions .btn.link, .acc-table td.actions .btn.link { padding: 3px 5px; }
}
