:root {
  --bg: #0b1020;
  --bg-soft: #111830;
  --card: #141c33;
  --card-2: #182142;
  --border: #23305a;
  --text: #e8eeff;
  --muted: #93a1c8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, .12), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(167, 139, 250, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.small { font-size: 12px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: .3px;
}
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card .logo {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 22px; margin-bottom: 16px;
}
input[type="password"], input[type="text"], input[type="date"], select, input[type="search"] {
  width: 100%;
  background: #0d1428;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .15);
}
button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  padding: 9px 14px;
  font-size: 13px;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #1f2a52; border-color: #334272; }
button:active { transform: translateY(1px); }
button.primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-color: transparent;
  color: #04121f;
  font-weight: 700;
}
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button:disabled { opacity: .55; cursor: not-allowed; }
.login-card button.primary { width: 100%; margin-top: 16px; padding: 11px; font-size: 14px; }
.login-err { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: rgba(11, 16, 32, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 14px; color: #06121f;
}
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: transparent;
  border: 1px solid transparent;
  padding: 7px 13px;
  color: var(--muted);
  border-radius: 9px;
}
.tabs button.active {
  background: rgba(56, 189, 248, .14);
  border-color: rgba(56, 189, 248, .35);
  color: var(--text);
  font-weight: 600;
}
.spacer { flex: 1; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.controls select, .controls input[type="date"] { width: auto; min-width: 120px; padding: 8px 10px; font-size: 13px; }
.chips { display: flex; gap: 4px; background: #0d1428; border: 1px solid var(--border); padding: 3px; border-radius: 11px; }
.chips button {
  background: transparent; border: none; color: var(--muted);
  padding: 5px 10px; font-size: 12.5px; border-radius: 8px;
}
.chips button.active { background: rgba(56, 189, 248, .16); color: var(--text); font-weight: 600; }

main { padding: 20px 22px 60px; max-width: 1560px; margin: 0 auto; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cfdaf8;
}
.card h3 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.kpi-label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi-value.accent { color: var(--accent); }
.kpi-value.good { color: var(--good); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.bad { color: var(--bad); }

.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1100px) {
  .row2, .row3 { grid-template-columns: 1fr; }
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(35, 48, 90, .7); }
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:hover { background: rgba(56, 189, 248, .06); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.path { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.tbl-wrap { max-height: 460px; overflow: auto; border-radius: 10px; }
.bar-cell { position: relative; }
.bar-bg {
  position: absolute; left: 0; top: 4px; bottom: 4px;
  background: linear-gradient(90deg, rgba(56, 189, 248, .28), rgba(56, 189, 248, .08));
  border-radius: 6px; z-index: 0;
}
.bar-fg { position: relative; z-index: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  background: rgba(56, 189, 248, .13); color: var(--accent);
}
.chip.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: rgba(52, 211, 153, .14); color: var(--good); }
.chip.warn { background: rgba(251, 191, 36, .14); color: var(--warn); }
.chip.bad { background: rgba(248, 113, 113, .15); color: var(--bad); }
.chip.mut { background: rgba(147, 161, 200, .14); color: var(--muted); }

/* ---------- 图表 ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart .grid-line { stroke: rgba(35, 48, 90, .85); stroke-width: 1; }
.chart .axis-line { stroke: rgba(35, 48, 90, 1); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .hover-line { stroke: rgba(232, 238, 255, .35); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: fixed; pointer-events: none; z-index: 90;
  background: #0a1020ee; border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 9px; font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); min-width: 130px;
  opacity: 0; transition: opacity .1s;
}
.chart-tip.on { opacity: 1; }
.chart-tip .t-title { color: var(--muted); margin-bottom: 5px; font-size: 11.5px; }
.chart-tip .t-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .t-row b { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; }

/* ---------- 进度条 ---------- */
.progress { height: 8px; background: #0d1428; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.ingest-log {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  background: #0a1020; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; max-height: 180px; overflow: auto; white-space: pre-wrap;
}

/* ---------- 日志页 ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.log-table td { font-family: var(--mono); font-size: 12px; }
.log-table td.t { white-space: nowrap; color: var(--muted); }
.badge {
  display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: rgba(147, 161, 200, .16); color: var(--muted); font-family: var(--mono);
}
.badge.s2 { background: rgba(52, 211, 153, .16); color: var(--good); }
.badge.s3 { background: rgba(56, 189, 248, .16); color: var(--accent); }
.badge.s4 { background: rgba(251, 191, 36, .16); color: var(--warn); }
.badge.s5 { background: rgba(248, 113, 113, .16); color: var(--bad); }

.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #101a33; border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 11px; z-index: 120; font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, .25); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, rgba(35,48,90,.25), rgba(35,48,90,.55), rgba(35,48,90,.25));
  background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
