:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d6dde6;
  --soft-line: #e8edf2;
  --text: #1b2633;
  --muted: #667085;
  --blue: #175cd3;
  --blue-soft: #eaf2ff;
  --red: #b42318;
  --green: #047857;
  --amber: #9a5b06;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

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

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

.topbar p,
.panel-head p,
.panel-head span,
.metric span {
  color: var(--muted);
  font-size: 13px;
}

.topbar p {
  margin-top: 3px;
}

.nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-links a,
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 13px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.nav-links a:hover,
button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: #134fb2;
  color: #fff;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

main {
  padding: 18px 24px 32px;
}

.toolbar,
.summary-grid,
.notice,
.panel {
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  min-width: 210px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  outline: none;
}

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

.metric,
.panel,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric {
  min-height: 88px;
  padding: 12px 14px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  min-height: 25px;
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.notice {
  padding: 11px 14px;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.6;
}

.notice.error {
  color: var(--red);
}

.notice p + p {
  margin-top: 4px;
}

.panel {
  padding: 14px;
}

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

.panel-head p {
  margin-top: 3px;
}

.table-wrap {
  max-height: calc(100vh - 280px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
}

table {
  width: 100%;
  min-width: 850px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  min-width: 120px;
  padding: 9px 11px;
  border-right: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
  text-align: right;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7f9fb;
  color: var(--text);
}

thead th span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.metric-column {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 170px;
  background: #fbfcfd;
  text-align: left;
  font-weight: 700;
}

.metric-column strong {
  display: block;
}

.metric-column span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

thead .metric-column {
  z-index: 4;
  background: #f1f4f7;
}

tbody tr:hover td,
tbody tr:hover th {
  background: #f8fbff;
}

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

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

.empty-row {
  height: 160px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.charts-section {
  margin-bottom: 14px;
}

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

.chart-card {
  min-width: 0;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.chart-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  margin-bottom: 6px;
}

.chart-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.chart-axis-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
}

.chart-legend {
  display: flex;
  align-items: center;
  align-content: flex-start;
  gap: 6px 14px;
  min-height: 39px;
  margin-bottom: 4px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--soft-line);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.chart-legend-key {
  position: relative;
  flex: 0 0 30px;
  width: 30px;
  height: 12px;
}

.chart-legend-line {
  position: absolute;
  top: 5px;
  left: 0;
  width: 30px;
  height: 2px;
  background: var(--series-color);
}

.chart-series-style-1 .chart-legend-line {
  background: repeating-linear-gradient(to right, var(--series-color) 0 7px, transparent 7px 11px);
}

.chart-series-style-2 .chart-legend-line {
  background: repeating-linear-gradient(to right, var(--series-color) 0 2px, transparent 2px 6px);
}

.chart-series-style-3 .chart-legend-line {
  background: repeating-linear-gradient(
    to right,
    var(--series-color) 0 10px,
    transparent 10px 13px,
    var(--series-color) 13px 15px,
    transparent 15px 18px
  );
}

.chart-series-style-4 .chart-legend-line {
  background: repeating-linear-gradient(to right, var(--series-color) 0 12px, transparent 12px 17px);
}

.chart-legend-marker {
  position: absolute;
  top: 2px;
  left: 11px;
  width: 8px;
  height: 8px;
  background: var(--series-color);
}

.marker-circle {
  border-radius: 50%;
}

.marker-triangle {
  width: 10px;
  height: 9px;
  top: 1px;
  left: 10px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.marker-diamond {
  transform: rotate(45deg);
}

.marker-cross {
  background: transparent;
}

.marker-cross::before,
.marker-cross::after {
  position: absolute;
  top: 3px;
  left: -1px;
  width: 10px;
  height: 2px;
  background: var(--series-color);
  content: "";
}

.marker-cross::before {
  transform: rotate(45deg);
}

.marker-cross::after {
  transform: rotate(-45deg);
}

.chart-legend-item em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
}

.chart-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 250px;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -100%);
  pointer-events: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 5px 7px;
  box-shadow: 0 3px 10px rgba(27, 38, 51, 0.12);
  font-size: 11px;
  line-height: 1.4;
  min-width: 150px;
  max-width: min(260px, calc(100% - 16px));
  white-space: pre-line;
}

.charts-empty {
  grid-column: 1 / -1;
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 14px;
  }

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

  .toolbar label {
    flex: 1 1 220px;
  }

  input,
  select {
    width: 100%;
    min-width: 0;
  }

  .table-wrap {
    max-height: none;
  }

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

  .chart-card:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 18px 16px;
  }

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

  .toolbar button {
    flex: 1 1 calc(50% - 5px);
  }

  .metric {
    min-height: 78px;
  }
}
