:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ec;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --up: #16a34a;
  --up-soft: #e8f7ee;
  --down: #dc2626;
  --down-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fdf4e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #191c21;
    --border: #2a2f37;
    --text: #e6e8eb;
    --muted: #9aa3af;
    --accent: #5b8dff;
    --accent-soft: #1c2740;
    --up: #4ade80;
    --up-soft: #14301f;
    --down: #f87171;
    --down-soft: #3a1a1c;
    --warn: #fbbf24;
    --warn-soft: #3a2e14;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  font-weight: 650;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .2px;
}
.brand:hover { text-decoration: none; }

.brand-logo {
  width: 22px;
  height: 22px;
  display: block;
  flex: 0 0 auto;
}

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}
.flash-ok { border-color: color-mix(in srgb, var(--up) 40%, var(--border)); background: var(--up-soft); color: var(--up); }
.flash-error { border-color: color-mix(in srgb, var(--down) 40%, var(--border)); background: var(--down-soft); color: var(--down); }

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.2px; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 620; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -.5px; }
.stat-value.ok { color: var(--up); }
.stat-value.bad { color: var(--down); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h2 { margin: 0; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.site-name { font-weight: 600; display: block; margin-bottom: 2px; }
.site-url { color: var(--muted); font-size: 12.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-up { background: var(--up-soft); color: var(--up); }
.badge-down { background: var(--down-soft); color: var(--down); }
.badge-unknown { background: var(--warn-soft); color: var(--warn); }
.badge-paused { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); filter: none; }
.btn-danger { background: transparent; color: var(--down); border-color: var(--border); }
.btn-danger:hover { background: var(--down-soft); filter: none; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.inline { display: inline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

form.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 550; font-size: 13.5px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.check { display: flex; align-items: flex-start; gap: 9px; }
.check input { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--accent); }
.check span { font-size: 13.5px; }
.check .hint { display: block; color: var(--muted); font-size: 12.5px; }
.form-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}
.form-foot .spacer { flex: 1; }

.section-title { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 26px 0 10px; }

.tpl-box { border: 1px solid var(--border); border-radius: 9px; padding: 0 14px; background: var(--surface); }
.tpl-box summary { cursor: pointer; padding: 12px 0; font-weight: 550; font-size: 13.5px; }
.tpl-body { padding-bottom: 14px; display: grid; gap: 14px; }
.tpl-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.tpl-title { font-weight: 620; font-size: 13px; }
.tpl-block input, .tpl-block textarea { background: var(--surface); }

.trend {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 170px;
  padding: 8px 4px 0;
  overflow-x: auto;
}
.trend-col { flex: 1 0 6px; min-width: 6px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.trend-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
  min-height: 2px;
  transition: background .15s;
}
.trend-bar.failed { background: var(--down); }
.trend-bar.empty { background: var(--border); }
.trend-col:hover .trend-bar { background: var(--accent); }
.trend-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11.5px;
  padding: 6px 4px 0;
}

.code-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}
.sc-2xx { background: var(--up-soft); color: var(--up); }
.sc-3xx { background: var(--accent-soft); color: var(--accent); }
.sc-4xx { background: var(--warn-soft); color: var(--warn); }
.sc-5xx { background: var(--down-soft); color: var(--down); }
.sc-none { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.sc-other { background: var(--bg); color: var(--muted); }

.dist-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}
.dist-fill { height: 100%; border-radius: 4px; }
.dist-fill.sc-2xx { background: var(--up); }
.dist-fill.sc-3xx { background: var(--accent); }
.dist-fill.sc-4xx { background: var(--warn); }
.dist-fill.sc-5xx { background: var(--down); }
.dist-fill.sc-none { background: var(--muted); }
.dist-fill.sc-other { background: var(--muted); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.kv .stat { box-shadow: none; background: var(--bg); border-color: transparent; padding: 12px 14px; }
.kv .stat-value { font-size: 19px; }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty p { margin: 0 0 18px; }

.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.tabs a { padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.tabs a:hover { text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 28px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .08);
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; text-align: center; }
.login-logo { display: block; width: 68px; height: 68px; margin: 0 auto 18px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; text-align: center; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border));
  font-size: 13.5px;
  margin-bottom: 18px;
}
.notice a { color: inherit; text-decoration: underline; }

@media (max-width: 900px) {
  .hide-md { display: none; }
  .trunc { max-width: 190px; }
  .actions { flex-wrap: nowrap; }
  .actions .btn { padding: 4px 8px; font-size: 12px; }
}

@media (max-width: 760px) {
  .hide-sm { display: none; }
  .trunc { max-width: 110px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 14px; padding: 0 14px; }
  .who { display: none; }
  .wrap { padding: 18px 14px 48px; }
}
