:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --panel-muted: #eef0f3;
  --line: #e6eaf0;
  --text: #20242a;
  --muted: #7b828c;
  --subtle: #a0a7b2;
  --blue: #2f6bff;
  --blue-soft: #edf4ff;
  --teal: #2fc0b2;
  --orange: #ffa62b;
  --red: #ff4d3d;
  --green: #25b45b;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(20, 27, 45, 0.04);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 1024px;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 204px;
  height: 100vh;
  flex: 0 0 204px;
  padding: 24px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #2f6bff 0%, #2fc0b2 100%);
}

.brand strong {
  display: block;
  font-size: 17px;
  line-height: 1.25;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.primary-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 700;
  border-radius: 8px;
  background: var(--blue-soft);
}

.primary-dot {
  width: 6px;
  height: 18px;
  border-radius: 999px;
  background: var(--blue);
}

.sub-menu {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.nav-item {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 26px;
  text-align: left;
  color: #555b66;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.nav-item:hover {
  background: #f2f5fa;
}

.nav-item.is-active {
  color: var(--blue);
  font-weight: 700;
  background: #f1f6ff;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.update-time {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.page-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.page-tabs.is-hidden {
  display: none;
}

.tab-button,
.filter-button,
.segment,
.pill-button {
  height: 36px;
  min-width: 76px;
  padding: 0 18px;
  color: #555b66;
  background: var(--panel-muted);
  border: 1px solid transparent;
  border-radius: 6px;
}

.tab-button.is-active,
.filter-button.is-active,
.pill-button.is-active {
  color: var(--blue);
  font-weight: 700;
  background: #ffffff;
  border-color: var(--blue);
}

.tab-button:disabled {
  cursor: not-allowed;
  color: #b7bec8;
  background: #f1f2f4;
}

.filter-card {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 82px;
  margin-bottom: 22px;
  padding: 20px 24px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.date-filter {
  position: relative;
}

.date-box {
  display: flex;
  align-items: center;
  width: 360px;
  height: 44px;
  padding: 0 14px 0 18px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  background: var(--panel-muted);
  border: 1px solid transparent;
  border-radius: 8px;
}

.date-box:hover,
.date-box:focus-visible,
.date-filter.is-open .date-box {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
  outline: none;
}

.date-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-icon {
  position: relative;
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-left: 14px;
  border: 2px solid #8a919c;
  border-radius: 2px;
}

.date-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: -2px;
  right: -2px;
  height: 2px;
  background: #8a919c;
}

.date-icon::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 3px;
  width: 7px;
  height: 5px;
  border-left: 2px solid #8a919c;
  border-right: 2px solid #8a919c;
}

.date-popover {
  position: absolute;
  z-index: 20;
  top: 56px;
  left: 0;
  width: 760px;
  padding: 0;
  background: #ffffff;
  border: 1px solid #d7dbe2;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(20, 27, 45, 0.14);
}

.date-popover::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 52px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-left: 1px solid #d7dbe2;
  border-top: 1px solid #d7dbe2;
  transform: rotate(45deg);
}

.date-popover.is-hidden {
  display: none;
}

.calendar-panel {
  position: relative;
  overflow: hidden;
  border-radius: inherit;
}

.calendar-header {
  display: grid;
  grid-template-columns: 104px 1fr 104px;
  align-items: center;
  height: 66px;
  border-bottom: 1px solid var(--line);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 18px;
}

.calendar-nav.next {
  justify-content: flex-end;
  padding-right: 18px;
  padding-left: 0;
}

.calendar-nav-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #8a919c;
  font-size: 28px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.calendar-nav-button:hover,
.calendar-nav-button:focus-visible {
  color: var(--blue);
  background: #f1f6ff;
  outline: none;
}

.calendar-title-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  text-align: center;
}

.calendar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  padding: 22px 34px 26px;
}

.calendar-month {
  min-width: 0;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 42px);
  justify-content: space-between;
}

