/* 独立状态页沿用论坛的状态组件及配色，字体使用系统字体。 */
:root {
  color-scheme: light;
  --pd-color-primary: #64748b;
  --pd-color-text: #111827;
  --pd-color-text-secondary: #6b7280;
  --pd-color-text-tertiary: #9ca3af;
  --pd-color-surface: #fff;
  --pd-color-surface-subtle: #f9fafb;
  --pd-color-surface-soft: #f3f4f6;
  --pd-color-border: #e5e7eb;
  --pd-color-border-strong: #d1d5db;
  --pd-color-success: #15803d;
  --pd-color-success-soft: #ecfdf3;
  --pd-color-warning: #b77900;
  --pd-color-warning-soft: #fff7e6;
  --pd-color-error: #dc2626;
  --pd-color-error-soft: #fff1f0;
  --pd-card-radius: 8px;
  --pd-card-radius-page: 12px;
  --status-background: #f3f4f6;
}

:root[data-health="operational"] {
  --pd-color-primary: #15803d;
}

:root[data-health="degraded"] {
  --pd-color-primary: #9a6700;
}

:root[data-health="critical"] {
  --pd-color-primary: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 280px;
  padding: 48px 24px;
  background: var(--status-background);
  color: var(--pd-color-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
p {
  margin: 0;
}
button,
select,
input {
  font: inherit;
}
[hidden] {
  display: none;
}

.pd-server-stats {
  max-width: 1080px;
  margin: 0 auto;
  color: var(--pd-color-text);
  padding-bottom: 16px;
}

.pd-server-stats .pd-stats-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.pd-server-stats .pd-stats-heading h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 650;
  margin-bottom: 6px;
}

.pd-stats-logo {
  display: block;
  width: auto;
  height: 38px;
}

.pd-server-stats .pd-stats-heading p,
.pd-server-stats .pd-stats-footnote {
  color: var(--pd-color-text-secondary);
  font-size: 12px;
  line-height: 1.8;
}

.pd-server-stats .pd-stats-refresh {
  display: inline-grid;
  grid-template-columns: 16px auto;
  grid-template-rows: 16px;
  align-items: center;
  align-content: center;
  justify-content: center;
  box-sizing: border-box;
  appearance: none;
  flex: 0 0 112px;
  gap: 7px;
  border: 1px solid var(--pd-color-border);
  background: var(--pd-color-surface);
  background-clip: padding-box;
  color: var(--pd-color-text-secondary);
  border-radius: var(--pd-card-radius, 8px);
  width: 112px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  margin: 0;
  padding: 0 12px;
  cursor: pointer;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}

.pd-server-stats .pd-stats-refresh:disabled {
  cursor: wait;
  opacity: 0.65;
}

.pd-server-stats .pd-stats-subscribe {
  background: var(--pd-color-primary);
  background-clip: padding-box;
  color: #fff;
}

.pd-stats-action-label {
  display: block;
  line-height: 16px;
}

.pd-stats-refresh:hover,
.pd-stats-subscription-actions :is(a, button):hover {
  filter: brightness(0.96);
}

:is(button, select, input, a):focus-visible {
  outline: 2px solid var(--pd-color-primary);
  outline-offset: 3px;
}

.pd-stats-subscription {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--pd-color-border);
  border-radius: 16px;
  background: var(--pd-color-surface);
  color: var(--pd-color-text);
  box-shadow: 0 16px 64px rgb(17 24 39 / 16%);
}

.pd-stats-subscription::backdrop {
  background: rgb(17 24 39 / 28%);
}

.pd-stats-subscription-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.pd-stats-subscription h2 {
  font-size: 20px;
  font-weight: 600;
}

.pd-stats-subscription-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  padding: 6px;
  border: 0;
  border-radius: 50%;
  background: var(--pd-color-surface-soft);
  color: var(--pd-color-text-secondary);
  cursor: pointer;
}

.pd-stats-subscription-close svg {
  width: 20px;
  height: 20px;
}

