:root {
  color-scheme: light;
  --ink: #152033;
  --muted: #667085;
  --line: #dde4ee;
  --panel: #ffffff;
  --page: #f5f7fb;
  --blue: #2f6fed;
  --green: #17a673;
  --orange: #f2994a;
  --red: #e55353;
  --purple: #8d5cf6;
  --cyan: #21a7b8;
  --gold: #b88700;
  --shadow: 0 18px 50px rgba(40, 55, 90, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 360px;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.sidebar,
.insights {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.brand,
.panel,
.topbar,
.graph-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 108px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 7px rgba(23, 166, 115, 0.15);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.controls {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--blue);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.check-pill input {
  width: 13px;
  height: 13px;
  accent-color: var(--blue);
}

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

.metric {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

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

.stage {
  display: grid;
  grid-template-rows: auto minmax(540px, 1fr);
  gap: 12px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 16px 18px;
}

.toolbar button {
  min-width: 72px;
  min-height: 36px;
  border-radius: 8px;
  font-weight: 700;
}

.graph-shell {
  overflow: hidden;
  min-height: 540px;
}

.graph {
  width: 100%;
  height: 100%;
  min-height: 540px;
}

.mini-chart,
.bar-chart {
  width: 100%;
  height: 210px;
}

.rank-list {
  display: grid;
  gap: 8px;
  max-height: 328px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 3px;
}

.rank-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
}

.rank-card:hover {
  border-color: #aebddb;
  background: #f9fbff;
}

.rank-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.score {
  flex: 0 0 auto;
  min-width: 34px;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.1);
  color: var(--blue);
  padding: 2px 7px;
  text-align: center;
  font-size: 12px;
}

.rank-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.tag {
  max-width: 100%;
  border-radius: 999px;
  background: #f1f4f9;
  color: #4a5568;
  padding: 3px 7px;
  font-size: 11px;
  line-height: 1.25;
}

.compact {
  max-height: 238px;
}

.focus-panel {
  padding-bottom: 10px;
}

.focus-panel.is-hidden {
  display: none;
}

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

.focus-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 8px;
}

.focus-stat strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.focus-stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.relation-table {
  display: grid;
  gap: 8px;
  max-height: 360px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 3px;
}

.relation-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.relation-row.supplier {
  border-left-color: var(--red);
}

.relation-row.affiliate {
  border-left-color: var(--purple);
}

.relation-row.channel {
  border-left-color: var(--cyan);
}

.relation-row.partner {
  border-left-color: var(--gold);
}

.relation-row header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.relation-row strong {
  font-size: 13px;
  line-height: 1.35;
}

.relation-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.relation-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.relation-badge.supplier {
  background: #fff1f1;
  color: var(--red);
}

.relation-badge.affiliate {
  background: #f4efff;
  color: var(--purple);
}

.relation-badge.channel {
  background: #eaf8fb;
  color: var(--cyan);
}

.relation-badge.partner {
  background: #fff7df;
  color: var(--gold);
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 300px minmax(420px, 1fr);
  }

  .insights {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app,
  .insights {
    grid-template-columns: 1fr;
  }

  .stage {
    grid-template-rows: auto 560px;
  }

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