:root {
  --bg: #080b12;
  --bg-soft: #0d111b;
  --panel: rgba(17, 22, 34, 0.82);
  --panel-solid: #111622;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e8ebf4;
  --muted: #8b94a9;
  --dim: #5f687c;
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #f5b544;
  --pink: #f472b6;
  --red: #fb7185;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --surface-1: rgba(255, 255, 255, 0.025);
  --surface-2: rgba(255, 255, 255, 0.04);
  --surface-3: rgba(255, 255, 255, 0.06);
  --surface-4: rgba(255, 255, 255, 0.09);
  --grid: rgba(255, 255, 255, 0.055);
  --axis: rgba(255, 255, 255, 0.22);
  --topbar: rgba(8, 11, 18, 0.9);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

body[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #eef2f8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.18);
  --text: #111827;
  --muted: #475569;
  --dim: #64748b;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --surface-1: rgba(15, 23, 42, 0.025);
  --surface-2: rgba(15, 23, 42, 0.04);
  --surface-3: rgba(15, 23, 42, 0.06);
  --surface-4: rgba(15, 23, 42, 0.09);
  --grid: rgba(15, 23, 42, 0.1);
  --axis: rgba(15, 23, 42, 0.28);
  --topbar: rgba(248, 250, 252, 0.9);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: clip;
  color-scheme: dark;
}

body {
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(34, 211, 238, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body[data-theme="light"] {
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 92, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(34, 211, 238, 0.07), transparent 55%),
    var(--bg);
  color-scheme: light;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px 40px;
  min-width: 0;
}

/* ------------------------------- 顶栏 ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px 22px;
  flex-wrap: wrap;
  margin: -22px -28px 18px;
  padding: 18px 28px 16px;
  background: var(--topbar);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  order: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
  display: grid;
  place-items: center;
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
  font-weight: 700;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.app-version {
  margin-left: 6px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 500;
}

.toolbar {
  order: 3;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.16s ease;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  background: rgba(124, 92, 255, 0.2);
  color: #cfc4ff;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.35);
}

.segmented.sm button {
  padding: 5px 10px;
  font-size: 12px;
}

.dates {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.dates input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 9px;
  color: var(--text);
  color-scheme: dark;
  font-size: 12px;
}

.dates .arrow {
  color: var(--dim);
}

.actions {
  order: 2;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  min-width: 0;
}

.pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 8px;
  background: #38bdf8;
  color: #06121c;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.pending-badge[hidden] {
  display: none !important;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-1);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}

.pill.live::before {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
}

.pill.demo::before {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 181, 68, 0.16);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-4);
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: linear-gradient(135deg, #7c5cff, #5b8cff);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(91, 118, 255, 0.32);
}

.btn.primary:hover {
  box-shadow: 0 10px 28px rgba(91, 118, 255, 0.42);
}

.btn.ghost {
  background: transparent;
}

.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn.danger {
  color: var(--red);
  border-color: rgba(251, 113, 133, 0.35);
}

.btn.danger:hover {
  background: rgba(251, 113, 133, 0.1);
}

.btn .spin {
  width: 13px;
  height: 13px;
  border: 2px solid var(--axis);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------- 提示条 ------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  margin-bottom: 18px;
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid rgba(245, 181, 68, 0.25);
  background: rgba(245, 181, 68, 0.08);
  color: #f6d79a;
}

.banner.info {
  border-color: rgba(34, 211, 238, 0.22);
  background: rgba(34, 211, 238, 0.07);
  color: #a5ecf7;
}

.banner b {
  color: #fff;
  font-weight: 600;
}

.banner-text {
  flex: 1;
  min-width: 0;
}

.banner .close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
}

/* ------------------------------- KPI ------------------------------- */

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

.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 14px;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 92, 255, 0.55), transparent);
  opacity: 0.6;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi .value {
  margin-top: 7px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}

.kpi .value small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 3px;
}

