:root {
  --bg: #0f1720;
  --bg-accent: #1d3557;
  --card: rgba(9, 15, 24, 0.84);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e9f1fb;
  --muted: #9ab0c8;
  --good: #8dd694;
  --warn: #ffcb77;
  --bad: #ff7b72;
  --highlight: #77d4fc;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Aptos", "Trebuchet MS", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(119, 212, 252, 0.18), transparent 35%),
    radial-gradient(circle at top right, rgba(255, 203, 119, 0.16), transparent 24%),
    linear-gradient(140deg, #081018 0%, #102033 48%, #081018 100%);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--highlight);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #77d4fc 0%, #ffd166 100%);
  color: #0c1420;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
}

#refresh-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.overview-card,
.server-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.overview-card {
  padding: 20px 22px;
}

.overview-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 10px;
}

.overview-card strong {
  font-size: 1.5rem;
}

.overview-card.filterable {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.overview-card.filterable:hover {
  border-color: rgba(119, 212, 252, 0.3);
  background: rgba(119, 212, 252, 0.06);
}

.overview-card.filterable.active {
  border-color: var(--highlight);
  background: rgba(119, 212, 252, 0.1);
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.server-card {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.server-name {
  margin: 0;
  font-size: 1.45rem;
}

.server-address,
.last-check {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.status-badge,
.service-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-up,
.service-up {
  background: rgba(141, 214, 148, 0.16);
  color: var(--good);
}

.status-down,
.service-down {
  background: rgba(255, 123, 114, 0.16);
  color: var(--bad);
}

.status-warn,
.service-warn {
  background: rgba(255, 203, 119, 0.16);
  color: var(--warn);
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.88rem;
}

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

.metric {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

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

.metric strong {
  display: block;
  font-size: 1.1rem;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.service-section h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
  color: var(--muted);
  font-weight: 700;
}

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

.service-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.service-row strong {
  font-size: 0.96rem;
}

.service-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 1.05rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
}

.error-box {
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 123, 114, 0.08);
  color: #ffd2cf;
  line-height: 1.5;
}

.hero-buttons {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-icon {
  background: none;
  box-shadow: none;
  font-size: 1.6rem;
  padding: 4px 10px;
  color: var(--muted);
  line-height: 1;
}

.btn-icon:hover {
  color: var(--text);
}

/* 设置弹窗 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}

.overlay.hidden {
  display: none;
}

.settings-panel {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: #131d2a;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.settings-body {
  padding: 20px 24px 24px;
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 12px;
}

.form-row span {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.form-row input:focus {
  outline: none;
  border-color: var(--highlight);
}

.form-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  justify-self: end;
  accent-color: var(--highlight);
}

.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

.alert-msg {
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
  min-height: 1.4em;
}

.alert-msg.success { color: var(--good); }
.alert-msg.error { color: var(--bad); }

/* 卡片操作栏 */
.card-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 999px;
}

/* 图表弹窗 */
.chart-panel {
  width: min(800px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: #131d2a;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.chart-toolbar {
  display: flex;
  gap: 8px;
  padding: 16px 24px 0;
}

.chart-range.active {
  border-color: var(--highlight);
  background: rgba(119, 212, 252, 0.12);
  color: var(--highlight);
}

.chart-container {
  padding: 16px 24px 24px;
  position: relative;
  height: 280px;
}

/* 告警记录 */
.alert-history-body {
  padding: 16px 24px 24px;
  max-height: 60vh;
  overflow-y: auto;
}

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

.alert-record {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  align-items: start;
}

.alert-record-badge {
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 2px;
}

.alert-record-badge.type-alert {
  background: rgba(255, 123, 114, 0.16);
  color: var(--bad);
}

.alert-record-badge.type-recovery {
  background: rgba(141, 214, 148, 0.16);
  color: var(--good);
}

.alert-record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.alert-record-header strong {
  font-size: 0.95rem;
}

.alert-record-header time {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.alert-record-detail {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

.alert-history-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
  margin: 0;
}

.alert-history-empty.hidden {
  display: none;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 28px;
  }

  .hero,
  .card-header {
    flex-direction: column;
    align-items: start;
  }

  .hero-actions {
    align-items: start;
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .overview,
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

