:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e3e6ec;
  --border-strong: #cfd4dc;
  --text: #1b2130;
  --muted: #667085;
  --accent: #2563eb;
  --accent-hover: #1d4fd8;
  --accent-soft: #e8efff;
  --on-accent: #ffffff;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --ok: #12965a;
  --ok-soft: #e4f6ec;
  --warn: #b25e09;
  --warn-soft: #fdf1e1;
  --purple: #7c3aed;
  --purple-soft: #f0e9ff;
  --release: #0e8f63;
  --release-soft: #e1f5ec;
  --tag: #2563eb;
  --tag-soft: #e6eeff;
  --pr: #7c3aed;
  --pr-soft: #efe8ff;
  --issue: #c2620a;
  --issue-soft: #fdefdf;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a22;
    --surface-2: #1d222c;
    --border: #282e3a;
    --border-strong: #363e4d;
    --text: #e5e8ee;
    --muted: #949cab;
    --accent: #5b8cf5;
    --accent-hover: #74a0f8;
    --accent-soft: #1b2944;
    --on-accent: #0b1220;
    --danger: #f2685c;
    --danger-soft: #3a1d1b;
    --ok: #3ccf8e;
    --ok-soft: #14301f;
    --warn: #f0a24a;
    --warn-soft: #3a2a14;
    --purple: #a98bfa;
    --purple-soft: #2a2145;
    --release: #3ccf8e;
    --release-soft: #14301f;
    --tag: #74a0f8;
    --tag-soft: #1b2944;
    --pr: #a98bfa;
    --pr-soft: #2a2145;
    --issue: #f0a24a;
    --issue-soft: #3a2a14;
    --shadow: none;
    color-scheme: dark;
  }
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

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

.small {
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- 按钮与表单 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover {
  background: var(--surface-2);
}

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

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

.btn-danger-text {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  padding: 0 10px;
}

.btn-danger-text:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

input[type="text"],
input[type="password"],
select {
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hint.warn {
  color: var(--warn);
}

.form-error {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* ---------- 加载 / 登录 ---------- */

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  display: block;
  margin: 0 auto 14px;
}

.login-card h1 {
  font-size: 22px;
}

.login-card .muted {
  margin: 6px 0 20px;
}

.login-card input {
  width: 100%;
  margin-bottom: 12px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar {
    background: var(--surface);
  }
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

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

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

.brand p {
  margin: 0;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 状态卡片 ---------- */

main.container {
  padding-top: 20px;
  padding-bottom: 32px;
}

.banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.banner-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-sub {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value.ok {
  color: var(--ok);
}

.stat-value.bad {
  color: var(--danger);
}

.stat-value.busy {
  color: var(--accent);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* ---------- 卡片 ---------- */

.card {
  margin-bottom: 16px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-2 .card {
  margin-bottom: 16px;
}

/* ---------- 添加监控项 ---------- */

.add-form {
  display: flex;
  gap: 8px;
}

.add-form input {
  flex: 1 1 auto;
}

.add-form select {
  flex: 0 0 auto;
}

/* ---------- 监控项列表 ---------- */

.group + .group {
  margin-top: 18px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.group-desc {
  font-weight: 400;
}

.group-desc::before {
  content: "·";
  margin-right: 8px;
}

.items {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
}

.item + .item {
  border-top: 1px solid var(--border);
}

.item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.item-name {
  font-weight: 600;
  word-break: break-word;
}

.item-title {
  margin-top: 2px;
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  flex: 0 0 auto;
  min-width: 58px;
  margin-top: 1px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.badge-release {
  background: var(--release-soft);
  color: var(--release);
}

.badge-tag {
  background: var(--tag-soft);
  color: var(--tag);
}

.badge-pr {
  background: var(--pr-soft);
  color: var(--pr);
}

.badge-issue {
  background: var(--issue-soft);
  color: var(--issue);
}

.badge-test {
  background: var(--surface-2);
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-open {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-merged {
  background: var(--purple-soft);
  color: var(--purple);
}

.pill-closed {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.pill-neutral {
  background: var(--accent-soft);
  color: var(--accent);
}

.empty {
  margin: 8px 0 0;
  padding: 24px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

/* ---------- 通知 / 检查记录 ---------- */

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  padding: 10px 0;
}

.entry + .entry {
  border-top: 1px solid var(--border);
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.entry-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.entry-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  align-self: center;
}

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

.dot.bad {
  background: var(--danger);
}

details {
  margin-top: 6px;
}

summary {
  width: max-content;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

pre {
  max-height: 320px;
  margin: 8px 0 0;
  padding: 10px 12px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 设置 ---------- */

.settings {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 16px 24px;
  align-items: start;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.field select {
  width: 100%;
}

.inline {
  display: flex;
  gap: 8px;
}

.inline input {
  flex: 1 1 auto;
}

.field-actions {
  grid-column: 1 / -1;
}

.qq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.qq-row .field-label {
  display: inline;
  margin-right: 10px;
}

.footer {
  padding: 8px 0 0;
  text-align: center;
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 600px) {
  body {
    font-size: 14px;
  }

  .card {
    padding: 16px 14px;
  }

  .add-form {
    flex-wrap: wrap;
  }

  .add-form input {
    flex-basis: 100%;
  }

  .add-form select {
    flex: 1 1 auto;
  }

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

  .item {
    flex-wrap: wrap;
    gap: 8px 10px;
  }

  .item .btn-danger-text {
    margin-left: auto;
  }

  .entry-head {
    flex-wrap: wrap;
  }

  .entry-title {
    flex-basis: 100%;
    white-space: normal;
  }

  .topbar-actions .btn {
    min-height: 34px;
    padding: 0 12px;
  }
}
