:root {
  --bg: #0b1020;
  --bg-soft: #111a2e;
  --panel: #131d33;
  --panel-2: #18243d;
  --line: #24304d;
  --text: #e6edf7;
  --muted: #8b9ab5;
  --dim: #61708c;

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --sky: #38bdf8;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --pink: #f472b6;
  --emerald: #34d399;

  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image: radial-gradient(1200px 600px at 15% -10%, #16233d 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #14243a 0%, transparent 55%);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 40px;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6366f1;
  box-shadow: 0 0 10px #6366f1;
  align-self: center;
  flex: none;
}

.brand__sub {
  color: var(--dim);
  font-size: 12px;
}

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

.interval {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.interval select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.btn:hover {
  background: var(--panel-2);
  border-color: #2f3d5e;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: linear-gradient(180deg, #4f7cf7, #3b63dd);
  border-color: #4f7cf7;
  font-weight: 560;
}

.btn--primary:hover {
  background: linear-gradient(180deg, #5c87ff, #4470ea);
  border-color: #5c87ff;
}

.btn--icon {
  padding: 6px 9px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.spin {
  display: inline-block;
  transition: transform 0.2s;
}

.spin--active {
  animation: rotate 0.9s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- 卡片区 ---------------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  padding-top: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px 16px 14px;
  background: linear-gradient(180deg, var(--panel), #101828);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent, #64748b);
  opacity: 0.85;
}

.card--error {
  border-color: #3a2530;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.card__badge {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent, #94a3b8);
  background: color-mix(in srgb, var(--accent, #94a3b8) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #94a3b8) 32%, transparent);
}

.card__name {
  font-size: 14px;
  font-weight: 620;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__sub {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  flex: none;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill--normal {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 12%, transparent);
  border-color: color-mix(in srgb, var(--good) 30%, transparent);
}

.pill--warning {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.pill--danger,
.pill--error {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}

.pill--loading {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-color: var(--line);
}

/* 主读数 */
.headline {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.headline__label {
  font-size: 11.5px;
  color: var(--muted);
  margin-right: 6px;
}

.headline__value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.headline__unit {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.tone-good {
  color: var(--good);
}
.tone-warn {
  color: var(--warn);
}
.tone-bad {
  color: var(--bad);
}
.tone-neutral {
  color: var(--text);
}

/* 进度条 */
.meters {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.meter__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  margin-bottom: 4px;
}

.meter__label {
  color: #c3cfe4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter__value {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: #22304c;
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.45s ease;
}

.bar__fill--good {
  background: linear-gradient(90deg, #2fbf8f, #34d399);
}
.bar__fill--warn {
  background: linear-gradient(90deg, #e0a52a, #fbbf24);
}
.bar__fill--bad {
  background: linear-gradient(90deg, #e05266, #fb7185);
}

.meter__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--dim);
}

.meter__foot > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter__foot > span:last-child {
  flex: none;
  text-align: right;
}

/* 事实列表 */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.fact {
  min-width: 0;
}

.fact__label {
  font-size: 10.5px;
  color: var(--dim);
}

.fact__value {
  font-size: 12px;
  color: #d4deee;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__note {
  font-size: 11px;
  color: var(--warn);
  line-height: 1.5;
}

.card__note--error {
  color: var(--bad);
}

.card__foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  font-size: 10.5px;
  color: var(--dim);
}

.card__empty {
  padding: 14px 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--dim);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

/* 骨架屏 */
.skeleton {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #1b2740, #24334f, #1b2740);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------------- 页脚 ---------------- */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--dim);
}

/* ---------------- 设置抽屉 ---------------- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 20, 0.72);
  backdrop-filter: blur(3px);
}

.drawer[hidden] {
  display: none;
}

.drawer__panel {
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: min(88vh, 900px);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer__head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 620;
}

.drawer__body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #0e1729;
}

.field h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.toggles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  appearance: none;
  width: 34px;
  height: 19px;
  flex: none;
  border-radius: 999px;
  background: #2b3956;
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}

.toggle input:checked {
  background: #4f7cf7;
}

.toggle input:checked::after {
  transform: translateX(15px);
}

.input {
  display: block;
  margin-bottom: 12px;
}

.input > span {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  color: #b9c6dc;
}

.input input,
.input textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s;
}

.input textarea {
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.input input:focus,
.input textarea:focus {
  border-color: #4f7cf7;
}

.input small {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--dim);
  line-height: 1.5;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11.5px;
  color: #c3cfe4;
  cursor: pointer;
}

.checkbox input {
  margin: 2px 0 0;
  accent-color: #4f7cf7;
}

.hint {
  margin: 0;
  padding: 11px 13px;
  font-size: 11.5px;
  line-height: 1.65;
  color: #cbb98a;
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  border-radius: 10px;
}

.hint code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: #f0d9a0;
}

@media (max-width: 560px) {
  .app {
    padding: 16px 13px 32px;
  }

  .board {
    grid-template-columns: 1fr;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .facts {
    grid-template-columns: 1fr 1fr;
  }
}