.pd-stats-subscription p {
  font-size: 13px;
  color: var(--pd-color-text-secondary);
}

.pd-stats-subscription label {
  display: block;
  margin: 20px 0 8px;
  font-size: 13px;
  font-weight: 500;
}

.pd-stats-subscription :is(select, input) {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--pd-color-border-strong);
  border-radius: 8px;
  background: var(--pd-color-surface);
  color: var(--pd-color-text);
  font-size: 13px;
}

.pd-stats-subscription input {
  background: var(--pd-color-surface-subtle);
}

.pd-stats-subscription-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.pd-stats-subscription-actions :is(button, a) {
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--pd-color-border);
  border-radius: 8px;
  background: var(--pd-color-surface);
  color: var(--pd-color-text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}

.pd-stats-subscription-actions button {
  border-color: var(--pd-color-primary);
  background: var(--pd-color-primary);
  color: #fff;
}

.pd-stats-subscription .pd-stats-subscription-hint {
  margin-top: 20px;
  font-size: 12px;
  line-height: 1.7;
}

.pd-stats-subscription .pd-stats-subscription-feedback {
  min-height: 20px;
  margin-top: 8px;
  color: var(--pd-color-primary);
  font-size: 12px;
}

.pd-stats-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--pd-color-border);
  border-radius: var(--pd-card-radius-page);
  background: var(--pd-color-surface);
}

.pd-stats-overview-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pd-stats-overview-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--pd-color-success);
  background: var(--pd-color-success-soft);
  font-size: 21px;
  font-weight: 600;
}

.pd-stats-overview-icon--offline {
  color: var(--pd-color-error);
  background: var(--pd-color-error-soft);
}

.pd-stats-overview-icon--warning {
  color: var(--pd-color-warning);
  background: var(--pd-color-warning-soft);
}

.pd-stats-overview-icon--waiting {
  color: var(--pd-color-text-secondary);
  background: var(--pd-color-surface-soft);
}

.pd-stats-overview-status strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.pd-stats-overview-status p {
  margin-top: 4px;
  font-size: 11px;
  color: var(--pd-color-text-secondary);
}

.pd-stats-count {
  flex-shrink: 0;
  text-align: right;
}

.pd-stats-count strong {
  display: block;
  color: var(--pd-color-primary);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.pd-stats-count span {
  display: block;
  margin-top: 4px;
  color: var(--pd-color-text-secondary);
  font-size: 10px;
}

.pd-stats-stale .pd-stats-count strong {
  color: var(--pd-color-text-secondary);
}

.pd-stats-error {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--pd-color-warning-soft);
  color: var(--pd-color-text);
  font-size: 12px;
  line-height: 1.7;
}

.pd-stats-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px 18px;
  border: 1px solid var(--pd-color-border);
  border-radius: var(--pd-card-radius-page);
  background: var(--pd-color-surface);
}

.pd-stats-node-info,
.pd-stats-history {
  min-width: 0;
}

.pd-stats-node-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-width: 0;
}

.pd-stats-node-info {
  flex: 1 1 auto;
}

.pd-stats-node-summary {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
}

.pd-stats-node-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.pd-stats-service-icon {
  display: block;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  color: var(--pd-color-primary);
}

