:root {
  --bg: #050a16;
  --bg-soft: #0a1428;
  --panel: rgba(12, 24, 46, 0.72);
  --panel-line: rgba(72, 170, 255, 0.16);
  --cyan: #22d3ee;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --green: #26e0a3;
  --amber: #ffb020;
  --red: #ff5d73;
  --text: #e6f1ff;
  --muted: #7f97b8;
  --dim: #4c6484;
  --mono: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(60, 130, 220, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 130, 220, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 620px; height: 620px; left: -160px; top: -220px; background: rgba(34, 211, 238, 0.20); }
.glow-b { width: 720px; height: 720px; right: -220px; bottom: -320px; background: rgba(139, 92, 246, 0.18); }

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 18px 8px;
}

/* ---------------- header ---------------- */
.topbar {
  height: 68px;
  flex: 0 0 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: #03121f;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--purple));
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.45);
}

.brand-text h1 {
  font-size: 22px;
  letter-spacing: 3px;
  font-weight: 600;
  background: linear-gradient(90deg, #eaf6ff, #8fd8ff 60%, #b39bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p { font-size: 11px; color: var(--dim); letter-spacing: 1.6px; margin-top: 3px; }

.statusbar { display: flex; align-items: center; gap: 10px; font-family: var(--mono); }

.daterange {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--panel-line);
  background: rgba(18, 36, 64, 0.6);
  border-radius: 7px;
}
.daterange .tilde { color: var(--dim); font-size: 11px; }
.daterange input[type="date"] {
  background: transparent;
  border: 0;
  color: #9fc4e8;
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 2px;
  outline: none;
  color-scheme: dark;
  width: 122px;
}
.daterange input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(1) saturate(3) hue-rotate(160deg);
  cursor: pointer;
  opacity: 0.8;
}

.presets { display: flex; gap: 4px; }
.presets button {
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 11.5px;
  color: #8fb4d8;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid rgba(72, 170, 255, 0.16);
  background: rgba(18, 36, 64, 0.45);
  cursor: pointer;
  transition: all 0.15s;
}
.presets button:hover { color: var(--cyan); border-color: rgba(34, 211, 238, 0.45); }
.presets button.active {
  color: #04121f;
  background: linear-gradient(135deg, #37e0ff, #3b82f6);
  border-color: transparent;
}

.tag {
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: #9fc4e8;
  padding: 5px 11px;
  border: 1px solid var(--panel-line);
  background: rgba(18, 36, 64, 0.6);
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.tag.warn { color: var(--amber); border-color: rgba(255, 176, 32, 0.4); }

.live {
  display: flex; align-items: center; gap: 7px;
  font-size: 15px; color: #b9d9f5; letter-spacing: 1px;
}
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.btn {
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 12.5px;
  color: #061421;
  padding: 7px 16px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  background: linear-gradient(135deg, #37e0ff, #3b82f6);
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.45);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 26px rgba(59, 130, 246, 0.65); }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; }

/* ---------------- layout ---------------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr) 408px;
  gap: 14px;
}

.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; min-width: 0; }

.panel {
  position: relative;
  background: linear-gradient(160deg, rgba(16, 32, 58, 0.86), rgba(8, 17, 33, 0.78));
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 32px rgba(28, 88, 160, 0.10), 0 10px 26px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid rgba(34, 211, 238, 0.55);
  pointer-events: none;
}
.panel::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; border-radius: 3px 0 0 0; }
.panel::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; border-radius: 0 0 3px 0; }

.panel-title {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: #cfe6ff;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-left: 10px;
  position: relative;
  margin-bottom: 8px;
}
.panel-title::before {
  content: "";
  position: absolute; left: 0; top: 3px;
  width: 3px; height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--purple));
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
}
.panel-title small { font-size: 10.5px; font-weight: 400; color: var(--dim); letter-spacing: 0.6px; }
.panel-title .as-of {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 400;
  color: #7aa3cc;
  letter-spacing: 0.3px;
  font-family: "Bahnschrift", "Consolas", monospace;
}
.panel-title .as-of::before { content: "截至 "; color: #5a7d9f; font-family: inherit; }

.panel-gauge { flex: 0 0 268px; }
.chart { flex: 1 1 auto; min-height: 0; width: 100%; }
.chart-gauge { flex: 1 1 auto; margin-top: -12px; }

/* ---------------- gauge meta ---------------- */
.gauge-meta {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: -8px; padding-bottom: 4px;
}
.state-pill {
  font-size: 13px; padding: 3px 12px; border-radius: 20px;
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
}
.delta { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }

/* ---------------- overheat ---------------- */
.overheat { flex: 0 0 auto; }
.overheat-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 9px;
}
.overheat-head b { font-family: var(--mono); font-size: 30px; line-height: 1; color: var(--amber); text-shadow: 0 0 18px rgba(255, 176, 32, 0.45); }
.overheat-head span { font-size: 12.5px; color: var(--muted); }

