:root {
  --bg: #080b10;
  --bg2: #0d131a;
  --panel: rgba(18, 25, 34, 0.86);
  --panel-solid: #121921;
  --line: #223040;
  --line-soft: #1a2532;
  --text: #e8eff6;
  --muted: #8fa3b8;
  --faint: #5d6f83;
  --red: #e4573d;
  --gold: #d8a24a;
  --cyan: #35c4c8;
  --green: #4cc38a;
  --blue: #5b8ff9;
  --violet: #9b7bf0;
  --radius: 14px;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(228, 87, 61, 0.16), transparent 60%),
    radial-gradient(760px 480px at 88% 8%, rgba(53, 196, 200, 0.13), transparent 62%),
    linear-gradient(180deg, #0a0f15 0%, #070a0f 100%);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  pointer-events: none;
  z-index: -1;
}

.mono, .num { font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 11, 16, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 20px;
  color: #0a0f15;
  background: linear-gradient(145deg, var(--red), #f07a4a);
  box-shadow: 0 6px 18px rgba(228, 87, 61, 0.35);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.14em;
  font-weight: 700;
}
.brand-cn { color: var(--gold); letter-spacing: 0.08em; margin-left: 6px; font-size: 15px; }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.top-metrics { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }

.metric {
  min-width: 92px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
}
.metric .k { font-size: 11.5px; color: var(--faint); letter-spacing: 0.06em; }
.metric .v { font-size: 18px; font-weight: 700; line-height: 1.2; }
.metric .v small { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 3px; }

.top-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.pill {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--cyan);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(340px, 1fr);
  gap: 14px;
  padding: 14px 18px 0;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: 0.04em; font-weight: 650; }

.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

.graph-scroll { overflow-x: auto; overflow-y: hidden; }
#graph { width: 100%; min-width: 1040px; height: auto; display: block; }

.panel-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 16px 10px; font-size: 11.5px; color: var(--faint);
  border-top: 1px solid var(--line-soft);
}

/* ---------- graph ---------- */
.node-rect {
  fill: rgba(19, 27, 37, 0.92);
  stroke: rgba(255,255,255,0.10);
  stroke-width: 1;
  rx: 12;
}
.node-g { cursor: pointer; }
.node-g.dim { opacity: 0.32; }
.node-g.sel .node-rect { stroke: var(--gold); stroke-width: 1.8; fill: rgba(216,162,74,0.10); }
.node-g:hover .node-rect { stroke: var(--cyan); }

.node-id { font-size: 12.5px; font-weight: 700; fill: var(--muted); letter-spacing: 0.06em; }
.node-name { font-size: 13.5px; font-weight: 650; fill: var(--text); }
.node-sub { font-size: 10.5px; fill: var(--faint); }
.node-dot { r: 4; }

