:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #e6ebf2;
  --blue: #176bff;
  --green: #22c66f;
  --orange: #ffad1f;
  --purple: #8957f6;
  --cyan: #07bfd3;
  --pink: #fb5c91;
  --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, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  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-icon { width: 24px; text-align: center; }

.nav {
  display: grid;
  gap: 4px;
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 14px;
  color: #344052;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-align: left;
}

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

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

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

.sync-time {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.main {
  max-height: 100vh;
  overflow-y: auto;
  padding: 16px 20px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

h1, h2, p { margin: 0; }

h1 { font-size: 20px; }
h2 { font-size: 15px; }

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

select,
button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

button:hover,
select:hover { background: #f8fafc; }

.page { display: none; }
.page.active { display: block; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.kpi {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 78px;
  padding: 12px 16px;
}

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 18px;
}

.icon.blue { background: #eaf2ff; color: var(--blue); }
.icon.green { background: #e7f8ee; color: var(--green); }
.icon.orange { background: #fff4e5; color: var(--orange); }
.icon.purple { background: #f3eeff; color: var(--purple); }
.icon.pink { background: #ffeaf2; color: var(--pink); }
.icon.cyan { background: #e5fafe; color: var(--cyan); }

.kpi-body { min-width: 0; }
.kpi-body span {
  color: #263246;
  font-size: 12px;
  white-space: nowrap;
}
.kpi-body strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(18px, 1.6vw, 24px);
  white-space: nowrap;
}
.kpi-body p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.panel { overflow: hidden; }
.panel.mt { margin-top: 12px; }

.panel-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

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

.panel-bd {
  padding: 12px 16px;
  overflow-x: auto;
}

.chart {
  height: 300px;
  padding: 12px 16px 16px;
}

.realtime-panel { margin-bottom: 12px; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line);
}

.metric {
  min-height: 82px;
  padding: 14px 16px;
  background: #fff;
}

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

.metric strong {
  font-size: 22px;
  white-space: nowrap;
}

.bar-list {
  display: grid;
  gap: 10px;
  min-height: 260px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 260px) minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  min-height: 30px;
  font-size: 13px;
}

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

.bar-track {
  height: 14px;
  border-radius: 4px;
  background: #eef2f7;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 4px;
  background: var(--blue);
}

.bar-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap { overflow: auto; }

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

th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:hover { background: #f6f8fb; }

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

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-weight: 700;
}

.status.success { background: #dcfce7; color: #166534; }
.status.failed { background: #fee2e2; color: #991b1b; }
.status.skipped { background: #ffedd5; color: #9a3412; }

svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis {
  stroke: #d5dce7;
  stroke-width: 1;
}

.line-net {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
}

.line-gmv {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { max-height: none; padding: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-value { text-align: left; }
}
