:root {
  --bg: #111312;
  --panel: #1b1f1d;
  --panel-2: #232823;
  --line: #333b34;
  --text: #f1f4ee;
  --muted: #a7b0a3;
  --green: #55d38a;
  --teal: #39c4c9;
  --amber: #f0b84e;
  --red: #ee6d66;
  --violet: #a98df6;
  --white-soft: rgba(255, 255, 255, 0.08);
  color-scheme: dark;
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background:
    linear-gradient(180deg, rgba(85, 211, 138, 0.07), transparent 280px),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.dashboard {
  width: min(100%, 1920px);
  margin: 0 auto;
  padding: 24px;
}

.portal,
.analysis-page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 42px 24px;
}

.portal-hero {
  min-height: 260px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 42px;
  background:
    radial-gradient(circle at 20% 10%, rgba(85, 211, 138, 0.22), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025));
}

.portal-hero h1 {
  font-size: clamp(36px, 5vw, 64px);
}

.portal-desc {
  max-width: 640px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.portal-card {
  min-height: 260px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.portal-card:hover {
  transform: translateY(-4px);
  border-color: rgba(85, 211, 138, 0.5);
}

.portal-card h2 {
  font-size: 28px;
}

.portal-card p {
  color: var(--muted);
  line-height: 1.75;
}

.portal-card strong {
  color: var(--green);
}

.portal-tag {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: #07130d;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.analysis-card {
  background:
    radial-gradient(circle at 85% 15%, rgba(240, 184, 78, 0.18), transparent 34%),
    var(--panel);
}

.analysis-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.back-link {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.04);
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-total {
  grid-column: 1 / -1;
  min-height: 132px;
  background:
    radial-gradient(circle at 12% 20%, rgba(85, 211, 138, 0.18), transparent 28%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.025));
}

.summary-total .value {
  font-size: clamp(34px, 3vw, 46px);
}

.analysis-card-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.analysis-content {
  display: grid;
  gap: 16px;
  color: #dfe7dc;
  line-height: 1.9;
  font-size: 15px;
}

.analysis-content strong {
  color: var(--green);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.toolbar,
.metric-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.top-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.date-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
}

.date-select {
  height: 32px;
  min-width: 132px;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  color: var(--text);
  background: var(--panel-2);
  outline: none;
}

.filter,
.metric {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.filter.active,
.metric.active {
  color: #07130d;
  background: var(--green);
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
}

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

.kpi .value {
  margin-top: 12px;
  font-size: clamp(24px, 2vw, 34px);
  font-weight: 780;
  line-height: 1;
}

.kpi .sub {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.layout-main {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 14px;
}

.full-span {
  margin-bottom: 14px;
}

.history-panel {
  min-height: 340px;
}

.panel {
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.panel.wide {
  min-height: 300px;
}

.panel.compact {
  min-height: 250px;
}

.funnel-panel {
  min-height: 250px;
}

.trend-panel {
  min-height: 235px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.chart-controls .date-select {
  min-width: 118px;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid rgba(85, 211, 138, 0.35);
  color: var(--green);
  font-size: 12px;
}

canvas {
  display: block;
  width: 100%;
}

#trendChart {
  height: 150px;
}

#dateStoreBar {
  height: 260px;
}

.history-table {
  max-height: 260px;
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th,
.history-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: right;
  white-space: nowrap;
}

.history-table th:first-child,
.history-table td:first-child {
  text-align: left;
  color: var(--text);
}

.history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel-2);
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.funnel {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding-top: 2px;
}

.funnel-step {
  position: relative;
  display: grid;
  align-content: center;
  width: var(--w);
  min-height: 38px;
  padding: 6px 28px;
  clip-path: polygon(7% 0, 93% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, rgba(85, 211, 138, 0.88), rgba(57, 196, 201, 0.82));
  color: #07130d;
  overflow: hidden;
}

.funnel-step:nth-child(2) {
  background: linear-gradient(90deg, rgba(57, 196, 201, 0.86), rgba(240, 184, 78, 0.76));
}

.funnel-step:nth-child(3) {
  background: linear-gradient(90deg, rgba(240, 184, 78, 0.86), rgba(238, 109, 102, 0.72));
}

.funnel-step:nth-child(4) {
  background: linear-gradient(90deg, rgba(238, 109, 102, 0.86), rgba(169, 141, 246, 0.74));
}

.funnel-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
}

.funnel-value {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 740;
}

.roi-list,
.ranking {
  display: grid;
  gap: 10px;
}

.anchor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.anchor-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  min-height: 82px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025));
}

.anchor-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #07130d;
  background: var(--green);
  font-weight: 800;
}

.anchor-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 700;
}

.anchor-shop {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.anchor-foot {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.combo-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.combo-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025));
}

.combo-main {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: center;
}

.combo-anchor,
.combo-product {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.combo-anchor {
  font-weight: 760;
}

.combo-product {
  color: var(--muted);
  font-size: 12px;
}

.combo-pay {
  color: var(--green);
  font-weight: 800;
}

.combo-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.combo-metrics span {
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
}

.roi-item,
.rank-item {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 45px;
}

.rank-item {
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.rank-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.rank-meta,
.roi-value {
  color: var(--muted);
  font-size: 12px;
}

.rank-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--white-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.product .rank-item {
  min-height: 54px;
}

.product-detail {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.product-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025));
}

.product-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.product-name {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  font-size: 13px;
  font-weight: 740;
}

.product-store {
  padding: 4px 7px;
  border-radius: 6px;
  color: #07130d;
  background: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.product-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.product-stat {
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.product-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.product-stat strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.best-anchor {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1280px) {
  body {
    min-width: 0;
  }

  .dashboard {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-controls {
    align-items: flex-start;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout-main {
    grid-template-columns: 1fr;
  }

  .portal-grid,
  .analysis-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .toolbar {
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 26px;
  }
}
