/*
  营销统计页面样式：参考排名详情页的浅色工作台、两行表头和配置弹窗。
*/
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9e2ec;
  --text: #23314d;
  --muted: #72809a;
  --brand: #0086d5;
  --brand-strong: #006faf;
  --brand-soft: #eef6ff;
  --accent-soft: #fff5e8;
  --font-ui: "PingFang SC", "Avenir Next", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-ui);
}

button,
input,
select {
  font: inherit;
}

h1,
h3,
p {
  margin: 0;
}

.page-shell {
  padding: 24px;
}

.detail-topbar,
.panel,
.config-modal {
  border: 1px solid var(--line);
  background: var(--panel);
}

.detail-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 16px;
}

.page-title {
  font-size: 22px;
  line-height: 1.08;
  font-weight: 700;
}

.summary-path {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.section-title--small {
  font-size: 16px;
  line-height: 1.2;
}

.topbar-actions,
.toolbar-section,
.filter-row,
.dimension-row,
.table-panel__subhead,
.table-panel__left,
.table-panel__controls,
.detail-actions,
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid #b8d1ec;
  border-radius: 12px;
  background: #eef6ff;
  color: #155ea6;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: #e3f0ff;
}

.btn-primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-strong);
}

.btn-secondary--compact {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
}

.detail-layout {
  margin-top: 16px;
}

.panel,
.config-modal {
  border-radius: 16px;
  padding: 18px;
}

.workbench-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.workbench-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.toolbar-section--right {
  justify-content: flex-end;
}

.view-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.view-toolbar__config {
  margin-left: auto;
}

.view-path {
  min-width: 0;
  overflow: hidden;
  color: #4f5f76;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-tabs,
.pill-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f6f8fb;
  width: max-content;
  flex: 0 0 auto;
}

.page-tab,
.pill-tab {
  min-height: 38px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.page-tab.active,
.pill-tab.active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  border: 1px solid #cfe0f2;
}

.pill-tabs {
  border-radius: 10px;
}

.pill-tab {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
}

.input {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d8e0ea;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.input--search {
  width: 220px;
}

.input--page-size {
  width: 118px;
}

.filter-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  min-width: 0;
}

.summary-view,
.detail-view {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.filter-row label:first-child {
  min-width: min(520px, 100%);
}

.org-drill,
.table-back-link {
  border: 0;
  background: transparent;
  color: #155ea6;
  font-weight: 600;
  cursor: pointer;
}

.org-drill {
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-back-link {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #b8d1ec;
  border-radius: 999px;
  background: #eef6ff;
}

.row-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.meta-chip,
.permission-badge,
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: #f6f8fb;
}

.meta-chip--main {
  color: var(--brand);
  background: var(--brand-soft);
}

.permission-badge {
  color: #b76d00;
  background: var(--accent-soft);
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.summary-card strong {
  font-size: 22px;
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.context-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #4f5f76;
  font-size: 13px;
}

.context-summary span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding-right: 0;
  border-right: 0;
}

.context-summary--detail {
  width: 100%;
}

.table-wrapper {
  overflow: auto;
  max-height: 58vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  scrollbar-width: thin;
  min-width: 0;
}

.stat-table,
.detail-data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.stat-table {
  min-width: 1180px;
  table-layout: auto;
}

.stat-table th,
.stat-table td,
.detail-data-table th,
.detail-data-table td {
  padding: 12px 14px;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  white-space: nowrap;
}

.stat-table th,
.detail-data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfd;
  color: #607189;
  font-size: 13px;
}

.total-row td {
  background: #fff0e5;
  font-weight: 700;
}

.total-row .sticky-name {
  background: #fff0e5 !important;
}

.total-row .sticky-channel {
  background: #fff0e5 !important;
}

.stat-table .head-group th {
  top: 0;
  z-index: 4;
  height: 44px;
  text-align: center;
  background: #f6f9fc;
  font-weight: 700;
}

.stat-table .head-business th {
  top: 44px;
  z-index: 3;
  height: 54px;
  background: #fbfcfe;
  text-align: center;
}

