:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f3f5f7;
  --text: #15181d;
  --text-soft: #5f6875;
  --text-faint: #929aa5;
  --border: #e3e7ec;
  --border-strong: #d7dce2;
  --brand: #087ec2;
  --brand-soft: #e6f4fb;
  --excellent: #059669;
  --good: #2eae4f;
  --warning: #f08c00;
  --critical: #ef3e36;
  --unknown: #d8dde2;
  --unknown-text: #7f8791;
  --focus: #1479b8;
  --shadow: 0 2px 10px rgba(17, 24, 39, 0.045);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid rgba(20, 121, 184, 0.22);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
}

.header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: min(100% - 48px, 1600px);
  min-height: 64px;
  margin: 0 auto;
  gap: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  color: var(--text);
  text-decoration: none;
  gap: 10px;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 17px;
  font-weight: 800;
}

.brand-mark img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

#brand-fallback {
  display: none;
}

.brand-mark.image-missing img {
  display: none;
}

.brand-mark.image-missing #brand-fallback {
  display: inline;
}

.brand-name {
  font-size: 20px;
  font-weight: 750;
  white-space: nowrap;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  height: 64px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.primary-nav::-webkit-scrollbar {
  display: none;
}

.primary-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  padding: 0 17px;
  color: #31363d;
  font-weight: 650;
  text-decoration: none;
}

.primary-nav a:hover {
  color: var(--brand);
}

.primary-nav a[aria-current="page"] {
  color: var(--brand);
}

.primary-nav a[aria-current="page"]::after {
  position: absolute;
  right: 17px;
  bottom: 0;
  left: 17px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand);
  content: "";
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
  gap: 6px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--unknown);
}

.status-dot.status-excellent {
  background: var(--excellent);
}

.status-dot.status-good {
  background: var(--good);
}

.status-dot.status-warning {
  background: var(--warning);
}

.status-dot.status-critical {
  background: var(--critical);
}

.status-dot.status-unknown {
  background: var(--unknown);
}

.icon-button,
.refresh-button {
  border: 1px solid var(--border-strong);
  color: #39424d;
  background: var(--surface);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  place-items: center;
  font-size: 20px;
}

.icon-button:hover,
.refresh-button:hover {
  border-color: #aeb7c1;
  background: var(--surface-muted);
}

.icon-button:disabled,
.refresh-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.is-spinning .refresh-symbol,
.icon-button.is-spinning span {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

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

.page-shell {
  width: min(100% - 48px, 1600px);
  margin: 0 auto;
  padding: 36px 0 52px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 22px;
  gap: 28px;
}

.page-heading h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: 0;
}

.page-heading p,
.section-heading p {
  margin: 7px 0 0;
  color: var(--text-soft);
  line-height: 1.5;
}

.refresh-meta {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  gap: 14px;
}

.refresh-countdown {
  padding-left: 14px;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.health-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  margin-bottom: 26px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 18px;
}

.health-title-wrap {
  display: flex;
  align-items: center;
  min-width: max-content;
  padding-right: 18px;
  border-right: 1px solid var(--border);
  gap: 9px;
}

.health-icon {
  display: grid;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--excellent);
  background: #e9f8f2;
  font-size: 20px;
  font-weight: 700;
  place-items: center;
}

.health-title-wrap h2 {
  margin: 0;
  font-size: 15px;
  white-space: nowrap;
}

