:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #65727f;
  --line: #dce3e6;
  --brand: #176b67;
  --blue: #2f6fbb;
  --gold: #b6812d;
  --red: #c2413b;
  --green: #20845b;
  --soft: #edf6f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.hidden,
.view {
  display: none !important;
}

.view.active {
  display: block !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(23, 33, 43, 0.08);
}

.app {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 16px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

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

input,
select,
button {
  height: 40px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  min-width: 150px;
  border: 1px solid var(--line);
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

button {
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  height: 36px;
  background: #e8eef1;
  color: #31404c;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

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

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

.kpi {
  padding: 14px;
  min-height: 106px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.1;
}

.kpi em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.up {
  color: var(--green) !important;
}

.down {
  color: var(--red) !important;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2 {
  grid-template-columns: 1.25fr 1fr;
}

.wide {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

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

canvas {
  width: 100%;
  display: block;
}

.issue-list {
  display: grid;
  gap: 10px;
}

.issue {
  border-left: 4px solid var(--gold);
  background: #fff9eb;
  padding: 11px 12px;
  border-radius: 6px;
}

.issue.high {
  border-left-color: var(--red);
  background: #fff1ef;
}

.issue b {
  display: block;
  margin-bottom: 5px;
}

.issue p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.issue small {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf1f3;
  color: #41505c;
  font-size: 12px;
}

.large .issue {
  padding: 14px;
}

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

.metric {
  padding: 14px;
  background: #fbfcfc;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

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

.table-wrap.tall {
  max-height: 680px;
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f3;
  text-align: right;
  white-space: nowrap;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #244b4a;
  color: #fff;
  font-weight: 700;
}

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

.chart-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.chart-card img {
  width: 100%;
  display: block;
}

.chart-card p {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .kpis,
  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app {
    padding: 14px;
  }

  .topbar,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-2,
  .kpis,
  .metric-grid,
  .chart-wall {
    grid-template-columns: 1fr;
  }

  input,
  select,
  button {
    width: 100%;
  }
}
