:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #1a222d;
  --line: #232d3b;
  --line-soft: #1c2530;
  --text: #e6edf6;
  --text-dim: #8b9bb0;
  --text-mute: #61708a;
  --accent: #3b82f6;
  --accent-dim: #1e3a5f;
  --green: #22c55e;
  --green-bg: #12301f;
  --amber: #f59e0b;
  --amber-bg: #33260b;
  --red: #ef4444;
  --red-bg: #38181a;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 186px;
  flex: 0 0 186px;
  background: #0a0e14;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 16px; }
.brand-logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(140deg, #3b82f6, #6366f1);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.brand-txt { font-size: 13px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { font-size: 10px; color: var(--text-mute); margin-top: 1px; }

.nav-label {
  font-size: 10px; color: var(--text-mute);
  padding: 12px 10px 6px; letter-spacing: .6px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); cursor: pointer;
  font-size: 13px; line-height: 1.2;
  margin-bottom: 1px; border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover { background: #12181f; color: var(--text); }
.nav-item.active {
  background: #16202c; color: #fff;
  border-color: #22303f;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .ico { width: 15px; text-align: center; opacity: .8; font-size: 12px; }
.nav-item .badge-dot {
  margin-left: auto; font-size: 10px; padding: 1px 5px;
  border-radius: 20px; background: var(--red); color: #fff; font-weight: 600;
}

.side-foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding: 10px 8px 2px; }
.side-foot .row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-mute); margin-bottom: 5px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dot.off { background: var(--text-mute); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px; flex: 0 0 56px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px; background: var(--panel);
}
.crumb { font-size: 14px; font-weight: 600; }
.crumb small { display: block; font-size: 11px; color: var(--text-mute); font-weight: 400; margin-top: 2px; }

.pills { display: flex; gap: 7px; margin-left: 8px; flex-wrap: wrap; }
.pill {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: #1b2531; border: 1px solid #26313f; color: var(--text-dim);
  white-space: nowrap;
}
.pill b { color: var(--text); font-weight: 600; }
.pill.g { background: var(--green-bg); border-color: #1d5133; color: #86efac; }
.pill.a { background: var(--amber-bg); border-color: #5b4315; color: #fcd34d; }
.pill.r { background: var(--red-bg); border-color: #5c2326; color: #fca5a5; }
.pill.b { background: #14273f; border-color: #1f3f63; color: #93c5fd; }

.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  padding: 6px 12px; border-radius: 7px; font-size: 12px; cursor: pointer;
  border: 1px solid #2a3646; background: #1b2431; color: var(--text);
  transition: .14s; white-space: nowrap;
}
.btn:hover { background: #22303f; border-color: #35455a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2f74e0; }
.btn.ghost { background: transparent; }
.btn.danger { background: #2a1618; border-color: #4a1f23; color: #fca5a5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 3px 8px; font-size: 11px; }

.content { flex: 1; overflow: auto; padding: 16px 18px 40px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 12px 14px;
}
.card .k { font-size: 11px; color: var(--text-mute); margin-bottom: 6px; }
.card .v { font-size: 21px; font-weight: 650; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.card .v small { font-size: 11px; color: var(--text-mute); font-weight: 400; margin-left: 3px; }
.card .sub { font-size: 11px; color: var(--text-dim); margin-top: 5px; }

.panel {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 14px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 14px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  text-align: left; padding: 8px 10px; font-weight: 500; color: var(--text-mute);
  background: #121821; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid #19212b; vertical-align: middle; }
tbody tr:hover { background: #131a23; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.prod-name { font-weight: 500; color: var(--text); }
.prod-meta { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: var(--text-dim); }

.tag { font-size: 10px; padding: 2px 7px; border-radius: 5px; border: 1px solid; white-space: nowrap; display: inline-block; }
.tag.green { color: #86efac; background: var(--green-bg); border-color: #1d5133; }
.tag.amber { color: #fcd34d; background: var(--amber-bg); border-color: #5b4315; }
.tag.red { color: #fca5a5; background: var(--red-bg); border-color: #5c2326; }
.tag.gray { color: var(--text-dim); background: #1b2531; border-color: #2a3646; }
.tag.blue { color: #93c5fd; background: #14273f; border-color: #1f3f63; }

.delta-up { color: #f87171; }
.delta-down { color: #4ade80; }

/* ---------- 表单 ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid2 > * { min-width: 0; }
.field { margin-bottom: 12px; min-width: 0; }
.field label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 5px; }
.field .hint { font-size: 10px; color: var(--text-mute); margin-top: 4px; line-height: 1.5; }
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 7px 9px; border-radius: 7px;
  border: 1px solid #2a3646; background: #0f1620; color: var(--text);
  font-size: 12px; font-family: inherit; outline: none; transition: .14s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #101a26; }
textarea { resize: vertical; line-height: 1.6; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; }
.switch input { width: 34px; height: 18px; appearance: none; background: #2a3646; border-radius: 20px; position: relative; cursor: pointer; transition: .16s; }
.switch input:checked { background: var(--accent); }
.switch input::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: .16s;
}
.switch input:checked::after { left: 18px; }

/* ---------- 其它 ---------- */
.search { display: flex; gap: 8px; align-items: center; }
.search input { width: 300px; }

.empty { text-align: center; padding: 46px 10px; color: var(--text-mute); font-size: 12px; line-height: 1.8; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 99;
  display: flex; flex-direction: column; gap: 8px;
}
.toast div {
  background: #1b2431; border: 1px solid #2f3d4f; color: var(--text);
  padding: 9px 14px; border-radius: 8px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: in .18s ease;
  max-width: 380px;
}
.toast div.err { border-color: #5c2326; background: #2a1618; color: #fca5a5; }
.toast div.ok { border-color: #1d5133; background: #12301f; color: #86efac; }
@keyframes in { from { transform: translateY(6px); opacity: 0; } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(4,7,11,.72);
  display: none; place-items: center; z-index: 80; padding: 20px;
}
.modal-mask.show { display: grid; }
.modal {
  width: 100%; max-width: 760px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 13px; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; }

.code {
  background: #0b1119; border: 1px solid #1e2836; border-radius: 7px;
  padding: 10px 12px; font-family: ui-monospace, Menlo, monospace;
  font-size: 11px; color: #9fb3c8; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-height: 220px; overflow: auto;
}

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1080px) { .split { grid-template-columns: 1fr; } }

.login-mask {
  position: fixed; inset: 0; background: #080b10; z-index: 200;
  display: grid; place-items: center;
}
.login-box {
  width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px;
}
.login-box h2 { margin: 0 0 4px; font-size: 15px; }
.login-box p { margin: 0 0 16px; font-size: 11px; color: var(--text-mute); }

.legend { font-size: 11px; color: var(--text-mute); line-height: 1.9; }
.legend b { color: var(--text-dim); font-weight: 600; }

.steps { counter-reset: s; }
.steps li { font-size: 12px; color: var(--text-dim); line-height: 1.8; margin-bottom: 6px; }
.steps code { background: #0b1119; padding: 1px 5px; border-radius: 4px; font-size: 11px; color: #93c5fd; }

/* ---------- 跟价方式切换 ---------- */
.seg {
  display: inline-flex; gap: 3px; padding: 3px; margin-top: 2px;
  background: #0f1620; border: 1px solid #2a3646; border-radius: 8px;
}
.seg button {
  padding: 5px 12px; border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-dim);
  font-size: 11.5px; font-family: inherit; transition: .14s;
}
.seg button:hover { color: var(--text); background: #16202c; }
.seg button.on { background: var(--accent-dim); color: #bfdbfe; }
.seg button:disabled { opacity: .45; cursor: default; }

.preview {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  background: #0f1620; border: 1px dashed #2a3646;
  font-size: 11.5px; color: var(--text-dim); line-height: 1.7;
}
.preview b { color: #93c5fd; font-weight: 600; }
.preview .hl { color: #86efac; font-weight: 600; }

/* ---------- SKU 明细弹窗 ---------- */
.modal.wide { max-width: 1180px; }
#skuTableWrap { max-height: calc(92vh - 178px); }
.sku-toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; border-bottom: 1px solid var(--line-soft); background: #101720;
}
.sku-toolbar input[type=text] { width: 280px; }
.sku-toolbar .spacer { margin-left: auto; }
.sku-stats { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.sku-stats .sk {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: #131c26; border: 1px solid #24313f; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.sku-stats .sk i { font-style: normal; font-size: 10px; color: var(--text-mute); }
.sku-stats .sk.blue { color: #93c5fd; border-color: #1f3f63; background: #14273f; }
.sku-stats .sk.green { color: #86efac; border-color: #1d5133; background: var(--green-bg); }
.sku-stats .sk.red { color: #fca5a5; border-color: #5c2326; background: var(--red-bg); }
.sku-stats .sk.gray { color: #9aa9bd; }
.sku-main { font-size: 12.5px; color: #dce7f3; font-weight: 500; }
.sku-sub { font-size: 10.5px; color: var(--text-mute); margin-top: 1px; }

/* ---------- 高级设置折叠 ---------- */
details.adv { margin-top: 14px; border-top: 1px dashed #24313f; padding-top: 12px; }
details.adv > summary {
  cursor: pointer; font-size: 11.5px; color: var(--text-dim);
  list-style: none; user-select: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸ "; color: var(--text-mute); }
details.adv[open] > summary::before { content: "▾ "; }
details.adv > summary:hover { color: var(--text); }

/* 对话订单视图下隐藏跟价按钮，避免误点 */
body[data-view="cs"] .top-actions { display: none; }