.sticky-name {
  position: sticky !important;
  left: 0;
  z-index: 5 !important;
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  background: #fff !important;
  font-weight: 700;
}

.sticky-channel {
  position: sticky !important;
  left: 240px;
  z-index: 5 !important;
  width: 110px;
  min-width: 110px;
  max-width: 110px;
  background: #fff !important;
  text-align: center !important;
}

.stat-table th:not(.sticky-name):not(.sticky-channel),
.stat-table td:not(.sticky-name):not(.sticky-channel) {
  width: 118px;
  min-width: 118px;
  text-align: center;
}

.head-group .sticky-name {
  z-index: 7 !important;
  background: #f6f9fc !important;
}

.head-group .sticky-channel {
  z-index: 7 !important;
  background: #f6f9fc !important;
}

.stat-value {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.stat-value:hover {
  text-decoration: underline;
}

.row-muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.sticky-head-main {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.scope-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid #cfe0f2;
  border-radius: 999px;
  background: #eef6ff;
}

.scope-switch button {
  min-height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4f6b8c;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.scope-switch button.active {
  background: #fff;
  color: var(--brand);
}

.channel-filter {
  width: 100%;
  min-height: 30px;
  border: 1px solid #cfe0f2;
  border-radius: 8px;
  background: #fff;
  color: #607189;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.business-head-cell {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.detail-head-cell {
  display: grid;
  gap: 6px;
  justify-items: stretch;
}

.field-title-row,
.sticky-title-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.head-search-input {
  width: 100%;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid #d8e0ea;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.head-tool {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #155ea6;
  cursor: pointer;
}

.head-tool:hover {
  background: #eef6ff;
}

.head-tool.active {
  background: #eef6ff;
  color: var(--brand);
}

.icon-sort {
  position: relative;
  width: 12px;
  height: 15px;
}

.icon-sort::before,
.icon-sort::after {
  position: absolute;
  left: 2px;
  width: 0;
  height: 0;
  content: "";
}

.icon-sort::before {
  top: 1px;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  border-left: 4px solid transparent;
}

.icon-sort::after {
  bottom: 1px;
  border-top: 5px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}



.empty-state-cell {
  background: #fff !important;
  text-align: center !important;
}

.table-empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 42px 12px;
  color: var(--muted);
}

.table-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip button {
  margin-left: 6px;
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
}

.pager {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.is-hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(15, 23, 42, 0.24);
  z-index: 20;
}

.overlay--open {
  display: block;
}

.config-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  display: none;
  width: min(780px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  transform: translate(-50%, -50%);
  z-index: 21;
}

.config-modal--open {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.config-modal__head,
.config-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.config-modal__body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  min-height: 360px;
  overflow: hidden;
}

.config-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.config-column__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 2px;
}

.config-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.config-item.active {
  color: var(--brand);
  border-color: #b8d1ec;
  background: #eef6ff;
}

.link-clear,
.close-icon {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
}

.close-icon {
  font-size: 22px;
}



@media (max-width: 900px) {
  .page-shell {
    padding: 12px;
  }

  .detail-topbar,
  .workbench-toolbar {
    display: grid;
  }

  .summary-cards,
  .config-modal__body,
  .compare-modal__body {
    grid-template-columns: 1fr;
  }

  .guide-popover {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    width: auto;
  }
}

.guide-overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(16, 24, 40, 0.28);
  z-index: 90;
}

.guide-overlay--open {
  display: block;
}

.guide-target-active {
  position: relative;
  z-index: 91 !important;
  border-radius: 14px;
  box-shadow:
    0 0 0 3px rgba(0, 134, 213, 0.18),
    0 16px 36px rgba(18, 38, 63, 0.18);
}

.guide-popover {
  position: fixed;
  top: 120px;
  right: 24px;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: none;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 48px rgba(24, 37, 57, 0.16);
  z-index: 92;
  overflow: auto;
}

.guide-popover--open {
  display: grid;
}

.guide-popover__head,
.guide-popover__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.guide-popover__body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  display: grid;
  gap: 8px;
}

.guide-popover__body p {
  margin: 0;
}

.guide-popover__body ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.guide-popover__body li {
  margin: 0;
}

.guide-popover__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
