:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2328; background: #f6f8fa; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: #24292f; color: #fff; }
.top a { color: #fff; text-decoration: none; }
.brand a { font-weight: 700; font-size: 16px; }
nav { display: flex; gap: 16px; flex: 1; }
nav a { opacity: .8; }
nav a.on { opacity: 1; border-bottom: 2px solid #58a6ff; padding-bottom: 2px; }
.right { display: flex; align-items: center; gap: 12px; }
.muted { color: #6e7781; }
main { max-width: 1600px; margin: 28px auto; padding: 0 32px; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 28px 0 10px; font-size: 17px; }
.card { background: #fff; border: 1px solid #d0d7de; border-radius: 8px; padding: 20px; }
.card.narrow { max-width: 360px; margin: 60px auto; }
label { display: block; margin: 10px 0; }
input, select { width: 100%; padding: 7px 9px; border: 1px solid #d0d7de; border-radius: 6px;
  font: inherit; background: #fff; }
button { padding: 8px 14px; border: 1px solid #1f883d; border-radius: 6px;
  background: #1f883d; color: #fff; font: inherit; cursor: pointer; }
button.link { background: none; border: none; color: #fff; opacity: .8; cursor: pointer; padding: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #d0d7de;
  border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eaeef2; text-align: left; }
th { background: #f6f8fa; font-weight: 600; }
tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.tiles { display: flex; gap: 14px; }
.tile { flex: 1; background: #fff; border: 1px solid #d0d7de; border-radius: 8px; padding: 16px; }
.tile .label { color: #6e7781; font-size: 12px; }
.tile .num { font-size: 28px; font-weight: 700; }
.tile .num.bad { color: #b42318; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; }
.badge.success { background: #dafbe1; color: #116329; }
.badge.failed { background: #ffebe9; color: #b42318; }
.badge.skipped { background: #eaeef2; color: #57606a; }
.badge.retrying { background: #fff8c5; color: #7d4e00; }
.err { color: #b42318; }
.filters { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; }
.filters label { margin: 0; }
.filters select { min-width: 160px; }
details pre { max-height: 320px; overflow: auto; background: #f6f8fa; padding: 10px;
  border-radius: 6px; font-size: 12px; }
footer { text-align: center; color: #6e7781; font-size: 12px; margin: 40px 0 20px; }
@media (prefers-color-scheme: dark) {
  body { background: #0d1117; color: #e6edf3; }
  .card, table, .tile { background: #161b22; border-color: #30363d; }
  th { background: #21262d; }
  th, td { border-color: #30363d; }
  input, select { background: #0d1117; color: #e6edf3; border-color: #30363d; }
  details pre { background: #0d1117; }
  .muted { color: #8b949e; }
}

.btnlink { display: inline-block; padding: 7px 10px; border: 1px solid #d0d7de; border-radius: 6px;
  background: #fff; color: #1f2328; text-decoration: none; }
.flow-head { display: flex; flex-wrap: wrap; align-items: end; gap: 18px; margin-bottom: 14px; }
.flow-head h1 { margin: 0; }
.flow-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 18px; }
#cy { height: calc(100vh - 220px); min-height: 760px; background: #fff; border: 1px solid #d0d7de; border-radius: 8px; }
.side { background: #fff; border: 1px solid #d0d7de; border-radius: 8px; padding: 16px; max-height: calc(100vh - 220px); overflow: auto; }
.side h2 { margin-top: 0; font-size: 16px; }
.side h3 { font-size: 13px; margin: 14px 0 6px; }
ul.tight { margin: 4px 0; padding-left: 18px; }
table.kv { border: none; background: none; }
table.kv th, table.kv td { border: none; padding: 3px 8px 3px 0; background: none; }
table.kv th { color: #6e7781; font-weight: 500; white-space: nowrap; }
.badge.NOT_STARTED, .badge.LATE, .badge.UPSTREAM_BLOCK { background: #fff1e5; color: #953800; }
.badge.MISSING { background: #ffebe9; color: #b42318; }
.badge.INVALID { background: #fbefff; color: #8250df; }
.badge.PENDING, .badge.UNKNOWN, .badge.EXTERNAL { background: #eaeef2; color: #57606a; }
.badge.READY, .badge.SUCCESS_INFERRED { background: #dafbe1; color: #116329; }
.badge.RUNNING { background: #ddf4ff; color: #0969da; }
@media (prefers-color-scheme: dark) {
  #cy, .side, .btnlink { background: #161b22; border-color: #30363d; color: #e6edf3; }
  .btnlink { color: #e6edf3; }
}
@media (max-width: 900px) { .flow-wrap { grid-template-columns: 1fr; } #cy { height: 480px; } }

@media (min-width: 2000px) {
  main { max-width: 2600px; padding: 0 48px; }
  .flow-wrap { grid-template-columns: minmax(0, 1fr) 620px; gap: 24px; }
  #cy { height: calc(100vh - 240px); min-height: 1200px; }
  .side { max-height: calc(100vh - 240px); }
  .top { padding: 16px 40px; }
}
@media (min-width: 3000px) {
  #cy { min-height: 1600px; }
}

/* flow side panel: 下游影响按 layer 折叠 */
.impact-group { margin: 4px 0; }
.impact-group summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
.impact-group ul { margin-top: 4px; }
.badge.type { background: #eaeef2; color: #1f2328; border: 1px solid #d0d7de; }
.badge.layer { background: #f6f8fa; color: #57606a; border: 1px solid #d8dee4; }

/* 下游影响树 */
.impact-tree { margin: 2px 0 6px 14px; padding-left: 10px; border-left: 1px dashed #d0d7de; }
.impact-tree li { margin: 3px 0; }
.impact-child summary { cursor: pointer; color: #57606a; font-size: 12px; }

/* ---------- flow page v2 (4K-first) ---------- */
body.flow-page { height: 100vh; overflow: hidden; background: #eef2f7; color-scheme: light; }
body.flow-page .top { height: 64px; padding: 0 32px; gap: 32px;
  background: linear-gradient(90deg, #0f172a 0%, #16233a 100%); }
body.flow-page .top .brand a { font-size: 19px; letter-spacing: .2px; }
body.flow-page .top nav { gap: 28px; }
body.flow-page .top nav a { padding: 20px 0 17px; border-bottom: 3px solid transparent; color: #cbd5e1; }
body.flow-page .top nav a.on { border-color: #38bdf8; color: #fff; }
body.flow-page main { max-width: none; width: 100%; height: calc(100vh - 64px);
  margin: 0; padding: 18px 32px 16px; display: flex; }
body.flow-page footer { display: none; }

.flow-shell { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; width: 100%; }
.flow-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex: none; }
.flow-pagehead h1 { margin: 0; font-size: 27px; letter-spacing: -.4px; }
.flow-pagehead p { margin: 4px 0 0; color: #64748b; font-size: 13.5px; }
.flow-filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.flow-filters .field { display: flex; flex-direction: column; gap: 4px; }
.flow-filters .field span { font-size: 11px; color: #64748b; letter-spacing: .5px; text-transform: uppercase; }
.flow-filters input, .flow-filters select { height: 38px; border: 1px solid #d8e0ea; border-radius: 8px;
  background: #fff; padding: 0 11px; font: inherit; font-size: 14px; color: #0f172a; }
.flow-filters .date { width: 132px; font-variant-numeric: tabular-nums; }
.flow-filters .primary { height: 38px; border: 0; border-radius: 8px; background: #2563eb; color: #fff;
  padding: 0 18px; font: inherit; font-weight: 650; cursor: pointer;
  box-shadow: 0 5px 14px rgba(37,99,235,.22); }
.flow-filters .btnlink { height: 38px; padding: 0 12px; line-height: 36px; border-radius: 8px;
  border: 1px solid #d8e0ea; background: #fff; color: #334155; font-size: 13px; }

.flow-kpis { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; flex: none; }
.flow-kpis .kpi { background: #fff; border: 1px solid #d8e0ea; border-radius: 12px;
  min-height: 76px; padding: 11px 15px; display: flex; align-items: center; gap: 13px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.flow-kpis .kpi > i { width: 5px; height: 40px; border-radius: 4px; background: #2563eb; flex: none; }
.flow-kpis .kpi.ok > i { background: #16a34a; }
.flow-kpis .kpi.warn > i { background: #d97706; }
.flow-kpis .kpi.bad > i { background: #dc2626; }
.flow-kpis .kpi.unk > i { background: #64748b; }
.flow-kpis .label { color: #64748b; font-size: 12px; letter-spacing: .3px; }
.flow-kpis .num { font-size: 27px; font-weight: 750; line-height: 1.05; font-variant-numeric: tabular-nums; }
.flow-kpis .num small { font-size: 13px; color: #64748b; font-weight: 500; margin-left: 4px; }
.flow-kpis .sub { color: #64748b; font-size: 11.5px; margin-top: 2px; }

.flow-workspace { display: grid; grid-template-columns: minmax(0,1fr) 460px; gap: 14px;
  flex: 1; min-height: 0; }
.graph-card { background: #fff; border: 1px solid #d8e0ea; border-radius: 13px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  box-shadow: 0 2px 8px rgba(15,23,42,.05); }
.graph-toolbar { height: 56px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid #d8e0ea; background: #fff; }
.graph-toolbar .title { font-weight: 700; font-size: 15.5px; }
.graph-toolbar .count { color: #64748b; font-size: 12.5px; }
.graph-toolbar .seg { display: flex; gap: 2px; padding: 3px; margin-left: auto;
  background: #f8fafc; border: 1px solid #d8e0ea; border-radius: 8px; }
.graph-toolbar .seg button { border: 0; background: none; padding: 6px 10px; border-radius: 6px;
  font: inherit; font-size: 12.5px; color: #64748b; cursor: pointer; }
.graph-toolbar .seg button.on { background: #fff; color: #0f172a; font-weight: 600;
  box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.graph-toolbar .search { width: 180px; }
.graph-toolbar .search input { width: 100%; height: 34px; border: 1px solid #d8e0ea;
  border-radius: 8px; padding: 0 10px; font: inherit; font-size: 13px; background: #fff; }
.graph-toolbar .icon { width: 34px; height: 34px; border: 1px solid #d8e0ea; background: #fff;
  border-radius: 8px; color: #64748b; font: inherit; font-size: 16px; cursor: pointer; }
.graph-toolbar .icon:hover { background: #f8fafc; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; background:
  radial-gradient(circle at 1px 1px, rgba(100,116,139,.16) 1px, transparent 0) 0 0/22px 22px,
  linear-gradient(180deg,#fbfdff,#f7fafc); }
#cy { position: absolute; inset: 0; }
.legend { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 13px;
  align-items: center; padding: 9px 12px; font-size: 11.5px; color: #64748b;
  background: rgba(255,255,255,.93); border: 1px solid #d8e0ea; border-radius: 9px;
  backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(15,23,42,.07); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.legend .legend-sep { border-left: 1px solid #d8e0ea; padding-left: 12px; }

.inspector { background: #fff; border: 1px solid #d8e0ea; border-radius: 13px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  box-shadow: 0 2px 8px rgba(15,23,42,.05); }
.insp-tabs { display: flex; gap: 22px; padding: 0 16px; border-bottom: 1px solid #d8e0ea; flex: none; }
.insp-tabs .tab { border: 0; background: none; padding: 15px 0 12px; font: inherit; font-size: 13.5px;
  color: #64748b; border-bottom: 3px solid transparent; cursor: pointer; }
.insp-tabs .tab.on { color: #0f172a; border-color: #2563eb; font-weight: 650; }
.insp-tabs .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: #f8fafc; border: 1px solid #d8e0ea; border-radius: 999px; font-size: 11px; color: #64748b; }
.insp-body { padding: 17px; overflow: auto; min-height: 0; }
.node-title { margin: 0; font-size: 19px; letter-spacing: -.2px; }
.node-sub { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 8px 0 15px; }
.kv { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 7px 12px; margin: 0; font-size: 13px; }
.kv dt { color: #64748b; }
.kv dd { margin: 0; word-break: break-all; }
.kv dd.mono, .mono { font-family: ui-monospace,SFMono-Regular,Menlo,monospace; font-size: 12px; }
.section-label { margin: 17px 0 6px; font-size: 11px; letter-spacing: .6px; color: #64748b; text-transform: uppercase; }
.side-link { margin-top: 16px; }
.side-link a { color: #2563eb; text-decoration: none; font-weight: 600; }
ul.checks { list-style: none; margin: 0; padding: 0; }
ul.checks li { padding: 6px 0; border-bottom: 1px solid #eef2f7; font-size: 12.5px; }
ul.checks .ok { color: #15803d; font-weight: 700; }
ul.checks .bad { color: #b91c1c; font-weight: 700; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.bad { background: #fee2e2; color: #b91c1c; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.unk { background: #e2e8f0; color: #475569; }
.badge.info { background: #e0f2fe; color: #0369a1; }
.badge.gray { background: #f8fafc; color: #64748b; border: 1px solid #d8e0ea; }

.anomaly-strip { flex: none; min-height: 48px; display: flex; align-items: center; gap: 9px;
  padding: 8px 14px; background: #fff; border: 1px solid #d8e0ea; border-radius: 11px;
  overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.anomaly-title { font-weight: 750; color: #b91c1c; font-size: 13px; white-space: nowrap; margin-right: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 7px;
  padding: 5px 9px; background: #fee2e2; color: #b91c1c; font: inherit; font-size: 11.5px;
  white-space: nowrap; cursor: pointer; }
.chip.warn { background: #fef3c7; color: #b45309; }
.chip.more { margin-left: auto; background: #f8fafc; color: #64748b; border: 1px solid #d8e0ea; }

@media (max-width: 1600px) {
  .flow-workspace { grid-template-columns: minmax(0,1fr) 420px; }
  .graph-toolbar .search { width: 150px; }
}
@media (min-width: 2000px) {
  body.flow-page main { padding: 22px 40px 18px; }
  .flow-pagehead h1 { font-size: 30px; }
  .flow-pagehead p { font-size: 15px; }
  .flow-workspace { grid-template-columns: minmax(0,1fr) 560px; gap: 18px; }
  .flow-kpis { gap: 14px; }
  .flow-kpis .kpi { min-height: 82px; }
  .flow-kpis .num { font-size: 30px; }
}
@media (min-width: 3000px) {
  .flow-workspace { grid-template-columns: minmax(0,1fr) 620px; }
  .graph-toolbar { height: 62px; }
}
@media (max-width: 1100px) {
  body.flow-page main { overflow: auto; }
  .flow-workspace { grid-template-columns: 1fr; }
  #cy { position: relative; height: 64vh; }
  .canvas-wrap { min-height: 64vh; }
}

/* 4K readable refinements */
body.flow-page .top nav { font-size: 15.5px; }
body.flow-page .top .brand a { font-size: 20px; }
@media (min-width: 2000px) {
  .flow-kpis .label { font-size: 13px; }
  .flow-kpis .sub { font-size: 12.5px; }
  .graph-toolbar .title { font-size: 17px; }
  .graph-toolbar .count { font-size: 13.5px; }
  .graph-toolbar .seg button { font-size: 13.5px; }
  .graph-toolbar .search input { font-size: 14px; }
  .graph-toolbar .icon { font-size: 18px; }
  .legend { font-size: 13px; padding: 10px 14px; }
  .insp-tabs .tab { font-size: 15px; }
  .insp-body { padding: 20px; }
  .node-title { font-size: 21px; }
  .kv { grid-template-columns: 108px minmax(0,1fr); font-size: 14px; }
  .kv dd.mono, .mono { font-size: 13px; }
  .badge { font-size: 12.5px; }
  .anomaly-strip .chip, .anomaly-strip .anomaly-title { font-size: 13px; }
}
.graph-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 2; padding: 6px 12px; border-radius: 8px; border: 1px solid #fde68a;
  background: #fffbeb; color: #92400e; font-size: 12px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(15,23,42,.06); }
@media (min-width: 2000px) {
  .graph-hint { font-size: 14px; padding: 8px 16px; }
}

/* contrast + button alignment + merged inspector */
body.flow-page { color: #0f172a; }
body.flow-page .flow-pagehead p,
body.flow-page .flow-kpis .label,
body.flow-page .flow-kpis .sub,
body.flow-page .graph-toolbar .count,
body.flow-page .kv dt,
body.flow-page .legend,
body.flow-page main .muted,
body.flow-page .section-label,
body.flow-page .badge.gray,
body.flow-page .insp-head .muted { color: #475569; }
body.flow-page button,
body.flow-page .btnlink {
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; font-family: inherit;
}
body.flow-page .flow-filters .primary { line-height: 1; }
body.flow-page .flow-filters .btnlink { height: 38px; line-height: 1; padding: 0 13px; }
body.flow-page .graph-toolbar .seg button { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
body.flow-page .graph-toolbar .icon { line-height: 1; }
body.flow-page .chip { justify-content: center; line-height: 1.15; }
body.flow-page .top button.link { line-height: 1; }
body.flow-page .top .muted { color: #cbd5e1; }
body.flow-page #cy { background: transparent; border: 0; border-radius: 0; color: #0f172a; }
body.flow-page .btnlink { color: #334155; background: #fff; border-color: #d8e0ea; }

.insp-head { height: 48px; flex: none; display: flex; align-items: center; gap: 8px;
  padding: 0 16px; border-bottom: 1px solid #d8e0ea; font-weight: 700; font-size: 14px; }
.insp-head .muted { margin-left: auto; font-weight: 400; font-size: 11.5px; }
.insp-body { padding: 16px; }
.impact-tree a { color: #1d4ed8; text-decoration: none; }
.impact-tree a:hover { text-decoration: underline; }
@media (min-width: 2000px) {
  .insp-head { height: 54px; font-size: 15.5px; }
  .insp-head .muted { font-size: 12.5px; }
}
@media (min-width: 2000px) {
  .insp-body { font-size: 15.5px; }
  .insp-body .kv { font-size: 14.5px; }
  .insp-body .section-label { font-size: 12px; }
  .impact-tree li { font-size: 14px; }
  .insp-body .checks li { font-size: 13.5px; }
}