.meter {
  position: relative;
  height: 12px;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(38, 224, 163, 0.18), rgba(255, 176, 32, 0.16), rgba(255, 93, 115, 0.18));
  overflow: hidden;
  border: 1px solid rgba(120, 170, 220, 0.14);
}
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 7px;
  background: linear-gradient(90deg, #26e0a3, #ffb020 62%, #ff5d73);
  box-shadow: 0 0 14px rgba(255, 176, 32, 0.5);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.meter i {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(10, 20, 38, 0.75);
}
.meter-scale {
  display: flex; justify-content: space-between;
  margin-top: 4px; font-family: var(--mono); font-size: 9.5px; color: var(--dim);
}

.mini-stats {
  margin-top: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
  padding-top: 12px;
}
.mini-stats div {
  background: rgba(18, 38, 68, 0.5);
  border: 1px solid rgba(70, 150, 230, 0.12);
  border-radius: 7px;
  padding: 8px 10px;
}
.mini-stats dt { font-size: 10.5px; color: var(--dim); letter-spacing: 0.5px; }
.mini-stats dd { font-size: 13px; color: #cfe6ff; margin-top: 4px; font-weight: 600; }
.mini-stats div:last-child { grid-column: span 2; }

/* ---------------- breadth ---------------- */
.panel-breadth { flex: 1 1 auto; }
.breadth { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; }
.breadth-bar {
  height: 14px; border-radius: 7px; overflow: hidden; display: flex;
  background: rgba(20, 38, 64, 0.8);
  border: 1px solid rgba(100, 160, 230, 0.14);
}
.breadth-bar span { height: 100%; transition: width 0.7s ease; }
.bar-up { background: linear-gradient(90deg, #ff6b81, #ff3d55); box-shadow: 0 0 12px rgba(255, 61, 85, 0.4); }
.bar-down { background: linear-gradient(90deg, #1fbf8a, #12936a); }
.breadth-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.breadth-legend b { font-family: var(--mono); font-size: 14px; color: var(--text); margin-left: 4px; }
.dot-up, .dot-down { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.dot-up { background: #ff4d63; }
.dot-down { background: #16a97b; }

.limit-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.limit-row div {
  background: rgba(18, 38, 68, 0.5);
  border: 1px solid rgba(70, 150, 230, 0.12);
  border-radius: 7px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.limit-row span { font-size: 10.5px; color: var(--dim); }
.limit-row b { font-family: var(--mono); font-size: 17px; color: #d7ecff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; overflow: hidden; }
.chips span {
  font-size: 11px; color: #9ec6ec;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(34, 211, 238, 0.07);
  border: 1px solid rgba(34, 211, 238, 0.18);
}
.chips span b { color: var(--cyan); font-family: var(--mono); margin-left: 3px; }

/* ---------------- kpis ---------------- */
.kpis-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: #cfe6ff;
  padding-left: 10px;
  margin-bottom: 6px;
  position: relative;
}
.kpis-head::before {
  content: "";
  position: absolute; left: 0; top: 3px;
  width: 3px; height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--purple));
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
}
.kpis-head .as-of {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 400;
  color: #7aa3cc;
  letter-spacing: 0.3px;
  font-family: "Bahnschrift", "Consolas", monospace;
}
.kpis-head .as-of::before { content: "截至 "; color: #5a7d9f; }
.kpis { flex: 0 0 92px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi {
  position: relative;
  border-radius: 10px;
  padding: 12px 14px;
  background: linear-gradient(150deg, rgba(20, 44, 78, 0.9), rgba(9, 20, 38, 0.8));
  border: 1px solid var(--panel-line);
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -20px; top: -26px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.22), transparent 68%);
}
.kpi-label { font-size: 11px; color: var(--muted); letter-spacing: 0.8px; }
.kpi-value {
  font-family: var(--mono); font-size: 25px; line-height: 1.25;
  color: #eaf7ff; margin-top: 5px;
  text-shadow: 0 0 16px rgba(80, 190, 255, 0.35);
  white-space: nowrap;
}
.kpi-value em { font-style: normal; font-size: 11px; color: var(--dim); margin-left: 3px; }
.kpi-sub { font-family: var(--mono); font-size: 11.5px; margin-top: 2px; color: var(--muted); }
.kpi-sub.up { color: #ff6b7f; }
.kpi-sub.down { color: #22cf95; }

/* ---------------- charts ---------------- */
.panel-chart { flex: 1 1 0; min-height: 160px; }
.chart-trend { flex: 1 1 auto; }
.chart-score { flex: 1 1 auto; }

.split { flex: 1 1 0; min-height: 190px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; }

/* ---------------- official error ---------------- */
.err-stats {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 8px;
}
.err-stats div {
  background: rgba(18, 38, 68, 0.5);
  border: 1px solid rgba(70, 150, 230, 0.12);
  border-radius: 7px;
  padding: 6px 8px;
}
.err-stats span { display: block; font-size: 10px; color: var(--dim); white-space: nowrap; }
.err-stats b {
  display: block;
  font-family: var(--mono);
  font-size: 16px;
  color: #ffd166;
  margin-top: 3px;
  white-space: nowrap;
}
.err-stats b.na { color: var(--dim); }

.err-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.err-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: right; font-weight: 500; color: var(--dim);
  padding: 4px 4px 6px;
  background: rgba(9, 20, 38, 0.96);
  border-bottom: 1px solid rgba(70, 150, 230, 0.16);
}
.err-table th:first-child { text-align: left; }
.err-table td {
  text-align: right;
  padding: 5px 4px;
  font-family: var(--mono);
  color: #c9e2fb;
  border-bottom: 1px solid rgba(70, 150, 230, 0.08);
}
.err-table td:first-child { text-align: left; color: #9db9d8; }
.err-table tr.derived td:first-child::after {
  content: "推算";
  font-size: 9px;
  color: var(--dim);
  margin-left: 4px;
  font-family: "Microsoft YaHei", sans-serif;
}

/* ---------------- table ---------------- */
.panel-table { flex: 1 1 auto; }
.table-wrap { flex: 1 1 auto; overflow: auto; min-height: 0; }
.table-wrap::-webkit-scrollbar { width: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(70, 150, 230, 0.35); border-radius: 3px; }

.ind-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.ind-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: right;
  font-weight: 500; color: var(--dim);
  padding: 6px 4px 7px;
  background: rgba(9, 20, 38, 0.96);
  border-bottom: 1px solid rgba(70, 150, 230, 0.16);
  white-space: nowrap;
}
.ind-table th:first-child { text-align: left; }
.ind-table td {
  padding: 7px 4px;
  border-bottom: 1px solid rgba(70, 150, 230, 0.08);
  text-align: right;
  font-family: var(--mono);
  color: #c9e2fb;
  white-space: nowrap;
}
.ind-table td:first-child { text-align: left; font-family: "Microsoft YaHei", sans-serif; color: #a9c9e8; }
.ind-table tr:hover td { background: rgba(34, 211, 238, 0.05); }
.ind-name { display: flex; align-items: center; gap: 6px; }
.ind-name i {
  width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto;
  background: var(--green); box-shadow: 0 0 6px var(--green);
}
.ind-name i.miss { background: var(--dim); box-shadow: none; }
.ind-name i.short { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.bar-cell { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.bar-cell .track { width: 44px; height: 4px; border-radius: 2px; background: rgba(90, 140, 200, 0.22); overflow: hidden; }
.bar-cell .fill { height: 100%; border-radius: 2px; }
.na { color: var(--dim); }

/* ---------------- sources ---------------- */
.panel-sources { flex: 0 0 218px; }
.sources { list-style: none; overflow: auto; font-size: 11.5px; display: flex; flex-direction: column; gap: 6px; }
.sources::-webkit-scrollbar { width: 4px; }
.sources::-webkit-scrollbar-thumb { background: rgba(70, 150, 230, 0.3); border-radius: 3px; }
.sources li { display: flex; align-items: flex-start; gap: 7px; color: #9db9d8; }
.sources li i { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: var(--green); }
.sources li.failed i { background: var(--red); }
.sources li.partial i, .sources li.unavailable i { background: var(--amber); }
.sources li.cached i { background: var(--cyan); }
.sources li span { line-height: 1.45; }
.sources li small { color: var(--dim); display: block; font-size: 10px; }

/* ---------------- footer ---------------- */
.footer {
  flex: 0 0 26px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; color: var(--dim); letter-spacing: 0.5px;
  padding: 0 4px;
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%; bottom: 40px;
  transform: translate(-50%, 24px);
  padding: 11px 22px;
  border-radius: 8px;
  background: rgba(10, 24, 44, 0.95);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: #d8ecff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  max-width: 70vw;
  white-space: pre-wrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 93, 115, 0.6); color: #ffd0d6; }

/* ---------------- responsive ---------------- */
@media (max-width: 1560px) {
  .layout { grid-template-columns: 306px minmax(0, 1fr) 360px; }
  .kpis { grid-template-columns: repeat(5, 1fr); gap: 9px; }
  .kpi { padding: 10px 11px; }
  .kpi-value { font-size: 21px; }
}

@media (max-width: 1280px) {
  html, body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .col { min-height: auto; }
  .panel-gauge { flex: 0 0 300px; }
  .panel-chart { min-height: 300px; }
  .split { grid-template-columns: 1fr; min-height: auto; }
  .panel-official { flex: 0 0 320px; }
  .panel-table { flex: 0 0 460px; }
  .panel-sources { flex: 0 0 240px; }
  .kpis { flex: 0 0 auto; grid-template-columns: repeat(2, 1fr); }
}
