:root {
  --bg: #080c13;
  --bg-soft: #0c121c;
  --panel: #101826;
  --panel-2: #131d2d;
  --line: rgba(148, 163, 184, .13);
  --line-strong: rgba(148, 163, 184, .24);
  --text: #e6edf6;
  --muted: #8595ab;
  --faint: #5d6b80;
  --accent: #6ee7b7;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background:
    radial-gradient(1100px 600px at 82% -10%, rgba(56, 189, 248, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(110, 231, 183, .07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; }

.app { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------ sidebar */
.sidebar {
  width: 228px; flex: 0 0 228px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 24, 38, .92), rgba(8, 12, 19, .96));
  padding: 22px 14px 16px;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, rgba(110,231,183,.22), rgba(56,189,248,.18));
  border: 1px solid rgba(110,231,183,.35); color: var(--accent);
}
.brand-name { font-weight: 650; letter-spacing: .3px; font-size: 15px; }
.brand-sub { color: var(--faint); font-size: 11px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 9px;
  color: var(--muted); font-size: 13.5px; transition: .16s ease;
  border: 1px solid transparent;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { color: var(--text); background: rgba(148,163,184,.06); }
.nav-item.active {
  color: #dcfce7; background: linear-gradient(90deg, rgba(110,231,183,.13), rgba(110,231,183,.04));
  border-color: rgba(110,231,183,.18);
}
.nav-item.active svg { stroke: var(--accent); }

.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.pipe-mini { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px rgba(52,211,153,.65); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.sidebar-foot .muted { margin-top: 8px; font-size: 11px; }

/* ------------------------------------------------------------ main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  padding: 26px 30px 18px; border-bottom: 1px solid var(--line);
  background: rgba(8,12,19,.55); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.title-block h1 { margin: 0; font-size: 21px; font-weight: 620; letter-spacing: .2px; }
.title-block p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 9px; }

.view { padding: 24px 30px 60px; max-width: 1500px; width: 100%; }
.loading { color: var(--muted); padding: 48px; text-align: center; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ buttons */
.btn {
  border: 1px solid rgba(110,231,183,.35); background: linear-gradient(180deg, rgba(110,231,183,.18), rgba(110,231,183,.10));
  color: #d1fae5; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 12.5px;
  transition: .15s ease;
}
.btn:hover { background: rgba(110,231,183,.24); border-color: rgba(110,231,183,.5); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--faint); }
.btn.danger { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.12); color: #fecaca; }
.btn.small { padding: 5px 10px; font-size: 11.5px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--faint); }

/* ------------------------------------------------------------ generic */
.panel {
  background: linear-gradient(180deg, rgba(19,29,45,.72), rgba(13,20,32,.72));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.panel-title { font-size: 13.5px; font-weight: 600; letter-spacing: .2px; }
.panel-sub { color: var(--faint); font-size: 11.5px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1.55fr 1fr; }
.grid.cols-2e { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-2, .grid.cols-2e, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .view { padding: 16px; }
  .topbar { padding: 16px; }
  .grid.cols-2, .grid.cols-2e, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
.section-gap { margin-top: 16px; }

/* ------------------------------------------------------------ stages */
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 1100px) { .stages { grid-template-columns: repeat(2, 1fr); } }
.stage {
  position: relative; display: block; padding: 14px 14px 13px; border-radius: 12px;
  background: linear-gradient(160deg, rgba(19,29,45,.9), rgba(11,17,27,.9));
  border: 1px solid var(--line); overflow: hidden; transition: .18s ease;
}
.stage:hover { border-color: rgba(110,231,183,.3); transform: translateY(-1px); }
.stage-top { display: flex; justify-content: space-between; align-items: center; }
.stage-no { font-family: var(--mono); color: var(--accent); font-size: 11px; letter-spacing: 1px; }
.stage-name { font-size: 12.8px; font-weight: 600; margin-top: 9px; }
.stage-desc { color: var(--faint); font-size: 10.8px; line-height: 1.5; margin-top: 4px; min-height: 32px; }
.stage-stat { margin-top: 8px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.stage.empty { opacity: .55; }

/* ------------------------------------------------------------ kpi */
.kpi { padding: 15px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.kpi-label { color: var(--muted); font-size: 11.5px; display: flex; justify-content: space-between; }
.kpi-value { font-size: 26px; font-weight: 620; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-note { color: var(--faint); font-size: 11px; margin-top: 4px; }
.kpi.good .kpi-value { color: var(--accent); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.bad .kpi-value { color: var(--danger); }

/* ------------------------------------------------------------ projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px; margin-top: 4px; }
.project-card {
  padding: 12px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(19,29,45,.75), rgba(11,17,27,.75));
  cursor: pointer; transition: .16s ease;
}
.project-card:hover { border-color: rgba(110,231,183,.32); transform: translateY(-1px); }
.project-card.active { border-color: rgba(110,231,183,.55); box-shadow: 0 0 0 3px rgba(110,231,183,.07); }
.project-name { font-size: 12.8px; font-weight: 600; }
.project-metrics { margin-top: 7px; font-size: 11px; color: var(--muted); }
.project-foot { margin-top: 6px; font-size: 10.5px; color: var(--faint); }
.project-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.project-pill {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(148,163,184,.05);
  color: var(--text); font-size: 11px; cursor: pointer;
}
.project-pill:hover { border-color: rgba(110,231,183,.35); }
.project-pill .mono { color: var(--faint); font-size: 10px; }

/* ------------------------------------------------------------ table */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-weight: 500; color: var(--faint); font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 9px 12px; background: rgba(15,23,36,.9); position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid rgba(148,163,184,.07); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(148,163,184,.045); }
tr.clickable { cursor: pointer; }
.cell-main { color: var(--text); }
.cell-sub { color: var(--faint); font-size: 11px; margin-top: 2px; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2.5px 8px; border-radius: 999px;
  font-size: 10.5px; border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.badge.ok { color: #a7f3d0; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.25); }
.badge.warn { color: #fde68a; background: rgba(251,191,36,.10); border-color: rgba(251,191,36,.24); }
.badge.bad { color: #fecaca; background: rgba(248,113,113,.11); border-color: rgba(248,113,113,.26); }
.badge.info { color: #bae6fd; background: rgba(56,189,248,.10); border-color: rgba(56,189,248,.24); }
.badge.violet { color: #ddd6fe; background: rgba(167,139,250,.11); border-color: rgba(167,139,250,.25); }
.badge.gray { color: var(--muted); background: rgba(148,163,184,.08); border-color: var(--line); }
.score { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px; display: inline-block; }
.score.hi { color: #a7f3d0; background: rgba(52,211,153,.1); }
.score.mid { color: #fde68a; background: rgba(251,191,36,.1); }
.score.low { color: #fecaca; background: rgba(248,113,113,.12); }

/* ------------------------------------------------------------ charts */
.chart-legend { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--muted); }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 10px; fill: var(--faint); font-family: var(--mono); }
.chart .grid-line { stroke: rgba(148,163,184,.10); stroke-width: 1; }
.chart .axis { stroke: rgba(148,163,184,.18); stroke-width: 1; }

/* ------------------------------------------------------------ events */
.events { display: flex; flex-direction: column; gap: 0; }
.event { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px dashed rgba(148,163,184,.10); }
.event:last-child { border-bottom: none; }
.event-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); margin-top: 5px; }
.event-dot.bad { background: var(--danger); }
.event-dot.ok { background: var(--accent); }
.event-dot.warn { background: var(--warn); }
.event-title { font-size: 12.4px; line-height: 1.45; }
.event-detail { color: var(--faint); font-size: 11px; margin-top: 3px; line-height: 1.5; }
.event-time { color: var(--faint); font-size: 10.5px; font-family: var(--mono); white-space: nowrap; }

/* ------------------------------------------------------------ forms */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 120px; }
.field label { font-size: 11px; color: var(--faint); }
.input, select.input, textarea.input {
  background: rgba(8,12,19,.7); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 10px; color: var(--text); outline: none; font-size: 12.5px;
}
.input:focus { border-color: rgba(110,231,183,.45); box-shadow: 0 0 0 3px rgba(110,231,183,.08); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

/* ------------------------------------------------------------ drawer */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(720px, 92vw);
  background: #0b111b; border-left: 1px solid var(--line-strong);
  z-index: 60; display: flex; flex-direction: column;
  box-shadow: -30px 0 60px rgba(0,0,0,.5);
}
.drawer-mask { position: fixed; inset: 0; background: rgba(3,6,10,.6); z-index: 50; backdrop-filter: blur(2px); }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 20px 22px; border-bottom: 1px solid var(--line);
}
.drawer-kicker { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-family: var(--mono); }
.drawer-title { font-size: 15px; margin-top: 4px; line-height: 1.45; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; }

/* ------------------------------------------------------------ trace detail */
.detail-block { margin-bottom: 20px; }
.detail-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 7px; }
.quote {
  background: rgba(8,12,19,.6); border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; line-height: 1.7; font-size: 13px; color: #dbe5f1;
}
.score-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 9px; }
.score-card { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: rgba(8,12,19,.45); }
.score-card .top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.score-card .val { font-size: 20px; font-family: var(--mono); margin: 6px 0 3px; }
.score-card .why { font-size: 11px; color: var(--faint); line-height: 1.55; }
.waterfall { display: flex; flex-direction: column; gap: 6px; }
.wf-row { display: grid; grid-template-columns: 110px 1fr 64px; gap: 10px; align-items: center; font-size: 12px; }
.wf-bar-wrap { background: rgba(148,163,184,.08); border-radius: 4px; height: 22px; position: relative; overflow: hidden; }
.wf-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.wf-type { color: var(--faint); font-size: 10.5px; font-family: var(--mono); }
.wf-lat { text-align: right; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.meta-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.meta-item .k { color: var(--faint); font-size: 10px; }
.meta-item .v { font-family: var(--mono); font-size: 11px; margin-top: 3px; word-break: break-all; }

/* ------------------------------------------------------------ review cards */
.review-card { border: 1px solid var(--line); border-radius: 11px; padding: 14px; margin-bottom: 10px; background: rgba(11,17,27,.5); }
.review-card .rc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.review-card .rc-q { font-size: 13px; font-weight: 550; line-height: 1.5; }
.review-card .rc-a { color: var(--muted); font-size: 12px; line-height: 1.65; margin-top: 6px; }
.review-card .rc-reason { color: var(--faint); font-size: 11px; margin-top: 6px; border-left: 2px solid rgba(248,113,113,.4); padding-left: 8px; }
.review-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ misc */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 8px 12px; color: var(--muted); cursor: pointer; font-size: 12.5px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { color: var(--faint); font-size: 10.5px; margin-left: 4px; }
.empty-state { color: var(--faint); text-align: center; padding: 40px 10px; font-size: 12.5px; line-height: 1.7; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.verdict { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); margin-bottom: 14px; }
.verdict.good { background: rgba(52,211,153,.07); border-color: rgba(52,211,153,.25); }
.verdict.bad { background: rgba(248,113,113,.07); border-color: rgba(248,113,113,.25); }
.verdict.warn { background: rgba(251,191,36,.07); border-color: rgba(251,191,36,.25); }
.verdict-title { font-size: 14px; font-weight: 600; }
.verdict-sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--faint); }
pre.code {
  background: #070b12; border: 1px solid var(--line); border-radius: 9px; padding: 13px 14px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.7; color: #b6c6da; overflow-x: auto;
}
.list-divider { height: 1px; background: var(--line); margin: 14px 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.note { font-size: 11.5px; color: var(--faint); line-height: 1.7; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #14202f; border: 1px solid var(--line-strong); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: .22s ease; z-index: 100; box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(248,113,113,.5); }

.spinner {
  display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(110,231,183,.25);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