.kpi .delta {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi .delta .up {
  color: var(--green);
}

.kpi .delta .down {
  color: var(--red);
}

.kpi .delta .flat {
  color: var(--dim);
}

/* ------------------------------- 卡片布局 ------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  min-width: 0;
}

.charts > *,
.bottom > *,
.insights > * {
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 0;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-head .sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.chart-card {
  min-height: 352px;
  display: flex;
  flex-direction: column;
}

.chart {
  flex: 0 0 280px;
  height: 280px;
  min-height: 0;
  padding: 8px 12px 0;
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .axis-text {
  fill: #6b7488;
  font-size: 10px;
  font-family: var(--font);
}

.chart .hover-line {
  stroke: var(--axis);
  stroke-dasharray: 3 4;
}

body[data-theme="light"] .banner {
  color: #92400e;
  background: rgba(245, 181, 68, 0.16);
  border-color: rgba(217, 119, 6, 0.28);
}

body[data-theme="light"] .banner.info {
  color: #0e7490;
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(14, 116, 144, 0.22);
}

body[data-theme="light"] .banner b {
  color: #0f172a;
}

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  box-shadow: var(--shadow);
  min-width: 130px;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s;
  z-index: 5;
}

.chart-tip .tip-day {
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 11px;
}

.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: space-between;
  line-height: 1.7;
}

.chart-tip .tip-row span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cfd5e4;
}

.chart-tip .dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 6px 20px 16px;
  font-size: 11.5px;
  color: var(--muted);
}

.legend .item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.legend .item.off {
  opacity: 0.35;
}

.legend .swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

/* ------------------------------- 漏斗 ------------------------------- */

.funnel-card {
  min-height: 330px;
}

.funnel {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.funnel-row .funnel-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 5px;
}

.funnel-row .funnel-top .step {
  color: #c3cadb;
}

.funnel-row .funnel-top .num {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.funnel-row .funnel-top .num em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
  margin-left: 5px;
  font-size: 11px;
}

.funnel-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.funnel-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c5cff, #22d3ee);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.funnel-empty,
.empty {
  padding: 34px 10px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

/* ------------------------------- 表格 ------------------------------- */

.table-card {
  margin-bottom: 14px;
  overflow: hidden;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
  padding: 6px 6px 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1180px;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: var(--dim);
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel-solid);
  z-index: 1;
}

thead th.num {
  text-align: right;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  color: var(--muted);
}

thead th.sorted {
  color: #b9aaff;
}

thead th.sorted::after {
  content: " ↓";
  font-size: 10px;
}

thead th.sorted.asc::after {
  content: " ↑";
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: rgba(124, 92, 255, 0.06);
}

tbody tr.selected {
  background: rgba(124, 92, 255, 0.1);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.domain-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.domain-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex: none;
}

.domain-cell .host {
  font-weight: 550;
  letter-spacing: 0.1px;
}

.domain-cell .promoter {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  border: 1px solid var(--line);
  color: var(--dim);
  margin-left: 6px;
  vertical-align: 1px;
}

.tag.warn {
  color: #e8b25f;
  border-color: rgba(245, 181, 68, 0.3);
  background: rgba(245, 181, 68, 0.08);
}

.share-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}

.share-bar .track {
  flex: 1;
  height: 5px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.share-bar .track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c5cff, #22d3ee);
}

.share-bar span {
  font-size: 11.5px;
  color: var(--muted);
  width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delta-inline {
  font-size: 10.5px;
  margin-left: 4px;
}

.delta-inline.up {
  color: var(--green);
}

.delta-inline.down {
  color: var(--red);
}

.commission-cell small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

/* ------------------------------- 底部两块 ------------------------------- */

.bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.orders {
  padding: 8px 20px 16px;
}

.order-row {
  display: grid;
  grid-template-columns: 96px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 12.5px;
}

.order-row:last-child {
  border-bottom: 0;
}

.order-row .no {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.order-row .host {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row .status {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.order-row .status.paid {
  color: #7ee0b8;
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.08);
}

.order-row .status.refund {
  color: #f8a9b6;
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.08);
}

.order-row .amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.order-row .amt small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--dim);
  margin-top: 1px;
}

