:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --faint: #5d6474;
  --accent: #83acf8;
  --ok: #7fd39a;
  --dl: #83acf8;
  --warn: #f0c96b;
  --err: #f08a8a;
  --cool: #b7a3ff;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --panel: #ffffff;
    --panel-2: #f0f2f6;
    --line: #e0e3ea;
    --text: #1d2230;
    --muted: #5d6474;
    --faint: #9aa1b0;
    --accent: #3f6fd8;
    --ok: #2f9a57;
    --dl: #3f6fd8;
    --warn: #b9850e;
    --err: #c94545;
    --cool: #7a5ccc;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding: 20px 20px 32px; max-width: 1280px; margin: 0 auto; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; letter-spacing: .02em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 500; }
.num, .mono { font-variant-numeric: tabular-nums; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.services { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.services li { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.off { background: var(--err); }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.err { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.cool { background: color-mix(in srgb, var(--cool) 20%, transparent); color: var(--cool); }
.badge.dl { background: color-mix(in srgb, var(--dl) 18%, transparent); color: var(--dl); }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .foot { color: var(--faint); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .value { color: var(--accent); }

.errors { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.hint { color: var(--faint); font-size: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 18px 0 8px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.sw.dl { background: var(--dl); }
.sw.ok { background: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2 .card { margin-bottom: 12px; }

/* 流水线 */
.funnel { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.stage { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; position: relative; min-width: 0; }
.stage .n { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stage .t { color: var(--muted); font-size: 12px; }
.stage .x { color: var(--faint); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage.hot { outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.stage.done .n { color: var(--ok); }
.stage.bad .n { color: var(--err); }

.bars { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; align-items: end; height: 110px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; min-width: 0; }
.bar .pair { display: flex; gap: 1px; align-items: flex-end; height: 92px; }
.bar .pair i { flex: 1; border-radius: 2px 2px 0 0; min-height: 1px; }
.bar .pair i.dl { background: color-mix(in srgb, var(--dl) 70%, transparent); }
.bar .pair i.ok { background: var(--ok); }
.bar .h { font-size: 10px; color: var(--faint); text-align: center; height: 16px; line-height: 16px; }
.bar.now .h { color: var(--text); }

/* 账号 */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.acct { background: var(--panel-2); border-radius: 10px; padding: 12px; min-width: 0; }
.acct .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.acct .name { font-weight: 600; font-size: 15px; }
.acct .kind { color: var(--faint); font-size: 12px; margin-left: 6px; font-weight: 400; }
.acct .meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.acct .reason { color: var(--warn); font-size: 12px; margin-top: 6px; }
.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; }
.meter.hi i { background: var(--warn); }
.meter.full i { background: var(--err); }

.spark { height: 120px; position: relative; }
.spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.spark .area { fill: color-mix(in srgb, var(--accent) 18%, transparent); }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark .lbl { fill: var(--faint); font-size: 10px; }
.empty { color: var(--faint); font-size: 12px; padding: 12px 0; }

.table-wrap { overflow-x: auto; }
table.jobs { width: 100%; border-collapse: collapse; font-size: 13px; }
.jobs th { text-align: left; color: var(--faint); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.jobs td:nth-child(3) { white-space: nowrap; }
.jobs td { padding: 7px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); vertical-align: middle; }
.jobs td.code { font-weight: 600; white-space: nowrap; }
.jobs td.code .nm { display: block; font-weight: 400; color: var(--faint); font-size: 11px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobs .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.jobs .prog-col { width: 38%; }
.prog { display: flex; align-items: center; gap: 8px; }
.prog .meter { flex: 1; margin: 0; }
.prog span { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
tr.paused td { opacity: .55; }

/* 入库 */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.stat .n { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .t { color: var(--muted); font-size: 12px; }
.gpus { display: grid; gap: 8px; margin-top: 12px; }
.gpu { display: grid; grid-template-columns: 92px 1fr 120px; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.gpu .meter { margin: 0; }
.gpu .v { text-align: right; font-variant-numeric: tabular-nums; }
h3.mini { margin: 16px 0 6px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 13px; min-width: 0; }
.list li:last-child { border-bottom: 0; }
.list .when { color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; flex: none; }
.list .what { min-width: 0; overflow-wrap: anywhere; }
.list .code { font-weight: 600; white-space: nowrap; }
.list .note { color: var(--muted); font-size: 12px; }
.alerts li .what { color: var(--text); }
.alerts { max-height: 320px; overflow-y: auto; }
#problems { max-height: 260px; overflow-y: auto; }

.events { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 0 24px; }
.events li { display: flex; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 13px; }
.events .when { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; width: 40px; flex: none; }
.events .code { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

footer { color: var(--faint); font-size: 12px; text-align: center; margin-top: 8px; }

@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  body { padding: 14px 12px 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 21px; }
  .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bars { gap: 1px; }
  .bar .h { font-size: 9px; }
  .bar:nth-child(odd) .h { visibility: hidden; }
  .kpi:last-child { grid-column: 1 / -1; }
  /* 在途任务改成卡片：第一行番号、账号、阶段，第二行进度 */
  .jobs thead { display: none; }
  .jobs, .jobs tbody { display: block; }
  .jobs tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center;
    padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
  .jobs td { border: 0; padding: 0; }
  .jobs td.code .nm { max-width: none; }
  .jobs td:nth-child(2) { color: var(--muted); font-size: 12px; }
  .jobs td:nth-child(3) { font-size: 12px; }
  .jobs td:nth-child(4) { grid-column: 1 / -1; }
  .jobs td:nth-child(5) { display: none; }
  .jobs td.empty { grid-column: 1 / -1; }
  .prog span { min-width: 0; }
  .gpu { grid-template-columns: 70px 1fr 96px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  body { padding: 12px 8px 20px; }
  .kpis { gap: 6px; }
  .kpi .value { font-size: 18px; }
  .kpi .value small { font-size: 11px; }
  .card { padding: 12px; }
  .stage .n { font-size: 18px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
}