.pd-stats-node-title h2 {
  min-width: 0;
  max-width: calc(100% - 26px);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pd-stats-node-status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 64px;
  width: 64px;
  gap: 4px;
  color: var(--pd-color-text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.pd-stats-node-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.pd-stats-node-status--online {
  color: var(--pd-color-success);
}

.pd-stats-node-status--offline {
  color: var(--pd-color-error);
}

.pd-stats-node-uptime {
  color: var(--pd-color-text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pd-stats-availability {
  display: inline-flex;
  align-items: baseline;
  justify-self: center;
  gap: 6px;
  color: var(--pd-color-text-secondary);
  font-size: 10px;
  white-space: nowrap;
}

.pd-stats-availability strong {
  font-size: inherit;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pd-stats-days {
  display: grid;
  grid-template-columns: repeat(90, minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
}

.pd-stats-day {
  display: block;
  width: 100%;
  min-width: 0;
  height: 23px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--pd-color-border-strong);
  cursor: pointer;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.pd-stats-day--good,
.pd-stats-legend-good {
  background: var(--pd-color-success);
}

.pd-stats-day--partial,
.pd-stats-legend-partial {
  background: var(--pd-color-warning);
}

.pd-stats-day--poor,
.pd-stats-legend-poor {
  background: var(--pd-color-error);
}

.pd-stats-day--unknown,
.pd-stats-legend-unknown {
  background: var(--pd-color-border-strong);
}

.pd-stats-day:focus-visible {
  outline: 2px solid var(--pd-color-primary);
  outline-offset: 2px;
}

.pd-stats-dates {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
  color: var(--pd-color-text-tertiary);
  font-size: 9px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.pd-stats-tooltip {
  position: fixed;
  z-index: 100;
  max-width: calc(100% - 16px);
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--pd-color-text);
  color: var(--pd-color-surface);
  font-size: 11px;
  line-height: 1.7;
  font-weight: 400;
  white-space: pre;
  text-align: center;
  pointer-events: none;
}

.pd-stats-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 12px;
  color: var(--pd-color-text-secondary);
  font-size: 10px;
}

.pd-stats-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pd-stats-legend i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.pd-stats-empty {
  padding: 32px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--pd-color-text-secondary);
}

.pd-stats-events {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--pd-color-border);
  border-radius: var(--pd-card-radius-page);
  background: var(--pd-color-surface);
}

.pd-stats-events-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pd-stats-events-heading h2 {
  font-size: 14px;
  font-weight: 600;
}

.pd-stats-events-heading > span {
  color: var(--pd-color-text-tertiary);
  font-size: 10px;
}

.pd-stats-events-empty {
  margin-top: 14px;
  color: var(--pd-color-text-secondary);
  font-size: 12px;
}

.pd-stats-events-list {
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.pd-stats-event {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--pd-color-border);
}

.pd-stats-event:first-child {
  border-top: 0;
}

.pd-stats-event-content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.pd-stats-event-name {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pd-stats-event-kind {
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 10px;
}

.pd-stats-event-kind--offline {
  background: var(--pd-color-error-soft);
  color: var(--pd-color-error);
}

.pd-stats-event-kind--recovery {
  background: var(--pd-color-success-soft);
  color: var(--pd-color-success);
}

.pd-stats-event-time {
  color: var(--pd-color-text-secondary);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.pd-stats-footer {
  margin-top: 18px;
}

.pd-stats-footnote + .pd-stats-footnote {
  margin-top: 4px;
}

.pd-stats-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pd-stats-refresh-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 16px;
  text-align: center;
}

.pd-stats-refresh.is-refreshing .pd-stats-refresh-icon {
  display: none;
}

.pd-stats-refresh-spinner {
  display: none;
  justify-self: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.pd-stats-refresh.is-refreshing .pd-stats-refresh-spinner {
  display: inline-block;
  animation: status-refresh 0.7s linear infinite;
}

.pd-stats-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--pd-color-border-strong);
  border-radius: var(--pd-card-radius);
  background: var(--pd-color-surface);
}

.pd-stats-preview[hidden] {
  display: none;
}

.pd-stats-preview-favicon {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.pd-stats-preview-copy {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 140px;
}

.pd-stats-preview-copy strong {
  font-size: 12px;
  font-weight: 600;
}

.pd-stats-preview-copy span {
  color: var(--pd-color-text-secondary);
  font-size: 11px;
}

.pd-stats-preview-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.pd-stats-preview-button,
.pd-stats-preview-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--pd-color-border);
  border-radius: 6px;
  background: var(--pd-color-surface);
  color: var(--pd-color-text-secondary);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.pd-stats-preview-button[aria-pressed="true"] {
  border-color: var(--pd-color-primary);
  background: var(--pd-color-surface-subtle);
  color: var(--pd-color-primary);
}

.pd-stats-preview-exit {
  background: var(--pd-color-surface-soft);
}

.pd-stats-preview-actions button:hover {
  background: var(--pd-color-surface-soft);
}

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

@media (max-width: 800px) {
  .pd-stats-days {
    gap: 1px;
  }
}

@media (max-width: 620px) {
  body {
    padding: 24px 12px;
  }
  .pd-stats-node {
    padding: 12px 14px;
  }
  .pd-stats-node-title {
    gap: 6px;
  }
  .pd-stats-day {
    height: 18px;
    border-radius: 1px;
  }
  .pd-stats-dates {
    font-size: 9px;
  }
  .pd-stats-overview {
    gap: 12px;
    padding: 16px;
  }
  .pd-stats-overview-status strong {
    font-size: 14px;
  }
  .pd-stats-count strong {
    font-size: 22px;
  }
  .pd-stats-legend {
    justify-content: flex-start;
  }
  .pd-stats-events {
    padding: 16px;
  }
  .pd-stats-event {
    grid-template-columns: 19px minmax(0, 1fr);
    gap: 4px 8px;
  }
  .pd-stats-event-time {
    grid-column: 2;
    font-size: 9px;
  }
  .pd-stats-footer .pd-stats-footnote {
    font-size: 10px;
  }
  .pd-stats-preview-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-basis: 100%;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pd-stats-refresh.is-refreshing .pd-stats-refresh-spinner {
    animation: none;
  }
}

[hidden] {
  display: none;
}

.pd-stats-logo--fish {
  width: 38px;
}

.pd-stats-logo-english {
  color: var(--pd-color-primary);
  font-size: 25px;
  font-weight: 400;
  white-space: nowrap;
}

.pd-stats-language {
  box-sizing: border-box;
  appearance: none;
  width: 72px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--pd-color-border);
  border-radius: var(--pd-card-radius);
  background: var(--pd-color-surface);
  background-clip: padding-box;
  color: var(--pd-color-text-secondary);
  font-size: 12px;
  line-height: 16px;
  cursor: pointer;
}

.pd-stats-clock-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
  color: var(--pd-color-text-secondary);
  font-size: 11px;
}

.pd-stats-clock {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  white-space: nowrap;
}

.pd-stats-clock-digit {
  position: relative;
  display: inline-block;
  width: 0.7em;
  height: 20px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--pd-color-surface);
  perspective: 120px;
  text-align: center;
}

