:root {
  /* 主字体：LXGW WenKai Mono（等宽，由 Vite 打包子集 woff2）；无则回退系统字体 */
  --font-app: "LXGW WenKai Mono", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --font-mono: "LXGW WenKai Mono", ui-monospace, "Cascadia Code", monospace;
  /* 随机背景高斯模糊（CSS blur 无百分比，按「10%」诉求取 10px，可按需改） */
  --rand-bg-blur: 10px;
  --rand-bg-scale: 1.08;
  font-family: var(--font-app);
  line-height: 1.5;
  font-weight: 400;
  color: #222;
  background-color: #f4f6f8;
  --green: #2ecc71;
  --green-dark: #27ae60;
  --red: #e74c3c;
  --card: #fff;
  --muted: #6b7280;
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: #dfe6eb;
}

#root {
  min-height: 100vh;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* https://randbg.smyhub.com — 全站随机底图，轻微缩放避免模糊露边 */
.app-rand-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  filter: blur(var(--rand-bg-blur));
  transform: scale(var(--rand-bg-scale));
  transform-origin: center center;
}

@media (prefers-reduced-motion: reduce) {
  .app-rand-bg {
    filter: none;
    transform: none;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

a.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  padding: 0.35rem 0.5rem;
  margin: 0;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a.brand:hover {
  text-decoration: none;
}

a.brand:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.admin-code-sample {
  display: inline-block;
  padding: 0.25rem 0.45rem;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 0.9rem;
  word-break: break-all;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  touch-action: manipulation;
  cursor: pointer;
}

.brand-text {
  font-weight: 700;
  font-size: 1.1rem;
}

.top-nav {
  display: flex;
  gap: 1rem;
}

.top-nav a {
  font-weight: 500;
  color: #374151;
}

.main-area {
  flex: 1;
  padding: 1.25rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-intro {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.dot.ok {
  background: var(--green);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.pill.active {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.12);
  color: var(--green-dark);
}

.search input {
  min-width: 220px;
  width: min(420px, 100%);
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  font: inherit;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 1rem;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.card-title-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  min-width: 0;
}

.card-name {
  margin: 0;
  font-size: 1.05rem;
  word-break: break-word;
}

.card-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.card-sub-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.card-sub-row-model {
  min-width: 0;
  width: 100%;
}

.card-sub-col-protocol {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.card-sub-protocol-path {
  color: #0f766e;
  font-weight: 500;
  font-size: 0.76rem;
  line-height: 1.35;
  word-break: break-word;
}

.card-sub-meta-after,
.card-sub-paused-after {
  margin-top: 0.2rem;
  font-size: 0.76rem;
  line-height: 1.35;
}

.card-sub-model {
  color: #1e3a5f;
  font-weight: 600;
  word-break: break-word;
}

.card-sub-protocol {
  color: #0f766e;
  font-weight: 500;
}

.card-sub-meta {
  color: #64748b;
  font-weight: 500;
}

.card-sub-paused {
  color: #c2410c;
  font-weight: 600;
}

.card-sub-sep {
  color: #cbd5e1;
  font-weight: 400;
}

.card-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.badge-ok {
  background: rgba(46, 204, 113, 0.16);
  color: var(--green-dark);
}

.badge-bad {
  background: rgba(231, 76, 60, 0.12);
  color: #c0392b;
}

.btn-detail {
  display: inline-block;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--green), #58d68d);
  color: #fff;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

.btn-detail:hover {
  filter: brightness(1.03);
}

.btn-detail:focus-visible {
  outline: 2px solid var(--green-dark);
  outline-offset: 2px;
}

.probe-detail-dialog {
  max-width: min(520px, 94vw);
  width: 100%;
  margin: auto;
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.probe-detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.probe-detail-inner {
  padding: 1rem 1.15rem 1.15rem;
}

.probe-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.probe-detail-title {
  margin: 0;
  font-size: 1.05rem;
}

.probe-detail-close {
  border: none;
  background: #f1f5f9;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  display: grid;
  place-items: center;
  padding: 0;
}

.probe-detail-close:hover {
  background: #e2e8f0;
}

.probe-detail-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.88rem;
}

.probe-detail-dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.probe-detail-dl dd {
  margin: 0;
  word-break: break-word;
}

.probe-detail-code {
  display: block;
  font-size: 0.78rem;
  background: #f8fafc;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  word-break: break-all;
  margin-bottom: 0.35rem;
}

.probe-detail-link-wrap {
  font-size: 0.85rem;
}

.probe-detail-error {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.probe-detail-error strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: #c0392b;
}

.probe-detail-pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fef2f2;
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  max-height: 220px;
  overflow: auto;
}

.probe-detail-io {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.probe-detail-io strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  margin-top: 0.65rem;
  color: #374151;
}

.probe-detail-io strong:first-child {
  margin-top: 0;
}

.probe-detail-io-pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  max-height: 200px;
  overflow: auto;
}

.probe-detail-io-out {
  background: #f0fdf4;
  border-color: rgba(46, 204, 113, 0.25);
}

.timeline {
  display: flex;
  align-items: stretch;
  gap: 1px;
  height: 42px;
  padding: 4px 2px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.timeline-empty {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.25rem 0.35rem;
}

.tl-seg {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 1px;
  align-self: stretch;
  background: #cbd5e1;
}

.tl-seg.tl-none {
  background: #e2e8f0;
  opacity: 0.9;
}

.tl-seg.tl-up {
  background: var(--green);
}

.tl-seg.tl-warn {
  background: linear-gradient(180deg, #facc15, #eab308);
  box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.22);
}

.tl-seg.tl-down {
  background: var(--red);
}

.card-mid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.card-mid-edge {
  color: #94a3b8;
  font-size: 0.72rem;
}

.card-mid-pct {
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.card-foot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
  font-size: 0.78rem;
}

.card-foot-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.card-foot-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-metric-value {
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
  color: #1e293b;
}

.card-metric-value-muted {
  color: #94a3b8 !important;
  font-weight: 500;
}

.card-accent-http-ok {
  color: #15803d;
}

.card-accent-http-info {
  color: #0369a1;
}

.card-accent-http-client {
  color: #c2410c;
}

.card-accent-http-server {
  color: #b91c1c;
}

.card-accent-latency-good {
  color: #15803d;
}

.card-accent-latency-mid {
  color: #b45309;
}

.card-accent-latency-slow {
  color: #b91c1c;
}

.card-accent-pct-high {
  color: #15803d;
}

.card-accent-pct-mid {
  color: #3f6212;
}

.card-accent-pct-low {
  color: #b45309;
}

.card-accent-pct-critical {
  color: #b91c1c;
}

.card-foot-probe-time {
  min-width: 0;
}

.card-foot-probe-value {
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
  word-break: break-word;
  color: #3730a3;
}

.card-foot-wide {
  grid-column: 1 / -1;
}

.card-foot-count-row {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.35rem;
  margin-top: 0.1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.card-foot-count-value {
  font-size: 0.9rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #6d28d9;
}

.banner {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.35);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  margin: 0;
}

.banner.error {
  background: rgba(231, 76, 60, 0.08);
  border-color: rgba(231, 76, 60, 0.35);
  color: #922b21;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 1rem;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  width: min(360px, 100%);
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.28);
}

.modal-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.admin-token-backdrop {
  z-index: 10002;
}

.admin-token-modal {
  width: min(300px, 100%);
  padding: 0.85rem 0.95rem;
}

.admin-token-title {
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}

.admin-token-input {
  font-size: 0.9rem;
}

.admin-token-modal .modal-actions {
  margin-top: 0.55rem;
}

.modal-input {
  width: 100%;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font: inherit;
}

.modal-err {
  color: #c0392b;
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  padding: 0.4rem 0.75rem;
  font: inherit;
  cursor: pointer;
  background: #fff;
}

.btn.primary {
  background: linear-gradient(145deg, var(--green), #58d68d);
  color: #fff;
  border: none;
  font-weight: 600;
}

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

.btn.ghost {
  background: transparent;
}

.btn.small {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}

.btn.danger {
  border-color: rgba(192, 57, 43, 0.45);
  color: #c0392b;
}

.admin-form-section {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.65rem 1rem;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: #374151;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  font: inherit;
}

.admin-form textarea {
  grid-column: 1 / -1;
  min-height: 5.5rem;
  resize: vertical;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.admin-monitor-grid {
  margin-top: 0.75rem;
}

.admin-monitors-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-monitors-head h2 {
  margin: 0;
}

.admin-monitor-dialog {
  max-width: min(720px, 96vw);
}

.admin-monitor-dialog-inner {
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

.admin-form--modal {
  overflow-y: auto;
  padding-right: 0.15rem;
  flex: 1;
  min-height: 0;
}

.card-admin-footer {
  margin-top: 0.15rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.card-admin-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: center;
}

.card-admin-fallback-msg {
  margin: 0;
}

.admin-actions-bar {
  display: flex;
  justify-content: flex-end;
}

.pwa-update-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  max-width: min(520px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(46, 204, 113, 0.35);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.pwa-update-text {
  margin: 0;
  font-size: 0.88rem;
  color: #374151;
  flex: 1 1 12rem;
}

.pwa-update-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-foot {
    grid-template-columns: 1fr;
  }
}