.edge { fill: none; stroke: rgba(143,163,184,0.30); stroke-width: 1.4; marker-end: url(#arrow); }
.edge.hot { stroke: var(--cyan); stroke-width: 2.2; marker-end: url(#arrowHot); }
.edge.risk { stroke: rgba(228,87,61,0.45); stroke-dasharray: 5 4; marker-end: url(#arrowRisk); }
.edge.faded { opacity: 0.12; }

.edge-label { font-size: 9.5px; fill: var(--faint); }
.group-label { font-size: 10.5px; fill: var(--faint); letter-spacing: 0.22em; }

/* ---------- detail ---------- */
.detail-panel { height: 556px; overflow-y: auto; }

.detail-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0;
  background: linear-gradient(180deg, rgba(15,21,29,0.98), rgba(15,21,29,0.86));
  backdrop-filter: blur(8px);
  z-index: 5;
}
.detail-title { display: flex; align-items: center; gap: 8px; }
.detail-title .id { font-size: 12px; color: var(--gold); letter-spacing: 0.1em; font-weight: 700; }
.detail-title h3 { margin: 0; font-size: 17px; font-weight: 700; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px;
  border: 1px solid currentColor; opacity: 0.95;
}
.b-completed { color: var(--green); }
.b-running { color: var(--cyan); }
.b-waiting_review { color: var(--gold); }
.b-waiting_data { color: var(--blue); }
.b-waiting_confirm { color: var(--red); }
.b-idle { color: var(--faint); }
.b-terminated { color: var(--faint); }

.detail-desc { margin: 8px 0 0; font-size: 12.8px; color: var(--muted); }

.event-row { margin-top: 10px; }
.event-row .k { font-size: 11px; color: var(--faint); letter-spacing: 0.05em; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.chip.in { color: var(--cyan); border-color: rgba(53,196,200,0.32); background: rgba(53,196,200,0.06); }
.chip.out { color: var(--gold); border-color: rgba(216,162,74,0.32); background: rgba(216,162,74,0.06); }

.section-label {
  padding: 12px 16px 6px;
  font-size: 11px; letter-spacing: 0.12em; color: var(--faint);
}

.node-card {
  margin: 0 12px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.node-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 11px;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12.5px;
}
.node-card-head b { font-weight: 650; }
.node-card-head .tok { font-size: 10.5px; color: var(--faint); font-family: ui-monospace, monospace; }

.io-grid { display: grid; grid-template-columns: 1fr 1fr; }
.io-cell { padding: 8px 10px; min-width: 0; }
.io-cell + .io-cell { border-left: 1px dashed var(--line-soft); }
.io-cell .lab { font-size: 10px; letter-spacing: 0.1em; color: var(--faint); margin-bottom: 4px; }
.io-cell .lab.in { color: rgba(91,143,249,0.85); }
.io-cell .lab.out { color: rgba(76,195,138,0.85); }

pre.json {
  margin: 0; font-size: 10.5px; line-height: 1.45;
  color: #c8d6e5; background: rgba(0,0,0,0.28);
  border-radius: 6px; padding: 7px 8px;
  max-height: 112px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.task-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px; padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}
.task-row .tid { font-family: ui-monospace, monospace; color: var(--muted); font-size: 11px; }
.task-row .meta { color: var(--faint); font-size: 10.8px; }
.task-row .right { text-align: right; }

/* ---------- tabs ---------- */
.tabs-panel { margin: 14px 18px 18px; }
.tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.tab {
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px;
  color: var(--muted); cursor: pointer; border: 1px solid transparent;
  background: transparent;
}
.tab.on { color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.04); }
.tab .n { color: var(--gold); font-family: ui-monospace, monospace; margin-left: 5px; font-size: 11px; }

.tab-body { padding: 4px 0 8px; max-height: 380px; overflow: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 12.3px; }
.table th {
  position: sticky; top: 0;
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: 0.06em;
  color: var(--faint); padding: 8px 12px;
  background: rgba(15,21,29,0.96);
  border-bottom: 1px solid var(--line-soft);
}
.table td { padding: 7px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #cfdae6; }
.table td.mono { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.table .dim { color: var(--faint); }

.ticket {
  margin: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  display: flex; gap: 12px; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap;
}
.ticket .left { min-width: 0; }
.ticket .t1 { font-size: 12.5px; }
.ticket .t2 { font-size: 11px; color: var(--faint); font-family: ui-monospace, monospace; margin-top: 2px; }
.ticket pre.json { margin-top: 6px; max-height: 96px; }
.ticket .btns { display: flex; gap: 6px; }
.btn {
  padding: 6px 12px; border-radius: 8px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--text);
}
.btn.ok { border-color: rgba(76,195,138,0.5); color: var(--green); }
.btn.no { border-color: rgba(228,87,61,0.5); color: var(--red); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.bar-row { display: grid; grid-template-columns: 64px 1fr 72px; gap: 10px; align-items: center; padding: 7px 14px; font-size: 12px; }
.bar-track { height: 7px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--cyan), var(--green)); }
.bar-fill.gold { background: linear-gradient(90deg, var(--gold), #f0c070); }
.bar-row .num { text-align: right; color: var(--muted); font-size: 11px; }

.audit-head { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px 14px; font-size: 12px; color: var(--muted); }
.audit-head b { color: var(--text); }

.empty { padding: 26px 16px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* ---------- footer ---------- */
.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 20px 22px; font-size: 11.5px; color: var(--faint);
}
.footer b { color: var(--muted); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 16px);
  background: rgba(20,28,38,0.96); border: 1px solid var(--line);
  color: var(--text); padding: 10px 16px; border-radius: 10px;
  font-size: 12.5px; box-shadow: var(--shadow);
  opacity: 0; transition: all .22s ease; z-index: 60; pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .detail-panel { height: auto; max-height: none; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; font-size: 17px; }
  .brand-text h1 { font-size: 14px; }
  .brand-text p { font-size: 11px; }
  .top-metrics {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .top-meta { order: 4; width: 100%; justify-content: space-between; }
  .brand { width: 100%; }
  .metric { width: auto; min-width: 0; padding: 6px 9px; }
  .top-metrics .metric:last-child:nth-child(odd) { grid-column: span 2; }
  .metric .v { font-size: 16px; }
  .layout { padding: 10px 10px 0; }
  .tabs-panel { margin: 10px; }
  #graph { min-width: 980px; }
  .io-grid { grid-template-columns: 1fr; }
  .io-cell + .io-cell { border-left: 0; border-top: 1px dashed var(--line-soft); }
  .table th, .table td { padding: 6px 9px; }
  .footer { padding: 0 12px 18px; }
}
