:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --border: #e5e7eb;
  --text: #111827;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2563eb;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --down: #dc2626;
  --down-bg: #fef2f2;
  --gray-bg: #f3f4f6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  flex: 0 0 auto;
}

.brand-text h1 { margin: 0; font-size: 18px; line-height: 1.3; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.muted { font-size: 13px; color: var(--text-dim); }

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-soft); border-color: #d1d5db; }
.btn:disabled { opacity: 0.6; cursor: default; }

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.summary-left { display: flex; align-items: center; gap: 14px; }

.summary-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.summary-dot.ok { background: var(--ok); }
.summary-dot.warn { background: var(--warn); }
.summary-dot.down { background: var(--down); }
.summary-dot.unknown { background: var(--text-faint); }

.summary-title { font-size: 16px; font-weight: 700; }
.summary-sub { font-size: 13px; color: var(--text-dim); }

.summary-stats { display: flex; gap: 26px; }

.summary-stat { text-align: right; }
.summary-stat .ss-label { font-size: 12px; color: var(--text-dim); }
.summary-stat .ss-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-stat .ss-value.ok { color: var(--ok); }
.summary-stat .ss-value.warn { color: var(--warn); }
.summary-stat .ss-value.down { color: var(--down); }

.platforms { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }

details.platform {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

details.platform summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
}

details.platform summary::-webkit-details-marker { display: none; }

.pf-name { font-weight: 700; font-size: 15px; min-width: 130px; }
.pf-home { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.pf-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.pf-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.pf-status.ok { color: var(--ok); }
.pf-status.degraded { color: var(--warn); }
.pf-status.down { color: var(--down); }
.pf-status.unknown { color: var(--text-dim); }
.pf-status.ok .dot { background: var(--ok); }
.pf-status.degraded .dot { background: var(--warn); }
.pf-status.down .dot { background: var(--down); }
.pf-status.unknown .dot { background: var(--text-faint); }

.pf-meta { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.pf-latency { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-uptime { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-uptime.ok { color: var(--ok); }
.pf-uptime.degraded { color: var(--warn); }
.pf-uptime.down { color: var(--down); }
.pf-uptime.unknown { color: var(--text-faint); }

.chevron {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  transition: transform 0.18s ease;
  color: var(--text-faint);
}

details.platform[open] .chevron { transform: rotate(180deg); }

.pf-content {
  border-top: 1px solid var(--border);
  padding: 16px 18px 18px;
  background: var(--bg);
}

.uptime-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.chip {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  min-width: 110px;
}

.chip .chip-label { font-size: 11px; color: var(--text-dim); }
.chip .chip-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip .chip-value.ok { color: var(--ok); }
.chip .chip-value.degraded { color: var(--warn); }
.chip .chip-value.down { color: var(--down); }
.chip .chip-value.unknown { color: var(--text-faint); }
.chip .chip-sample { font-size: 11px; color: var(--text-faint); }

.models-title { font-size: 13px; color: var(--text-dim); margin: 4px 0 8px; }

.model-table { width: 100%; border-collapse: collapse; }

.model-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.model-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.model-table tr:last-child td { border-bottom: 0; }
.model-table .m-name { font-weight: 600; }

.m-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.m-badge.ok { background: var(--ok-bg); color: var(--ok); }
.m-badge.degraded { background: var(--warn-bg); color: var(--warn); }
.m-badge.down { background: var(--down-bg); color: var(--down); }
.m-badge.missing { background: var(--gray-bg); color: var(--text-dim); }
.m-badge.inherited { background: var(--gray-bg); color: var(--text-dim); }

.m-note { font-size: 12px; color: var(--text-faint); }

.spark-wrap { margin-top: 14px; }
.spark-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.spark { display: block; width: 100%; height: 44px; }

.pf-lastcheck { margin-top: 10px; font-size: 12px; color: var(--text-faint); }

.footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 26px 0 40px;
}

.loading, .empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 14px;
}

@media (max-width: 720px) {
  .summary-stats { gap: 16px; }
  details.platform summary { flex-wrap: wrap; }
  .pf-meta { margin-left: 0; width: 100%; justify-content: space-between; }
  .pf-name { min-width: 0; }
}
