:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1e2430;
  --muted: #667085;
  --line: #d8dee9;
  --teal: #0f8f82;
  --amber: #bc7a08;
  --rose: #c44764;
  --violet: #6b5ccf;
  --ink: #293241;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(16px, 4vw, 44px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 38px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 22px;
  cursor: pointer;
}

.icon-button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 143, 130, 0.25);
  outline-offset: 2px;
}

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

.metric,
.chart-panel,
.table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 112px;
  padding: 18px;
  border-left-width: 5px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

.accent-teal {
  border-left-color: var(--teal);
}

.accent-amber {
  border-left-color: var(--amber);
}

.accent-rose {
  border-left-color: var(--rose);
}

.accent-violet {
  border-left-color: var(--violet);
}

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 120px;
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  height: 40px;
  border: 1px solid #c7cfda;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

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

.chart-panel,
.table-section {
  padding: 16px;
}

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

.panel-title span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

canvas {
  display: block;
  width: 100%;
  height: 320px;
  border-radius: 6px;
  background: #fbfcfe;
}

.table-section {
  margin-top: 16px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e6ebf2;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6fa;
  color: #3a4556;
  font-size: 12px;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #293241;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  font-size: 14px;
}

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

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

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
  }

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

  canvas {
    height: 280px;
  }
}
