/* ============================================================
   Beacon Monitor — status page styles
   ============================================================ */

:root {
  --bg: #f4f5f8;
  --bg-soft: #eceef3;
  --card: #ffffff;
  --card-soft: #fafbfd;
  --border: #e5e8ef;
  --border-strong: #d5dae4;
  --text: #14161c;
  --text-2: #3d4351;
  --muted: #6d7484;
  --muted-2: #9aa1b0;

  --green: #17a34a;
  --green-soft: #e7f8ee;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --amber-soft: #fdf2e3;
  --gray-bar: #e3e6ed;
  --brand: #4f46e5;
  --brand-soft: #eeecff;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 28px -16px rgba(16, 24, 40, 0.22);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, 0.35);

  --radius: 16px;
  --radius-sm: 10px;
  --max: 1120px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-soft: #101319;
  --card: #14171f;
  --card-soft: #181c25;
  --border: #232833;
  --border-strong: #2f3644;
  --text: #e9ebf2;
  --text-2: #c3c9d6;
  --muted: #98a0b0;
  --muted-2: #6b7385;

  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --gray-bar: #252b36;
  --brand: #8b85ff;
  --brand-soft: rgba(139, 133, 255, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }

/* hidden 属性必须胜过组件自身的 display */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: inherit; text-decoration: none; }

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 380px at 18% -8%, rgba(79, 70, 229, 0.10), transparent 70%),
    radial-gradient(680px 320px at 92% 2%, rgba(23, 163, 74, 0.08), transparent 72%);
}
html[data-theme="dark"] .bg-glow {
  background:
    radial-gradient(760px 380px at 18% -8%, rgba(139, 133, 255, 0.16), transparent 70%),
    radial-gradient(680px 320px at 92% 2%, rgba(52, 211, 153, 0.10), transparent 72%);
}

.page {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 20px 56px;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px 20px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand), #6d63ff);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(79, 70, 229, 0.7);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text small {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: var(--card); }
.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn .i { width: 15px; height: 15px; }

html[data-theme="light"] .i-sun,
html[data-theme="dark"] .i-moon { display: none; }
html[data-theme="light"] .i-moon { display: block; }

/* ---------------- hero ---------------- */

.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 30px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    radial-gradient(520px 200px at 0% 0%, var(--green-soft), transparent 72%),
    var(--card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--green-soft), transparent 68%);
  pointer-events: none;
}
.hero.is-down {
  background: radial-gradient(520px 200px at 0% 0%, var(--red-soft), transparent 72%), var(--card);
}
.hero.is-down::after { background: radial-gradient(circle, var(--red-soft), transparent 68%); }

.hero-main { min-width: 0; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.hero-badge.is-down { background: var(--red-soft); color: var(--red); }
.hero-badge.is-loading { background: var(--bg-soft); color: var(--muted); }

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(23, 163, 74, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(23, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 163, 74, 0); }
}

.hero h1 {
  margin: 12px 0 4px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--muted-2);
}
.hero-meta .sep { opacity: 0.6; }

.hero-stats {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: none;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  overflow: hidden;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 92px;
  padding: 14px 18px;
  border-left: 1px solid var(--border);
}
.stat:first-child { border-left: 0; }
.stat b {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat span { font-size: 11.5px; color: var(--muted); }

/* ---------------- groups ---------------- */

.groups { margin-top: 28px; display: flex; flex-direction: column; gap: 26px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 2px;
}
.group-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.group-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.group-count.is-ok { background: var(--green-soft); color: var(--green); }
.group-count.is-bad { background: var(--red-soft); color: var(--red); }
.group-head .spacer { flex: 1; }
.group-head .group-note { font-size: 12px; color: var(--muted-2); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--green);
  opacity: 0.85;
}
.card.is-down::before { background: var(--red); }
.card.is-slow::before { background: var(--amber); }
.card.is-pending::before { background: var(--muted-2); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 630;
  letter-spacing: -0.01em;
}
.card-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .ext { width: 13px; height: 13px; color: var(--muted-2); flex: none; opacity: 0; transition: opacity 0.15s ease; }
.card:hover .ext { opacity: 1; }

