:root{
  --bg:#f6f8fc;
  --bg2:#eef3fb;
  --panel:#ffffff;
  --panel-2:#f8fbff;
  --panel-3:#f4f8fe;
  --line:#d9e2f0;
  --line-soft:#e6edf7;
  --text:#142033;
  --muted:#5f6f86;
  --accent:#2563eb;
  --accent-2:#1d4ed8;
  --accent-soft:#e8f0ff;
  --good:#12805c;
  --warn:#b7791f;
  --danger:#c24141;
  --shadow:0 10px 28px rgba(24,39,75,.08);
  --radius:18px;
  --radius-sm:12px;
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  background:linear-gradient(180deg,var(--bg) 0%, var(--bg2) 100%);
  color:var(--text);
  font-family:Arial,Helvetica,sans-serif;
}

body{
  min-height:100vh;
}

a{
  color:var(--accent-2);
  text-decoration:none;
}
a:hover{
  text-decoration:underline;
}

.app-shell{
  max-width:1500px;
  margin:0 auto;
  padding:24px 22px 36px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  flex-wrap:wrap;
  margin-bottom:20px;
}

.title-block h1{
  margin:0;
  font-size:34px;
  line-height:1.05;
  letter-spacing:.01em;
  color:#10213d;
}

.title-block .sub{
  margin-top:8px;
  color:var(--muted);
  font-size:15px;
  line-height:1.6;
}

.badge-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#ffffffd9;
  color:#28415f;
  font-size:12px;
  box-shadow:var(--shadow);
}

.toolbar{
  display:grid;
  grid-template-columns:220px 260px 1fr 140px;
  gap:12px;
  margin-bottom:18px;
}

.input,
.select,
.button{
  width:100%;
  padding:13px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  outline:none;
  font-size:14px;
  box-shadow:var(--shadow);
}

.input:focus,
.select:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}

.button{
  cursor:pointer;
  font-weight:700;
  background:linear-gradient(180deg,#2f6df6,#2459cf);
  color:#fff;
  border-color:#2b61d8;
}

.layout{
  display:grid;
  grid-template-columns:320px 1fr 330px;
  gap:18px;
}

.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:20px;
  box-shadow:var(--shadow);
  padding:18px;
  min-width:0;
}

.card h2,
.card h3{
  margin:0 0 12px 0;
  color:#10213d;
}

.muted{
  color:var(--muted);
}

.section-note{
  margin-bottom:14px;
  color:var(--muted);
  line-height:1.6;
}

.panel-scroll{
  max-height:72vh;
  overflow:auto;
}

.root-list,
.search-results,
.detail-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.root-item,
.search-item,
.detail-item{
  border:1px solid var(--line);
  background:var(--panel-3);
  border-radius:14px;
  padding:12px;
}

.root-item:hover,
.search-item:hover{
  border-color:#9ab6e3;
}

.root-item .id,
.search-item .id,
.detail-item .id{
  color:var(--muted);
  font-size:12px;
  margin-top:4px;
  word-break:break-all;
}

.tree-stage{
  border:1px solid var(--line);
  border-radius:18px;
  background:var(--panel-3);
  min-height:72vh;
  padding:14px;
  overflow:auto;
}

.tree-toolbar{
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:12px;
}

.tree-toolbar .mini{
  font-size:12px;
  color:var(--muted);
}

.tree-root-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.tree-node{
  position:relative;
  margin:6px 0;
}

.tree-row{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:38px;
  padding:8px 10px;
  border:1px solid transparent;
  border-radius:12px;
  transition:.12s ease;
}

.tree-row:hover{
  background:#edf4ff;
  border-color:var(--line);
}

.tree-row.selected{
  background:var(--accent-soft);
  border-color:#8fb3f5;
}

.tree-indent{
  display:inline-block;
  width:18px;
  flex:0 0 18px;
}

.tree-toggle{
  width:22px;
  height:22px;
  border-radius:8px;
  border:1px solid var(--line);
  background:#f0f5ff;
  color:#1f4fa7;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  flex:0 0 22px;
  font-size:12px;
  line-height:1;
}

.tree-toggle.empty{
  visibility:hidden;
}

.tree-labels{
  min-width:0;
  flex:1;
}

.tree-label{
  font-size:15px;
  font-weight:700;
  color:#122443;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.tree-sub{
  color:var(--muted);
  font-size:12px;
  margin-top:3px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.tree-chip{
  padding:4px 8px;
  font-size:11px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#eef4ff;
  color:#21467e;
}

.tree-children{
  margin-left:26px;
  padding-left:12px;
  border-left:1px dashed #c6d5eb;
}

.breadcrumb{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:14px;
}

.breadcrumb a,
.breadcrumb span{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#f4f8ff;
  color:#21467e;
}

.meta-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.meta-box{
  padding:12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--panel-3);
}

.meta-key{
  color:var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.05em;
  margin-bottom:6px;
}

.meta-value{
  word-break:break-word;
  line-height:1.5;
}

.debug-wrap{
  margin-top:16px;
  border-top:1px solid var(--line);
  padding-top:16px;
}

.debug-toggle{
  width:100%;
  text-align:left;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--panel-3);
  color:var(--text);
  cursor:pointer;
  font-weight:700;
}

.debug-panel{
  margin-top:10px;
  display:none;
}

.debug-panel.open{
  display:block;
}

.debug-pre{
  margin:0;
  white-space:pre-wrap;
  word-break:break-word;
  background:#f7faff;
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  max-height:260px;
  overflow:auto;
  color:#29415f;
  font-size:12px;
}

.empty-state,
.empty-box{
  color:var(--muted);
  padding:16px 4px;
}

.notice{
  font-size:12px;
  color:var(--muted);
  margin-top:8px;
}

.warn{
  color:var(--warn);
}

.ok{
  color:var(--good);
}

@media (max-width:1180px){
  .layout{
    grid-template-columns:1fr;
  }
}

@media (max-width:860px){
  .toolbar{
    grid-template-columns:1fr;
  }
  .meta-grid{
    grid-template-columns:1fr;
  }
}
/* DAG breadcrumb refinement patch */
.toolbar-hierarchy{
  grid-template-columns:260px 1fr 140px;
}

.layout-hierarchy{
  grid-template-columns:320px 1fr 360px;
}

.stack-gap-lg{
  margin-top:18px;
}

.stack-gap-md{
  margin-top:16px;
}

.path-note{
  min-height:20px;
}

.breadcrumb-badge{
  margin-right:8px;
}

.parent-rail{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.parent-rail-group{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.parent-rail-group-secondary{
  padding-top:2px;
}

.parent-rail-item{
  display:inline-flex;
  align-items:center;
  gap:8px;
  max-width:100%;
}

.parent-rail-item .parent-rail-label{
  display:inline-block;
  max-width:190px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.parent-rail-item .parent-rail-role{
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.04em;
  opacity:.85;
}

.parent-rail-item.preferred{
  background:#e6f0ff;
  border-color:#8fb3f5;
  color:#163a72;
}

.parent-rail-item.direct{
  background:#f4f8ff;
}

.parent-rail-item.alternate{
  background:#f8fbff;
  color:#385270;
}

.tree-chip-dag{
  background:#eef6ff;
  border-color:#bcd3fb;
}

#refreshLiveBtn {
  white-space: nowrap;
}

@media (max-width:1180px){
  .layout-hierarchy{
    grid-template-columns:1fr;
  }
}

@media (max-width:860px){
  .toolbar-hierarchy{
    grid-template-columns:1fr;
  }

  .parent-rail-item .parent-rail-label{
    max-width:100%;
  }
}
