.nav-link {
  font-size: 0.8rem;
  color: var(--accent);
  margin-right: 0.35rem;
  white-space: nowrap;
}

.app-header .brand {
  flex-wrap: nowrap;
}

.app-header .layout-tag {
  white-space: nowrap;
}

.uni-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}

.uni-layout.side-collapsed {
  grid-template-columns: 44px 1fr;
}

.uni-side {
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.uni-side-head {
  flex: 0 0 auto;
  padding: 0.85rem 1rem 0.35rem;
  border-bottom: 1px solid transparent;
}

.uni-side-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.uni-side-head h2 {
  margin: 0;
  font-size: 1rem;
}

.uni-side-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 1rem 1rem;
}

.uni-side-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  height: 100%;
  padding: 0.65rem 0.2rem;
  background: inherit;
}

.uni-side-rail-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  user-select: none;
}

.uni-side.collapsed > .uni-side-head,
.uni-side.collapsed > .uni-side-body {
  display: none !important;
}

.uni-side.collapsed > .uni-side-rail {
  display: flex;
}

.uni-side .col-collapse-btn {
  margin-top: 0;
}

.as-of-row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
  width: 100%;
}

.as-of-row input[type="date"] {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 9.5rem;
}

.as-of-clear {
  flex: 0 0 auto;
  width: auto !important;
  margin-top: 0 !important;
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.uni-side .secondary,
.uni-side button {
  margin-top: 0.45rem;
}

.uni-main {
  padding: 0.85rem 1rem 1.25rem;
  overflow: auto;
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  font-size: 0.84rem;
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #f4f4f5;
  border-radius: 8px;
  align-items: baseline;
}

.summary-bar .sum-chip {
  white-space: nowrap;
}

.summary-insight {
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.summary-insight.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.summary-bar strong {
  color: var(--text);
  font-weight: 650;
}

.progress-box {
  font-size: 0.78rem;
  color: var(--muted);
  max-height: 9rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  background: #fff;
  white-space: pre-wrap;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.tab {
  width: auto !important;
  padding: 0.35rem 0.7rem !important;
  font-size: 0.82rem !important;
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.tab.active {
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
}

.uni-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.uni-table th,
.uni-table td {
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.uni-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg);
}

.ret-pos {
  color: #b91c1c;
}

.ret-neg {
  color: #15803d;
}

.runs-window {
  max-height: 16rem;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.runs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.runs-head .section-label {
  margin: 0;
  flex: 0 1 auto;
}

.runs-search {
  flex: 1 1 6rem;
  min-width: 0;
  max-width: 9.5rem;
  padding: 0.22rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.3;
  font-family: inherit;
}

.runs-search::placeholder {
  color: #94a3b8;
}

.runs-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.run-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
}

.run-item {
  text-align: left;
  flex: 1;
  min-width: 0;
  padding: 0.3rem 1.75rem 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 400;
}

.run-item:hover {
  background: #f8fafc;
}

.run-del {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.run-row:hover .run-del,
.run-row:focus-within .run-del {
  opacity: 1;
  pointer-events: auto;
}

.run-del:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.ret-detail {
  font-size: 0.72rem;
  line-height: 1.3;
  margin-top: 0.15rem;
  max-width: 14rem;
}

#panel-dates {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  resize: vertical;
}

.l3-theme-select,
.field .l3-theme-select {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 8.5rem;
  max-height: 14rem;
  padding: 0.12rem;
  font-size: 0.72rem;
  line-height: 1.35;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.l3-theme-select option {
  padding: 0.08rem 0.3rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.scope-tree {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 10rem;
  max-height: 18rem;
  overflow: auto;
  padding: 0.35rem 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text);
}

.scope-tree-root,
.scope-tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.scope-tree-item {
  position: relative;
  margin: 0;
  padding: 0;
}

.scope-tree-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  min-height: 1.55rem;
}

.scope-tree-twist {
  flex: 0 0 1.1rem;
  width: 1.1rem;
  height: 1.3rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
}

.scope-tree-twist:hover {
  background: #f3f4f6;
  color: var(--text);
}

.scope-tree-twist.is-leaf {
  display: none;
}

.scope-tree-node {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 0.16rem 0.28rem;
  border-radius: 4px;
  cursor: pointer;
}

.scope-tree-node:hover {
  background: #f3f4f6;
}

.scope-tree-node.is-selected {
  background: #e8eef8;
  font-weight: 600;
}

.scope-tree-badge {
  margin-left: 0.3rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
}

/* Nested lists: vertical rail + horizontal ticks */
.scope-tree-children {
  margin: 0 0 0.05rem 0.48rem;
  padding: 0 0 0 0.4rem;
  border-left: 1px solid #c9d1d9;
}

.scope-tree-children > .scope-tree-item {
  position: relative;
}

.scope-tree-children > .scope-tree-item > .scope-tree-row {
  position: relative;
}

.scope-tree-children > .scope-tree-item > .scope-tree-row::before {
  content: "";
  position: absolute;
  left: -0.4rem;
  /* 经验值：对准名称文字中线（flex 行高 + node padding） */
  top: 0.72rem;
  width: 0.36rem;
  border-top: 1px solid #c9d1d9;
  transform: none;
}

/* 未展开的末行：竖线只画到行中线，与短横对齐 */
.scope-tree-children > .scope-tree-item:last-child:not(.is-expanded)::after {
  content: "";
  position: absolute;
  left: -0.4rem;
  top: 50%;
  bottom: 0;
  width: 1px;
  background: #fff;
}

.scope-tree-item:not(.is-expanded) > .scope-tree-children {
  display: none;
}

.scope-mode-pill {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #eef2f7;
  color: var(--muted);
}

.scope-mode-pill.is-ready {
  background: #e8f5e9;
  color: #2e7d32;
}

.scope-mode-pill.is-blocked {
  background: #f5f5f5;
  color: #757575;
}

.pick-mode-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pick-mode-opt {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: var(--text);
  margin-bottom: 0;
  cursor: pointer;
  line-height: 1.3;
}

/* Override .field label { display:block } and .field input { width:100% } */
.pick-mode-opt input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  accent-color: #2563eb;
}

.panel-table {
  font-size: 0.8rem;
}

.section-label {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.85rem;
}

/* 窄屏：设置在上、结果在下；设置可收起到顶栏 */
@media (max-width: 960px) {
  .uni-layout,
  .uni-layout.side-collapsed {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    overflow-y: auto;
  }

  .uni-side {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    max-height: 48vh;
  }

  .uni-side.collapsed {
    max-height: 48px;
  }

  .uni-side.collapsed > .uni-side-rail {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    height: 48px;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .uni-side-rail-label {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    letter-spacing: 0;
  }

  .uni-main {
    flex: 1 1 auto;
    min-height: 52vh;
    width: 100%;
  }
}