.card-host {
  margin-top: -6px;
  font-size: 11.5px;
  color: var(--muted-2);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  flex: none;
  background: var(--bg-soft);
  color: var(--muted);
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-up { background: var(--green-soft); color: var(--green); }
.pill-down { background: var(--red-soft); color: var(--red); }
.pill-slow { background: var(--amber-soft); color: var(--amber); }
.pill-pending { background: var(--bg-soft); color: var(--muted-2); }

.card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 0 2px;
}
.metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.metric span { font-size: 11px; color: var(--muted-2); white-space: nowrap; }
.metric b {
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric b.warn { color: var(--amber); }
.metric b.bad { color: var(--red); }
.metric b.dim { color: var(--muted-2); font-weight: 500; }

.heartbeat {
  display: flex;
  align-items: stretch;
  gap: 1px;
  height: 28px;
  cursor: default;
}
.hb-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 1px;
  background: var(--gray-bar);
  opacity: 0.7;
  transition: background 0.2s ease, opacity 0.15s ease;
}
.hb-bar.up { background: var(--green); opacity: 0.92; }
.hb-bar.slow { background: var(--amber); opacity: 0.92; }
.hb-bar.down { background: var(--red); opacity: 1; }
.hb-bar:hover { opacity: 1; filter: brightness(1.08); }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted-2);
}
.card-foot .hint { opacity: 0; transition: opacity 0.15s ease; }
.card:hover .card-foot .hint { opacity: 1; }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  background: var(--card);
}
.empty-state b { display: block; margin-bottom: 6px; color: var(--text); font-size: 15px; }
.empty-state a { color: var(--brand); font-weight: 600; }

/* ---------------- skeleton ---------------- */

.skeleton-group {
  width: 140px;
  height: 16px;
  border-radius: 6px;
  background: var(--bg-soft);
  margin-bottom: 14px;
  animation: shimmer 1.4s infinite linear;
}
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 14px; }
.skeleton-card {
  height: 162px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--card) 25%, var(--bg-soft) 37%, var(--card) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ---------------- footer ---------------- */

.footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted-2);
  font-size: 12px;
}
.footer p { margin: 0 0 6px; }
.footer a { color: var(--muted); border-bottom: 1px solid var(--border-strong); }
.footer a:hover { color: var(--brand); border-color: var(--brand); }

/* ---------------- modal ---------------- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(9, 11, 16, 0.45);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}
.modal-panel {
  position: relative;
  width: min(680px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: popIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } }

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.modal-title-row { display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 680; letter-spacing: -0.02em; }
.modal-url {
  display: inline-block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-url:hover { color: var(--brand); }

.modal-body { padding: 16px 20px 20px; }

.range-tabs {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--bg-soft);
  margin-bottom: 16px;
}
.range-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.range-tabs button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.chart-stat {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  border: 1px solid var(--border);
}
.chart-stat span { display: block; font-size: 11px; color: var(--muted-2); margin-bottom: 2px; }
.chart-stat b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

.chart-box {
  height: 210px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-soft);
  padding: 12px 8px 4px;
  overflow: hidden;
}
.chart-box svg { width: 100%; height: 100%; display: block; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted-2); font-size: 13px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.detail-grid div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 3px 0; }
.detail-grid dt { margin: 0; font-size: 12.5px; color: var(--muted); }
.detail-grid dd {
  margin: 0;
  font-size: 12.5px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}

.bar-tip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  padding: 6px 9px;
  border-radius: 7px;
  background: rgba(17, 20, 27, 0.92);
  color: #fff;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: nowrap;
  transform: translate(-50%, -130%);
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
}
.bar-tip[hidden] { display: none; }

/* ---------------- responsive ---------------- */

/* ---------------- 嵌入模式（?embed=1，供博客 iframe 使用） ---------------- */

html[data-embed="1"] .topbar,
html[data-embed="1"] .footer,
html[data-embed="1"] .bg-glow { display: none; }

html[data-embed="1"] .page { max-width: none; padding: 10px 12px 12px; }
html[data-embed="1"] .group-note { display: none; }
html[data-embed="1"] .hero { padding: 18px 20px; gap: 16px; border-radius: 16px; }
html[data-embed="1"] .hero h1 { font-size: 21px; margin-top: 8px; }
html[data-embed="1"] .hero-meta { margin-top: 10px; }
html[data-embed="1"] .stat { min-width: 76px; padding: 10px 14px; }
html[data-embed="1"] .groups { margin-top: 16px; gap: 18px; }
html[data-embed="1"] .cards { grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); gap: 12px; }
html[data-embed="1"] .card { padding: 14px 14px 10px; }
html[data-embed="1"] body { background: transparent; }

@media (max-width: 860px) {
  .hero { flex-direction: column; align-items: stretch; gap: 20px; padding: 22px; }
  .hero h1 { font-size: 24px; }
  .hero-stats { justify-content: space-between; }
  .stat { flex: 1; min-width: 0; padding: 12px 10px; }
  .page { padding: 16px 14px 44px; }
  .chart-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
}

@media (max-width: 520px) {
  .btn span { display: none; }
  .btn { width: 34px; padding: 0; justify-content: center; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .brand-text strong { font-size: 15px; }
  .hero h1 { font-size: 21px; }
  .cards { grid-template-columns: 1fr; }
  .card-metrics { gap: 4px; }
  .modal { padding: 0; }
  .modal-panel { max-height: 100vh; border-radius: 0; width: 100%; }
  .hero-meta { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
