:root {
  --bg: #F5F3EF;
  --panel: #FFFFFF;
  --ink: #1B1F1D;
  --ink2: #4E534E;
  --muted: #8B877E;
  --line: #E6E2D9;
  --line-soft: #F0EDE6;
  --pine: #1E4A3A;
  --pine2: #2C6650;
  --rail: #16241E;
  --rail2: #23352C;
  --clay: #C1703F;
  --amber: #D9A441;
  --sky: #4C7A94;
  --sage: #8CA98D;
  --plum: #9A6B84;
  --red: #B0453A;
  --green: #2E7D5B;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 31, 29, .04), 0 12px 28px -20px rgba(27, 31, 29, .25);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.num, .tbl td.num { font-variant-numeric: tabular-nums; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }

.rail {
  width: 240px;
  flex: 0 0 240px;
  background: var(--rail);
  color: #DDE5DF;
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 0 4px 22px; }
.logo { width: 34px; height: 34px; flex: 0 0 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 15px; letter-spacing: .02em; color: #F3F0E7; font-weight: 600; }
.brand-text span { font-size: 10.5px; color: #7E9188; letter-spacing: .02em; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  font-size: 13px; color: #A9BAB1; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .45; }
.nav-item:hover { background: rgba(255, 255, 255, .055); color: #E8EFEA; }
.nav-item.active { background: var(--rail2); color: #F6F2E9; font-weight: 500; }
.nav-item.active .dot { background: var(--amber); opacity: 1; box-shadow: 0 0 0 3px rgba(217, 164, 65, .15); }

.rail-sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 18px 4px 14px; }

.snap-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 6px 8px; font-size: 10.5px; letter-spacing: .12em;
  color: #6F857C; text-transform: uppercase;
}
.snap-head em { font-style: normal; color: #A9BAB1; letter-spacing: 0; }

.snap-list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; flex: 1; margin: 0 -4px; padding: 0 4px; }
.snap-list::-webkit-scrollbar { width: 4px; }
.snap-list::-webkit-scrollbar-thumb { background: #33473D; border-radius: 4px; }

.snap-item {
  padding: 8px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s;
}
.snap-item:hover { background: rgba(255, 255, 255, .05); }
.snap-item.active { background: rgba(217, 164, 65, .1); border-color: rgba(217, 164, 65, .28); }
.snap-name { font-size: 12px; color: #D8E1DB; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snap-item.active .snap-name { color: #F6EBD6; }
.snap-meta { font-size: 10.5px; color: #7E9188; margin-top: 3px; font-variant-numeric: tabular-nums; }
.snap-item.active .snap-meta { color: #B7A383; }

.rail-foot { padding-top: 14px; }
.btn-upload {
  width: 100%; padding: 9px; border-radius: 9px;
  background: var(--amber); color: #241B0B; font-size: 12.5px; font-weight: 600;
  letter-spacing: .02em; transition: filter .15s;
}
.btn-upload:hover { filter: brightness(1.06); }
.rail-note { font-size: 10px; color: #65796F; text-align: center; margin-top: 9px; }

.main { flex: 1; min-width: 0; padding: 24px 30px 48px; max-width: 1560px; }

.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.sub { font-size: 12px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.seg { display: inline-flex; background: #EAE6DE; padding: 3px; border-radius: 10px; gap: 1px; }
.seg button {
  padding: 6px 11px; border-radius: 8px; font-size: 12px; color: #6B685F;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27, 31, 29, .1); font-weight: 500; }

.ghost {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 7px 12px; font-size: 12px; color: var(--ink2); transition: border-color .15s, color .15s;
}
.ghost:hover { border-color: #CFC9BC; color: var(--ink); }

/* ---------------- 卡片 / 网格 ---------------- */
.grid { display: grid; gap: 16px; margin-top: 16px; }
.g22 { grid-template-columns: 2fr 1fr; }
.g11 { grid-template-columns: 1fr 1fr; }
.g21 { grid-template-columns: 2fr 1fr; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px 20px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; }
.card-head .hint { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-head .hint b { font-weight: 600; color: var(--ink2); }

/* ---------------- KPI ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px 13px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 11.5px; color: var(--muted); letter-spacing: .03em; display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 27px; font-weight: 600; letter-spacing: -.025em; margin-top: 7px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; min-height: 18px; }
.kpi-hint { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { position: absolute; right: 14px; top: 15px; opacity: .85; }

.delta { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--green); background: rgba(46, 125, 91, .09); }
.delta.down { color: var(--red); background: rgba(176, 69, 58, .09); }
.delta.flat { color: var(--muted); background: rgba(139, 135, 126, .1); }

/* ---------------- 图表 ---------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #1E2622; color: #F2EFE7; border-radius: 8px; padding: 8px 10px;
  font-size: 11px; line-height: 1.55; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .5);
  opacity: 0; transition: opacity .12s; white-space: nowrap;
}
.chart-tip.show { opacity: 1; }
.chart-tip .t { color: #A9BAB1; font-size: 10.5px; margin-bottom: 3px; }
.chart-tip .r { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip .r i { display: inline-block; width: 6px; height: 6px; border-radius: 2px; margin-right: 5px; }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-box { position: relative; flex: 0 0 auto; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center b { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.donut-center span { font-size: 10px; color: var(--muted); margin-top: 1px; }

.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.legend .sw { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 7px; }
.legend .nm { color: var(--ink2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .vl { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.legend .pc { color: var(--muted); width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; max-height: 560px; border-radius: 10px; }
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: #DDD8CD; border-radius: 8px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 11px; color: var(--muted);
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: #fff; z-index: 2; letter-spacing: .03em;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .arrow { opacity: .45; margin-left: 2px; font-size: 9px; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:hover td { background: #FBFAF6; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; }
.tbl .name { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .sku-cell { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.tbl .muted { color: var(--muted); }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); background: #FCFBF8; }

.chip { display: inline-block; padding: 1.5px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 500; letter-spacing: .01em; white-space: nowrap; }
.chip.amz { background: #FDF1E0; color: #9A5A22; }
.chip.wmt { background: #E9F1F7; color: #2F6485; }
.chip.other { background: #EFEDE7; color: #6B685F; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 5px; font-size: 10.5px; font-weight: 600; }
.badge.a { background: rgba(46, 125, 91, .1); color: var(--green); }
.badge.b { background: rgba(217, 164, 65, .16); color: #96691A; }
.badge.c { background: #EFEDE7; color: #7C786F; }
.badge.alert { background: rgba(176, 69, 58, .1); color: var(--red); }

/* ---------------- 预警 / 洞察 ---------------- */
.alerts { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow-y: auto; padding-right: 2px; }
.alerts::-webkit-scrollbar { width: 4px; }
.alerts::-webkit-scrollbar-thumb { background: #E0DBD0; border-radius: 4px; }
.alert-item { border-left: 2.5px solid var(--amber); background: #FCFAF6; border-radius: 0 8px 8px 0; padding: 9px 11px; }
.alert-item.high { border-left-color: var(--red); background: #FDF8F6; }
.alert-title { font-size: 12px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.alert-title .lv { font-size: 9.5px; font-weight: 600; padding: 1px 4px; border-radius: 3px; background: rgba(176, 69, 58, .1); color: var(--red); }
.alert-item.mid .lv { background: rgba(217, 164, 65, .18); color: #96691A; }
.alert-detail { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

.insight { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px dashed var(--line); }
.insight:last-child { border-bottom: none; }
.insight .ix { flex: 0 0 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.insight .tx b { font-weight: 600; }
.insight .tx { font-size: 12.5px; color: var(--ink2); line-height: 1.6; }
.insight .tx em { font-style: normal; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ix.grow { background: rgba(46, 125, 91, .1); color: var(--green); }
.ix.risk { background: rgba(176, 69, 58, .09); color: var(--red); }
.ix.eff { background: rgba(76, 122, 148, .1); color: var(--sky); }
.ix.mix { background: rgba(217, 164, 65, .16); color: #96691A; }

/* ---------------- 漏斗 ---------------- */
.funnel { display: flex; flex-direction: column; gap: 4px; }
.fn-row { display: grid; grid-template-columns: 62px 1fr 92px; align-items: center; gap: 12px; }
.fn-label { font-size: 11.5px; color: var(--muted); }
.fn-bar-wrap { background: #F4F1EA; border-radius: 6px; height: 30px; position: relative; overflow: hidden; }
.fn-bar { height: 100%; border-radius: 6px; display: flex; align-items: center; padding-left: 10px; color: #fff; font-size: 11.5px; font-weight: 600; min-width: 4px; }
.fn-val { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.fn-rate { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: -2px; font-variant-numeric: tabular-nums; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 70px 20px; }
.empty .ic { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 14px; background: #EDE9E0; display: flex; align-items: center; justify-content: center; }
.empty h2 { font-size: 16px; font-weight: 600; }
.empty p { font-size: 12.5px; color: var(--muted); margin: 8px auto 20px; max-width: 380px; line-height: 1.7; }

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 1.5px dashed #D5CFC2; border-radius: 12px; padding: 30px 20px;
  text-align: center; background: #FCFBF7; transition: border-color .18s, background .18s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--pine2); background: #F6FAF7; }
.dropzone .dz-ic { font-size: 22px; color: var(--pine2); }
.dropzone .dz-t { font-size: 13px; font-weight: 500; margin-top: 8px; }
.dropzone .dz-s { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.file-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; background: #F7F5F0; border-radius: 8px; font-size: 11.5px; }
.file-row .fn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fs { color: var(--muted); font-variant-numeric: tabular-nums; }
.file-row .rm { color: var(--muted); font-size: 14px; padding: 0 3px; }
.file-row .rm:hover { color: var(--red); }

.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.fld input, .fld select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #FCFBF8; font-size: 12.5px; color: var(--ink); outline: none;
}
.fld input:focus, .fld select:focus { border-color: var(--pine2); background: #fff; }

/* ---------------- 弹窗 ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(18, 24, 20, .45);
  backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .45); animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0 } }
.modal.wide { max-width: 780px; }
.modal-head { padding: 18px 22px 12px; display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.modal-body { padding: 4px 22px 16px; overflow-y: auto; }
.modal-foot { padding: 12px 22px 18px; display: flex; justify-content: flex-end; gap: 9px; }
.x { color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 4px; }
.x:hover { color: var(--ink); }

.btn-primary { background: var(--pine); color: #fff; border-radius: 9px; padding: 8px 16px; font-size: 12.5px; font-weight: 500; }
.btn-primary:hover { background: var(--pine2); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-plain { border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; font-size: 12.5px; color: var(--ink2); background: #fff; }
.btn-plain:hover { border-color: #CFC9BC; }

.map-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.map-row .lab { font-size: 11.5px; color: var(--ink2); }
.map-row .lab b { color: var(--red); }
.map-row select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 11.5px; background: #FCFBF8; }

.preview-tbl { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-top: 8px; }
.preview-tbl th, .preview-tbl td { border: 1px solid var(--line-soft); padding: 4px 6px; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.preview-tbl th { background: #F7F5F0; color: var(--muted); font-weight: 500; }

/* ---------------- 提示 ---------------- */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #1E2622; color: #F2EFE7; padding: 10px 14px; border-radius: 10px;
  font-size: 12px; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .5);
  animation: slide .2s ease; max-width: 380px; line-height: 1.5;
}
.toast.err { background: #5A2A25; }
.toast.ok { background: #1E4A3A; }
@keyframes slide { from { transform: translateY(8px); opacity: 0 } }

.loading { padding: 60px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .g22, .g11, .g21 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: relative; padding: 14px 16px; }
  .brand { padding-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; }
  .rail-sep, .snap-head { display: none; }
  .snap-list { flex-direction: row; overflow-x: auto; margin-top: 10px; }
  .snap-item { flex: 0 0 auto; max-width: 220px; }
  .rail-foot { padding-top: 10px; }
  .btn-upload { width: auto; padding: 8px 14px; }
  .rail-note { display: none; }
  .main { padding: 18px 16px 40px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
}

/* ---------------- 损益瀑布 / 四象限 / 盈亏 ---------------- */
.red { color: #B0453A; font-weight: 600; }
.row-active td { background: #FBF6EC !important; }
.link { color: var(--pine2); font-size: 12px; padding: 2px 6px; }
.link.danger { color: var(--red); }
.link:hover { text-decoration: underline; }

.acct-hd { background: #F7F5F0; font-weight: 600; color: var(--ink); font-size: 11.5px; letter-spacing: .03em; }
.owner { display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 600; }
.owner.mu { background: rgba(76,122,148,.12); color: var(--sky); }
.owner.bu { background: rgba(217,164,65,.18); color: #96691A; }
.owner.fu { background: rgba(154,107,132,.12); color: var(--plum); }

.abc-note { margin-top: 8px; font-size: 11px; color: var(--muted); display: flex; gap: 10px; align-items: center; }

/* 横向条形列表 */
.hbar { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.hb-rank { flex: 0 0 18px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.hb-body { flex: 1; min-width: 0; }
.hb-top { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 3px; }
.hb-name { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-top b { font-weight: 600; font-variant-numeric: tabular-nums; }
.hb-track { height: 7px; background: #F0EDE6; border-radius: 4px; overflow: hidden; }
.hb-fill { height: 100%; border-radius: 4px; }

/* 品类条形 */
.cbars { display: flex; flex-direction: column; gap: 11px; }
.cbar { display: grid; grid-template-columns: 76px 1fr 110px; align-items: center; gap: 10px; }
.cb-name { font-size: 11.5px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-track { height: 9px; background: #F0EDE6; border-radius: 5px; overflow: hidden; }
.cb-fill { height: 100%; border-radius: 5px; }
.cb-val { font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.cb-val span { display: block; font-size: 10.5px; color: var(--muted); }

/* 盈亏平衡 */
.be { display: flex; flex-direction: column; gap: 10px; }
.be-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink2); }
.be-row b { font-variant-numeric: tabular-nums; color: var(--ink); }
.be-track { height: 12px; background: #F0EDE6; border-radius: 6px; overflow: hidden; }
.be-fill { height: 100%; border-radius: 6px; transition: width .4s; }
.be-note { font-size: 10.5px; color: var(--muted); line-height: 1.6; }

/* 表格工具栏 / 分页 */
.tbl-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.tb-search { flex: 1; min-width: 160px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; background: #FCFBF8; }
.tb-sel { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; background: #FCFBF8; }
.tb-count { font-size: 11px; color: var(--muted); margin-left: auto; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.pg { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px; line-height: 1; }
.pg:disabled { opacity: .4; }

/* 下载列表 */
.dl-list { display: flex; flex-direction: column; gap: 8px; }
.dl { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 10px; text-decoration: none; color: var(--ink); transition: border-color .15s, background .15s; }
.dl:hover { border-color: var(--pine2); background: #F8FAF8; }
.dl-ic { font-size: 18px; }
.dl b { font-size: 12.5px; font-weight: 600; display: block; }
.dl small { font-size: 11px; color: var(--muted); }

/* 口径说明 */
.scope { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.scope-item b { font-size: 12.5px; display: block; margin-bottom: 4px; }
.scope-item p { font-size: 11.5px; color: var(--muted); line-height: 1.7; }

.funnel-note { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
@media (max-width: 760px) { .scope { grid-template-columns: 1fr; } }

/* ---------------- 产品层级切换 ---------------- */
.prod-seg { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; }
.seg-item {
  padding: 6px 13px; border-radius: 9px; font-size: 12.5px; color: #6B685F;
  background: #EAE6DE; transition: background .15s, color .15s;
}
.seg-item:hover { color: var(--ink); }
.seg-item.on { background: var(--pine); color: #fff; font-weight: 500; }
.prod-hint { font-size: 11px; color: var(--muted); margin-left: auto; }
@media (max-width: 760px) { .prod-hint { display: none; } }

/* ---------------- 数据汇总（科目视角） ---------------- */
.sum-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tb-label { font-size: 12px; color: var(--muted); }
.sum-period { font-size: 11.5px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.sum-kpi .kpi-value { font-size: 24px; }
.rate-pill { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: rgba(30,74,58,.08); color: var(--pine); font-variant-numeric: tabular-nums; }
.kpi-value.pos { color: var(--pine); }
.kpi-value.neg { color: var(--red); }

.sum-tbl td { padding-top: 6px; padding-bottom: 6px; }
.sum-tbl .calc-row td { background: #FBF8F1; font-weight: 600; border-top: 1px solid var(--line); }
.sum-tbl .warn-row td { background: #FDF7F4; }
.sum-tbl .warn-row td:first-child { box-shadow: inset 2px 0 0 #C1703F; }
.calc-tag { display: inline-block; min-width: 14px; margin-right: 4px; color: #96691A; font-size: 11px; }
.lv-tick { display: inline-block; width: 4px; height: 4px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: #C9C4B8; }
.lv-tick.lv1 { width: 6px; height: 6px; background: var(--pine); }
.lv-tick.lv2 { background: var(--sage); }
.lv-tick.lv3 { background: #C9B98A; }
.lv-tick.lv4 { background: #D8D2C6; }
.rate-track { height: 7px; background: #F1EEE7; border-radius: 4px; overflow: hidden; }
.rate-fill { height: 100%; border-radius: 4px; background: #B9C7BC; }
.rate-fill.warn { background: #C1703F; }
.rate-fill.calc { background: #D9A441; }
@media (max-width: 1180px) { .kpi-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .kpi-3 { grid-template-columns: 1fr; } }

/* ---------------- 科目月度矩阵 ---------------- */
.mm-toggle { display: inline-flex; gap: 2px; background: #EAE6DE; padding: 3px; border-radius: 9px; }
.mm-toggle button { padding: 4px 12px; border-radius: 7px; font-size: 11.5px; color: #6B685F; transition: background .15s, color .15s; }
.mm-toggle button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27,31,29,.1); font-weight: 500; }
.matrix-wrap { max-height: 620px; overflow: auto; }
.matrix-tbl { border-collapse: separate; border-spacing: 0; }
.matrix-tbl th, .matrix-tbl td { white-space: nowrap; padding: 7px 9px; font-size: 11.5px; }
.matrix-tbl th { position: sticky; top: 0; background: #fff; z-index: 3; }
.matrix-tbl .col-name { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 150px; }
.matrix-tbl th.col-name { z-index: 4; }
.matrix-tbl td.col-name { background: #fff; }
.matrix-tbl tbody tr:hover td.col-name { background: #FBFAF6; }
.matrix-tbl .col-total { background: #FAF8F3; font-weight: 600; }
.matrix-tbl .calc-row .col-name, .matrix-tbl .calc-row td { background: #FBF8F1; font-weight: 600; }
.matrix-tbl .warn-row .col-name { box-shadow: inset 2px 0 0 #C1703F; }
.cell-ylw { background: rgba(217,164,65,.14); }
.cell-org { background: rgba(217,164,65,.30); }
.cell-red { background: rgba(193,112,63,.30); color: #7A3A18; font-weight: 600; }
.cell-legend { display: inline-block; padding: 1px 6px; border-radius: 4px; margin: 0 2px; font-size: 10.5px; }
.matrix-note { margin-top: 10px; font-size: 11px; color: var(--muted); }

/* 科目树折叠 */
.mm-right { display: flex; align-items: center; gap: 8px; }
.lnk-mini { font-size: 11px; color: var(--pine2); padding: 3px 6px; border-radius: 6px; }
.lnk-mini:hover { background: rgba(44,102,80,.08); text-decoration: underline; }
.tree-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-right: 6px; border-radius: 7px;
  font-size: 17px; font-weight: 700; line-height: 1; color: var(--pine);
  background: rgba(30,74,58,.09); cursor: pointer; vertical-align: middle;
  transition: background .12s, color .12s, transform .12s;
  flex: 0 0 24px;
}
.tree-toggle:hover { background: var(--pine); color: #fff; transform: scale(1.06); }
.tree-toggle:active { transform: scale(.96); }
.tree-toggle.ph { visibility: hidden; }

/* 维度月度矩阵补充 */
.dim-l1 td { font-weight: 600; }
.dim-l1 td.col-name { color: var(--pine); }
.neg-num { color: var(--red); }

/* ---------------- SPU 利润清单 ---------------- */
.pnl-tbl th.grp { text-align: center; background: #FAF9F5; font-weight: 600; font-size: 11px; }
.pnl-tbl thead tr:first-child th { position: sticky; top: 0; z-index: 3; background: #FAF9F5; }
.pnl-tbl thead tr:last-child th { position: sticky; top: 29px; z-index: 3; background: #fff; }
.pnl-tbl .name { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl-tbl .strong { font-weight: 600; }
.pnl-tbl .neg-num { color: var(--red); }

/* SPU 清单缩略图 */
.pnl-tbl td.img-cell, .pnl-tbl th.img-cell { width: 56px; min-width: 56px; padding: 4px 6px; text-align: center; }
.spu-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: #F4F1EA; }
.no-img { color: var(--muted); font-size: 11px; }
.pnl-tbl thead th.img-cell { padding: 7px 6px; }

/* 矩阵：图片 / 金额占比同时 / 排序 / 字号优化 */
.mm-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dim-matrix-img .spu-thumb { width: 40px; height: 40px; }
.matrix-tbl th.sortable { cursor: pointer; user-select: none; }
.matrix-tbl th.sortable:hover { background: #F6F3EC; color: var(--ink); }
.matrix-tbl .sarrow { font-size: 9px; opacity: .38; margin-left: 3px; }
.matrix-tbl th.sortable:hover .sarrow { opacity: .8; }
.both-cell .ca { display: block; font-weight: 600; line-height: 1.25; }
.both-cell .cr { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.matrix-tbl td.both-cell { padding-top: 5px; padding-bottom: 5px; }
/* 字号整体放大，便于查看 */
.matrix-tbl th, .matrix-tbl td { font-size: 12.5px; padding: 8px 11px; }
.matrix-tbl .col-name { font-size: 12.5px; }
.matrix-tbl .col-name img.spu-thumb { width: 44px; height: 44px; }

/* ---------------- SPU 利润清单 · 视觉重做 ---------------- */
.pnl-tbl { font-size: 12px; font-variant-numeric: tabular-nums; border-collapse: separate; border-spacing: 0; }
.pnl-tbl th, .pnl-tbl td { padding: 8px 10px; border-bottom: 1px solid #F1EEE6; }
.pnl-tbl thead th { background: #FAF9F5; font-size: 11.5px; font-weight: 600; color: var(--ink2); }
.pnl-tbl thead th.grp { text-align: center; border-left: 1px solid #EDE7DA; }
/* 单行/双行表头 均支持吸顶 */
.pnl-tbl thead.pnl-head-single th { position: sticky; top: 0 !important; z-index: 3; }
.pnl-tbl thead.pnl-head-double tr:first-child th { position: sticky; top: 0; z-index: 3; }
.pnl-tbl thead.pnl-head-double tr:last-child th { position: sticky; top: 30px; z-index: 3; background: #fff; }
/* 斑马 + 悬停 */
.pnl-tbl tbody tr:nth-child(even) td { background: #FCFBF8; }
.pnl-tbl tbody tr:hover td { background: #F7F4EC; }
/* 利润口径列（金色高亮） */
.pnl-tbl thead th.profit-col { background: #F6EED5 !important; }
.pnl-tbl tbody td.profit-col { background: #FBF5E4 !important; }
.pnl-tbl tbody tr:hover td.profit-col { background: #F8F0D9 !important; }
/* 合计行 */
.pnl-tbl tfoot td { background: #F4F1E8; font-weight: 600; border-top: 2px solid var(--line); }
.pnl-tbl tfoot td.profit-col { background: #F6EED5 !important; }
.pnl-tbl .spu-col { font-weight: 600; }
.pnl-tbl .name { font-size: 11.5px; color: var(--muted); }
.pnl-tbl .col-ttl { min-width: 160px; }
.pnl-tbl .neg-num { color: var(--red); }

/* SPU 清单：金额下叠双占比（占收入 / 占科目合计） */
.pnl-tbl td.both-cell { padding-top: 6px; padding-bottom: 6px; vertical-align: middle; }
.pnl-tbl .both-cell .ca { display: block; font-weight: 600; line-height: 1.35; }
.pnl-tbl .both-cell .cr { display: block; font-size: 10px; color: var(--muted); line-height: 1.25; }
.pnl-tbl .both-cell .ct { display: block; font-size: 9.5px; color: #4C7A94; line-height: 1.25; }
.pnl-tbl tfoot .both-cell .ca { font-weight: 700; }

/* 手动日期区间 */
.date-range { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 3px 8px; }
.date-range input[type="date"] { border: 0; background: transparent; font-size: 11.5px; color: var(--ink2); font-family: inherit; padding: 3px 2px; outline: none; width: 118px; }
.date-range input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
.dr-sep { color: var(--muted); font-size: 11px; }
.date-range.active { border-color: var(--pine2); box-shadow: 0 0 0 2px rgba(44,102,80,.1); }

/* 销售成本二级/三级明细列 */
.pnl-tbl thead th.sub2-col { background: #F7F5EE; font-weight: 500; font-size: 11px; }
.pnl-tbl thead th.sub3-col { background: #FAF9F5; font-weight: 400; font-size: 10.5px; color: var(--muted); }
.pnl-tbl tbody td.sub2-col { background: #FEFDFA; }
.pnl-tbl tbody td.sub3-col { background: #FEFDFA; color: var(--ink2); }

/* ---------------- 登录 ---------------- */
.login-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% 0%, #1E4A3A 0%, #14261F 60%, #0E1B16 100%); }
.login-box { background: var(--panel); border-radius: 16px; padding: 34px 30px 28px; width: 320px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.06); }
.login-logo { font-size: 30px; margin-bottom: 6px; }
.login-box h2 { font-size: 18px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.login-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 20px; }
.login-box input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px;
  font-family: inherit; background: #fff; margin-bottom: 12px; outline: none; }
.login-box input:focus { border-color: var(--pine2); box-shadow: 0 0 0 3px rgba(44,102,80,.12); }
.login-box button { width: 100%; padding: 11px; border-radius: 9px; background: var(--pine); color: #fff; font-size: 13px;
  font-weight: 600; letter-spacing: .08em; cursor: pointer; transition: background .15s; }
.login-box button:hover { background: #164034; }
.login-box button:disabled { opacity: .6; cursor: default; }
.login-err { margin-top: 10px; font-size: 12px; color: var(--red); min-height: 16px; }
.logout-link { font-size: 11px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.logout-link:hover { background: rgba(0,0,0,.05); color: var(--ink); }

/* ---------------- SPU 利润清单 · 紧凑版 ---------------- */
.pnl-tbl { font-size: 10.5px; }
.pnl-tbl th, .pnl-tbl td { padding: 4px 6px; border-bottom: 1px solid #F3F0E9; }
.pnl-tbl thead th { font-size: 9.5px; padding: 5px 5px; }
.pnl-tbl td.both-cell { padding: 3px 6px; }
.pnl-tbl .both-cell .ca { display: block; font-size: 10.5px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.pnl-tbl .both-cell .cr { display: inline; font-size: 8.5px; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.pnl-tbl .both-cell .cs { display: inline; font-size: 8.5px; color: #4C7A94; line-height: 1.2; margin-left: 5px; white-space: nowrap; }
.pnl-tbl .spu-thumb { width: 30px; height: 30px; border-radius: 4px; }
.pnl-tbl td.img-cell, .pnl-tbl th.img-cell { width: 36px; min-width: 36px; padding: 2px 3px; }
.pnl-tbl .spu-col { min-width: 62px; font-size: 10.5px; }
.pnl-tbl tfoot td { padding: 4px 6px; }

/* 表头：字号统一 + 长字段换行 */
.pnl-tbl thead th { font-size: 10px; font-weight: 600; white-space: normal; line-height: 1.2; vertical-align: bottom; word-break: break-word; padding: 5px 4px; }
.pnl-tbl thead th.sub2-col { font-size: 10px; font-weight: 600; white-space: normal; }
.pnl-tbl thead th.sub3-col { font-size: 10px; font-weight: 600; white-space: normal; color: var(--ink2); }
.pnl-tbl thead th.profit-col { font-weight: 700; }

/* 科目层级切换 */
.lv-label { font-size: 11px; color: var(--muted); margin-right: 2px; }
.lv-btn { padding: 4px 10px; border-radius: 7px; font-size: 11.5px; color: #6B685F; background: transparent; }
.lv-btn.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27,31,29,.1); font-weight: 600; }
.lv-btn:hover:not(.on) { background: rgba(255,255,255,.5); }

/* SPU 清单头部与列距优化 */
.pnl-tbl thead th { vertical-align: top; text-align: left; padding: 5px 3px 5px 4px; line-height: 1.15; position: relative; padding-right: 10px; }
.pnl-tbl thead th.num { text-align: left; }
.pnl-tbl thead th .sarrow { position: absolute; top: 3px; right: 1px; font-size: 8px; opacity: .5; }
.pnl-tbl th, .pnl-tbl td { padding-left: 4px; padding-right: 3px; }
.pnl-tbl td.col-name, .pnl-tbl th.col-name { padding-left: 6px; }
/* 图片悬停放大 */
.pnl-tbl .spu-thumb { transition: transform .15s ease, box-shadow .15s ease; transform-origin: left center; }
.pnl-tbl .spu-thumb:hover { transform: scale(2.1); box-shadow: 0 4px 14px rgba(0,0,0,.28); position: relative; z-index: 20; border-color: #C9C4B8; }

/* 表头 3+3 均分后进一步收窄 */
.pnl-tbl thead th { min-width: 34px; }
.pnl-tbl thead th.num { min-width: 34px; }

/* ===== 锁定前三列（图片 / SPU / 销量）===== */
.pnl-tbl th:nth-child(1), .pnl-tbl td:nth-child(1) {
  position: sticky; left: 0; z-index: 5;
  width: 36px; min-width: 36px; max-width: 36px;
}
.pnl-tbl th:nth-child(2), .pnl-tbl td:nth-child(2) {
  position: sticky; left: 36px; z-index: 5;
  width: 70px; min-width: 70px; max-width: 70px;
}
.pnl-tbl th:nth-child(3), .pnl-tbl td:nth-child(3) {
  position: sticky; left: 106px; z-index: 5;
  width: 76px; min-width: 76px; max-width: 76px;
}
.pnl-tbl thead th:nth-child(1), .pnl-tbl thead th:nth-child(2), .pnl-tbl thead th:nth-child(3) {
  z-index: 8; background: #FAF9F5;
}
.pnl-tbl tbody td:nth-child(1), .pnl-tbl tbody td:nth-child(2), .pnl-tbl tbody td:nth-child(3) {
  background: #fff;
}
.pnl-tbl tfoot td:nth-child(1), .pnl-tbl tfoot td:nth-child(2), .pnl-tbl tfoot td:nth-child(3) {
  background: #F4F1E8;
}
/* 锁定列右侧阴影，滚动时提示边界 */
.pnl-tbl th:nth-child(3), .pnl-tbl td:nth-child(3) { box-shadow: 2px 0 4px rgba(0,0,0,.06); }

/* ===== 二级 / 三级科目视觉区分 ===== */
.pnl-tbl thead th.sub2-col { background: #E3EEE2 !important; font-weight: 700; color: #2C4A32; }
.pnl-tbl thead th.sub3-col { background: #F2F7F1 !important; font-weight: 500; color: #6B7F6C; }
.pnl-tbl tbody tr td.sub2-col { background: #F1F7F0 !important; }
.pnl-tbl tbody tr td.sub3-col { background: #F9FBF8 !important; color: var(--ink2); }
.pnl-tbl tfoot td.sub2-col { background: #E9F2E8 !important; }
.pnl-tbl tfoot td.sub3-col { background: #F2F7F1 !important; }
/* 二级列表头底部加粗分隔线 */
.pnl-tbl thead th.sub2-col { border-bottom: 2px solid #CADCC8; }

/* 修复：图片放大时被锁定的 SPU 列遮挡 */
.pnl-tbl td:nth-child(1):hover { z-index: 7 !important; }
.pnl-tbl td:nth-child(1):hover .spu-thumb { position: relative; z-index: 3; }
.pnl-tbl tbody tr:hover td:nth-child(1) { background: transparent; }

/* 表头对称 2+2：进一步收窄 */
.pnl-tbl thead th { min-width: 0; padding: 5px 2px 5px 3px; }
.pnl-tbl th, .pnl-tbl td { padding-left: 3px; padding-right: 2px; }
.pnl-tbl thead th.num { min-width: 32px; }