.attribution {
  padding: 14px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attr-row .attr-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

.attr-row .attr-top code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #c9c1ff;
  background: rgba(124, 92, 255, 0.1);
  padding: 1px 6px;
  border-radius: 5px;
}

.attr-row .attr-top span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.attr-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.attr-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #22d3ee);
}

.attr-row.unknown .attr-bar i {
  background: linear-gradient(90deg, #f5b544, #f472b6);
}

.attribution-note {
  margin: 8px 20px 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.7;
}

.attribution-note strong {
  color: var(--muted);
  font-weight: 600;
}

.foot {
  display: flex;
  justify-content: flex-end;
  color: var(--dim);
  font-size: 11.5px;
  padding: 6px 4px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.foot-currency {
  color: var(--muted);
}

/* ------------------------------- 流量来源 / 推广人 ------------------------------- */

.insights {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: start;
}

.source-list {
  padding: 10px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 330px;
  overflow: auto;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 120px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 12.5px;
}

.source-row:last-child {
  border-bottom: 0;
}

.source-row .source-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.source-row .source-name b {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-kind {
  flex: none;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.source-kind.utm {
  color: #c9c1ff;
  border-color: rgba(124, 92, 255, 0.3);
  background: rgba(124, 92, 255, 0.1);
}

.source-kind.referrer {
  color: #8ee7f5;
  border-color: rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.08);
}

.source-kind.direct {
  color: #f3c270;
  border-color: rgba(245, 181, 68, 0.28);
  background: rgba(245, 181, 68, 0.07);
}

.source-row .source-visitors {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.source-row .source-visitors small {
  display: block;
  color: var(--dim);
  font-size: 10.5px;
  white-space: nowrap;
}

.source-row .source-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-row .source-bar .track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.source-row .source-bar .track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c5cff, #22d3ee);
}

.source-row .source-bar span {
  width: 38px;
  text-align: right;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.promoter-list {
  padding: 10px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.promoter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-2);
}

.promoter-row:last-child {
  border-bottom: 0;
}

.promoter-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.promoter-main .avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.85), rgba(34, 211, 238, 0.85));
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex: none;
}

.promoter-main b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.promoter-main small {
  display: block;
  color: var(--dim);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 210px;
}

.promoter-nums {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.promoter-nums b {
  display: block;
  font-size: 12.5px;
}

.promoter-nums small {
  display: block;
  color: var(--dim);
  font-size: 10.5px;
}

.promoter-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.promoter-bar .track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.promoter-bar .track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #22d3ee);
}

.promoter-bar span {
  width: 38px;
  text-align: right;
  font-size: 10px;
  color: var(--dim);
}

.source-empty {
  padding: 30px 10px;
  text-align: center;
  color: var(--dim);
  font-size: 12.5px;
}

/* ------------------------- 纯 API + Webhook（订单归因）模式 ------------------------- */

[data-mode="orders"] .traffic-only {
  display: none !important;
}

[data-mode="orders"] .charts {
  grid-template-columns: minmax(0, 1fr);
}

[data-mode="orders"] .insights {
  grid-template-columns: minmax(0, 1fr);
}

[data-mode="orders"] .kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* ------------------------------- 弹窗 / 登录 ------------------------------- */

dialog {
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--text);
  border-radius: 18px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(4, 6, 11, 0.7);
  backdrop-filter: blur(3px);
}

body[data-theme="light"] dialog {
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.18);
}

body[data-theme="light"] dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialog-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.dialog-card h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.dialog-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.dialog-card input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

.dialog-card input:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16);
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.dialog-actions .spacer {
  flex: 1;
}

/* ------------------------------- 登录 / 注册 ------------------------------- */

[data-role="promoter"] .admin-only {
  display: none !important;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.2px;
}

.boot-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(124, 92, 255, 0.3);
}