.calendar-weekdays {
  margin-bottom: 16px;
  color: #20242a;
  font-size: 20px;
  font-weight: 600;
}

.calendar-weekdays span {
  text-align: center;
}

.calendar-days {
  row-gap: 12px;
}

.calendar-day {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #20242a;
  font-size: 20px;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.calendar-day.is-muted {
  color: #c0c3c8;
}

.calendar-day.is-in-range {
  background: #edf4ff;
  border-radius: 0;
}

.calendar-day.is-start,
.calendar-day.is-end {
  color: var(--blue);
  background: #ffffff;
  border: 2px solid var(--blue);
  border-radius: 8px;
}

.calendar-day.is-today:not(.is-start):not(.is-end) {
  color: var(--blue);
}

.calendar-day:hover,
.calendar-day:focus-visible {
  color: var(--blue);
  background: #f1f6ff;
  outline: none;
}

.button-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: flex;
  align-items: center;
  width: 160px;
  height: 40px;
  padding: 4px;
  margin-left: auto;
  background: var(--panel-muted);
  border-radius: 8px;
}

.segment {
  width: 76px;
  min-width: 0;
  height: 32px;
  padding: 0;
  border-radius: 6px;
}

.segment.is-active {
  color: var(--blue);
  font-weight: 700;
  background: #ffffff;
}

.section {
  margin-bottom: 24px;
  padding: 24px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.section-title span,
.caption {
  color: var(--muted);
  font-size: 13px;
}

.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.metrics-grid {
  display: grid;
  gap: 16px;
}

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

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

.metric-card {
  display: block;
  width: 100%;
  min-height: 104px;
  padding: 16px 18px;
  text-align: left;
  background: var(--panel-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  appearance: none;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.metric-card:hover {
  border-color: #b8c8ff;
}

.metric-card:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(47, 107, 255, 0.16);
}

.metric-card.is-selected {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #5f6670;
  font-size: 15px;
  line-height: 1.35;
}

.metric-help {
  position: relative;
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  color: #aeb4bd;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  background: #ffffff;
  border: 2px solid #c8cdd4;
  border-radius: 50%;
  cursor: pointer;
}

.metric-help::before,
.metric-help::after {
  position: absolute;
  left: 50%;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.metric-help::before {
  content: "";
  bottom: calc(100% + 4px);
  border: 7px solid transparent;
  border-top-color: #171b20;
}

.metric-help::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 18px);
  width: max-content;
  max-width: 320px;
  padding: 10px 12px;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  background: #171b20;
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(20, 27, 45, 0.18);
}

.metric-help:hover::before,
.metric-help:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.metric-value {
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1.16;
  font-weight: 700;
  letter-spacing: 0;
  word-break: break-all;
}

.metric-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--subtle);
  font-size: 13px;
}

.delta {
  color: var(--red);
  font-weight: 700;
  white-space: nowrap;
}

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

.chart-panel {
  margin-top: 24px;
}

.chart {
  width: 100%;
  height: 280px;
}

.chart.tall {
  height: 360px;
}

.chart.small {
  height: 240px;
}

.checkbox-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5f6670;
  font-size: 13px;
}

.checkbox-list input {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
}

.retention-wrap {
  overflow-x: auto;
  padding-bottom: 2px;
}

.retention-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(130px, 0.85fr) repeat(5, minmax(140px, 1fr));
  width: 100%;
  min-width: 980px;
  align-items: stretch;
}

.retention-cell {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 0 12px;
  border-bottom: 1px solid #edf0f4;
  color: var(--text);
  font-size: 15px;
}

.retention-cell:not(.head):not(.heat) {
  background: #ffffff;
}

.retention-cell.head {
  color: var(--muted);
  font-weight: 700;
  border-bottom-color: transparent;
}

.retention-cell.heat {
  justify-content: center;
  color: #1e5b50;
  font-size: 17px;
  font-weight: 600;
  border-bottom: 0;
}

