/*
 * 站点质量监控控制台 —— 样式
 * 浅色主题，仪表盘风格
 */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2530;
  --text-dim: #6b7683;
  --text-mute: #98a1ad;

  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #16a34a;
  --ok-soft: #eaf7ee;
  --warn: #d97706;
  --warn-soft: #fef4e6;
  --err: #dc2626;
  --err-soft: #fdecec;
  --purple: #7c3aed;
  --cyan: #0891b2;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  padding: 0 18px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.logo h1 { font-size: 15px; margin: 0 0 2px; font-weight: 650; }
.logo p { margin: 0; font-size: 11px; color: var(--text-mute); }

.nav-item {
  padding: 9px 18px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  border-left: 3px solid transparent;
  transition: all .12s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0 0 3px; font-size: 19px; font-weight: 650; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  margin-bottom: 5px;
  color: var(--text-dim);
}
.field .hint { font-size: 11px; color: var(--text-mute); margin-top: 4px; }

input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
textarea { resize: vertical; min-height: 78px; font-family: ui-monospace, monospace; font-size: 12px; }

.row { display: grid; gap: 12px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.row.c4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- 复选组 ---------- */
.chk-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.chk:hover { border-color: var(--accent); }
.chk input { margin: 0; }
.chk.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- 按钮 ---------- */
.btn {
  padding: 7px 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1d4ed8; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.xs { padding: 2px 8px; font-size: 11px; line-height: 1.5; }
/* 卡片右上角的按钮组：状态标签 + 暂停/继续 */
.tc-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 指标卡 ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.metric .label { font-size: 11px; color: var(--text-dim); margin-bottom: 5px; }
.metric .value { font-size: 23px; font-weight: 650; line-height: 1.15; }
.metric .sub { font-size: 11px; color: var(--text-mute); margin-top: 3px; }
.metric.ok .value { color: var(--ok); }
.metric.warn .value { color: var(--warn); }
.metric.err .value { color: var(--err); }
.metric.accent .value { color: var(--accent); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  text-align: left;
  padding: 9px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.tbl-wrap { overflow-x: auto; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 550;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--accent-soft); color: var(--accent); }
.tag.mute { background: var(--bg); color: var(--text-mute); }
.tag.desktop { background: #f3e8ff; color: var(--purple); }
.tag.mobile { background: #ecfeff; color: var(--cyan); }

/* ---------- 进度条 ---------- */
.pbar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.pbar > div { height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- 条形图 ---------- */
.bar-row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.bar-label { width: 88px; font-size: 12px; color: var(--text-dim); flex-shrink: 0;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 16px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.bar-val { width: 92px; font-size: 11.5px; color: var(--text-dim); text-align: right; flex-shrink: 0; }

/* ---------- 提示条 ---------- */
.banner {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid;
}
.banner.info { background: var(--accent-soft); border-color: #bfdbfe; color: #1e40af; }
.banner.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.banner.err { background: var(--err-soft); border-color: #fecaca; color: #991b1b; }
.banner.ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }

/* ---------- 任务卡 ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  transition: all .12s;
  background: #fff;
}
.task-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.task-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.task-card .tc-head { display: flex; justify-content: space-between; align-items: center;
                      margin-bottom: 7px; gap: 10px; }
.task-card .tc-name { font-weight: 600; font-size: 13.5px; }
.task-card .tc-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }

/* ---------- 状态点 ---------- */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot.pending { background: var(--text-mute); }
.dot.running { background: var(--accent); animation: pulse 1.3s infinite; }
.dot.completed { background: var(--ok); }
.dot.failed { background: var(--err); }
.dot.cancelled { background: var(--warn); }
/* 暂停：橙色但不再闪烁 —— 一闪一闪会让人以为还在跑 */
.dot.paused { background: var(--warn); }

/* 轻量提示条 */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: #fff; padding: 9px 18px; border-radius: 6px;
  font-size: 13px; z-index: 999; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-mute); }
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .35; }
.empty p { margin: 0 0 4px; font-size: 13.5px; }
.empty small { font-size: 12px; }

/* ---------- 其他 ---------- */
.split { display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.dim { color: var(--text-dim); }
.mute { color: var(--text-mute); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 340px;
  overflow-y: auto;
  line-height: 1.65;
}
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.issue { padding: 8px 11px; border-radius: 6px; font-size: 12.5px; margin-bottom: 6px; }
.issue.error { background: var(--err-soft); color: #991b1b; }
.issue.warning { background: var(--warn-soft); color: #92400e; }
.issue .u { font-weight: 600; }
details summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim);
                  padding: 5px 0; user-select: none; }
details summary:hover { color: var(--text); }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .row.c4 { grid-template-columns: 1fr 1fr; }
  .row.c3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar { width: 60px; padding: 12px 0; }
  .sidebar .nav-item span, .logo h1, .logo p { display: none; }
  .main { padding: 14px; }
  .row.c2, .row.c4 { grid-template-columns: 1fr; }
}