.boot-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--axis);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.auth-screen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(124, 92, 255, 0.2), transparent 60%),
    radial-gradient(700px 400px at 90% 100%, rgba(34, 211, 238, 0.12), transparent 55%),
    rgba(5, 7, 12, 0.96);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 20px;
}

body[data-theme="light"] select,
body[data-theme="light"] option {
  background-color: #ffffff;
  color: #111827;
}

body[data-theme="light"] select {
  color-scheme: light;
}

body[data-theme="light"] .auth-screen {
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(124, 92, 255, 0.1), transparent 60%),
    radial-gradient(700px 400px at 90% 100%, rgba(34, 211, 238, 0.08), transparent 55%),
    rgba(244, 246, 251, 0.97);
}

.auth-card {
  position: relative;
  width: min(390px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-tools {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
}

.auth-lang {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}

.auth-lang:hover {
  color: var(--text);
  background: var(--surface-4);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 18px;
}

.auth-brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

body[data-theme="light"] .segmented button.active,
body[data-theme="light"] .auth-tabs button.active {
  background: rgba(124, 92, 255, 0.12);
  color: #5b21b6;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.28);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.auth-tabs button.active {
  background: rgba(124, 92, 255, 0.2);
  color: #d5cbff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.auth-form input,
.user-create input,
.user-create select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

.auth-form input:focus,
.user-create input:focus,
.user-create select:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16);
}

.btn.wide {
  width: 100%;
  justify-content: center;
  margin-top: 2px;
}

.auth-hint,
.auth-demo {
  margin: 0;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.6;
}

.auth-demo {
  text-align: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.auth-demo b {
  color: var(--muted);
  font-weight: 600;
}

.auth-error {
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.auth-ok {
  margin: 0;
  color: #46d39a;
  font-size: 12px;
  line-height: 1.6;
}

/* ------------------------------- 用户 / 团队 ------------------------------- */

.channel-card {
  margin-top: 16px;
}

#channelList {
  padding: 0 20px 18px;
}

.channel-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 72px 190px;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 12px;
}

.channel-row:last-child {
  border-bottom: 0;
}

.channel-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
}

.channel-name i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.channel-track {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.channel-track i {
  display: block;
  height: 100%;
  border-radius: 99px;
}

.channel-share {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.channel-meta {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 620px) {
  #channelList {
    padding: 0 16px 16px;
  }
  .channel-row {
    grid-template-columns: minmax(0, 1fr) 64px;
  }
  .channel-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .channel-meta {
    text-align: left;
    grid-column: 1 / -1;
  }
}

.payout-card {
  margin-top: 16px;
}

.payout-scroll {
  overflow-x: auto;
}

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

.payout-table th,
.payout-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--surface-2);
  text-align: left;
  white-space: nowrap;
}

.payout-table td small {
  display: block;
  color: var(--dim);
  font-size: 10.5px;
}

.payout-table .neg,
.warn-text {
  color: var(--red);
}

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

.payout-self > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

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

.payout-self b {
  font-size: 20px;
}

.payout-self b.neg {
  color: var(--red);
}

.payout-paypal {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.payout-paypal.warn {
  color: var(--red);
}

.payout-history {
  margin-top: 18px;
}

.payout-history h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.payment-row {
  display: grid;
  grid-template-columns: 100px 1.2fr 1.4fr 100px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.payment-row b {
  color: var(--text);
}

.payment-row.self {
  grid-template-columns: 100px 1.4fr 100px 1fr;
}

.payment-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paypal-line {
  display: block;
  margin-top: 2px;
  color: var(--dim);
  font-size: 10.5px;
}

.commission-since {
  display: block;
  margin-top: 3px;
  color: var(--dim);
  font-size: 10px;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .payout-self {
    grid-template-columns: minmax(0, 1fr);
  }
  .payment-row {
    grid-template-columns: 1fr auto;
  }
  .payment-row.self {
    grid-template-columns: 1fr auto;
  }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: 0.16s ease;
}

.user-chip:hover {
  background: var(--surface-4);
}

.user-chip .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: none;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
  min-width: 0;
}

.user-meta b {
  font-size: 12px;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  font-size: 10px;
  color: var(--muted);
}

.store-select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  color: var(--text);
  color-scheme: dark;
  font-size: 12px;
  max-width: 170px;
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.auto-refresh input {
  accent-color: #7c5cff;
}

.store-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.store-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-1);
}

