:root {
  --ink: #17213a;
  --muted: #75809a;
  --line: #e9ecf4;
  --surface: #ffffff;
  --canvas: #f5f6fa;
  --violet: #6957e8;
  --violet-soft: #eeeafd;
  --blue: #4d8ff7;
  --blue-soft: #eaf3ff;
  --orange: #f4a44c;
  --orange-soft: #fff3e4;
  --green: #43b889;
  --green-soft: #e7f8f1;
  --red: #e66979;
  --red-soft: #fff0f2;
  --shadow: 0 12px 32px rgba(39, 45, 78, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 30px 20px;
  background: #fbfbfd;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 12px;
  background: linear-gradient(145deg, #7e6cf0, #5043bd);
  box-shadow: 0 8px 18px rgba(105, 87, 232, 0.24);
  font-weight: 800;
}

.brand strong,
.brand small,
.profile strong,
.profile small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small,
.profile small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.main-nav {
  display: grid;
  gap: 8px;
  margin-top: 48px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #69738e;
  text-decoration: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
  transition: 180ms ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--violet);
  background: var(--violet-soft);
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 18px;
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid #e7e3fa;
  border-radius: 14px;
  background: linear-gradient(145deg, #f3f0ff, #fbfaff);
}

.sidebar-card-label,
.sidebar-card small {
  color: var(--muted);
  font-size: 10px;
}

.sidebar-card strong {
  display: block;
  margin-top: 8px;
  font-size: 15px;
}

.mini-progress {
  height: 5px;
  margin: 14px 0 8px;
  overflow: hidden;
  border-radius: 20px;
  background: #ded9f5;
}

.mini-progress span {
  display: block;
  width: 76.4%;
  height: 100%;
  border-radius: inherit;
  background: var(--violet);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--line);
}

.profile strong {
  font-size: 11px;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--violet);
  background: var(--violet-soft);
  font-size: 11px;
  font-weight: 750;
}

.main-content {
  grid-column: 2;
  min-width: 0;
  padding: 34px 38px 26px;
}

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

.eyebrow,
.panel-kicker {
  margin: 0 0 7px;
  color: var(--violet);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(22px, 2.3vw, 30px);
  letter-spacing: -0.04em;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-picker {
  display: grid;
  gap: 3px;
  min-width: 155px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.date-picker span {
  color: var(--muted);
  font-size: 9px;
}

.date-picker input {
  width: 100%;
  padding: 0;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 650;
}

.primary-button {
  height: 50px;
  padding: 0 18px;
  color: #fff;
  border: 0;
  border-radius: 10px;
  background: var(--violet);
  box-shadow: 0 8px 18px rgba(105, 87, 232, 0.2);
  font-size: 11px;
  font-weight: 700;
  transition: 180ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #5c4bd5;
}

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

.kpi-card,
.panel {
  border: 1px solid rgba(229, 232, 241, 0.85);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 17px 17px 13px;
  border-radius: 14px;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  opacity: 0;
  background: var(--violet);
  transition: opacity 180ms ease;
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-box {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}

.icon-box.violet {
  color: var(--violet);
  background: var(--violet-soft);
}

.icon-box.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.icon-box.orange {
  color: var(--orange);
  background: var(--orange-soft);
}

.icon-box.green {
  color: var(--green);
  background: var(--green-soft);
}

.growth-badge {
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 750;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.growth-badge.positive {
  background: var(--green-soft);
}

.growth-badge.negative {
  background: var(--red-soft);
}

.kpi-card p {
  margin: 15px 0 6px;
  color: var(--muted);
  font-size: 10px;
}

.kpi-card h2 {
  margin-bottom: 5px;
  font-size: clamp(20px, 2vw, 25px);
  letter-spacing: -0.04em;
}

.comparison {
  color: #9aa2b7;
  font-size: 9px;
}

.sparkline {
  height: 34px;
  margin: 8px -5px -4px;
}

.sparkline svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(260px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.lower-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
}

.panel {
  min-width: 0;
  padding: 19px;
  border-radius: 14px;
}

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

.panel-head h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.segmented-control {
  display: flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--canvas);
}

.segmented-control button,
.metric-tabs button,
.text-button {
  border: 0;
  background: transparent;
}

.segmented-control button {
  padding: 5px 9px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 9px;
}

.segmented-control button.active {
  color: var(--violet);
  background: #fff;
  box-shadow: 0 2px 8px rgba(36, 43, 70, 0.08);
  font-weight: 750;
}

.metric-tabs {
  display: flex;
  gap: 5px;
  margin-top: 18px;
}

.metric-tabs button {
  padding: 6px 10px;
  color: var(--muted);
  border-radius: 7px;
  font-size: 9px;
}

.metric-tabs button.active {
  color: var(--violet);
  background: var(--violet-soft);
  font-weight: 750;
}

.chart-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-top: 16px;
}

.chart-summary span,
.goal-stats span,
.forecast span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.chart-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.summary-growth {
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 750;
}

.line-chart-wrap {
  position: relative;
  height: 220px;
  margin-top: 9px;
}

.line-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 7px 9px;
  color: #fff;
  border-radius: 7px;
  background: #282943;
  box-shadow: 0 8px 18px rgba(38, 39, 63, 0.2);
  pointer-events: none;
  white-space: nowrap;
  font-size: 9px;
}

.status-dot,
.health-score {
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 750;
}

.goal-ring-wrap {
  display: grid;
  place-items: center;
  padding: 22px 0 18px;
}

.goal-ring {
  width: 142px;
  height: 142px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--violet) calc(var(--progress) * 1%), #eeedf7 0);
  box-shadow: inset 0 0 0 1px rgba(105, 87, 232, 0.05);
}

