:root {
  --red: #e02e24;
  --red-soft: #fff1f0;
  --red-dark: #b8231b;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e8eaed;
  --text: #1f2329;
  --text-2: #5f6672;
  --text-3: #9299a6;
  --green: #18a058;
  --orange: #e8871a;
  --blue: #2a6df4;
  --shadow: 0 1px 2px rgba(20, 30, 50, .04), 0 6px 20px rgba(20, 30, 50, .045);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3, p { margin: 0; }
code { background: #f2f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #b8231b; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 224px; flex: 0 0 224px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 18px 20px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #f0483e, #d3201a); color: #fff; font-weight: 800; font-size: 19px; display: grid; place-items: center; box-shadow: 0 4px 10px rgba(224,46,36,.25); }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .3px; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px; cursor: pointer; text-align: left; transition: .15s; font-size: 13.5px; }
.nav-item:hover { background: #f6f7f9; color: var(--text); }
.nav-item.active { background: var(--red-soft); color: var(--red); font-weight: 600; }
.nav-link { text-decoration: none; }
.nav-legacy { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.nav-legacy > summary { list-style: none; cursor: pointer; padding: 6px 12px; font-size: 11.5px; color: var(--text-3); border-radius: 6px; }
.nav-legacy > summary::-webkit-details-marker { display: none; }
.nav-legacy > summary::before { content: '▸ '; }
.nav-legacy[open] > summary::before { content: '▾ '; }
.nav-legacy > summary:hover { background: #f6f7f9; color: var(--text-2); }
.nav-legacy .nav-item { font-size: 12.5px; padding: 7px 12px 7px 22px; opacity: .8; }
.ico { width: 18px; text-align: center; font-size: 16px; opacity: .9; }
.sidebar-foot { padding: 14px 16px 18px; border-top: 1px solid var(--border); }
.mode-box { display: flex; flex-direction: column; gap: 6px; }
.mode-label { font-size: 11px; color: var(--text-3); }
.foot-note { font-size: 11px; color: var(--text-3); margin-top: 10px; }

/* Main */
.main { flex: 1; min-width: 0; }
.topbar { height: 72px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.subtitle { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { padding: 22px 28px 40px; max-width: 1500px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5; }
.badge-demo { background: #fff4e5; color: #c26a00; }
.badge-live { background: #e8f7ee; color: #17834a; }
.badge-outline { background: #f6f7f9; color: var(--text-2); border: 1px solid var(--border); }
.badge-ok { background: #e8f7ee; color: var(--green); }
.badge-err { background: var(--red-soft); color: var(--red); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #f0f1f3; color: var(--text-2); font-weight: 500; vertical-align: middle; margin-left: 6px; }
.tag-ok { background: #e8f7ee; color: var(--green); }
.muted { color: var(--text-3); font-size: 12px; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { font-size: 15px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .panel { margin-bottom: 18px; }
.para { color: var(--text-2); font-size: 13px; line-height: 1.85; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.75; margin-top: 10px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.steps { padding-left: 18px; margin: 0; color: var(--text-2); font-size: 13px; line-height: 2; }
.steps b { color: var(--text); }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); opacity: .75; }
.stat-card:nth-child(2)::after { background: var(--orange); }
.stat-card:nth-child(3)::after { background: var(--blue); }
.stat-card:nth-child(4)::after { background: var(--green); }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-card strong { font-size: 28px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 11px; color: var(--text-3); }

/* Forms */
.input { width: 100%; padding: 8px 11px; border: 1px solid #dcdfe5; background: #fff; border-radius: 8px; color: var(--text); outline: none; transition: .15s; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(224,46,36,.09); }
.input::placeholder { color: #b7bdc7; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-2); }
.field span i { color: var(--red); font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; align-items: end; }
.form-grid .field { margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--red); width: 15px; height: 15px; }
.quick-row { display: flex; gap: 10px; }
.quick-row .input { max-width: 420px; }
.quick-result { margin-top: 12px; font-size: 13px; }
.filter-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.filter-row .input { width: auto; flex: 1; min-width: 130px; }
.filter-row .input.sm { flex: 0 0 auto; width: 128px; }
.filter-row .check { margin: 0 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 8px 15px; border: 1px solid #dcdfe5; background: #fff; color: var(--text); border-radius: 8px; cursor: pointer; font-size: 13px; text-decoration: none; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #b9bfc9; background: #fafbfc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--text-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); border-color: #f3c9c6; }
.btn-danger:hover { background: var(--red-soft); }
.link { border: 0; background: none; color: var(--red); cursor: pointer; font-size: 12px; padding: 0; }
.icon-btn { border: 0; background: none; font-size: 22px; color: var(--text-3); cursor: pointer; line-height: 1; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-info { background: #eef4ff; border-color: #d7e5ff; color: #2155b0; }
.alert-warn { background: #fff8e9; border-color: #f7e3b8; color: #9a6200; }
.alert-error { background: var(--red-soft); border-color: #f6cecb; color: var(--red-dark); }
.alert-ok { background: #eaf8f0; border-color: #c9edda; color: #147a46; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); background: #fafbfc; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px; }
.table td { padding: 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.table tr:hover td { background: #fcfcfd; }
.w40 { width: 40px; } .w90 { width: 90px; } .w100 { width: 100px; } .w120 { width: 120px; } .w130 { width: 130px; }
.goods-cell { display: flex; gap: 10px; align-items: center; min-width: 240px; }
.thumb { width: 44px; height: 44px; border-radius: 7px; object-fit: cover; background: #f1f2f4; flex: 0 0 44px; border: 1px solid var(--border); }
.goods-title { font-size: 13px; line-height: 1.45; max-width: 380px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.goods-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.price-main { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.price-sub { font-size: 11px; color: var(--text-3); }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11.5px; background: #f2f3f5; color: var(--text-2); }
.st-ready { background: #eaf1ff; color: #2a6df4; }
.st-published { background: #e8f7ee; color: var(--green); }
.st-ignored { background: #f2f3f5; color: var(--text-3); }
.empty { text-align: center; color: var(--text-3); padding: 28px 10px !important; font-size: 13px; }
.bulk-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); margin-top: 14px; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.pager { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; }
.pager > div { display: flex; align-items: center; gap: 9px; }
.page-num { font-size: 12px; color: var(--text-2); min-width: 22px; text-align: center; }
.mini-list { display: flex; flex-direction: column; gap: 2px; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #f2f3f5; font-size: 12.5px; }
.mini-item:last-child { border-bottom: 0; }
.mini-item .kw { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item .num { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.result-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.result-grid div { background: #fafbfc; border-radius: 8px; padding: 10px 12px; }
.result-grid span { display: block; font-size: 11px; color: var(--text-3); }
.result-grid b { font-size: 18px; }
.checklist { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); line-height: 1.9; font-size: 13px; }

/* Modal + toast */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 25, 35, .42); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.18); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-wide { max-width: 780px; }
textarea.input.mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; font-size: 11.5px; line-height: 1.55; white-space: pre; background: #fafbfc; }
.edit-preview { display: flex; gap: 10px; align-items: center; background: #fafbfc; border-radius: 8px; padding: 9px; margin-bottom: 15px; font-size: 12px; color: var(--text-2); }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translate(-50%, 20px); background: #262b33; color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 80vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 推手授权 */
.oauth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0 6px; }
.copy-row code { flex: 1; min-width: 0; background: #f6f7f9; border: 1px solid var(--border); border-radius: 7px; padding: 9px 11px; font-size: 12px; line-height: 1.5; word-break: break-all; color: #b8231b; }
.oauth-state { margin: 8px 0 4px; font-size: 14px; font-weight: 600; }
.oauth-state.ok { color: var(--green); }
.oauth-state.no { color: var(--text-2); }

/* 部署接入清单 */
.guide { border: 1px solid var(--border); border-radius: 9px; margin-bottom: 10px; overflow: hidden; }
.guide summary { padding: 11px 14px; cursor: pointer; font-size: 13px; font-weight: 600; background: #fafbfc; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::before { content: '▸'; margin-right: 9px; color: var(--red); }
.guide[open] summary::before { content: '▾'; }
.guide pre { margin: 0; padding: 13px 16px; background: #242932; color: #e9ecf1; overflow-x: auto; font-size: 12px; line-height: 1.75; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.guide pre code { background: transparent; color: #ffd7a8; padding: 0; }
.guide .hint, .guide .para { margin: 0; padding: 11px 16px; }
.guide .steps { margin: 0; padding: 11px 16px 11px 34px; }
/* 旧版多多进宝配置：默认弱化，鼠标移入或展开时恢复可读 */
.legacy-block { opacity: .52; transition: opacity .18s; }
.legacy-block:hover, .legacy-block:focus-within, .legacy-block[open] { opacity: 1; }

.view { display: none; }
.view.active { display: block; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .oauth-grid { grid-template-columns: 1fr; }
}
/* 店铺后台导入 / 多店对比 */
.shop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.shop-card { border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; background: #fff; }
.shop-card .shop-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-card .shop-count { font-size: 24px; font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; margin-top: 4px; }
.shop-card .shop-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.steps { margin: 0 0 14px; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 2; }
.steps code { font-size: 11.5px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.import-box { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; background: #fafbfc; font-size: 13px; }
.import-box.ok { border-color: #bfe6cf; background: #f4fbf7; }
.import-box.err { border-color: #f3c9c6; background: #fff7f6; }
.import-box table { width: 100%; border-collapse: collapse; margin-top: 9px; font-size: 12px; }
.import-box th, .import-box td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.import-box th { color: var(--text-3); font-weight: 500; }
.cmp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.cmp-stat { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: #fff; }
.cmp-stat b { display: block; font-size: 22px; color: var(--red); font-variant-numeric: tabular-nums; }
.cmp-stat span { font-size: 12px; color: var(--text-2); }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-col { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cmp-col h4 { margin: 0; padding: 10px 13px; font-size: 13px; background: #fafbfc; border-bottom: 1px solid var(--border); }
.cmp-list { max-height: 340px; overflow: auto; }
.cmp-item { display: flex; gap: 9px; align-items: center; padding: 8px 13px; border-bottom: 1px solid #f2f3f5; font-size: 12.5px; }
.cmp-item:last-child { border-bottom: 0; }
.cmp-item img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; background: #f2f3f5; flex: none; }
.cmp-item .ct { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-item .cp { color: var(--red); font-weight: 600; flex: none; }
@media (max-width: 900px) { .cmp-grid { grid-template-columns: 1fr; } }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 12px 16px; border-bottom: 0; }
  .nav { flex-direction: row; overflow-x: auto; padding: 0 10px 10px; }
  .nav-item { width: auto; white-space: nowrap; padding: 7px 11px; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 12px 16px; }
  .content { padding: 16px; }
  .form-grid, .stat-grid, .result-grid { grid-template-columns: 1fr; }
  .filter-row .input { min-width: 100%; }
}