.store-row .store-main {
  min-width: 0;
}

.store-row .store-main b {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-row .store-main span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-row .store-badges {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 3px;
  flex-wrap: wrap;
}

.store-row .badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.store-row .badge.ok {
  color: #7ee0b8;
  border-color: rgba(52, 211, 153, 0.3);
}

.store-row .badge.warn {
  color: #f3c270;
  border-color: rgba(245, 181, 68, 0.3);
}

.store-row .store-ops {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.store-create {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.store-create h3 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

#domainStore {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  color-scheme: dark;
}

dialog#teamDialog {
  width: min(640px, calc(100vw - 32px));
}

dialog#storesDialog {
  width: min(780px, calc(100vw - 32px));
}

.dialog-card.wide {
  max-height: min(82vh, 760px);
  overflow: auto;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-1);
}

.user-row .who {
  min-width: 0;
}

.user-row .who b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row .who span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row .role-badge,
.user-row .state-badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.user-row .role-badge.admin {
  color: #d5cbff;
  border-color: rgba(124, 92, 255, 0.35);
  background: rgba(124, 92, 255, 0.12);
}

.user-row .state-badge.disabled {
  color: #f3c270;
  border-color: rgba(245, 181, 68, 0.3);
  background: rgba(245, 181, 68, 0.08);
}

.user-row .state-badge.pending {
  color: #8fd4ff;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.1);
}

.user-row .ops {
  display: flex;
  gap: 6px;
}

.rate-cell {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.rate-input {
  width: 58px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 6px;
  color: var(--text);
  font-size: 12px;
  text-align: right;
  outline: none;
}

.rate-input:focus {
  border-color: rgba(124, 92, 255, 0.5);
}

.user-create {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-create h3 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

select {
  color-scheme: dark;
}

.owner-select {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  max-width: 150px;
}

.owner-select:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.5);
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 1200px) {
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  [data-mode="orders"] .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app {
    padding: 16px 14px 28px;
  }
  .charts,
  .bottom,
  .insights {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    margin: -16px -14px 14px;
    padding: 14px;
    gap: 10px;
  }
  .brand {
    flex: 1 1 auto;
    margin-right: 0;
  }
  .actions {
    order: 2;
    flex: 1 1 100%;
    margin-left: 0;
    gap: 7px;
  }
  .toolbar {
    order: 3;
    flex: 1 1 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chart {
    flex-basis: 220px;
    height: 220px;
  }
  [data-mode="orders"] .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi .value {
    font-size: 20px;
  }
  .pill {
    display: none;
  }
  .auto-refresh span {
    display: inline;
    font-size: 10px;
  }
  .kpis .kpi:last-child:nth-child(odd) {
    grid-column: span 2;
  }
  .actions .btn {
    padding: 7px 10px;
    font-size: 12px;
  }
  .store-select {
    max-width: 130px;
  }
  .toolbar {
    gap: 8px;
  }
  .dates {
    display: flex;
    flex: 1 1 100%;
  }
  .dates input {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .segmented button {
    padding: 6px 9px;
    font-size: 12px;
  }
  .card-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  .source-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .source-row .source-bar {
    grid-column: 1 / -1;
  }
  .order-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 2px;
  }
  .order-row .host {
    grid-column: 1;
    grid-row: 1;
  }
  .order-row .amt {
    grid-column: 2;
    grid-row: 1;
  }
  .order-row .no {
    grid-column: 1;
    grid-row: 2;
    font-size: 10px;
  }
  .order-row .status {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }
  .foot {
    flex-direction: column;
    gap: 4px;
  }
}
