:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #66736f;
  --line: #dce5e2;
  --accent: #168a72;
  --accent-dark: #0d5f51;
  --warn: #b7791f;
  --bad: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  background: #101b19;
  color: #fff;
  padding: 18px 18px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #46635c #101b19;
  transition: width 0.18s ease, padding 0.18s ease;
  flex: 0 0 auto;
  /* 右缘一条分隔线，把侧栏和内容区脱开（2026-10-25 提升可读性） */
  border-right: 1px solid #1d302b;
  box-shadow: 6px 0 18px rgba(9, 20, 18, 0.18);
}
.sidebar-toggle {
  width: 100%;
  height: 34px;
  margin: 0 0 16px;
  border: 1px solid #29423c;
  border-radius: 8px;
  background: #182a26;
  color: #dcebe7;
  cursor: pointer;
  font-weight: 700;
}
.sidebar-toggle:hover { background: #213832; }
.toggle-closed { display: none; }
.sidebar-collapsed .sidebar {
  width: 66px;
  padding: 18px 10px 24px;
}
.sidebar-collapsed .sidebar-toggle {
  height: 42px;
  padding: 0;
  writing-mode: vertical-rl;
}
.sidebar-collapsed .toggle-open { display: none; }
.sidebar-collapsed .toggle-closed { display: inline; }
.sidebar-collapsed .brand,
.sidebar-collapsed nav {
  display: none;
}

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 700;
}
.brand small { display: block; color: #aac2bc; margin-top: 3px; }
.brand-switcher,
.brand-single {
  margin: -14px 0 18px;
  padding: 10px;
  border: 1px solid #29423c;
  border-radius: 8px;
  background: #152521;
}
.brand-switcher label,
.brand-single span {
  display: grid;
  gap: 6px;
  color: #aac2bc;
  font-size: 12px;
  font-weight: 700;
}
.brand-switcher select {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #35564e;
  border-radius: 8px;
  background: #0f1c19;
  color: #fff;
  font-weight: 800;
}
.brand-single strong {
  display: block;
  margin-top: 5px;
  color: #fff;
  font-size: 14px;
}
.sidebar-collapsed .brand-switcher,
.sidebar-collapsed .brand-single {
  display: none;
}
nav { display: grid; gap: 2px; padding-bottom: 18px; }
nav a {
  color: #e4f0ec;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
nav a:hover { background: #1e322d; color: #fff; }
/* 当前页：2026-10-25 加强 —— 原来 #213832 叠在 #101b19 上几乎看不出区别，
   现在用「更亮的青绿底 + 4px 亮色左条 + 白字加粗」，一眼能定位。 */
nav a.active {
  background: linear-gradient(90deg, rgba(22, 138, 114, 0.42) 0%, rgba(22, 138, 114, 0.14) 100%);
  color: #fff;
  font-weight: 800;
  border-left: 4px solid #35d6ad;
  box-shadow: 0 2px 10px rgba(9, 26, 23, 0.45);
}
nav a.sub-nav {
  margin-left: 14px;
  padding: 8px 10px;
  color: #c6dad4;
  font-size: 13px;
}
nav a.sub-nav.active {
  background: rgba(22, 138, 114, 0.3);
  color: #fff;
  border-left: 4px solid #35d6ad;
}

/* 侧栏分组：一级分类可折叠，展开一个收起其它 */
nav details.nav-group { border-radius: 8px; }
nav summary.nav-group-title {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  /* 2026-10-25：分组标题原来 #7e9a93 / 12px，在深底上几乎看不见 →
     提亮 + 加大 + 加一条下分隔线，层级一眼可辨。
     2026-10-25 再调：分组标题是**一级分类**，原来 13px 跟下面的页面条目一样大，
     反而看不出哪级更大 → 提到 15px/900，并让出呼吸空间。 */
  color: #a6c4bd;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #1e322d;
}
nav summary.nav-group-title::-webkit-details-marker { display: none; }
nav summary.nav-group-title:hover { color: #dcefe9; background: #1a2b27; }
/* 展开中的分组：标题更亮，和下面的条目明显分层 */
nav details.nav-group[open] > summary.nav-group-title {
  color: #d6ebe5;
  border-bottom-color: #2a4a42;
}
nav summary.nav-group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
nav summary.nav-group-title::after {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.95;
  transition: transform 0.15s ease;
}
nav details.nav-group[open] > summary.nav-group-title::after { transform: rotate(-135deg); }
nav .nav-group-items { display: grid; gap: 2px; padding: 4px 0 8px; }
nav .nav-children { display: grid; gap: 2px; }
/* 层级递进：一级分类(分组标题) 15px > 一级页面 14px > 二级 13px > 三级 12.5px */
nav a.nav-link { display: block; padding: 9px 12px; font-size: 14px; }
/* 2026-10-25：二级/三级项缩进加大 + 颜色提亮，原来 14px 缩进 + 13px 灰字
   和一级项几乎分不出层级。 */
nav a.nav-link.nav-depth-1 {
  margin-left: 20px;
  padding: 7px 10px;
  color: #c6dad4;
  font-size: 13px;
}
nav a.nav-link.nav-depth-1.active {
  background: rgba(22, 138, 114, 0.3);
  color: #fff;
  font-weight: 800;
  border-left: 4px solid #35d6ad;
}
nav a.nav-link.nav-depth-2 { margin-left: 36px; padding: 6px 10px; font-size: 12.5px; }

/* ------------------------------------------------------------------
   上级分类提示（2026-10-25）
   点进二级/三级分类时，光高亮当前项看不出「我在哪个上级分类下」。
   → 含有当前页的分组标题：亮色 + 左条 + 淡底
   → 含有当前页的上级链接：次级亮色 + 淡左条（比当前页弱一档）
   标记类由 base.html 的 JS 加（has-active / has-active-child）；
   下面两条 :has() 是纯 CSS 兜底，浏览器不支持 :has() 时由 JS 规则生效。
   ------------------------------------------------------------------ */
nav details.nav-group.has-active > summary.nav-group-title,
nav details.nav-group:has(a.active) > summary.nav-group-title {
  color: #8ff0d4;
  background: rgba(22, 138, 114, 0.16);
  box-shadow: inset 3px 0 0 #35d6ad;
  border-bottom-color: #2f5a4f;
}
nav a.nav-link.has-active-child,
nav a.nav-link:has(+ .nav-children a.active) {
  color: #e6f5f1;
  background: rgba(22, 138, 114, 0.12);
  border-left: 3px solid rgba(53, 214, 173, 0.55);
  font-weight: 700;
}
nav a.nav-link.has-active-child:hover,
nav a.nav-link:has(+ .nav-children a.active):hover {
  background: rgba(22, 138, 114, 0.2);
}

.content { flex: 1; padding: 28px; max-width: 1440px; position: relative; }
.page-load-timer {
  position: absolute;
  top: 12px;
  right: 28px;
  z-index: 20;
  min-width: 82px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 14px rgba(15, 38, 34, 0.08);
}
.page-load-timer[data-ready="1"] {
  color: var(--accent-dark);
}
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: #eef4f1;
}
.auth-panel { width: min(440px, calc(100vw - 32px)); }
.auth-brand { color: var(--ink); margin-bottom: 18px; }
.auth-brand small { color: var(--muted); }
.form-grid { display: grid; gap: 14px; }
.form-grid .panel { padding: 18px; }
.error-text { color: var(--bad); font-weight: 700; }
.warning-text { color: #a15c00; font-weight: 700; }
.import-upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.upload-progress {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
}
.upload-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1ebe7;
}
.upload-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #12715b, #36a27f);
  transition: width 160ms ease;
}
.upload-progress .hint {
  margin: 8px 0 0;
}
.upload-progress-log {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.upload-progress-log li:last-child {
  color: var(--ink);
  font-weight: 600;
}
.upload-progress-elapsed {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.upload-progress[data-state="error"] {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff5f5;
}
.upload-progress[data-state="error"] .upload-progress-bar {
  background: var(--bad);
}
.coverage-tree {
  display: grid;
  gap: 10px;
}
.coverage-node,
.coverage-platform {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.coverage-node > summary,
.coverage-platform > summary {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(190px, 1.3fr) repeat(3, minmax(90px, 0.7fr));
  gap: 12px;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
}
.coverage-node > summary::-webkit-details-marker,
.coverage-platform > summary::-webkit-details-marker {
  display: none;
}
.coverage-node > summary::before,
.coverage-platform > summary::before {
  content: "+";
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-dark);
}
.coverage-node > summary,
.coverage-platform > summary {
  grid-template-columns: 24px minmax(140px, 1.5fr) minmax(190px, 1.3fr) repeat(3, minmax(90px, 0.7fr));
}
.coverage-node[open] > summary::before,
.coverage-platform[open] > summary::before {
  content: "-";
}
.coverage-platforms {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}
.coverage-platform {
  background: #f8fbfa;
}
.coverage-platform .wide-table {
  padding: 0 12px 12px;
}
.coverage-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 0 12px 12px;
}
.coverage-pager label {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
}
.coverage-pager select {
  min-width: 76px;
}
.coverage-pager div {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.coverage-pager button {
  padding: 7px 10px;
}
.date-list summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 800;
}
.date-list p {
  max-width: 560px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  white-space: normal;
}
.admin-search-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 240px) auto auto;
  gap: 12px;
  align-items: end;
}
.admin-edit-form {
  display: grid;
  gap: 20px;
}
.admin-edit-section {
  display: grid;
  gap: 12px;
}
.admin-user-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.admin-list-table td span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.button-link:hover { background: var(--accent-dark); }
.muted-link {
  background: #eef4f1;
  color: var(--ink);
}
.muted-link:hover { background: #dce9e5; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 18px; }
p { color: var(--muted); margin: 8px 0 0; }

.filter-bar, .panel, .kpis article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 38, 34, 0.05);
}
.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
  align-items: end;
}
.activity-filter { grid-template-columns: repeat(4, minmax(130px, 1fr)) auto; }
.compact-filter { grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; }
/* 带「区域」筛选的页面多一个字段，列数 +1
   注意：grid-template-columns 里 repeat(auto-fit, ...) 不能和 auto 轨道混用（整条声明会被判非法），
   所以这里用显式列数。 */
