:root {
  --ink: #1b211d;
  --ink-2: #4a5550;
  --ink-3: #7d8a83;
  --paper: #f6f4ee;
  --paper-2: #fffdf8;
  --line: #e2dfd4;
  --green: #235c43;
  --green-2: #2f7a58;
  --green-soft: #e6efe8;
  --clay: #bc5c3c;
  --clay-soft: #f7e7df;
  --gold: #b8862f;
  --side: #15221c;
  --side-2: #1d2f26;
  --side-w: 248px;
  --danger: #a33a2f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(21, 34, 28, .06), 0 8px 24px -12px rgba(21, 34, 28, .25);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, #eef1e6 0%, transparent 60%),
    radial-gradient(800px 400px at 0% 100%, #f3ece2 0%, transparent 55%),
    var(--paper);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== 布局 ==================== */
.shell { display: grid; grid-template-columns: var(--side-w, 248px) 1fr; min-height: 100dvh; }

.side-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(21, 34, 28, .45);
  z-index: 45; backdrop-filter: blur(1px);
}
.side-backdrop.show { display: block; }

.side {
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: #d8e3dc;
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
  /* 现在是 <img>：透明底 logo，深色侧栏上直接显示，不加色块 */
  background: transparent;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .28));
}
.brand-name { font-family: var(--serif); font-size: 17px; letter-spacing: 1px; color: #f2f0e6; }
.brand-sub { font-size: 11px; color: #8ba396; letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group[hidden] { display: none; }
.nav-group-title {
  width: 100%; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 9px 5px; color: #71897c; font: inherit; font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-align: left;
}
.nav-group-title:hover { color: #a9bdb1; }
.nav-group-title i { font-style: normal; font-size: 13px; transition: transform .15s; }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 9px; color: #b8c9bf;
  text-decoration: none; cursor: pointer; font-size: 13.5px;
  border-left: 2px solid transparent; transition: .16s;
}
.nav-item em { font-style: normal; font-size: 10px; color: #5f7768; letter-spacing: .5px; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #eef3ef; }
.nav-item.active { background: rgba(231, 201, 138, .12); color: #f0dfb8; border-left-color: var(--gold); }
.nav-item.active em { color: var(--gold); }

.side-foot { margin-top: auto; font-size: 10.5px; color: #6c8477; line-height: 1.6; word-break: break-all; }

.main { padding: 20px 26px 40px; min-width: 0; }

/* 视图切换：只显示当前页，其余隐藏 */
.view { display: none; }
.view.active { display: block; }
.view > .card + .card, .view > .kpis + .grid2 { margin-top: 16px; }

.top { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.top-title h1 { font-family: var(--serif); font-size: 24px; margin: 0; letter-spacing: 1px; }
.top-title p { margin: 3px 0 0; color: var(--ink-3); font-size: 12.5px; }
.top-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }

/* ==================== 控件 ==================== */
.btn {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--green-2); color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #f4f7f2; }
.btn.primary:hover { background: var(--green-2); color: #fff; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e3c9c4; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }

.sel, .inp, input[type="month"], select, input[type="text"], input[type="number"] {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  padding: 8px 10px; border-radius: 9px; font-size: 13px; font-family: inherit; outline: none;
}
.sel:focus, .inp:focus, input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px var(--green-soft); }

/* ==================== 卡片 ==================== */
.card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-hd h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.card-hd .hint { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.card-hd .tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* 窄屏：工具栏必须换行，否则几个按钮加起来能到 500px，把页面撑出横向滚动条 */
@media (max-width: 640px) {
  .card-hd .tools { width: 100%; margin-left: 0; justify-content: flex-start; }
  .card-hd .tools .btn, .card-hd .tools .sel { flex: 0 1 auto; }
  .card-hd .hint { margin-left: 0; width: 100%; order: 3; }
}
.note { font-size: 12px; color: var(--ink-3); margin: -4px 0 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }

/* ==================== KPI ==================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--green-2);
}
.kpi.clay::after { background: var(--clay); }
.kpi.gold::after { background: var(--gold); }
.kpi .k { font-size: 11.5px; color: var(--ink-3); letter-spacing: .4px; }
.kpi .v { font-family: var(--serif); font-size: 25px; margin-top: 4px; letter-spacing: .5px; }
.kpi .s { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.neg { color: var(--danger); }
.pos { color: var(--green); }

/* ==================== 条形 / 结构 ==================== */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 108px 1fr 92px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .nm { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 20px; background: #efece2; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green-2), #6ba383); border-radius: 6px; min-width: 2px; }
.bar-fill.loss { background: linear-gradient(90deg, #b4523a, #d08a70); }
.bar-row .amt { text-align: right; font-variant-numeric: tabular-nums; }

.mix { display: flex; flex-direction: column; gap: 8px; }
.mix-row { display: grid; grid-template-columns: 86px 1fr 90px; gap: 8px; align-items: center; font-size: 12.5px; }
.mix-track { height: 8px; background: #efece2; border-radius: 99px; overflow: hidden; }
.mix-fill { height: 100%; border-radius: 99px; }
.mix-row .amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid #eeebe2; white-space: nowrap; }
th { color: var(--ink-3); font-weight: 500; font-size: 11.5px; letter-spacing: .3px; background: #fbf9f3; position: sticky; top: 0; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
tbody tr:hover { background: #fbf9f2; }
td.num, th.num { font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; background: #fbf8ef; border-top: 1px solid var(--line); }
.empty { padding: 26px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ==================== 表单 ==================== */
.form { display: flex; flex-direction: column; gap: 12px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
.drop {
  border: 1.5px dashed #cfd6c8; border-radius: 12px; background: #faf9f3;
  padding: 22px; text-align: center; cursor: pointer; position: relative; transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--green-2); background: var(--green-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-inner { display: flex; flex-direction: column; gap: 5px; pointer-events: none; }
.drop-inner strong { font-size: 13.5px; color: var(--green); }
.drop-inner span { font-size: 11.5px; color: var(--ink-3); }
.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; gap: 8px; align-items: center; font-size: 12px; background: #fbf9f3; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.file-row .tag { margin-left: auto; color: var(--green); font-size: 11px; }

.hidden { display: none !important; }
.result { margin-top: 12px; font-size: 12.5px; }
.result .ok { color: var(--green); }
.result .err { color: var(--danger); }

.fee-list { display: flex; flex-direction: column; gap: 1px; }
.fee-row { display: flex; justify-content: space-between; padding: 8px 2px; border-bottom: 1px dashed #ece8dd; font-size: 12.5px; }
.fee-row span:first-child { color: var(--ink-2); }
.fee-row span:last-child { font-variant-numeric: tabular-nums; }
.fee-row.total { border-bottom: none; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line);
  font-size: 11.5px; cursor: pointer; color: var(--ink-2); background: var(--paper-2);
}
.chip.active { background: var(--green); color: #f2f6f1; border-color: var(--green); }

/* ==================== 弹窗 ==================== */
.modal {
  position: fixed; inset: 0; background: rgba(21, 34, 28, .42); backdrop-filter: blur(2px);
  display: none; place-items: center; padding: 18px; z-index: 40;
}
.modal.open { display: grid; }
.modal-box {
  background: var(--paper-2); border-radius: 16px; width: min(720px, 100%);
  max-height: 86dvh; overflow: auto; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45);
}
.modal-hd { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper-2); }
.modal-hd h3 { margin: 0; font-size: 15px; }
.modal-hd .x { margin-left: auto; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--ink-3); line-height: 1; }
.modal-body { padding: 16px 18px 20px; }
.modal-body .form .row { grid-template-columns: 1fr 1fr; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.scope-summary { white-space: nowrap; }
.scope-preview { margin-top: 4px; color: var(--ink-3); font-size: 11px; line-height: 1.35; max-width: 220px; }
.scope-help { margin: 0 0 12px; color: var(--ink-3); font-size: 13px; line-height: 1.6; }
.scope-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.scope-toolbar span { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.scope-option {
  display: flex; align-items: center; gap: 9px; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  cursor: pointer; min-height: 42px;
}
.scope-option:hover { border-color: var(--green-2); }
.scope-option input { width: 17px; height: 17px; accent-color: var(--green); flex: 0 0 auto; }
.scope-option span { font-size: 13px; color: var(--ink); line-height: 1.35; }
.scope-option em { margin-left: auto; color: var(--ink-3); font-size: 10.5px; font-style: normal; white-space: nowrap; }

@media (max-width: 620px) {
  .scope-grid { grid-template-columns: 1fr; }
  .scope-preview { max-width: 150px; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #f3f1e8; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
  max-width: min(520px, 90vw);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #6d2a22; }

.warn-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: var(--clay-soft); color: var(--danger); font-size: 10.5px; vertical-align: 1px;
}

.qc-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed #ece8dd; font-size: 13px; align-items: baseline; }
.qc-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-2); flex: 0 0 auto; }
.qc-item.warn .dot { background: var(--gold); }
.qc-item.bad .dot { background: var(--danger); }
.qc-item .t { color: var(--ink-2); }
.qc-item .d { margin-left: auto; color: var(--ink-3); font-size: 12px; }

/* ==================== 响应式 ==================== */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 50;
    transform: translateX(-102%); transition: transform .22s ease;
    height: 100dvh;
  }
  .side.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn {
    display: grid; place-items: center; width: 38px; height: 38px;
    border: 1px solid var(--line); background: var(--paper-2); border-radius: 9px;
    font-size: 16px; cursor: pointer; color: var(--ink);
  }
  .main { padding: 16px 14px 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .top-title h1 { font-size: 20px; }
  .top-tools { width: 100%; margin-left: 0; }
  .top-tools .sel { flex: 1; }
  .kpi .v { font-size: 21px; }
  .bar-row { grid-template-columns: 84px 1fr 80px; }
  .form .row { grid-template-columns: 1fr; }
  th, td { padding: 7px 8px; }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 19px; }
}

/* 发货端口 */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.ch-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: var(--paper-2); box-shadow: 0 1px 0 rgba(27,33,29,.02);
}
.ch-top { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; }
.ch-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.ch-dot.local { background: var(--gold); }
.ch-dot.linyi { background: var(--green-2); }
.ch-dot.dropship { background: var(--clay); }
.ch-meta, .ch-note, .ch-partner { font-size: 12px; color: var(--ink-3); margin-top: 7px; line-height: 1.5; }
.mini { font-size: 11.5px; color: var(--ink-3); }
.sel.sm { padding: 3px 6px; font-size: 12px; border-radius: 6px; margin-right: 4px; }

/* 状态标签 */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 11.5px; white-space: nowrap;
}
.tag.gold { background: #f7efdd; border-color: #e8d9b0; color: #8a6a1e; }
.tag.ok { background: var(--green-soft); border-color: #cfe0d5; color: var(--green); }

/* 订单号/运单号用等宽字体，便于核对 */
.mono { font-family: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace; letter-spacing: -.2px; }

/* 多月趋势 */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
}
.segmented button {
  border: 0; border-radius: 6px; padding: 5px 10px;
  background: transparent; color: var(--ink-3);
  font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.segmented button.on {
  background: var(--green); color: #fff;
}

.trend {
  display: flex; align-items: flex-end; gap: 10px;
  height: 190px; padding: 10px 4px 0; overflow-x: auto;
}
.tr-col { flex: 0 0 62px; max-width: 96px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.tr-bar {
  flex: 1; width: 100%; display: flex; align-items: flex-end;
  background: linear-gradient(180deg, rgba(35,92,67,.04), rgba(35,92,67,.01));
  border-radius: 6px 6px 0 0;
}
.tr-bar i { display: block; width: 100%; background: linear-gradient(180deg, var(--green-2), var(--green)); border-radius: 6px 6px 0 0; }
.tr-bar i.down { background: linear-gradient(180deg, var(--clay), var(--danger)); }
.tr-val { font-size: 11px; color: var(--ink-2); margin-top: 5px; white-space: nowrap; }
.tr-mon { font-size: 11px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; }

.daily-legend {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  margin: 4px 0 2px; color: var(--ink-3); font-size: 12px;
}
.daily-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 8px; color: var(--ink-3); font-size: 12px;
}
.daily-toolbar input[type="range"] { width: 150px; accent-color: var(--green); }
#dailyChartHeightValue { min-width: 32px; font-variant-numeric: tabular-nums; }
.card.daily-collapsed #dailyCardBody { display: none; }
.card.daily-collapsed .card-hd { margin-bottom: 0; }
.daily-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-bar { display: inline-block; width: 11px; height: 11px; border-radius: 3px 3px 1px 1px; background: rgba(35,92,67,.22); }
.legend-line { display: inline-block; width: 20px; height: 2px; background: var(--gold); position: relative; }
.legend-line::after {
  content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); left: 7px; top: -2.5px;
}
.daily-chart-scroll { overflow-x: auto; padding: 4px 0 0; }
.daily-chart-svg { display: block; width: 100%; min-width: 760px; height: auto; }
.daily-grid { stroke: #d9d6ca; stroke-width: 1; stroke-dasharray: 3 5; }
.daily-axis { fill: var(--ink-3); font-size: 11px; }
.daily-sales-area { fill: url(#dailySalesGradient); }
.daily-sales-line { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.daily-sales-point { fill: #fff; stroke: var(--gold); stroke-width: 2; }
.daily-qty-bar { fill: rgba(35,92,67,.20); }
.daily-qty-bar:hover { fill: rgba(35,92,67,.38); }

.daily-store-table { min-width: max-content; }
.daily-store-table th:first-child,
.daily-store-table td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--paper-2); min-width: 150px;
}
.daily-store-table thead th:first-child { z-index: 3; }
.daily-store-table th:not(:first-child),
.daily-store-table td:not(:first-child) { min-width: 58px; text-align: right; }
.daily-store-table tfoot td:first-child { background: #fbf8ef; }

.chip.on { background: var(--green); color: #fff; border-color: var(--green); }

/* 顶栏用户区 */
.user-box { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--line); }
.u-name {
  font-size: 12.5px; color: var(--ink-2); max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) {
  .user-box { border-left: 0; padding-left: 0; margin-left: 0; }
  .u-name { display: none; }
}

/* 独立工具栏行：窄屏自动换行，输入框独占一行，按钮横向排开 */
.filter-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: -2px 0 12px; min-width: 0;
}
.filter-row .sel { flex: 1 1 180px; min-width: 0; max-width: 260px; }
.filter-row .btn { flex: 0 0 auto; }
@media (max-width: 480px) {
  .filter-row .sel { flex: 1 1 100%; max-width: none; }
  .filter-row .btn { flex: 1 1 auto; }
}

/* 窄屏兜底：标题栏竖排，任何工具栏都不会把卡片撑破。
   min-width:0 是关键——flex 子项默认 min-width:auto，
   内容超过容器时不会收缩，直接顶出横向滚动条。 */
.card-hd > * { min-width: 0; }
.card-hd .tools { max-width: 100%; }
@media (max-width: 640px) {
  .card-hd { flex-direction: column; align-items: stretch; gap: 8px; }
  .card-hd .hint { margin-left: 0; order: 2; }
  .card-hd .tools {
    margin-left: 0; order: 3;
    display: flex; flex-wrap: wrap; justify-content: flex-start;
  }
  .card-hd .tools > * { flex: 0 1 auto; min-width: 0; }
  .card-hd .tools .sel { flex: 1 1 140px; }
}

/* 平台抓取状态 */
.fetch-status {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  font-size: 13px; color: var(--ink-2);
}
.fs-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: 0 0 9px; }
.fs-dot.ok { background: var(--green-2); box-shadow: 0 0 0 3px rgba(47,122,88,.15); }
.fs-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(163,58,47,.15); }
.fs-dot.off { background: var(--gold); }
.fs-text { line-height: 1.5; }

@media (max-width: 640px) {
  .fetch-status { font-size: 12px; }
}

/* 登录提醒横幅 */
.login-bar {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  background: #fdf8ee;
  font-size: 13px; color: var(--ink-2);
}
.login-bar.is-warn {
  border-left-color: var(--danger);
  background: #fdf1ef;
}
.lb-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); flex: 0 0 9px;
}
.login-bar.is-warn .lb-dot { background: var(--danger); }
.lb-text { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.lb-text strong { font-size: 13.5px; color: var(--ink); }
.lb-text span { color: var(--ink-2); }
.lb-btn { flex: 0 0 auto; white-space: nowrap; }
.lb-close {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  font-size: 19px; line-height: 1; color: var(--ink-3); padding: 2px 5px;
  border-radius: 6px;
}
.lb-close:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* 抖店登录弹层 */
.lg-intro {
  font-size: 12.5px; line-height: 1.65; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; margin-bottom: 14px;
}
.lg-label {
  display: block; font-size: 12px; color: var(--ink-3);
  margin: 0 0 5px 2px; letter-spacing: .02em;
}
.lg-row { display: flex; gap: 8px; margin-bottom: 13px; }
.lg-input {
  flex: 1 1 auto; min-width: 0;
  padding: 9px 11px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink);
  font-family: inherit;
}
.lg-input:focus { outline: 2px solid var(--green-1); outline-offset: -1px; border-color: var(--green-1); }
.lg-input:disabled { background: var(--paper); color: var(--ink-3); }
.lg-row .btn { flex: 0 0 auto; white-space: nowrap; }
.lg-sep { height: 1px; background: var(--line); margin: 14px 0 12px; }
.lg-shops {
  max-height: 240px; overflow-y: auto;
  margin: 4px 0 10px;
  border: 1px solid var(--line); border-radius: 9px;
}
.lg-shops:empty { display: none; }
.lg-shop {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; box-sizing: border-box;
  padding: 9px 12px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink);
  font-family: inherit; font-size: 13px; text-align: left;
  cursor: pointer;
}
.lg-shop:last-child { border-bottom: 0; }
.lg-shop:hover { background: var(--paper); }
.lg-shop.cur { background: #eef4ef; cursor: default; }
.lg-shop.busy { opacity: .55; }
.lg-shop-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-shop-act { flex: 0 0 auto; font-size: 11.5px; color: var(--green-2); }
.lg-shop.cur .lg-shop-act { color: var(--ink-3); }
.lg-status { min-height: 20px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); margin-bottom: 6px; }
.lg-status.ok { color: var(--green-2); }
.lg-status.bad { color: var(--danger); }
.lg-tip { font-size: 11.5px; color: var(--ink-3); }

body.modal-open { overflow: hidden; }

@media (max-width: 640px) {
  /* 按钮跟输入框同一行：独占一行会被看成属于下面的验证码框 */
  .lg-row { flex-wrap: nowrap; }
  .lg-row .btn {
    flex: 0 0 auto;
    padding-left: 10px; padding-right: 10px;
    font-size: 12.5px;
    letter-spacing: -.01em;
  }
  .lg-input { font-size: 16px; } /* 小于 16px 时 iOS 会自动放大页面 */
  .login-bar {
    position: relative; flex-wrap: wrap;
    padding: 10px 12px 11px; gap: 9px;
  }
  /* 手机上按钮独占一行，× 挂到右上角，避免和按钮挤在一起误触 */
  .lb-text { flex: 1 1 100%; padding-right: 34px; }
  .lb-btn { flex: 1 1 100%; }
  .lb-close {
    position: absolute; top: 4px; right: 4px;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; padding: 0;
  }
}

/* 平台抓取：月份选择与进度 */
.fetch-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.fl-label { font-size: 12px; color: var(--ink-3); }
.fl-month { width: 150px; flex: 0 0 auto; }
.fetch-progress {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 10px; background: var(--paper);
}
.fp-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fp-head b { font-size: 13px; color: var(--ink); }
.fp-sub { font-size: 12px; color: var(--ink-3); }
.fp-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 7px; }
.fp-bar i { display: block; height: 100%; background: var(--green-2); transition: width .3s; }
.fp-tip { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.fp-list { display: flex; flex-direction: column; gap: 5px; }
.fp-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.fp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: 0 0 7px; }
.fp-item.ok .fp-dot { background: var(--green-2); }
.fp-item.bad .fp-dot { background: var(--danger); }
.fp-shop { color: var(--ink); font-weight: 500; }
.fp-msg { color: var(--ink-3); }
.fp-item.bad .fp-msg { color: var(--danger); }
.fp-err { margin-top: 7px; font-size: 12px; color: var(--danger); }

@media (max-width: 640px) {
  .fetch-row { gap: 7px; }
  .fl-month { width: 100%; }
  .fetch-row .btn { flex: 1 1 auto; }
}

/* 订单抓取 */
.fl-hint { font-size: 11.5px; color: var(--ink-3); }
.fp-bad { color: var(--danger); }
.order-code {
  border: 1px solid var(--green-2); border-radius: 10px;
  padding: 12px 13px; margin-bottom: 10px; background: #f4f8f5;
}
.oc-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.oc-tip { font-size: 12.5px; color: var(--ink-2); margin-bottom: 9px; line-height: 1.5; }
.oc-tip b { color: var(--ink); }
.oc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.oc-input { width: 150px; letter-spacing: 2px; font-size: 16px; }
.oc-msg { margin-top: 6px; font-size: 12px; color: var(--danger); min-height: 16px; }

@media (max-width: 640px) {
  .oc-row { gap: 7px; }
  .oc-input { width: 100%; }
  .oc-row .btn { flex: 1 1 auto; }
}

/* 今日发货与揽收 */
.feed-box { padding: 2px 0 0; }
.feed-empty { padding: 18px 4px; font-size: 13px; color: var(--ink-3); line-height: 1.7; }
.feed-path { font-size: 11.5px; color: var(--ink-3); word-break: break-all; }
.feed-sum { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.fs-item {
  flex: 1 1 84px; min-width: 84px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.fs-item em { display: block; font-size: 21px; font-weight: 700; font-style: normal; line-height: 1.15; color: var(--ink); }
.fs-item span { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.fs-item.ok em { color: var(--green-2); }
.fs-item.warn em { color: var(--clay); }
.fs-item.bad em { color: var(--danger); }
.feed-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.feed-dot.ok { background: var(--green-2); }
.feed-dot.bad { background: var(--danger); }
.feed-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.feed-table th, .feed-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.feed-table th { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.feed-table td.num, .feed-table th.num { text-align: right; }
.feed-store { font-weight: 500; }
.feed-ok { color: var(--green-2); font-weight: 600; }
.feed-warn { color: var(--clay); font-weight: 600; }
.feed-row-bad td { color: var(--danger); font-size: 12px; }
.feed-row-stale td { background: #fff8e8; }
.feed-mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.feed-prod { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-foot { margin-top: 10px; font-size: 11px; color: var(--ink-3); line-height: 1.6; }
.feed-sub { margin: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--clay); }
.feed-done { margin-top: 10px; padding: 9px 11px; font-size: 12.5px; color: var(--green-2); background: #f2f8f4; border-radius: 8px; }
@media (max-width: 640px) {
  .fs-item { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .fs-item em { font-size: 19px; }
  .feed-prod { max-width: 150px; }
}

/* 店铺登录入口 */
.sl-box { padding: 2px 0 0; }
.sl-sum { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--ink); }
.sl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.sl-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; background: var(--paper); font-size: 12.5px;
}
.sl-item.is-bad { border-color: rgba(188,92,60,.4); background: #faf3f0; }
.sl-name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.sl-dot.ok { background: var(--green-2); }
.sl-state { font-size: 12px; white-space: nowrap; }
.sl-state.ok { color: var(--green-2); font-weight: 600; background: #edf6f0; padding: 2px 8px; border-radius: 6px; }
.sl-state.bad { color: var(--clay); font-weight: 600; background: #f9eeea; padding: 2px 8px; border-radius: 6px; }
.sl-state.off { color: var(--ink-3); }
.sl-actual { font-size: 11px; color: var(--danger); margin-left: 6px; white-space: nowrap; }
.sl-dot.bad { background: var(--danger); }
.sl-dot.off { background: var(--ink-3); }
.sl-login-btn {
  padding: 5px 12px; font-size: 12px; margin: 0; font-weight: 600;
  color: #fff; background: var(--green-2); border: 0; border-radius: 7px;
}
.sl-login-btn:hover { filter: brightness(1.06); }

.sl-modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(20,28,24,.45);
  display: grid; place-items: center; padding: 16px;
}
.sl-modal[hidden] { display: none !important; }
.sl-dialog {
  width: 100%; max-width: 420px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 18px 18px; position: relative;
}
.sl-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; padding-right: 40px; }
.sl-close {
  position: absolute; right: 10px; top: 10px;
  width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1;
  cursor: pointer; margin: 0; padding: 0;
}
.sl-close:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.sl-row { display: flex; gap: 8px; }
.sl-input { flex: 1; min-width: 0; }
.sl-row .btn { flex: 0 0 auto; margin: 0; }
#pddLoginBtn {
  width: 100%; margin-top: 16px; padding: 12px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--green-2); border: 0; border-radius: 10px; cursor: pointer;
}
#pddLoginBtn:disabled { opacity: .6; cursor: default; }
.sl-msg { margin-top: 8px; font-size: 12.5px; color: var(--clay); min-height: 17px; }
.sl-tip { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }
@media (max-width: 640px) {
  .sl-grid { grid-template-columns: 1fr; }
  .sl-row { flex-direction: column; }
  .sl-row .btn { width: 100%; }
}




/* 退货到货：扫码枪常驻输入条 */
.ret-scan-bar {
  display: flex; gap: 10px; align-items: center;
  margin: 4px 0 14px;
}
.ret-scan-bar input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px;
  border: 2px solid var(--green-2); background: #fff;
  font-size: 15px; letter-spacing: 1px; outline: none;
}
.ret-scan-bar input:focus { box-shadow: 0 0 0 3px var(--green-soft); }
.ret-scan-state {
  font-size: 12px; color: var(--green-2, #2f7a58); white-space: nowrap;
  background: var(--green-soft, #e6efe8); border-radius: 8px; padding: 6px 10px;
}
@media (max-width: 480px) {
  .ret-scan-bar { flex-direction: column; align-items: stretch; }
  .ret-scan-state { text-align: center; }
}


.total-row td { border-top: 2px solid var(--line); font-weight: 600; background: var(--paper-2, #f6f4ee); }


/* 375px 窄屏：财务视图卡片强制收缩（追加规则，不改动既有布局模块） */
@media (max-width: 420px) {
  #view-finance .grid2 { grid-template-columns: 1fr; }
  #view-finance .card, #view-finance .erp-layout-module { min-width: 0; max-width: 100%; }
  #view-finance table { min-width: 0; }
}

/* ==================== 联耀式两级导航与内嵌工作面 ==================== */
.shell { grid-template-columns: var(--side-w, 248px) 1fr; }
.side {
  padding: 0;
  gap: 0;
  background: linear-gradient(168deg, #10231a 0%, #173326 68%, #1b3b2d 100%);
  isolation: isolate;
}
.side .brand {
  min-height: 78px;
  padding: 16px 17px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.nav { display: flex; flex-direction: row; gap: 0; padding: 0; }
.nav-rail {
  width: 70px;
  flex: 0 0 70px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 5px 12px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, .07);
  scrollbar-width: none;
}
.nav-rail::-webkit-scrollbar { width: 0; }
.nav-rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 55px;
  padding: 7px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #a9beb2;
  font-family: inherit;
  font-size: 10.5px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-rail-item .rail-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, .055);
  color: #dce9e1;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.nav-rail-item:hover { color: #fff; background: rgba(255, 255, 255, .055); }
.nav-rail-item.on { color: #fff; background: rgba(32, 158, 105, .18); }
.nav-rail-item.on .rail-icon { color: #fff; background: #21865e; }
.nav-panel {
  flex: 1;
  min-width: 0;
  padding: 9px 9px 14px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.np-title {
  padding: 6px 9px 9px;
  color: rgba(216, 231, 222, .43);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .15em;
}
.nav-panel .nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 39px;
  margin: 0 0 2px;
  padding: 8px 10px;
  border: 0;
  border-left: 0;
  border-radius: 7px;
  background: transparent;
  color: #bdcfc4;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.nav-panel .nav-item:hover { color: #fff; background: rgba(255, 255, 255, .065); }
.nav-panel .nav-item.active {
  color: #fff;
  border-left-color: transparent;
  background: linear-gradient(90deg, rgba(33, 134, 94, .78), rgba(33, 134, 94, .30));
  font-weight: 600;
  box-shadow: inset 2px 0 0 #5cd49b;
}
.nav-panel .ni-icon {
  width: 20px;
  flex: 0 0 20px;
  color: #85a795;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.nav-panel .nav-item.active .ni-icon { color: #eafff3; }
.nav-panel .ni-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .side-foot {
  margin-top: auto;
  padding: 11px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.side-resizer {
  position: absolute;
  z-index: 70;
  top: 78px;
  right: -5px;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}
.side-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .12);
  transition: background .15s, box-shadow .15s;
}
.side-resizer::after {
  content: "";
  position: absolute;
  top: 48%;
  left: 2px;
  width: 6px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  transform: translateY(-50%);
  transition: background .15s, box-shadow .15s;
}
.side-resizer:hover::before,
.side-resizer:focus-visible::before,
body.side-resizing .side-resizer::before {
  background: #68aaa3;
  box-shadow: 0 0 0 2px rgba(104, 170, 163, .18);
}
.side-resizer:hover::after,
.side-resizer:focus-visible::after,
body.side-resizing .side-resizer::after {
  background: #8bd0c3;
  box-shadow: 0 0 0 3px rgba(104, 170, 163, .12);
}
body.side-resizing {
  cursor: col-resize;
  user-select: none;
}
body.side-resizing iframe {
  pointer-events: none;
}

.embedded-view.active { display: block; }
.embedded-app {
  display: block;
  width: 100%;
  height: calc(100dvh - 98px);
  min-height: 540px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 8px 30px -24px rgba(21, 34, 28, .45);
}

body[data-view="products"] #monthSel,
body[data-view="products"] #recalcBtn,
body[data-view="packagingCatalog"] #monthSel,
body[data-view="packagingCatalog"] #recalcBtn,
body[data-view="purchase"] #monthSel,
body[data-view="purchase"] #recalcBtn,
body[data-view="suppliers"] #monthSel,
body[data-view="suppliers"] #recalcBtn,
body[data-view="financeRelations"] #monthSel,
body[data-view="financeRelations"] #recalcBtn,
body[data-view="promotion"] #monthSel,
body[data-view="promotion"] #recalcBtn,
body[data-view="misc"] #monthSel,
body[data-view="misc"] #recalcBtn {
  display: none;
}

/* 新增/编辑统一使用联耀式整页表单：保留左侧菜单，编辑区占满右侧 */
.modal {
  left: var(--side-w, 248px);
  right: 0;
  top: 0;
  bottom: 0;
  inset: 0 0 0 var(--side-w, 248px);
  padding: 0;
  place-items: stretch;
  background: var(--paper);
  backdrop-filter: none;
}
.modal.open { display: grid; }
.modal-box {
  width: 100%;
  height: 100dvh;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  box-shadow: none;
}
.modal-hd {
  min-height: 66px;
  padding: 12px 24px;
  box-shadow: 0 1px 0 rgba(21, 34, 28, .04);
}
.modal-hd h3 { font-size: 19px; }
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 36px;
}
#modalForm {
  width: min(1120px, 100%);
  max-width: 100%;
  margin: 0 auto;
}
#modalForm > .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 13px 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
}
.modal-actions {
  position: sticky;
  bottom: -1px;
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper-2) 96%, transparent);
  box-shadow: 0 -8px 24px -20px rgba(21, 34, 28, .45);
  backdrop-filter: blur(8px);
}
@media (max-width: 980px) {
  .modal { left: 0; inset: 0; }
  .modal-hd { padding: 10px 14px; }
  .modal-body { padding: 14px 12px 28px; }
  #modalForm > .row { grid-template-columns: 1fr; padding: 12px; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { width: 280px; }
  .side-resizer { display: none; }
  .embedded-app { height: calc(100dvh - 88px); min-height: 460px; }
}

@media (max-width: 560px) {
  .side { width: min(88vw, 280px); }
  .nav-rail { width: 64px; flex-basis: 64px; }
  .embedded-app { height: calc(100dvh - 78px); min-height: 420px; border-radius: 9px; }
}