.goal-ring-inner {
  width: 108px;
  height: 108px;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 18px rgba(51, 48, 97, 0.08);
}

.goal-ring-inner strong {
  font-size: 22px;
}

.goal-ring-inner span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.goal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.goal-stats div {
  padding: 10px;
  border-radius: 9px;
  background: var(--canvas);
}

.goal-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 11px;
}

.forecast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  padding: 10px;
  border: 1px dashed #dcd8f5;
  border-radius: 9px;
}

.forecast strong {
  color: var(--violet);
  font-size: 9px;
}

.text-button {
  padding: 0;
  color: var(--violet);
  font-size: 9px;
  font-weight: 700;
}

.channel-chart {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.channel-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 70px;
  align-items: center;
  gap: 10px;
}

.channel-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 650;
}

.channel-color {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.channel-track {
  height: 8px;
  overflow: hidden;
  border-radius: 10px;
  background: #f0f1f6;
}

.channel-bar {
  height: 100%;
  border-radius: inherit;
  transform-origin: left;
  animation: growBar 650ms ease both;
}

@keyframes growBar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.channel-value {
  text-align: right;
  font-size: 10px;
  font-weight: 700;
}

.channel-value small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 500;
}

.health-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

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

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

.health-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 750;
}

.health-icon.good {
  color: var(--green);
  background: var(--green-soft);
}

.health-icon.warn {
  color: var(--orange);
  background: var(--orange-soft);
}

.health-row strong,
.health-row small {
  display: block;
}

.health-row strong {
  font-size: 10px;
}

.health-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.health-row b {
  color: var(--green);
  font-size: 9px;
}

.health-row b.warning-text {
  color: var(--orange);
}

.table-panel {
  margin-top: 14px;
}

.segment-panel {
  margin-top: 14px;
}

.segment-hint {
  color: var(--muted);
  font-size: 9px;
}

.segment-target-bar {
  display: flex;
  gap: 3px;
  height: 42px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--canvas);
}

.segment-target-part {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px;
  color: #fff;
}

.segment-target-part strong,
.segment-target-part span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-target-part strong {
  font-size: 9px;
}

.segment-target-part span {
  font-size: 8px;
  opacity: 0.82;
}

.segment-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.segment-card {
  min-width: 0;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  transition: 180ms ease;
}

.segment-card:hover,
.segment-card.selected {
  transform: translateY(-2px);
  border-color: var(--segment-color);
  box-shadow: 0 9px 22px rgba(39, 45, 78, 0.08);
}

.segment-card-top,
.segment-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segment-card-top span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 750;
}

.segment-card-top i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--segment-color);
}

.segment-card-top b {
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--canvas);
  font-size: 8px;
}

.segment-card.done .segment-card-top b {
  color: var(--green);
  background: var(--green-soft);
}

