:root {
  color-scheme: dark;
  --bg: #06111f;
  --panel: rgba(13, 30, 48, 0.78);
  --line: rgba(89, 205, 255, 0.24);
  --text: #e7f4ff;
  --muted: #91a7b8;
  --cyan: #40d9ff;
  --green: #38d99a;
  --red: #ff5964;
  --gold: #f7c760;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Microsoft YaHei", Arial, sans-serif;
  background: linear-gradient(145deg, #040a13 0%, #071829 48%, #091c28 100%);
  color: var(--text);
}

.topbar, main, footer {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

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

h1, h2, p { margin: 0; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: 0; }
h2 { font-size: 18px; font-weight: 700; }
#updatedAt, .hint { color: var(--muted); margin-top: 8px; font-size: 13px; }

.risk-badge {
  border: 1px solid rgba(247, 199, 96, .4);
  color: var(--gold);
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(247, 199, 96, .08);
  white-space: nowrap;
}

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

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.metric {
  padding: 18px;
  min-height: 120px;
}

.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 28px; font-weight: 760; margin-top: 10px; overflow-wrap: anywhere; }
.metric .desc { color: var(--muted); font-size: 12px; margin-top: 10px; line-height: 1.45; }
.pos { color: var(--red); }
.neg { color: var(--green); }
.neutral { color: var(--cyan); }

.panel {
  padding: 18px;
  margin: 16px 0;
}

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

.range-tabs, .filters, .pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
button, input, select {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border: 1px solid rgba(126, 213, 255, .26);
  border-radius: 8px;
  padding: 8px 10px;
}
button { cursor: pointer; }
button.active, button:hover { border-color: var(--cyan); color: var(--cyan); }
input, select { min-height: 36px; }

.chart { height: 360px; width: 100%; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(126, 213, 255, .13);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
th { color: #b9d8ee; font-weight: 650; background: rgba(255,255,255,.035); }
td { color: #e9f7ff; }
.empty { color: var(--muted); padding: 18px 0 6px; display: none; }
.weight-warn { color: var(--gold); }
.weight-risk { color: var(--red); font-weight: 700; }
.pager { justify-content: flex-end; margin-top: 14px; }

.reason-detail {
  display: none;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(64, 217, 255, .24);
  border-radius: 8px;
  background: rgba(4, 13, 24, .55);
  line-height: 1.65;
}
.reason-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.reason-item strong { color: var(--cyan); display: block; margin-bottom: 4px; }
.health-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.health-item {
  border: 1px solid rgba(126, 213, 255, .18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255,255,255,.035);
}
.health-item .status-ok { color: var(--green); }
.health-item .status-missing { color: var(--gold); }
footer {
  color: var(--muted);
  font-size: 13px;
  padding: 20px 0 28px;
}

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

@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 22px; }
  .metric-grid { grid-template-columns: 1fr; }
  .health-list { grid-template-columns: 1fr; }
  .chart { height: 300px; }
}
