:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e8f0;
  --text: #1b2333;
  --muted: #6b7a90;
  --primary: #3b5bdb;
  --primary-d: #2f49b0;
  --accent: #e8590c;
  --ok: #0f8a5f;
  --err: #c92a2a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--primary), #6c8cff);
  color: #fff; font-weight: 700; display: grid; place-items: center; letter-spacing: .5px;
}
.topbar h1 { margin: 0; font-size: 15px; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.topstatus { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 12.5px; }
.meta b { color: var(--text); }

.pill {
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid transparent;
}
.pill.idle { background: #eef1f6; color: var(--muted); }
.pill.run  { background: #fff4e6; color: var(--accent); border-color: #ffd8a8; }
.pill.ok   { background: #e6f7f0; color: var(--ok); }
.pill.err  { background: #ffeaea; color: var(--err); }

.stats { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 13px; }
.stats span { background: #eef1f6; padding: 4px 10px; border-radius: 999px; }
tr.warn td { background: #fff9db; }
.ops { white-space: nowrap; }
.ops .btn { margin: 0 2px; }
th.vendor-col { white-space: nowrap; font-size: 12px; }
td.vendor-cell { font-size: 12px; }
.vendor-row {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
td.match-yes .match-title {
  color: var(--ok); font-weight: 600; line-height: 1.2;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
td.match-yes .match-title.match-ai { color: var(--primary); }
td.match-no { text-align: left; }
.price-pair {
  margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary);
  display: inline-flex; gap: 3px; align-items: baseline; flex-wrap: nowrap; white-space: nowrap;
}
.price-pair .sep { color: var(--muted); font-weight: 500; }
.price-pair.muted { color: var(--muted); font-weight: 500; }

.modal {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(16, 21, 31, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(920px, 100%); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 14px; padding: 16px 18px;
  border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(16,21,31,.18);
}
.bound-box {
  margin: 0 0 12px; padding: 10px 12px;
  background: #f4f7fb; border: 1px solid var(--line); border-radius: 10px;
}
.bound-box .bound-title { font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.bound-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px;
}
.bound-row .t-title { flex: 1; min-width: 0; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 2px; padding: 6px 16px 0; flex-wrap: wrap;
}
.tab {
  border: none; background: transparent; padding: 6px 12px; cursor: pointer;
  color: var(--muted); font-size: 13px; border-radius: 8px 8px 0 0; font-weight: 500;
}
.tab:hover { background: #e9edf5; }
.tab.active { background: #fff; color: var(--primary); font-weight: 600; }

main { padding: 0 16px 24px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.order-steps {
  display: flex; gap: 8px; list-style: none; padding: 0; margin: 8px 0 10px; flex-wrap: wrap;
}
.order-steps li {
  background: #eef8f6; border: 1px solid #cfe7e2; border-radius: 8px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; color: #1f6f63;
}
.order-steps li::before {
  content: counter(step) ". ";
  counter-increment: step;
}
.order-steps { counter-reset: step; }

.time-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.time-row select { width: auto; min-width: 72px; }
.time-suffix { color: var(--muted); font-variant-numeric: tabular-nums; }
.timelist + .btn { margin-top: 2px; }

.subtabs {
  display: flex; gap: 6px; margin: 16px 0 0; padding: 4px;
  background: #eef1f6; border-radius: 10px; width: fit-content;
}
.subtab {
  border: none; background: transparent; padding: 7px 16px; cursor: pointer;
  color: var(--muted); font-size: 13.5px; border-radius: 8px;
}
.subtab:hover { color: var(--text); }
.subtab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.subpane { display: none; }
.subpane.active { display: block; }

/* ---------- 卡片 ---------- */
.grid {
  display: grid; gap: 10px; margin-top: 10px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-top: 10px;
}
.card.tight { padding: 8px 10px; }
.grid .card { margin-top: 0; }
.card h2 { margin: 0 0 8px; font-size: 13.5px; }
.card h3 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.field label { font-size: 12.5px; color: var(--muted); }
.hint { color: #9aa7ba; font-size: 11.5px; }
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=password], select, textarea {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: #fbfcfe; color: var(--text); width: 100%;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c8d4f7; border-color: var(--primary); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hidden { display: none !important; }

.checks { display: grid; gap: 6px; }
.checks.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.chk, .switch {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 2px 0; cursor: pointer;
}
.chk input, .switch input { width: 15px; height: 15px; accent-color: var(--primary); }
.vname { color: var(--muted); font-size: 12px; }
.tag {
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: #fff4e6; color: var(--accent); font-weight: 600;
}

.seg {
  display: flex; gap: 4px; background: #eef1f6; padding: 3px; border-radius: 9px;
  margin: 10px 0;
}
.segbtn {
  flex: 1; border: none; background: transparent; padding: 7px 8px; cursor: pointer;
  border-radius: 7px; font-size: 13px; color: var(--muted);
}
.segbtn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- 按钮 ---------- */
.actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.proxy-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.proxy-until { margin-left: auto; color: #3d4d66; font-weight: 600; font-size: 13px; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn:hover { background: #f5f7fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(.93); }
.btn.ok { background: #0f8a5f; border-color: #0f8a5f; color: #fff; }
.btn.ok:hover { filter: brightness(.93); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.xs { padding: 1px 6px; font-size: 11px; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.msg { font-size: 13px; color: var(--muted); }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

/* ---------- 表格 ---------- */
.tablehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tablehead h2 { margin: 0; }
.badge {
  background: #eef1f6; color: var(--muted); border-radius: 999px;
  padding: 1px 9px; font-size: 12px; font-weight: 600;
}
.tablefoot { display: flex; justify-content: flex-end; margin-top: 8px; }
.pager { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.pager select { width: auto; padding: 3px 6px; }
.tablewrap { overflow: auto; max-height: 68vh; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; position: relative; }
.tablewrap.tall { max-height: calc(100vh - 190px); }
.loading {
  position: absolute; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(255,255,255,.82); color: var(--muted); font-size: 13px;
}
.loading[hidden] { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #dbe3f5; border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; background: #f7f9fc; z-index: 1;
  text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--muted); white-space: nowrap;
}
tbody td {
  padding: 4px 8px; border-bottom: 1px solid #f0f3f8; vertical-align: middle;
  white-space: nowrap;
}
tbody tr:hover { background: #fafbfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.price { font-weight: 700; color: var(--primary); }
td.stock0 { color: var(--err); }
.sku { color: var(--muted); font-size: 11px; font-weight: 400; }
.t-title { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

tbody tr.bad td { background: #fff8f8; }

/* ---------- 日志 ---------- */
.logtools { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.logtools select { width: auto; min-width: 148px; }
pre {
  background: #10151f; color: #cbd5e1; padding: 14px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.55; max-height: 66vh; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 10px 0 0;
}

/* ---------- 筛选条 ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  align-items: end;
}
.filterbar .field { margin-bottom: 0; min-width: 140px; flex: 0 0 160px; }
.filterbar.inline { flex: 1; min-width: 0; }
.filterbar.inline .field { flex: 0 0 180px; min-width: 140px; }
#gamesTable td.is-pin, #gamesTable th.is-pin { position: sticky; }
#gamesTable td.is-pin-end, #gamesTable th.is-pin-end {
  box-shadow: 6px 0 10px rgba(20, 32, 48, .14);
}
#gamesTable th.sort { cursor: pointer; user-select: none; }
#gamesTable thead th.sort,
#gamesTable thead th.sort.mid,
#gamesTable thead th.sort.sub,
#gamesTable thead th.sort.shop-mp,
#gamesTable thead th.sort.shop-jst,
#gamesTable thead th.sort.shop-self {
  color: #d9480f;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
#gamesTable thead th.sort:hover {
  color: #9a3412;
  filter: none;
}
#gamesTable thead th.sort.sort-on,
#gamesTable thead th.sort.sort-on.mid,
#gamesTable thead th.sort.sort-on.sub,
#gamesTable thead th.sort.sort-on.shop-mp,
#gamesTable thead th.sort.sort-on.shop-jst,
#gamesTable thead th.sort.sort-on.shop-self {
  color: #9a3412;
  font-weight: 800;
  text-decoration-style: solid;
}
#gamesTable .sort-ind {
  display: inline-block; min-width: 1em; margin-left: 2px;
  font-weight: 700; opacity: .55; letter-spacing: 0;
}
#gamesTable .sort-ind.on { opacity: 1; }
#gamesTable thead th { text-align: center; }
#gamesTable thead tr:nth-child(1) th { top: 0; z-index: 5; }
#gamesTable thead tr:nth-child(2) th { top: 30px; z-index: 4; }
#gamesTable thead tr:nth-child(3) th { top: 56px; z-index: 3; }
#gamesTable th.shop-top {
  font-weight: 700; font-size: 12.5px; color: #fff;
  border-bottom: 0; letter-spacing: .02em; padding: 6px 8px;
}
#gamesTable th.mid { font-weight: 600; font-size: 11.5px; }
#gamesTable th.sub { font-weight: 500; font-size: 11px; }
#gamesTable th.shop-start, #gamesTable td.shop-start {
  border-left: 3px solid rgba(20, 32, 48, .22);
}
#gamesTable th.shop-mp { background: #2457a3; color: #fff; }
#gamesTable th.shop-mp.mid, #gamesTable th.shop-mp.sub { background: #d9e7f8; color: #1c3f73; }
#gamesTable td.shop-mp { background: #f0f5fb; }
#gamesTable th.shop-jst { background: #1f7a63; color: #f3fffb; }
#gamesTable th.shop-jst.mid, #gamesTable th.shop-jst.sub { background: #d7efe8; color: #165445; }
#gamesTable td.grp-jst-cell { background: #eef8f6; }
#gamesTable th.shop-self { background: #4a5d78; color: #fff; }
#gamesTable th.shop-self.mid, #gamesTable th.shop-self.sub { background: #e4eaf3; color: #334056; }
#gamesTable td.shop-self { background: #f3f6fb; }
#gamesTable th.shop-self.dmg-h, #gamesTable td.shop-self.dmg { background: #ece4d8; color: #4a3d2c; }
#gamesTable th.shop-laolieren { background: #1f7f8c; color: #fff; }
#gamesTable th.shop-laolieren.mid, #gamesTable th.shop-laolieren.sub { background: #d4eef2; color: #155660; }
#gamesTable td.shop-laolieren { background: #eaf6f8; }
#gamesTable th.shop-laolieren.dmg-h, #gamesTable td.shop-laolieren.dmg { background: #d2e8ec; color: #155660; }
#gamesTable th.shop-cyber { background: #3d4eb0; color: #fff; }
#gamesTable th.shop-cyber.mid, #gamesTable th.shop-cyber.sub { background: #dde3fb; color: #2a3480; }
#gamesTable td.shop-cyber { background: #eef1fc; }
#gamesTable th.shop-cyber.dmg-h, #gamesTable td.shop-cyber.dmg { background: #d4dbf4; color: #2a3480; }
#gamesTable th.shop-hailuo { background: #b06a12; color: #fff; }
#gamesTable th.shop-hailuo.mid, #gamesTable th.shop-hailuo.sub { background: #f6e6c8; color: #6d4208; }
#gamesTable td.shop-hailuo { background: #fbf3e3; }
#gamesTable th.shop-hailuo.dmg-h, #gamesTable td.shop-hailuo.dmg { background: #eed8b0; color: #6d4208; }
#gamesTable th.shop-xizi { background: #9a3d68; color: #fff; }
#gamesTable th.shop-xizi.mid, #gamesTable th.shop-xizi.sub { background: #f3dce8; color: #6a2446; }
#gamesTable td.shop-xizi { background: #f9eef4; }
#gamesTable th.shop-xizi.dmg-h, #gamesTable td.shop-xizi.dmg { background: #ecc9da; color: #6a2446; }
#gamesTable .sticky-id, #gamesTable .sticky-name {
  position: sticky; background: #fff; z-index: 6;
}
#gamesTable thead .sticky-id, #gamesTable thead .sticky-name {
  background: #d9e7f8; z-index: 7; color: #1c3f73; text-align: left;
}
#gamesTable .sticky-id { left: 0; }
#gamesTable .sticky-name { left: 46px; }
#gamesTable td.t-title,
#gamesTable th.sticky-name {
  max-width: none;
  min-width: 18em;
  overflow: visible;
  text-overflow: unset;
}
#gamesTable tbody tr:hover td,
#gamesTable tbody tr:hover td.grp-jst-cell,
#gamesTable tbody tr:hover td.shop-mp,
#gamesTable tbody tr:hover td.shop-self,
#gamesTable tbody tr:hover td.shop-laolieren,
#gamesTable tbody tr:hover td.shop-cyber,
#gamesTable tbody tr:hover td.shop-hailuo,
#gamesTable tbody tr:hover td.shop-xizi,
#gamesTable tbody tr:hover td.sticky-id,
#gamesTable tbody tr:hover td.sticky-name,
#gamesTable tbody tr.bad:hover td {
  background: #d9e6ff;
}
td.muted { color: var(--muted); font-weight: 400; }

.account { display: flex; align-items: center; gap: 8px; }
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, #e8eef8 0%, #f4f6fb 45%, #eef6f3 100%);
}
.login-card {
  width: min(400px, calc(100% - 32px));
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 18px; box-shadow: 0 16px 40px rgba(27, 35, 51, .08);
}
.login-card .brand { margin-bottom: 16px; }
.login-card h1 { font-size: 16px; }
.login-card .btn.primary { width: 100%; margin-top: 4px; }
.captcha-row { display: flex; gap: 8px; align-items: stretch; }
.captcha-row input { flex: 1; min-width: 0; }
.captcha-btn {
  border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #f4f6fb;
  cursor: pointer; line-height: 0; flex: none;
}
.captcha-btn:hover { border-color: var(--primary); }
.captcha-btn img { display: block; border-radius: 7px; }