.kpi-list {
  display: flex;
  min-width: 0;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.kpi-list::-webkit-scrollbar {
  display: none;
}

.kpi-item {
  display: flex;
  min-width: max-content;
  align-items: center;
  padding: 4px 18px;
  border-right: 1px solid var(--border);
  gap: 8px;
}

.kpi-item:first-child {
  padding-left: 0;
}

.kpi-item:last-child {
  border-right: 0;
}

.kpi-icon {
  display: grid;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.kpi-icon-success {
  color: var(--excellent);
  background: #e9f8f2;
}

.kpi-icon-latency {
  color: #c47700;
  background: #fff4df;
}

.kpi-icon-tps {
  color: #087ec2;
  background: #e8f5fc;
}

.kpi-icon-groups {
  color: #5b55a5;
  background: #efeffb;
}

.kpi-label {
  color: var(--text-soft);
  white-space: nowrap;
}

.kpi-value {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-value.status-excellent {
  color: var(--excellent);
}

.kpi-value.status-good {
  color: var(--good);
}

.kpi-value.status-warning {
  color: var(--warning);
}

.kpi-value.status-critical {
  color: var(--critical);
}

.refresh-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 13px;
  gap: 6px;
}

.refresh-symbol {
  font-size: 17px;
  line-height: 1;
}

.notice {
  margin: -10px 0 24px;
  padding: 10px 12px;
  border: 1px solid #f4cf8a;
  border-radius: 6px;
  color: #75520c;
  background: #fff8e9;
  line-height: 1.5;
}

.notice.notice-error {
  border-color: #efb4b1;
  color: #8f2f2a;
  background: #fff1f0;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 16px;
  gap: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading p {
  font-size: 13px;
}

.legend {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--text-faint);
  font-size: 11px;
  gap: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-swatch.excellent,
.bucket.excellent {
  background: var(--excellent);
}

.legend-swatch.good,
.bucket.good {
  background: var(--good);
}

.legend-swatch.warning,
.bucket.warning {
  background: var(--warning);
}

.legend-swatch.critical,
.bucket.critical {
  background: var(--critical);
}

.legend-swatch.unknown {
  background: var(--unknown);
}

.bucket.unknown {
  background: var(--unknown);
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 20px;
}

.group-card {
  display: flex;
  min-width: 0;
  min-height: 264px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  min-width: 0;
  gap: 16px;
}

.group-identity {
  min-width: 0;
}

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

.group-name {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 11px;
  gap: 5px;
}

.status-pill span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 12px;
}

.group-price {
  min-width: 0;
  margin-top: 7px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-block {
  min-width: 88px;
  text-align: right;
}

.rate-value {
  display: block;
  font-size: 27px;
  font-weight: 760;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rate-value.status-excellent {
  color: var(--excellent);
}

.rate-value.status-good {
  color: var(--good);
}

.rate-value.status-warning {
  color: var(--warning);
}

.rate-value.status-critical {
  color: var(--critical);
}

.rate-value.status-unknown {
  color: var(--unknown-text);
}

.rate-label {
  display: block;
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 11px;
}

.bucket-region {
  margin: 23px 0 18px;
}

.bucket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-faint);
  font-size: 11px;
  gap: 12px;
}

.bucket-header span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(32, minmax(3px, 1fr));
  width: 100%;
  height: 24px;
  gap: 3px;
}

.bucket {
  display: block;
  width: 100%;
  min-width: 0;
  height: 24px;
  border-radius: 2px;
  cursor: default;
  transition: opacity 120ms ease, transform 120ms ease;
}

.bucket:hover,
.bucket:focus-visible {
  opacity: 0.78;
  transform: translateY(-2px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.metric {
  min-width: 0;
  padding: 14px 8px 0;
  border-right: 1px solid var(--border);
}

.metric:first-child {
  padding-left: 0;
}

.metric:last-child {
  padding-right: 0;
  border-right: 0;
}

.metric-label,
.metric-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-label {
  margin-bottom: 5px;
  color: var(--text-faint);
  font-size: 10px;
}

.metric-value {
  color: #3c444f;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bucket-tooltip {
  position: fixed;
  z-index: 100;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  padding: 9px 10px;
  border: 1px solid #303844;
  border-radius: 5px;
  color: #ffffff;
  background: #20262e;
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.18);
  font-size: 11px;
  line-height: 1.55;
  pointer-events: none;
}

.tooltip-title {
  display: block;
  margin-bottom: 2px;
  color: #cbd2db;
}

.tooltip-value {
  display: block;
  font-weight: 650;
}

.empty-state {
  display: flex;
  min-height: 230px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px dashed var(--border-strong);
  color: var(--text-soft);
  background: var(--surface);
  gap: 8px;
}

.empty-state[hidden] {
  display: none;
}

.empty-state span {
  color: var(--text-faint);
}

.skeleton-card {
  pointer-events: none;
}

.skeleton-line,
.skeleton-rate,
.skeleton-bucket,
.skeleton-metric {
  background: #e9edf1;
  animation: skeleton-pulse 1.3s ease-in-out infinite alternate;
}

.skeleton-line {
  width: 44%;
  height: 18px;
  border-radius: 4px;
}

.skeleton-rate {
  width: 76px;
  height: 29px;
  border-radius: 4px;
}

.skeleton-bucket {
  width: 100%;
  height: 24px;
  margin: 31px 0 19px;
  border-radius: 3px;
}

.skeleton-metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.skeleton-metric {
  height: 30px;
  border-radius: 3px;
}

@keyframes skeleton-pulse {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .header-inner,
  .page-shell {
    width: min(100% - 36px, 1600px);
  }

  .header-inner {
    gap: 20px;
  }

  .primary-nav a {
    padding-right: 13px;
    padding-left: 13px;
  }

  .primary-nav a[aria-current="page"]::after {
    right: 13px;
    left: 13px;
  }

  .health-strip {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

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

@media (max-width: 820px) {
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-top: 9px;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 43px;
    margin-right: -18px;
    margin-left: -18px;
    padding: 0 5px;
    border-top: 1px solid var(--border);
  }

  .primary-nav a {
    padding: 0 13px;
  }

  .health-strip {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .health-title-wrap {
    grid-column: 1;
  }

  .kpi-list {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .refresh-button {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 700px) {
  .header-inner,
  .page-shell {
    width: calc(100% - 28px);
  }

  .header-inner {
    gap: 12px;
  }

  .primary-nav {
    margin-right: -14px;
    margin-left: -14px;
  }

  .brand-name {
    font-size: 18px;
  }

  .header-status {
    display: none;
  }

  .page-shell {
    padding-top: 25px;
  }

  .page-heading {
    display: block;
  }

  .page-heading h1 {
    font-size: 24px;
  }

  .refresh-meta {
    justify-content: space-between;
    margin-top: 13px;
    white-space: normal;
  }

  .section-heading {
    display: block;
  }

  .legend {
    margin-top: 12px;
    overflow-x: auto;
  }

  .group-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .group-card {
    min-height: 252px;
    padding: 17px;
  }

  .bucket-grid {
    gap: 2px;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .header-tools {
    gap: 6px;
  }

  .health-strip {
    padding-right: 10px;
    padding-left: 10px;
  }

  .kpi-item {
    padding-right: 13px;
    padding-left: 13px;
  }

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

  .metric {
    padding-right: 5px;
    padding-left: 5px;
  }

  .metric-value {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