.pd-stats-clock-separator {
  white-space: pre;
}

.pd-stats-clock-digit::after {
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px solid rgb(107 114 128 / 12%);
  content: "";
  pointer-events: none;
}

.pd-stats-clock-old-bottom,
.pd-stats-clock-old-flap,
.pd-stats-clock-new-flap {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--pd-color-surface);
  backface-visibility: hidden;
  transform-origin: 50% 50%;
}

.is-flipping :is(.pd-stats-clock-old-bottom, .pd-stats-clock-old-flap, .pd-stats-clock-new-flap) {
  display: block;
}

.pd-stats-clock-old-bottom,
.pd-stats-clock-new-flap {
  clip-path: inset(50% 0 0);
}

.pd-stats-clock-old-flap {
  clip-path: inset(0 0 50%);
  animation: status-clock-top 240ms ease-in forwards;
}

.pd-stats-clock-new-flap {
  transform: rotateX(90deg);
  animation: status-clock-bottom 240ms 240ms ease-out forwards;
}

@keyframes status-clock-top {
  to {
    transform: rotateX(-90deg);
  }
}

@keyframes status-clock-bottom {
  to {
    transform: rotateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pd-stats-clock-old-bottom,
  .pd-stats-clock-old-flap,
  .pd-stats-clock-new-flap {
    display: none !important;
    animation: none;
  }
}

[hidden] {
  display: none;
}