.filter-bar:has(.store-scope-select) { grid-template-columns: repeat(6, minmax(140px, 1fr)) auto; }
.filter-bar.compact-filter:has(.store-scope-select) { grid-template-columns: repeat(6, minmax(120px, 1fr)) auto; }
.filter-bar.activity-filter:has(.store-scope-select) { grid-template-columns: repeat(5, minmax(120px, 1fr)) auto; }
/* 区域下拉：范围筛选，和门店下拉区分开 */
.store-scope-select { border-color: #b6d6cc; }
.checkbox-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.checkbox-panel legend {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.checkbox-panel strong { display: block; margin-bottom: 10px; }
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 12px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.check-item input { width: auto; }
.check-item:has(input:checked) {
  border-color: var(--accent);
  background: #e8f2ef;
  color: var(--accent-dark);
  font-weight: 700;
}
.check-item em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
}
/* 带层级的页面勾选列表（我的侧栏 / 用户权限） */
.check-list { display: grid; gap: 6px; }
.check-list .check-item { width: 100%; }
.check-item.check-depth-1 { margin-left: 18px; }
.check-item.check-depth-2 { margin-left: 36px; }
.check-item:has(input:disabled) { opacity: 0.5; }
.cost-category-filter {
  margin: 0;
}
.cost-category-filter .filter-heading {
  margin-bottom: 10px;
}
.cost-category-filter .mini-action {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--accent-dark);
  background: #e8f2ef;
}
.pk-filter {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}
.pk-options {
  grid-column: 1 / -1;
}
.compact-checks {
  max-height: 150px;
  overflow: auto;
}
.pk-up { color: #b42318; font-weight: 700; }
.pk-down { color: #0b7a55; font-weight: 700; }
.pk-flat { color: var(--muted); font-weight: 700; }
.traffic-progress-filter {
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
}
.traffic-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.traffic-chart-card {
  min-width: 0;
}
/* 分时流量页：曝光量级远大于下单/进店（1509 vs 9/40），
   放同一行会挤成竖条 → 第三张（曝光）独占一整行。 */
.traffic-hourly-charts > :nth-child(3) {
  grid-column: 1 / -1;
}
.traffic-hourly-charts > :nth-child(3) .traffic-hourly-chart {
  height: 320px;
}
.traffic-progress-chart {
  height: 340px;
}
.traffic-total-row td {
  background: #f1f8f4;
  font-weight: 700;
}
.kpis em {
  display: block;
  margin-top: 6px;
  font-style: normal;
}
.kpis .kpi-rate-red {
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.table-filter {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.mini-filter-group {
  display: grid;
  gap: 8px;
}
.filter-heading {
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-heading > span {
  color: var(--muted);
  font-weight: 700;
}
.mini-action {
  width: auto;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.filter-options,
.amount-section {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.amount-section {
  width: 100%;
  align-items: flex-start;
}
.amount-section-head {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 112px;
}
.amount-section-head strong {
  color: var(--muted);
  font-size: 12px;
}
.amount-section .filter-options {
  flex: 1;
}
.mini-filter-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}
.mini-filter-group input { width: auto; }
.mini-filter-group em { font-style: normal; font-size: 12px; }
.expandable-row { cursor: pointer; }
.expandable-row td:first-child::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 4px;
  background: #e8f2ef;
  color: var(--accent-dark);
  font-weight: 700;
}
.expandable-row.expanded td:first-child::before { content: "-"; }
.child-row > td {
  background: #f8fbfa;
  padding: 12px 18px;
}
.nested-table {
  background: #fff;
  border: 1px solid var(--line);
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea {
  resize: vertical;
}
button {
  border: 0;
  border-radius: 6px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
.period-controls {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}
.period-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.icon-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  font-size: 18px;
  line-height: 1;
}
.metric-link {
  width: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.metric-link:hover {
  background: transparent;
  color: var(--accent);
}
.table-sort-btn {
  width: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
}
.table-sort-btn:hover {
  background: transparent;
  color: var(--accent-dark);
}
.table-sort-btn::after {
  content: "↕";
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
}
.table-sort-btn.sort-asc::after { content: "↑"; color: var(--accent-dark); }
.table-sort-btn.sort-desc::after { content: "↓"; color: var(--accent-dark); }
.store-group-start td {
  border-top: 2px solid #c9d8d4;
}
.store-group-cell {
  background: #f8fbfa;
  font-weight: 700;
  vertical-align: middle;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpis article { padding: 18px; }
.kpis small { color: var(--muted); }
.kpis strong { display: block; font-size: 26px; margin-top: 8px; }
/* 口径提示徽标：「销售额（折前）/（折后）」等，用于同名不同口径的指标 */
.kpi-hint {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5f8f7;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
}
h2 > .kpi-hint { margin-left: 8px; }
th > .kpi-hint { margin-left: 5px; font-size: 10px; padding: 0 5px; }
.section-note {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.promo-metric-main {
  display: block;
  line-height: 1.25;
}
.promo-metric-delta {
  display: block;
  margin-top: 3px;
  text-align: right;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.promo-delta-up {
  color: var(--bad);
  font-weight: 700;
}
.promo-delta-down {
  color: #0b7a55;
  font-weight: 700;
}
.promo-delta-flat {
  color: var(--muted);
}
.risk-filter {
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
}
.risk-filter .full-row {
  grid-column: 1 / -1;
  margin-top: 0;
}
.risk-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.risk-count-red {
  color: var(--bad);
}
.risk-count-yellow {
  color: var(--warn);
}
.risk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.risk-pill.red {
  background: #fdecea;
  color: var(--bad);
}
.risk-pill.yellow {
  background: #fff4db;
  color: var(--warn);
}
.risk-pill.green {
  background: #e7f5f0;
  color: var(--accent-dark);
}
.risk-pill.muted {
  background: #eef2f1;
  color: var(--muted);
}
.risk-table {
  min-width: 1120px;
}
.risk-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fbfa;
  box-shadow: 0 1px 0 var(--line);
}
.risk-table th,
.risk-table td {
  vertical-align: top;
}
.risk-row-red td {
  background: #fff7f6;
}
.risk-row-yellow td {
  background: #fffbef;
}
.risk-row-muted td {
  color: var(--muted);
}
.risk-table td.risk-hit {
  background: #ffe8e5;
  box-shadow: inset 3px 0 0 #d92d20;
}
.risk-row-yellow td.risk-hit {
  background: #ffece3;
}
.risk-row-muted td.risk-hit {
  background: #fff0ed;
}
.risk-reason {
  min-width: 180px;
  max-width: 260px;
  white-space: normal;
  line-height: 1.45;
}
.risk-reason strong,
.risk-main,
.risk-sub {
  display: block;
}
.risk-reason details {
  margin-top: 6px;
}
.risk-reason summary {
  width: fit-content;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.risk-reason ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
}
.risk-main {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
}
.risk-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.risk-sub.promo-delta-up {
  color: var(--bad);
  font-weight: 700;
}
.risk-sub.promo-delta-down {
  color: #0b7a55;
  font-weight: 700;
}
.risk-sub.promo-delta-flat {
  color: var(--muted);
}
.promo-diagnosis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.diagnosis-list {
  display: grid;
  gap: 10px;
}
.diagnosis-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.diagnosis-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diagnosis-item span {
  align-self: start;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff4db;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}
.diagnosis-item p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}
.clickable-kpi {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.clickable-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 26px rgba(15, 38, 34, 0.12);
}
.platform-trend-panel .dashboard-grid {
  margin-bottom: 0;
}
.platform-trend-panel .wide {
  grid-column: 1 / -1;
}
.selected-row td {
  background: #eef7f4;
}
.muted-text {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.status-bad {
  color: var(--bad);
  font-weight: 700;
}
.platform-shangou,
.platform-meituan {
  display: block;
  font-weight: 700;
  line-height: 1.5;
}
.platform-shangou {
  color: #1d4ed8;
}
.platform-meituan {
  color: #b7791f;
}
.table-action {
  width: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.table-action:hover {
  background: transparent;
  color: var(--accent);
}
.table-action.danger {
  color: var(--bad);
}
.table-action:disabled {
  color: #a5afab;
  cursor: not-allowed;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #edf7f4;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
.status-pill.danger {
  background: #fee2e2;
  color: var(--bad);
}
.inline-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.compact-select {
  min-width: 260px;
  max-width: 360px;
}
.compact-number-form {
  gap: 6px;
}
.compact-number-input {
  width: 86px;
  padding: 6px 8px;
}
.compact-text-input {
  width: 110px;
  padding: 6px 8px;
}
.optional-combined-form {
  min-width: 560px;
}
.optional-detail-dialog {
  width: min(1180px, calc(100vw - 32px));
}
.optional-detail-dialog .modal-card {
  max-height: min(82vh, 860px);
  overflow: auto;
}
.optional-group-block {
  border: 1px solid #dcebe7;
  border-radius: 8px;
  padding: 12px;
  background: #fbfefd;
}
.optional-group-block + .optional-group-block {
  margin-top: 14px;
}
.optional-group-missing {
  border-color: #fecaca;
  background: #fff7f7;
}
.optional-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.optional-group-head h3 {
  margin: 0;
  font-size: 17px;
}
.optional-group-head span {
  color: var(--muted);
  font-weight: 700;
}
.optional-product-detail summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 800;
}
.optional-choice-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.optional-detail-form {
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: #f5faf8;
}
.optional-detail-form strong {
  min-width: 140px;
}
.optional-detail-form.save-ok {
  background: #eefaf3;
  box-shadow: inset 0 0 0 1px #9bd8ad;
}
.optional-detail-form.save-error {
  background: #fff2f2;
  box-shadow: inset 0 0 0 1px #fca5a5;
}
.inline-save-status {
  min-width: 56px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.optional-detail-form.save-ok .inline-save-status {
  color: var(--good);
}
.optional-detail-form.save-error .inline-save-status {
  color: var(--bad);
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-title-row h2 {
  margin-bottom: 0;
}
.panel-title-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.column-order-dialog .modal-card {
  width: min(520px, calc(100vw - 32px));
}
.column-order-dialog .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.column-order-list {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
  max-height: min(55vh, 520px);
  overflow-y: auto;
}
.column-order-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: grab;
}
.column-order-list li.dragging {
  opacity: .45;
}
.column-drag-handle {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: -3px;
}
.column-order-buttons {
  display: flex;
  gap: 5px;
}
.column-order-buttons .table-action {
  min-width: 32px;
  padding: 4px 8px;
}
.column-order-error {
  margin: 0 0 10px;
}
.action-cell {
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
}
.inline-delete-form {
  display: inline;
}
.modal-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 38, 34, 0.28);
}
.modal-dialog::backdrop {
  background: rgba(16, 27, 25, 0.45);
}
.modal-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h2 {
  margin: 0;
}
.modal-head .icon-btn {
  min-width: 34px;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #edf4f2;
  color: var(--ink);
}
.modal-head .icon-btn:hover {
  background: #dcebe7;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.wide-field {
  grid-column: 1 / -1;
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
}
.check-line input {
  width: auto;
}
.form-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 13px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
button.secondary {
  background: #edf4f2;
  color: var(--ink);
}
button.secondary:hover {
  background: #dcebe7;
}
.bundle-workspace {
  margin-bottom: 230px;
}
.bundle-table th:nth-last-child(2),
.bundle-table th:last-child,
.bundle-table td:nth-last-child(2),
.bundle-table td:last-child {
  width: 92px;
  text-align: center;
}
.bundle-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 72px;
  color: var(--ink);
  font-size: 13px;
}
.bundle-check input {
  width: auto;
}
.bundle-qty {
  width: 82px;
  min-width: 82px;
  padding: 8px 9px;
  text-align: center;
}
.truncate-hint {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bundle-float-panel {
  position: fixed;
  right: 24px;
  bottom: 22px;
  z-index: 30;
  width: min(420px, calc(100vw - 48px));
  max-height: min(560px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(80px, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 56px rgba(15, 38, 34, 0.18);
  backdrop-filter: blur(8px);
}
.bundle-float-panel.dragging {
  user-select: none;
  box-shadow: 0 24px 72px rgba(15, 38, 34, 0.24);
}
.bundle-float-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: move;
  touch-action: none;
}
.bundle-float-head strong {
  display: block;
}
.bundle-float-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}
.bundle-float-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bundle-float-head button,
.bundle-group-create button {
  width: auto;
  padding: 8px 12px;
}
.bundle-group-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.bundle-group-create input {
  padding: 8px 10px;
}
.bundle-picked-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}
.bundle-picked-group {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.bundle-picked-group-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 2px 2px 6px;
  border-bottom: 1px solid var(--line);
}
.bundle-picked-group-head small {
  color: var(--muted);
}
.bundle-picked-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e0e9e6;
  border-radius: 8px;
  background: #f8fbfa;
}
.bundle-include-toggle {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.bundle-include-toggle input {
  width: auto;
}
.bundle-picked-main {
  min-width: 0;
}
.bundle-picked-item strong,
.bundle-picked-item small {
  display: block;
}
.bundle-picked-item small {
  margin-top: 4px;
  color: var(--muted);
}
.bundle-group-select {
  margin-top: 7px;
  padding: 7px 9px;
}
.bundle-picked-item dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, auto));
  gap: 8px;
  margin: 0;
}
.bundle-picked-item dl div {
  display: grid;
  gap: 2px;
  text-align: right;
}
.bundle-picked-item dt {
  color: var(--muted);
  font-size: 12px;
}
.bundle-picked-item dd {
  margin: 0;
  font-weight: 700;
}
.bundle-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.bundle-totals span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}
.bundle-totals strong {
  color: var(--ink);
}
.status-pill.muted {
  background: #edf1ef;
  color: var(--muted);
}
.pagination {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 14px;
  color: var(--muted);
}
.pagination a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}
.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
  font-weight: 700;
}
.tab-nav a.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.settings-tab-nav {
  margin-top: -4px;
}
.checkbox-scroll {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.checkbox-scroll label {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
  text-align: left;
}
.checkbox-scroll input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}
.store-option-search {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}
.store-region-select optgroup {
  color: var(--muted);
  font-weight: 800;
}
.store-region-select option {
  color: var(--ink);
  font-weight: 400;
}
.store-region-checks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}
.store-filter-region {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.store-filter-region > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  background: #f3f7f6;
}
.store-region-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.store-region-action {
  width: auto;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #c7d8d3;
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.store-region-action:hover {
  border-color: var(--accent);
  background: #eef8f5;
}
.store-region-action.muted {
  color: var(--muted);
}
.store-filter-region-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  padding: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.detail-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
}
.detail-grid small {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}
.detail-grid strong {
  font-size: 22px;
}
.cost-edit-row {
  display: grid;
  grid-template-columns: 160px minmax(320px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.panel { padding: 18px; margin-bottom: 18px; overflow-x: auto; }
.wide { grid-column: 1 / -1; }
.chart { height: 320px; min-width: 0; }
.chart.small { height: 260px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.store-settings-grid {
  grid-template-columns: minmax(260px, 0.72fr) minmax(560px, 1.28fr);
  align-items: start;
}
.form-panel { display: grid; gap: 14px; align-content: start; }
.tracking-form {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.tracking-form .wide-field {
  grid-column: 1 / -1;
}
.detached-forms {
  display: none;
}
.compact-date-input {
  min-width: 138px;
  padding: 6px 8px;
}
.tracking-title-input {
  min-width: 260px;
}
.tracking-method-input {
  min-width: 220px;
}
.tracking-note-input {
  min-width: 260px;
  min-height: 44px;
  padding: 6px 8px;
}
.muted-row td {
  background: #f8faf9;
  color: var(--muted);
}
.action-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.form-row {
  display: grid;
  grid-template-columns: 180px 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.mapping-form {
  position: sticky;
  top: 12px;
  z-index: 8;
  grid-template-columns: auto 150px minmax(220px, 1fr) minmax(240px, 1fr) auto;
  align-items: end;
}
.mapping-form.is-active {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(18, 113, 91, 0.14);
}
.region-tree {
  display: grid;
  gap: 10px;
}
.region-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  overflow: hidden;
}
.region-node > summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--ink);
  background: #f3f7f6;
}
.region-node > summary span {
  color: var(--muted);
  font-size: 13px;
}
.region-node .wide-table {
  margin: 0;
}
.region-node.compact {
  border: 0;
  background: transparent;
}
.region-node.compact > summary {
  padding: 8px 0;
  background: transparent;
  font-weight: 700;
}
.region-checkbox-scroll {
  display: grid;
  gap: 6px;
  max-height: 520px;
  align-content: start;
}
.region-edit-panel {
  min-width: 0;
}
.region-edit-panel .region-node.compact label {
  width: 100%;
  padding: 6px 4px;
  border-radius: 6px;
  word-break: break-word;
}
.region-edit-panel .region-node.compact label:hover {
  background: #eef6f3;
}
.mapping-form-title {
  align-self: center;
  white-space: nowrap;
}
#raw-products,
#standard-products,
#mappingEditForm {
  scroll-margin-top: 96px;
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(320px, 640px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.product-monitor-setup {
  overflow: visible;
  position: relative;
  z-index: 3;
}
.product-search-field {
  position: relative;
}
.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: min(720px, calc(100vw - 72px));
  max-height: min(520px, 70vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 38, 34, 0.16);
}
.search-result-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
}
.search-result-item:hover {
  background: #e8f2ef;
  color: var(--accent-dark);
}
.search-result-empty {
  padding: 11px;
  color: var(--muted);
}
.action-chips form { display: inline; }
.action-chips button {
  width: auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e8f2ef;
  color: var(--accent-dark);
}
.action-chips button:hover {
  background: var(--accent);
  color: #fff;
}
.product-admin {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.product-category-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(15, 38, 34, 0.05);
}
.product-category-sidebar strong {
  padding: 4px 8px 8px;
}
.product-category-sidebar a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.product-category-sidebar a:hover,
.product-category-sidebar a.active {
  background: #dce9ff;
  color: #1652b8;
}
.product-category-sidebar span {
  color: var(--muted);
  font-size: 12px;
}
.product-admin-main {
  min-width: 0;
}
.product-setup-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}
.product-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(460px, 0.9fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}
.product-search-form {
  display: grid;
  grid-template-columns: 130px minmax(160px, 1fr) auto;
  gap: 10px;
}
.bulk-map-bar {
  display: grid;
  grid-template-columns: auto minmax(240px, 360px) auto auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.bulk-map-bar strong {
  align-self: center;
}
.pagination-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-top: 12px;
  color: var(--muted);
}
.pager-button {
  display: inline-block;
  padding: 7px 11px;
  border-radius: 6px;
  background: #e8f2ef;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}
.pager-button:hover {
  background: var(--accent);
  color: #fff;
}
.pager-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.raw-product-link {
  width: auto;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.raw-product-link:hover {
  background: transparent;
  color: var(--accent-dark);
}
.product-map-table {
  min-width: 1230px;
  table-layout: fixed;
}
.product-map-table .col-check { width: 48px; }
.product-map-table .col-index { width: 64px; }
.product-map-table .col-product { width: 390px; }
.product-map-table .col-platform { width: 86px; }
.product-map-table .col-status { width: 92px; }
.product-map-table .col-category { width: 130px; }
.product-map-table .col-standard { width: 170px; }
.product-map-table .col-number { width: 92px; }
.product-map-table .col-money { width: 126px; }
.product-map-table .col-action { width: 86px; }
.product-map-table th,
.product-map-table td {
  word-break: normal;
  overflow-wrap: anywhere;
}
.product-map-table tr.needs-mapping td {
  background: #fff9ed;
}
.product-map-table tr.is-editing td {
  background: #eaf6f2;
}
.product-status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.product-status-tabs a {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  padding: 7px 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  background: #f7fbf9;
}
.product-status-tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.product-map-table td:nth-child(3),
.product-map-table td:nth-child(4),
.product-map-table td:nth-child(5),
.product-map-table td:nth-child(6),
.product-map-table td:nth-child(7),
.product-map-table td:nth-child(8),
.product-map-table td:nth-child(9),
.product-map-table td:nth-child(10) {
  overflow-wrap: normal;
}
.standard-product-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.1fr) minmax(150px, 0.7fr) 120px minmax(260px, 1.2fr) 150px auto;
  gap: 12px;
  align-items: end;
}
.standard-product-row span {
  color: var(--muted);
  align-self: center;
}
.standard-products-panel summary {
  cursor: pointer;
  font-weight: 800;
  list-style-position: inside;
}
.standard-products-panel h2 {
  margin-top: 14px;
}
.category-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.category-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  overflow: hidden;
}
.category-column header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.category-column small {
  color: var(--muted);
}
.category-products {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px;
}
.category-products span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  font-size: 13px;
}
.category-products em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 13px; background: #f8fbfa; }
.table-scroll {
  max-height: min(68vh, 640px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  scrollbar-gutter: stable;
}
.table-scroll table {
  min-width: max-content;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f8fbfa;
  box-shadow: 0 1px 0 var(--line), 0 4px 10px rgba(15, 38, 34, 0.06);
}
.table-scroll .matrix-table th:first-child,
.table-scroll .matrix-table td:first-child {
  position: sticky;
  left: 0;
}
.table-scroll .matrix-table th:first-child {
  z-index: 8;
}
.table-scroll .matrix-table td:first-child {
  z-index: 3;
}
.table-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}
.sortable-table th {
  cursor: pointer;
}
.sortable-table th .table-sort-btn {
  width: 100%;
  justify-content: flex-start;
}
.table-sort-btn::after {
  content: "↕";
  color: #9aa6a2;
  font-size: 11px;
}
.table-sort-btn.sort-asc::after {
  content: "↑";
  color: var(--accent-dark);
}
.table-sort-btn.sort-desc::after {
  content: "↓";
  color: var(--accent-dark);
}
#storeChannelTable {
  min-width: 1080px;
}
.empty { text-align: center; color: var(--muted); padding: 28px; }
.hint { font-size: 13px; }
.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f5f0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
.status.failed { background: #fdecea; color: var(--bad); }
.status.partial { background: #fff4db; color: var(--warn); }
.status.skipped { background: #edf1ef; color: var(--muted); }
.status.ok { background: #e7f5f0; color: var(--accent-dark); }

/* 分时流量 · 多天区间（2026-11-07）
   背景：每轮采集只覆盖到「当天最后一次采集时刻」，各天长度不一样
   （实测 11-02 采满、11-06 只到 13 点、11-03 整天漏跑）。
   页面必须把「哪天缺、缺到几点」摆在显眼处，否则用户会把
   「没采到」误读成「那天生意差」。 */
.traffic-hourly-rangefacts {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.7;
}
.traffic-hourly-rangefacts code {
  background: #edf1ef;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}
.traffic-hourly-warn {
  margin: 8px 0 0;
  color: var(--warn);
  font-weight: 700;
}
.traffic-hourly-daytoggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 4px;
  font-size: 13px;
}
.traffic-hourly-daytoggle label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  cursor: pointer;
}
/* 逐日明细：日期/星期/已采集不许换行（换行会被读成两行数字） */
.traffic-hourly-daytable td:nth-child(1),
.traffic-hourly-daytable td:nth-child(2),
.traffic-hourly-daytable td:nth-child(3),
.traffic-hourly-daytable th:nth-child(1),
.traffic-hourly-daytable th:nth-child(2),
.traffic-hourly-daytable th:nth-child(3) { white-space: nowrap; }
/* 采集过程明细：时间戳和业务日不换行（换行会被读成两个数） */
.hourly-runs-table td:nth-child(1),
.hourly-runs-table td:nth-child(2),
.hourly-runs-table th:nth-child(1),
.hourly-runs-table th:nth-child(2) { white-space: nowrap; }

/* 手动补跑按钮（2026-11-04） */
.manual-task-list { display: flex; flex-direction: column; gap: 10px; }
.manual-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}
.manual-task-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.manual-task-main strong { font-size: 14px; }
.manual-task-note { color: var(--muted); }
.manual-task .button-link { flex: none; }
.manual-task .button-link:disabled { opacity: .55; cursor: not-allowed; }
.manual-task-message { margin: 10px 0 0; min-height: 18px; }
.manual-task-message.manual-task-ok { color: var(--accent-dark); }
.manual-task-inline .manual-task { padding: 6px 10px; background: transparent; }
.manual-task-inline .manual-task-list { flex-direction: row; gap: 10px; }
.status.manual_required { background: #fff4db; color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips span { background: #e8f2ef; border-radius: 999px; padding: 6px 10px; }
.import-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.import-action-grid form {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.import-action-grid .hint {
  margin: 0;
}
.account-row {
  display: grid;
  grid-template-columns: 110px 1.2fr 1fr 1.5fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.rate-result-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.rate-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.rate-rule-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.rate-rule-card p {
  margin: 8px 0 0;
}
.rate-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.rate-mode-toggle label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--ink);
}
.rate-mode-toggle input {
  width: auto;
}
.wide-table {
  overflow-x: auto;
}
.matrix-table {
  min-width: 1180px;
  table-layout: fixed;
}
.matrix-table th,
.matrix-table td {
  text-align: center;
  padding: 9px 8px;
}
.matrix-table th:first-child,
.matrix-table td:first-child {
  text-align: left;
  width: 96px;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}
.matrix-table th:first-child {
  background: #f8fbfa;
  z-index: 2;
}
.matrix-table td span {
  display: block;
  line-height: 1.35;
}
.daily-metric {
  color: #b42318;
  font-weight: 800;
}
.metric-down {
  color: #b42318;
}
.metric-up {
  color: #12715b;
}

@media (max-width: 900px) {
  body { display: block; }
  .sidebar { width: 100%; height: auto; position: static; overflow-y: visible; }
  .sidebar-toggle { display: none; }
  .sidebar-collapsed .sidebar { width: 100%; padding: 24px 18px; }
  .sidebar-collapsed .brand { display: flex; }
  .sidebar-collapsed nav { display: grid; }
  nav { display: block; padding-bottom: 12px; }
  nav .nav-group-items { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px; }
  .filter-bar, .kpis, .dashboard-grid, .two-col, .form-row, .mapping-form, .inline-form, .account-row, .product-admin, .product-setup-grid, .product-table-head, .product-search-form, .bulk-map-bar, .standard-product-row, .cost-edit-row, .tracking-form, .traffic-chart-grid, .promo-diagnosis-grid, .import-action-grid, .risk-filter, .risk-kpis { grid-template-columns: 1fr; }
  .bundle-workspace { margin-bottom: 330px; }
  .bundle-float-panel {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    max-height: 300px;
  }
  .bundle-picked-item,
  .bundle-totals {
    grid-template-columns: 1fr;
  }
  .bundle-group-create,
  .bundle-picked-group-head {
    grid-template-columns: 1fr;
    display: grid;
  }
  .bundle-picked-item dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pagination-bar { display: grid; }
  .product-category-sidebar { position: static; }
  .coverage-node > summary,
  .coverage-platform > summary {
    grid-template-columns: 24px 1fr;
  }
  .coverage-node > summary span,
  .coverage-platform > summary span {
    grid-column: 2;
  }
  .coverage-pager {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ================= 经营报表诊断（/reports/diagnosis） ================= */
.diagnosis-filter { grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; }
.diagnosis-filter input[type="number"] { width: 100%; }

/* 页内锚点导航 */
.diag-anchor {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 38, 34, 0.06);
}
.diag-anchor a {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7faf9;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.diag-anchor a:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 基准说明条 */
.diag-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(15, 38, 34, 0.05);
}
.diag-banner-main { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.diag-banner-main strong { font-size: 16px; }
.diag-banner-sub { color: var(--muted); font-size: 12.5px; }
.diag-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef6f4;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
.diag-chip.warn { background: #fdf3e3; color: var(--warn); }
.diag-skipped { color: var(--bad); margin-left: 6px; }

/* KPI：6 列 */
.diag-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.diag-kpis article { display: flex; flex-direction: column; }
.diag-kpis strong { font-size: 24px; }
.diag-kpis em { margin-top: 6px; font-style: normal; }

/* 今日判断 */
.diag-judge { border-left: 4px solid var(--accent); }
.finding-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}
.finding-list li {
  position: relative;
  padding: 9px 13px 9px 13px;
  border-radius: 6px;
  background: #f7faf9;
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.7;
}
.finding-list li b { color: var(--ink); }

/* 表格语义 */
.diag-kpis .up, .num .up, .finding-list .up { color: var(--bad); font-weight: 700; }
.diag-kpis .down, .num .down, .finding-list .down { color: #0b7a55; font-weight: 700; }
.diag-kpis .flat, .num .flat { color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
/* ⚠️ 经营报表诊断页：表格内容居中（2026-10-27 用户要求「表格内的数据要居中」）
   改之前：表头左对齐 + 数字右对齐，而 `.table-scroll table { min-width: max-content }`
   会把列撑得很宽 → 表头贴在列的最左、数字贴在列的最右，两者离得很远，看着很乱。
   改之后：表头和数据一起居中，每一列的标题就正对着自己那一列的数。
   ⚠️ 排序按钮是 base.html 的 JS 动态插进 th 的，按钮自身带 `text-align: left`，
      必须一起改；选择器要比 `.sortable-table th .table-sort-btn` 更具体才压得住。 */
.diagnosis-page th,
.diagnosis-page td {
  text-align: center;
}
/* ⚠️ 第一列是**行标识**（分组 / 平台 / 指标 / 商品 / 订单号），不是数据 —— 保持左对齐。
   表头也跟着左对齐，否则「表头左 + 数据居中」又会错开（这正是最初乱的原因）。 */
.diagnosis-page th:first-child,
.diagnosis-page td:first-child {
  text-align: left;
}
.diagnosis-page .sortable-table th .table-sort-btn {
  text-align: center;
}
.diagnosis-page .sortable-table th:first-child .table-sort-btn {
  text-align: left;
}
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12px; }
.row-total td { background: #f7faf9; font-weight: 700; }
.row-holiday td { background: #fffaf0; }
.row-active td { background: #eef6f4; font-weight: 700; }
.diag-trend-chart { height: 360px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: -1px; margin: 0 3px; }
.legend-dot.holiday { background: #d99a3c; }

@media (max-width: 1280px) {
  .diag-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .diag-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diagnosis-filter { grid-template-columns: 1fr; }
}

.diag-warn { color: var(--warn); margin-left: 6px; font-weight: 700; }

/* ---- 签名公开视图（店长日报链接 /r/<token>）----
   店长没有后台账号，侧栏里的「退出登录」「我的侧栏」对他毫无意义；
   内容区占满整屏，手机上少一层缩进。放在文件末尾覆盖前面的同名规则。 */
body.public-view .sidebar { display: none; }
body.public-view .content { max-width: none; padding: 18px 16px 48px; }
body.public-view .page-load-timer { display: none; }
@media (max-width: 640px) {
  body.public-view .content { padding: 12px 12px 40px; }
}
/* ---- 评价与评分：评价治理页 ---- */
.review-filter { grid-template-columns: repeat(6, minmax(130px, 1fr)) auto; }
.check-inline { display: flex; align-items: center; gap: 6px; }
.check-inline input { width: auto; }
.review-kpis .is-alert strong { color: var(--bad); }
.review-kpi-main strong { font-size: 34px; }
.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
  align-items: start;
}
.review-grid .panel { margin-bottom: 0; }
.review-trend-chart { height: 300px; }
.review-dist { list-style: none; margin: 0; padding: 0; }
.review-dist li {
  display: grid;
  grid-template-columns: 48px 1fr 68px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.review-dist-label { color: var(--muted); }
.review-dist-bar {
  display: block;
  height: 10px;
  background: #eef3f1;
  border-radius: 5px;
  overflow: hidden;
}
.review-dist-bar i { display: block; height: 100%; background: #3b6fb6; border-radius: 5px; }
.review-dist-none .review-dist-bar i { background: #b9c6c2; }
.review-dist-value { text-align: right; color: var(--muted); }
.review-table .is-negative { background: #fff6f3; }
.review-table .is-negative td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.review-content { max-width: 380px; white-space: normal; line-height: 1.5; }
.review-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-style: normal;
}
.review-upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.review-upload-list { list-style: none; margin: 8px 0 0; padding: 0; }
.review-upload-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.review-upload-list li.is-error { color: var(--bad); }
.review-upload-list em { color: var(--muted); font-style: normal; }
@media (max-width: 1100px) {
  .review-grid { grid-template-columns: 1fr; }
  .review-filter { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}

/* ---- 经营诊断：评价与评分区块 ---- */
.diag-review-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 4px;
}
.diag-review-overview > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fbfdfc;
}
.diag-review-overview small { color: var(--muted); display: block; }
.diag-review-overview strong { display: block; font-size: 24px; margin-top: 6px; }
.diag-review-overview strong.is-bad { color: var(--bad); }
.diag-review-overview strong span { font-size: 13px; color: var(--muted); margin-left: 3px; }
.diag-review-negative { background: #fff6f3; }
.diag-review-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
}
@media (max-width: 1100px) {
  .diag-review-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- 评价治理：上传校验报告 ---- */
.review-check-panel { border-left: 4px solid #3b6fb6; }
.review-check-list { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.review-check-item {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fbfdfc;
}
.review-check-item.has-error { border-left-color: var(--bad); background: #fff7f4; }
.review-check-item.has-warning { border-left-color: #d9a13c; background: #fffaf0; }
.review-check-item.is-clean { border-left-color: #2f9e6b; }
.review-check-item header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.review-check-flag { font-size: 13px; font-weight: 700; }
.review-check-item.has-error .review-check-flag { color: var(--bad); }
.review-check-item.has-warning .review-check-flag { color: #a9761c; }
.review-check-item.is-clean .review-check-flag { color: #2f9e6b; }
.review-check-errors, .review-check-warnings { margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.review-check-errors li { color: var(--bad); }
.review-check-warnings li { color: #8a6412; }
.review-check-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.review-check-stats b { color: var(--ink); font-weight: 700; }
.review-check-stats b.is-alert { color: var(--bad); }
.review-check-result { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: #2f9e6b; }
.review-check-result.is-error { color: var(--bad); }
.review-check-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.review-check-actions button.muted { background: #eef3f1; color: var(--muted); border-color: var(--line); }