.sources {
  display: grid;
  gap: 18px;
}

.source-row {
  display: grid;
  grid-template-columns: 90px minmax(180px, 1fr) 92px 72px;
  align-items: center;
  gap: 16px;
  color: var(--text);
  font-size: 14px;
}

.bar-track {
  height: 14px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.order-source-section {
  min-height: 280px;
}

.order-source-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 320px;
  gap: 48px;
  align-items: start;
}

.order-source-bars {
  display: grid;
  gap: 26px;
  padding: 6px 0 0 18px;
}

.order-source-row {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1fr) 120px;
  align-items: center;
  gap: 18px;
  color: var(--text);
  font-size: 14px;
}

.order-source-row strong {
  font-weight: 500;
}

.order-source-table-wrap {
  overflow: hidden;
}

.order-source-table-wrap .order-source-table {
  min-width: 0;
}

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

.profile-card {
  height: 360px;
  padding: 22px;
  background: #fafbfc;
  border-radius: 12px;
  overflow: hidden;
}

.profile-card.wide {
  height: 410px;
}

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profile-head h3 {
  margin: 0;
  font-size: 20px;
}

.view-toggle {
  display: flex;
  gap: 8px;
}

.view-toggle .pill-button {
  min-width: 58px;
  padding: 0 12px;
}

.table-wrap {
  overflow-x: auto;
}

.trade-aligned-table {
  table-layout: fixed;
  min-width: 1040px;
}

.trade-aligned-table .trade-col-primary {
  width: 18%;
}

.trade-aligned-table .trade-col-money {
  width: 17%;
}

.trade-aligned-table .trade-col-order {
  width: 16%;
}

.trade-aligned-table .trade-col-refund {
  width: 17%;
}

.trade-aligned-table .trade-col-refund-order {
  width: 16%;
}

.trade-aligned-table .trade-col-income {
  width: 16%;
}

.trade-aligned-table th:first-child,
.trade-aligned-table td:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trade-aligned-table th:not(:first-child),
.trade-aligned-table td:not(:first-child) {
  text-align: center;
}

.profile-table-wrap {
  height: 278px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.profile-table-wrap .profile-table {
  min-width: 0;
}

.profile-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.profile-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.profile-table-wrap::-webkit-scrollbar-track {
  background: #f0f2f5;
  border-radius: 999px;
}

.profile-table-wrap::-webkit-scrollbar-thumb {
  background: #c4c8cf;
  border: 2px solid #f0f2f5;
  border-radius: 999px;
}

.profile-table-wrap::-webkit-scrollbar-thumb:hover {
  background: #aeb4bd;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  height: 44px;
  padding: 0 14px;
  color: #7b828c;
  font-weight: 700;
  text-align: left;
  background: #f3f5f8;
  border-bottom: 1px solid var(--line);
}

td {
  height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

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

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.search-input {
  width: 260px;
  height: 40px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--blue);
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.page-button {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  color: #555b66;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.page-button.is-active {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.page-button:disabled {
  cursor: not-allowed;
  color: #c4c9d1;
  background: #f5f6f8;
}

.money-negative {
  color: var(--green);
  font-weight: 700;
}

.empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  background: #fafbfc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

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

.mini-chart-card {
  padding: 22px;
  background: #f7f8fa;
  border-radius: 12px;
}

.mini-chart-card h3 {
  margin: 0 0 12px;
  font-size: 20px;
}

.source-colors {
  --source-1: #2f6bff;
  --source-2: #2fc0b2;
  --source-3: #ffa62b;
}

@media (max-width: 1280px) {
  .main {
    padding: 24px;
  }

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

  .filter-card {
    flex-wrap: wrap;
  }

  .segmented {
    margin-left: 0;
  }

  .split-grid,
  .chart-pair,
  .order-source-layout {
    grid-template-columns: 1fr;
  }

  .order-source-row {
    grid-template-columns: 64px minmax(180px, 1fr) 120px;
  }
}
