:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #647186;
  --line: #d8dee8;
  --line-strong: #c5cedc;
  --blue: #246bfe;
  --green: #168a53;
  --amber: #b7791f;
  --orange: #c75b12;
  --red: #cf2e2e;
  --shadow: 0 18px 45px rgba(24, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(36, 107, 254, 0.08), rgba(36, 107, 254, 0) 280px),
    var(--bg);
}

button {
  font: inherit;
}

.page-shell {
  position: relative;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

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

.topbar > div {
  min-width: 0;
}

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

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.08;
  letter-spacing: 0;
}

.refresh-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.refresh-button {
  min-width: 96px;
  padding: 0 14px;
  box-shadow: 0 8px 18px rgba(24, 34, 51, 0.06);
}

.refresh-button:hover,
.copy-button:hover {
  border-color: var(--blue);
  background: #f6f9ff;
}

.refresh-button:active,
.copy-button:active {
  transform: translateY(1px);
}

.overview {
  display: grid;
  grid-template-columns: 1.45fr repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 26px rgba(24, 34, 51, 0.05);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  min-height: 27px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  line-height: 1.3;
}

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

.node-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.node-card.is-best {
  border-color: rgba(22, 138, 83, 0.5);
}

.node-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

.node-title-block {
  min-width: 0;
}

.node-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.node-name {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.node-meta {
  min-height: 21px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.recommend-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.recommend-badge {
  padding: 0 8px;
  color: #0f6a3e;
  background: #e6f6ee;
}

.status-pill {
  min-width: 54px;
  padding: 0 9px;
  border: 1px solid transparent;
}

.status-smooth {
  color: var(--green);
  background: #e8f7ef;
  border-color: #c6ebd7;
}

.status-busy {
  color: var(--amber);
  background: #fff5db;
  border-color: #f2d492;
}

.status-crowded {
  color: var(--orange);
  background: #fff0e5;
  border-color: #f4c5a2;
}

.status-full {
  color: var(--red);
  background: #ffebeb;
  border-color: #f4bbbb;
}

.usage-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.usage-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
}

.usage-percent {
  color: var(--muted);
  font-size: 15px;
}

.usage-bar {
  width: 100%;
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecf3;
}

.usage-fill {
  display: block;
  width: var(--usage-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--usage-color, var(--green));
  transition: width 0.25s ease;
}

.address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.node-address {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #263248;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 14px;
}

.copy-button {
  min-width: 74px;
  padding: 0 11px;
}

.copy-button.copied {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
}

.load-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid #f0b8b8;
  border-radius: 8px;
  color: #8d2323;
  background: #fff0f0;
}

@media (max-width: 860px) {
  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding-right: 0;
  }

  .refresh-button {
    position: static;
    width: 100%;
    min-width: 0;
    padding: 0 14px;
  }

  .refresh-button span:last-child {
    display: inline;
  }

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

  .metric-wide {
    grid-column: auto;
  }

  .node-card {
    padding: 14px;
  }

  .node-card-header {
    flex-direction: column;
    min-height: 0;
  }

  .status-pill {
    align-self: flex-start;
  }

  .usage-value {
    font-size: 24px;
  }

  .address-row {
    grid-template-columns: 1fr;
  }

  .copy-button {
    width: 100%;
  }
}
