:root {
  --bg: #f6f8fb;
  --panel: #fff;
  --text: #172033;
  --muted: #687386;
  --line: #e6ebf2;
  --blue: #176bff;
  --green: #22c66f;
  --orange: #ffad1f;
  --purple: #8957f6;
  --cyan: #07bfd3;
  --indigo: #6075f7;
  --pink: #fb5c91;
  --yellow: #f4b400;
  --sky: #56b7ff;
  --mint: #55d2b2;
  --shadow: 0 12px 34px rgba(24, 38, 64, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button, select, input {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  align-items: end;
  gap: 3px;
  width: 28px;
  height: 28px;
}

.brand-mark i {
  display: block;
  width: 6px;
  border-radius: 4px;
  background: var(--blue);
}

.brand-mark i:nth-child(1) { height: 12px; opacity: .65; }
.brand-mark i:nth-child(2) { height: 20px; opacity: .85; }
.brand-mark i:nth-child(3) { height: 28px; }

.nav {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  color: #344052;
  border-radius: 6px;
  text-decoration: none;
  cursor: default;
}

.nav a span {
  width: 20px;
  color: #7c8aa0;
  text-align: center;
}

.nav a.active {
  color: var(--blue);
  background: #eaf2ff;
  font-weight: 700;
}

.nav a.active span {
  color: var(--blue);
}

.sync-time {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding: 18px 24px 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.sync-time span {
  font-size: 20px;
}

.sync-time b {
  color: #344052;
  font-weight: 500;
}

.workspace {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.filters, .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter {
  position: relative;
}

.filter span {
  position: absolute;
  left: 14px;
  top: -7px;
  padding: 0 4px;
  background: white;
  color: var(--muted);
  font-size: 11px;
}

select, .actions button, .pager button, .pager input {
  height: 38px;
  border: 1px solid var(--line);
  background: white;
  color: #263246;
  border-radius: 6px;
}

select {
  min-width: 150px;
  padding: 0 36px 0 14px;
}

.actions button {
  padding: 0 12px;
  border-color: transparent;
}

.bell {
  position: relative;
  width: 38px;
}

.bell em {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  color: white;
  background: #ff3030;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  line-height: 18px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: white;
  background: linear-gradient(135deg, #7bb0ff, #4e7de8);
  border-radius: 50%;
}

main {
  padding: 16px 20px 24px;
}

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

.kpi {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 14px 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: none;
  color: white;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 800;
}

.icon.blue { background: linear-gradient(135deg, #4f85ff, #1b62f4); }
.icon.green { background: linear-gradient(135deg, #4ddc87, #0fa95d); }
.icon.orange { background: linear-gradient(135deg, #ffbd3c, #ff9416); }
.icon.purple { background: linear-gradient(135deg, #b46dff, #7847e8); }

.kpi-body {
  min-width: 0;
}

.kpi-body span {
  color: #263246;
  font-size: 14px;
  white-space: nowrap;
}

.kpi-body strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 1.8vw, 28px);
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.kpi-body p {
  display: flex;
  gap: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.kpi-body b {
  font-weight: 500;
}

.up { color: #ff1f1f; }
.down { color: #00aa63; }
.flat { color: var(--muted); }

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(460px, .94fr);
  gap: 18px;
  margin-bottom: 10px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.panel small {
  color: #9aa5b5;
  font-size: 13px;
}

.segmented {
  display: flex;
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-width: 62px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented .selected {
  color: white;
  background: var(--blue);
}

.unit {
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.bar-chart {
  display: grid;
  grid-template-columns: 52px 1fr;
  min-height: 268px;
  padding: 2px 16px 12px;
}

.axis {
  position: relative;
  height: 212px;
  color: var(--muted);
  font-size: 12px;
}

.axis span {
  position: absolute;
  right: 8px;
  transform: translateY(50%);
  white-space: nowrap;
}

.bars {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(42px, 1fr));
  align-items: end;
  gap: 20px;
  height: 212px;
  padding-top: 8px;
  border-bottom: 1px solid #ccd6e3;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 48px, #e9edf3 49px);
}

.bar-item {
  position: relative;
  display: grid;
  justify-items: center;
  align-items: end;
  height: 100%;
}

.bar-value {
  position: absolute;
  bottom: calc(var(--h) + 14px);
  color: #344052;
  font-size: 11px;
  white-space: nowrap;
}

.bar-col {
  width: min(52px, 70%);
  height: var(--h);
  min-height: 4px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c), white 12%), var(--c));
}

.bar-label {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #4a5568;
  font-size: 12px;
  text-align: center;
}

.bar-label b {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: white;
  background: var(--c);
  border-radius: 50%;
  font-size: 11px;
}

.bar-label span {
  max-width: 56px;
  line-height: 1.25;
}

.share-grid {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 0 22px 10px;
}

#shareCanvas {
  width: 100%;
  max-height: 238px;
}

.share-table {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
}

.share-head, .legend-row, .share-total {
  display: grid;
  grid-template-columns: minmax(74px, 1fr) 78px 38px;
  gap: 6px;
  align-items: center;
}

.share-head {
  color: #344052;
  font-weight: 700;
}

.legend-row {
  color: #344052;
}

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

.legend-name i {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
}

.legend-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-total {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.table-panel {
  overflow: hidden;
}

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

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

th, td {
  height: 34px;
  padding: 0 18px;
  border: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: #344052;
  background: #f8fafc;
  font-weight: 700;
}

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

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: white;
  background: var(--c);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.detail-link {
  color: var(--blue);
  font-weight: 700;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  color: #344052;
  font-size: 13px;
}

.pager div {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pager b, .pager button {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 6px;
}

.pager b {
  color: white;
  background: var(--blue);
}

.pager input {
  width: 46px;
  height: 30px;
  text-align: center;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chart-grid, .kpis { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .topbar, .filters, .actions { align-items: stretch; flex-direction: column; height: auto; }
  .topbar { padding: 14px; }
  main { padding: 14px; }
  .kpis, .chart-grid, .share-grid { grid-template-columns: 1fr; }
  .kpi { padding: 16px; }
}
