:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3e8ef;
  --brand: #2563eb;
  --ok: #12805c;
  --okbg: #e6f6ef;
  --err: #c0341d;
  --errbg: #fdecea;
  --warn: #8a5a00;
  --warnbg: #fdf4e0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px 56px; }

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 16px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.brand span { color: var(--brand); }
.topnav {
  display: flex;
  gap: 2px;
  margin-left: 4px;
  padding: 3px;
  background: #eef1f7;
  border-radius: 8px;
}
.topnav a {
  padding: 6px 15px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
}
.topnav a:hover { background: #e4e9f4; color: var(--ink); text-decoration: none; }
.topnav a.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 30, 60, .08); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .03);
}
.card h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: #eef2ff;
  color: var(--brand);
}

/* 状态格 */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fbfcfe; }
.stat .k { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.3; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }

.status-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.status-hero.ok { background: var(--okbg); border-color: #bfe6d6; }
.status-hero.fail { background: var(--errbg); border-color: #f3c9c1; }
.status-hero.warn { background: var(--warnbg); border-color: #f0dcae; }
.status-hero.idle { background: #f6f7fb; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--err); }
.dot.warn { background: #d69b00; }
.dot.idle { background: #9aa3b2; }
.hero-title { font-size: 16px; font-weight: 700; line-height: 1.35; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }

/* 状态徽标 */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.fail { background: var(--errbg); color: var(--err); }
.badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.run { background: #eef2ff; color: var(--brand); }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; letter-spacing: .2px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.ellipsis { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 表单 */
label.field { display: block; margin-bottom: 16px; }
label.field > .lab { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; }
label.field > .hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 96px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: auto; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 18px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); border-color: #d8dee9; }
.btn.ghost:hover { background: #f6f8fd; filter: none; }
.btn.danger { background: #fff; color: var(--err); border-color: #f0c3ba; }
.btn.sm { min-height: 30px; padding: 5px 12px; font-size: 12.5px; border-radius: 7px; }
.btnline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 提示条 */
.flash {
  padding: 11px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.flash.ok { background: var(--okbg); color: var(--ok); border-color: #bfe6d6; }
.flash.err { background: var(--errbg); color: var(--err); border-color: #f3c9c1; }
.flash.warn { background: var(--warnbg); color: var(--warn); border-color: #f0dcae; }

/* 登录页 */
.authbox {
  max-width: 380px;
  margin: 9vh auto 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 26px;
  box-shadow: 0 10px 30px rgba(20, 30, 60, .06);
}
.authbox h1 { font-size: 19px; margin: 0 0 4px; }
.authbox p.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.authbox .btn { width: 100%; margin-top: 4px; }

/* 分页 */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 详情 */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 16px; font-size: 13.5px; align-items: baseline; }
.kv .k { color: var(--muted); }
.errtext { color: var(--err); }

.empty { color: var(--muted); font-size: 13.5px; padding: 18px 0; text-align: center; }
.empty p { margin: 0 0 14px; }
.muted { color: var(--muted); }

/* 页面头部 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px 0 16px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; line-height: 1.3; }
.page-sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }
.crumb { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }

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

.notice {
  background: #f6f8fc;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13.5px;
  color: var(--ink);
}

.filterline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filterline select { width: auto; min-width: 180px; }

.badge.idle { background: #f1f3f7; color: var(--muted); }

/* 定时状态条 */
.schedule-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  font-size: 13.5px;
}
.schedule-line .muted { font-size: 12.5px; margin-left: 8px; }

/* 站点卡片 */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.site-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.site-card:hover { border-color: #d3dbe8; box-shadow: 0 4px 14px rgba(20, 30, 60, .05); }
.site-card.off { opacity: .72; }
.site-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.site-card-head .badge { flex: none; margin-top: 2px; }
.site-ident { min-width: 0; }
.site-name {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-name:hover { color: var(--brand); text-decoration: none; }
.site-domain {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-source {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f9fc;
  border: 1px solid #eef1f7;
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
}
.site-source .src-lab {
  flex: none;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  background: #e9edf5;
  border-radius: 4px;
  padding: 0 6px;
}
.site-source .src-url {
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-heat-wrap { display: flex; flex-direction: column; gap: 10px; }
.heat-cap { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
.heat-cap .cap-label { font-size: 12px; color: var(--muted); }
.heat-cap .heat-legend { gap: 9px; }
.site-meta {
  display: flex;
  align-items: center;
  gap: 4px 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.site-actions { margin-top: auto; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.site-actions form { display: inline-flex; }
.site-actions .btn { margin: 0; }

/* 30 天状态格 */
.heat { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.heat.compact { grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.heat.full { grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 4px; }
.heat .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.heat.compact .cell {
  height: 16px;
  font-size: 0;
  line-height: 0;
  border-radius: 3px;
}
.heat.full .cell { height: 28px; }
.cell.ok { background: #d8f3e6; color: #0f6b4d; border-color: #b7e4cf; }
.cell.warn { background: #fbeecb; color: #8a5a00; border-color: #f0dcae; }
.cell.fail { background: #f9d9d3; color: #a72a16; border-color: #f0c3ba; }
.cell.run { background: #dbe6ff; color: #1d4ed8; border-color: #c3d4fe; }
.cell.none { background: #f1f3f7; color: #9aa3b2; border-color: #e8ecf3; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.heat-legend.wide { margin-top: 14px; }
.heat-legend span { display: inline-flex; align-items: center; gap: 5px; }
.heat-legend .cell { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.site-heat-wrap .heat-legend { font-size: 11.5px; gap: 10px; }

/* 详情页布局 */
.detail-top {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.detail-top > .card { margin-bottom: 0; }
.detail-top + .card { margin-top: 16px; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }
.detail-side .card { margin-bottom: 0; }
.detail-side .status-hero { align-items: flex-start; }
.detail-side .status-hero .dot { margin-top: 4px; }
.stats2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.table-wrap { overflow-x: auto; }

@media (max-width: 960px) {
  .detail-top { grid-template-columns: 1fr; }
  .heat.full { grid-template-columns: repeat(15, minmax(0, 1fr)); }
}

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

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .row2 { grid-template-columns: 1fr; }
  .ellipsis { max-width: 160px; }
  .kv { grid-template-columns: 92px 1fr; }
  .heat { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .heat.full { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .heat.full .cell { height: 24px; }
  .table-wrap table { min-width: 520px; }
  .site-actions { justify-content: stretch; }
  .site-actions form, .site-actions .btn { flex: 1 1 0; }
  .page-head { align-items: flex-start; }
  .page-title { font-size: 20px; }
}