.segment-card.current .segment-card-top b {
  color: var(--violet);
  background: var(--violet-soft);
}

.segment-dates,
.segment-label,
.segment-pace {
  display: block;
  color: var(--muted);
  font-size: 8px;
}

.segment-dates {
  margin-top: 9px;
}

.segment-actual {
  display: block;
  margin-top: 14px;
  font-size: 18px;
}

.segment-label {
  margin-top: 3px;
}

.segment-progress {
  display: block;
  height: 5px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 10px;
  background: #f0f1f6;
}

.segment-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--segment-color);
}

.segment-footer {
  margin-top: 8px;
}

.segment-footer b {
  color: var(--segment-color);
  font-size: 10px;
}

.segment-footer em {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
}

.segment-pace {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.table-legend {
  display: flex;
  gap: 13px;
  color: var(--muted);
  font-size: 8px;
}

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

.table-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.edit-data-button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.table-panel.editing .edit-data-button {
  color: #fff;
  border-color: var(--violet);
  background: var(--violet);
}

.legend-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.positive-dot {
  background: var(--green);
}

.negative-dot {
  background: var(--red);
}

.table-scroll {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 10px;
}

th,
td {
  padding: 11px 9px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  background: #fafafd;
  font-size: 8px;
  font-weight: 700;
}

td {
  color: #4f5870;
}

.total-row td {
  color: var(--ink);
  border-top: 2px solid #ddd9fa;
  border-bottom: 0;
  background: #f8f7ff;
  font-weight: 800;
}

.total-row td:first-child {
  color: var(--violet);
}

.editable-number,
.row-actions {
  display: none;
}

.table-panel.editing .editable-cell .cell-display,
.table-panel.editing .status-display {
  display: none;
}

.table-panel.editing .editable-number {
  display: inline-block;
  width: 92px;
  padding: 6px 7px;
  color: #333a52;
  text-align: right;
  border: 1px solid #dcdfea;
  border-radius: 6px;
  background: #fff;
  outline: none;
  font: inherit;
}

.table-panel.editing .editable-number:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

.table-panel.editing .row-actions {
  display: inline-flex;
  gap: 5px;
}

.row-actions button {
  padding: 5px 7px;
  color: var(--violet);
  border: 1px solid #ded9ff;
  border-radius: 6px;
  background: var(--violet-soft);
  font-size: 8px;
  font-weight: 750;
}

.row-actions button.danger {
  color: var(--red);
  border-color: #ffd9d9;
  background: var(--red-soft);
}

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

.growth-cell {
  display: inline-flex;
  min-width: 52px;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 8px;
  font-weight: 700;
}

.growth-cell.positive {
  background: var(--green-soft);
}

.growth-cell.negative {
  background: var(--red-soft);
}

footer {
  padding-top: 18px;
  color: #9da4b5;
  text-align: center;
  font-size: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 11px 15px;
  color: #fff;
  border-radius: 9px;
  background: #282943;
  box-shadow: 0 10px 26px rgba(34, 35, 58, 0.22);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
  font-size: 10px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .sidebar {
    width: 76px;
    align-items: center;
    padding: 28px 12px;
  }

  .brand > span:last-child,
  .nav-item:not(.active) > :not(.nav-icon),
  .nav-item.active > :not(.nav-icon),
  .sidebar-card,
  .profile > span:last-child {
    display: none;
  }

  .main-nav {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .main-content {
    padding: 28px 24px;
  }
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 13px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand > span:last-child {
    display: block;
  }

  .main-nav {
    display: flex;
    width: auto;
    margin: 0;
  }

  .nav-item {
    display: none;
  }

  .nav-item.active {
    display: flex;
  }

  .profile {
    display: none;
  }

  .main-content {
    padding: 22px 14px;
  }

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

  .header-actions {
    width: 100%;
  }

  .date-picker {
    flex: 1;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 15px;
  }

  .trend-panel .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented-control {
    align-self: flex-start;
  }

  .line-chart-wrap {
    height: 190px;
  }

  .segment-card-grid {
    grid-template-columns: 1fr;
  }

  .table-panel .panel-head,
  .table-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .segment-target-part {
    padding: 0 5px;
  }

  .segment-target-part strong {
    font-size: 7px;
  }

  .segment-target-part span {
    display: none;
  }
}
