/*
  本次修改点：
  1. 美化聚宽式分类多选区，降低高度、增强分组感和可读性。
  2. 子库筛选暂时隐藏时保留原有样式，后续可恢复。
  3. 增加监控筛选条、研究口径选择器、准入状态和策略生成按钮样式。
  4. 增加策略构建页、策略看板删除模式与股票池省略显示样式。
*/
:root {
  --bg: #f7f9ff;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --line: #d7dee9;
  --line-strong: #b8c2d1;
  --text: #111c2d;
  --muted: #657184;
  --primary: #073d61;
  --primary-soft: #e2efff;
  --green: #13a15a;
  --green-bg: #dff9e9;
  --red: #d93025;
  --red-bg: #fde7e5;
  --orange: #e76f00;
  --orange-bg: #fff0dd;
  --gray-bg: #edf2f7;
  --shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
  --sidebar-open: 260px;
  --sidebar-closed: 88px;
  --sidebar-duration: 220ms;
  --sidebar-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.auth-locked {
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(7, 61, 97, 0.96), rgba(17, 28, 45, 0.94)),
    var(--bg);
}

body.auth-locked .app-shell {
  display: none;
}

body:not(.auth-locked) .login-view {
  display: none;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
}

.login-brand div {
  display: grid;
  gap: 3px;
}

.login-brand strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.login-brand span,
.login-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 850;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 61, 97, 0.12);
}

.login-form button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-open) minmax(0, 1fr);
  background: var(--bg);
  transition: grid-template-columns var(--sidebar-duration) var(--sidebar-ease);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-closed) minmax(0, 1fr);
}

.app-shell.is-collapsing .sidebar {
  pointer-events: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  contain: layout paint style;
  backface-visibility: hidden;
}

.brand {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 20px 16px 22px;
  min-height: 136px;
  overflow: hidden;
  transition: padding var(--sidebar-duration) var(--sidebar-ease);
}

.brand-title {
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-title,
.brand-version,
.nav-item span:not(.nav-icon),
.collapse-label {
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 140ms ease,
    transform var(--sidebar-duration) var(--sidebar-ease),
    max-width var(--sidebar-duration) var(--sidebar-ease);
}

.sidebar-collapsed .brand {
  padding: 24px 12px;
  min-height: 112px;
}

.sidebar-collapsed .brand-title,
.sidebar-collapsed .brand-version,
.sidebar-collapsed .nav-item span:not(.nav-icon),
.sidebar-collapsed .collapse-label {
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
}

.brand-mark {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(7, 61, 97, 0.1);
  transform: translateZ(0);
}

.brand-mark img {
  display: block;
  width: 142px;
  height: 142px;
  object-fit: cover;
  transform: translate(-45px, -33px);
}

.brand-version {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #f6f8fc;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.nav-list {
  display: grid;
  gap: 10px;
  padding: 0 14px;
  transition: padding var(--sidebar-duration) var(--sidebar-ease);
}

.nav-item {
  border: 0;
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 17px;
  cursor: pointer;
  overflow: hidden;
  transition:
    background-color 140ms ease,
    color 140ms ease,
    padding var(--sidebar-duration) var(--sidebar-ease);
}

.sidebar-collapsed .nav-list {
  padding: 0 12px;
}

.sidebar-collapsed .nav-item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
}

.sidebar-collapsed .nav-icon {
  font-size: 15px;
}

.nav-item.active {
  background: #e9eef3;
  color: var(--primary);
  font-weight: 700;
}

.nav-item.muted {
  color: #1f2937;
  opacity: 0.72;
  cursor: not-allowed;
}

.nav-icon {
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.nav-lock {
  color: #9aa5b4;
  font-size: 11px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 14px 24px;
  border-top: 1px solid var(--line);
}

.collapse-button {
  border: 0;
  background: transparent;
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
  border-radius: 8px;
  color: #1f2937;
  font-size: 18px;
  cursor: pointer;
  overflow: hidden;
  transition:
    background-color 140ms ease;
}

.collapse-button:hover {
  background: #f1f5fb;
}

.sidebar-collapsed .collapse-button {
  justify-content: center;
}

.collapse-icon {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.collapse-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 3px;
  width: 2px;
  height: 14px;
  border-radius: 999px;
  background: #1f2937;
}

.collapse-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 7px;
  width: 8px;
  height: 8px;
  border-left: 2px solid #1f2937;
  border-bottom: 2px solid #1f2937;
  transform: rotate(45deg);
  transition: transform var(--sidebar-duration) var(--sidebar-ease);
}

.sidebar-collapsed .collapse-icon::after {
  transform: rotate(-135deg);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 92px;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 18px;
}

h1 {
  margin: 0;
  color: var(--primary);
  font-size: 26px;
  line-height: 1;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line-strong);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.status-ok {
  color: var(--green);
  background: var(--green-bg);
}

.status-warn {
  color: var(--orange);
  background: var(--orange-bg);
}

.status-bad {
  color: var(--red);
  background: var(--red-bg);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 34px;
  padding: 0 16px;
  background: var(--surface);
  color: #2e3b4f;
  font-weight: 700;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--primary);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.icon-button.is-loading {
  background: var(--primary-soft);
  color: var(--primary);
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.content {
  padding: 26px 30px;
}

.category-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 22px 18px;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.02);
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-height: 38px;
}

.sub-filter-row {
  margin-top: 10px;
  padding-left: 126px;
}

.filter-label {
  width: 72px;
  padding-top: 4px;
  color: #2a3442;
  font-size: 15px;
  font-weight: 800;
}

.tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.market-filter-row {
  align-items: center;
}

.market-tabs {
  gap: 10px;
}

#categoryTabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(168px, 1fr));
  column-gap: 20px;
  row-gap: 10px;
  width: 100%;
}

.category-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.category-check:hover {
  background: #edf5ff;
}

.category-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.category-check.disabled {
  color: #9aa8ba;
  cursor: default;
  opacity: 0.72;
}

.category-check.disabled input {
  cursor: default;
}

.tab {
  border: 1px solid transparent;
  min-height: 34px;
  padding: 0 18px;
  border-radius: 4px;
  background: transparent;
  color: #293241;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab:disabled {
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.55;
}

.tabs-sub .tab {
  min-height: 30px;
  padding: 0 14px;
  font-size: 13px;
}

.tabs-sub .tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #c7d4e4;
}

.factor-subcategory {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.factor-table tbody tr.not-admitted {
  color: #8b98aa;
  background: #f8fafc;
}

.factor-table tbody tr.not-admitted .factor-link {
  color: #8b98aa;
}

.factor-table tbody tr.weak-alpha {
  background: #fffdf7;
}

.weak-tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--orange-bg);
  color: #b7791f;
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

.primary-action.compact {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.primary-action.compact:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 20px;
}

.research-period-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 2px;
  border-bottom: 1px solid var(--line);
}

.research-scope-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 2.3fr);
  gap: 16px;
  padding: 18px 0 2px;
  border-bottom: 1px solid var(--line);
}

.scope-readonly,
.scope-editable {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdff;
}

.scope-readonly strong,
.scope-editable strong {
  display: block;
  margin-bottom: 6px;
}

.scope-readonly span,
.scope-editable header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.scope-editable header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.scope-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.scope-grid label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.scope-grid select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  color: var(--primary);
  font-weight: 800;
}

.monitor-filter-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.monitor-filter-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.monitor-filter-row.compact {
  align-items: center;
}

.monitor-filter-label {
  padding-top: 4px;
  color: #2a3442;
  font-weight: 900;
}

.monitor-category-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 8px 16px;
}

.segmented-filter {
  display: inline-flex;
  gap: 6px;
}

.segmented-filter button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: #334155;
  font-weight: 800;
  cursor: pointer;
}

.segmented-filter button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.market-segmented {
  flex-wrap: wrap;
}

.market-segmented .market-filter,
.market-tabs .tab {
  min-width: 92px;
}

.market-segmented .market-filter:disabled,
.market-tabs .tab:disabled {
  color: #94a3b8;
  cursor: default;
  opacity: 0.58;
}

.period-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.period-pill,
.period-option {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 13px;
}

.period-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c7d4e4;
  background: var(--primary-soft);
  color: var(--primary);
}

.period-option {
  border: 1px solid var(--line);
  background: #f2f6ff;
  color: #8a95a6;
  cursor: not-allowed;
}

.period-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: right;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-weight: 800;
}

select,
.search input {
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #eef3ff;
  color: #233044;
  padding: 0 12px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.text-button.danger {
  color: var(--red);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search span {
  position: absolute;
  left: 14px;
  color: #718096;
  font-size: 0;
}

.search span::before {
  content: "搜索";
  font-size: 12px;
}

.search input {
  width: 244px;
  padding-left: 48px;
}

.error-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--red-bg);
  border-radius: 6px;
  padding: 14px 16px;
  color: var(--red);
  background: #fff5f5;
}

.hidden {
  display: none !important;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-scroll {
  overflow-x: auto;
}

.factor-table {
  width: 100%;
  min-width: 1540px;
  border-collapse: collapse;
  table-layout: fixed;
}

.drag-selecting,
.drag-selecting .factor-table {
  cursor: copy;
  user-select: none;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  height: 48px;
  color: #697386;
  background: #fbfcff;
  font-size: 13px;
  font-weight: 800;
}

tbody tr {
  height: 56px;
  transition: background 120ms ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f3f7ff;
}

tbody tr.selected {
  box-shadow: inset 4px 0 0 var(--primary);
}

.select-col {
  width: 68px;
}

.factor-table th:nth-child(2),
.factor-table td:nth-child(2) {
  width: 190px;
}

.factor-table th:nth-child(3),
.factor-table td:nth-child(3) {
  width: 92px;
}

.factor-table th:nth-child(4),
.factor-table td:nth-child(4) {
  width: 118px;
}

.factor-table th:nth-child(5),
.factor-table td:nth-child(5) {
  width: 128px;
}

.factor-table th:nth-child(6),
.factor-table td:nth-child(6) {
  width: 104px;
}

.factor-table th:nth-child(7),
.factor-table td:nth-child(7) {
  width: 104px;
}

.factor-table th:nth-child(8),
.factor-table td:nth-child(8),
.factor-table th:nth-child(9),
.factor-table td:nth-child(9),
.factor-table th:nth-child(10),
.factor-table td:nth-child(10),
.factor-table th:nth-child(11),
.factor-table td:nth-child(11) {
  width: 116px;
}

.factor-table th:nth-child(12),
.factor-table td:nth-child(12) {
  width: 150px;
}

.factor-table th:nth-child(13),
.factor-table td:nth-child(13) {
  width: 128px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.factor-name {
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
}

.factor-link {
  border: 0;
  padding: 0;
  max-width: 100%;
  background: transparent;
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.factor-link:hover {
  text-decoration: underline;
}

.factor-link:disabled {
  color: #6b7280;
  cursor: not-allowed;
  text-decoration: none;
}

tbody tr.openable {
  cursor: default;
}

.number {
  text-align: right;
  font-family: "JetBrains Mono", Consolas, monospace;
}

td.number {
  color: #0f172a;
  font-size: 17px;
  font-weight: 700;
}

.sortable,
.monitor-sortable,
.strategy-sortable {
  cursor: pointer;
  user-select: none;
}

.sortable::after,
.monitor-sortable::after,
.strategy-sortable::after {
  content: "↕";
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  min-height: 14px;
  padding: 0;
  border-radius: 0;
  color: #64748b;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.sortable.sort-desc::after,
.monitor-sortable.sort-desc::after,
.strategy-sortable.sort-desc::after {
  content: "↓";
  color: var(--primary);
  background: transparent;
}

.sortable.sort-asc::after,
.monitor-sortable.sort-asc::after,
.strategy-sortable.sort-asc::after {
  content: "↑";
  color: var(--primary);
  background: transparent;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge-green {
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid #a6edc2;
}

.badge-red {
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #ffc1ba;
}

.badge-orange {
  color: var(--orange);
  background: var(--orange-bg);
  border: 1px solid #ffd3a3;
}

.badge-blue {
  color: var(--primary);
  background: #eaf2ff;
  border: 1px solid #bfd5f2;
}

.badge-gray {
  color: #64748b;
  background: var(--gray-bg);
  border: 1px solid #dbe3ec;
}

.recommendation {
  font-weight: 800;
}

.recommendation.reusable {
  color: var(--green);
}

.recommendation.rerun {
  color: var(--orange);
}

.recommendation.missing {
  color: #64748b;
}

.muted-text {
  color: #94a3b8;
}

.muted-dash {
  color: #94a3b8;
  font-weight: 700;
}

.coverage-warning {
  color: #d97706;
}

.coverage-danger {
  color: var(--red);
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  margin: 2px 4px 2px 0;
  padding: 2px 7px;
  border-radius: 999px;
  color: #475569;
  background: #eef4fb;
  border: 1px solid #d7e2ee;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 20px;
}

.monitor-view {
  display: grid;
  gap: 18px;
}

.monitor-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px 24px;
  background: var(--surface);
}

.monitor-head h2 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 24px;
}

.monitor-head p {
  margin: 0;
  color: #536174;
  line-height: 1.7;
}

.monitor-note {
  display: grid;
  gap: 6px;
  width: min(420px, 42%);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: #edf5ff;
  color: #42526a;
  line-height: 1.6;
}

.monitor-note strong {
  color: var(--primary);
}

.monitor-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.monitor-stat-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 14px 16px;
  background: var(--surface);
}

.monitor-stat-card span {
  color: #526174;
  font-size: 13px;
  font-weight: 800;
}

.monitor-stat-card strong {
  color: #061b33;
  font-size: 28px;
  line-height: 1;
}

.monitor-stat-card small {
  color: #718096;
  line-height: 1.5;
}

.monitor-stat-card.clickable {
  cursor: pointer;
}

.monitor-stat-card.clickable.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(0, 68, 107, 0.12);
}

.monitor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.monitor-filter-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.monitor-filter {
  border: 1px solid var(--line);
  min-height: 34px;
  padding: 0 16px;
  border-radius: 4px;
  background: var(--surface);
  color: #334155;
  font-weight: 800;
  cursor: pointer;
}

.monitor-filter.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.monitor-toolbar-note {
  color: var(--muted);
  font-size: 13px;
}

.monitor-table {
  width: 100%;
  min-width: 1450px;
  border-collapse: collapse;
  table-layout: fixed;
}

.monitor-table th,
.monitor-table td,
.strategy-table th,
.strategy-table td,
.task-table th,
.task-table td {
  padding: 10px 14px;
  line-height: 1.25;
}

.monitor-table tbody tr,
.strategy-table tbody tr,
.task-table tbody tr {
  height: 56px;
}

.monitor-table th:nth-child(1),
.monitor-table td:nth-child(1) {
  width: 116px;
}

.monitor-table th:nth-child(2),
.monitor-table td:nth-child(2) {
  width: 152px;
}

.monitor-table th:nth-child(3),
.monitor-table td:nth-child(3) {
  width: 156px;
}

.monitor-table th:nth-child(4),
.monitor-table td:nth-child(4),
.monitor-table th:nth-child(5),
.monitor-table td:nth-child(5),
.monitor-table th:nth-child(6),
.monitor-table td:nth-child(6),
.monitor-table th:nth-child(7),
.monitor-table td:nth-child(7) {
  width: 118px;
}

.monitor-table th:nth-child(8),
.monitor-table td:nth-child(8) {
  width: 132px;
}

.monitor-table th:nth-child(9),
.monitor-table td:nth-child(9),
.monitor-table th:nth-child(10),
.monitor-table td:nth-child(10) {
  width: 112px;
}

.monitor-table th:nth-child(11),
.monitor-table td:nth-child(11) {
  width: 132px;
}

.monitor-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.monitor-dot.strong {
  background: var(--green);
}

.monitor-dot.medium {
  background: #f4b400;
}

.monitor-dot.weak {
  background: var(--red);
}

.monitor-dot.missing {
  background: #94a3b8;
}

.monitor-source-sub {
  display: inline;
  margin-left: 6px;
  margin-top: 0;
  color: #718096;
  font-size: 12px;
}

.market-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.market-cell .monitor-source-sub {
  display: block;
  margin-left: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.market-chip.market-us {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.market-chip.market-other {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.ic-bar-track {
  display: inline-flex;
  width: 92px;
  height: 7px;
  overflow: hidden;
  vertical-align: middle;
  border-radius: 999px;
  background: #d8e1ee;
}

.ic-bar-fill {
  display: block;
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
}

.ic-bar-fill.strong {
  background: var(--green);
}

.ic-bar-fill.medium {
  background: #f4b400;
}

.ic-bar-fill.weak {
  background: var(--red);
}

.ic-bar-fill.missing {
  background: #94a3b8;
}

.recent-ic,
.direction-pill,
.validation-badge {
  font-weight: 900;
}

.recent-ic.positive,
.direction-pill.positive {
  color: var(--green);
}

.recent-ic.negative,
.direction-pill.negative {
  color: var(--red);
}

.recent-ic.neutral,
.direction-pill.neutral {
  color: #64748b;
}

.direction-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: #e8f7ef;
}

.direction-pill.negative {
  background: #fff0f0;
}

.direction-pill.neutral {
  background: #eef2f7;
}

.validation-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: #0f5132;
}

.validation-badge.review {
  color: #b7791f;
}

.validation-badge.reject {
  color: var(--red);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-button {
  border: 1px solid var(--line-strong);
  min-width: 38px;
  height: 38px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.page-button.active {
  background: var(--primary);
  color: #fff;
}

.selection-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: var(--sidebar-open);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(10px);
}

.sidebar-collapsed .selection-bar {
  left: 88px;
}

.selection-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  color: #475569;
}

.selection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.danger-action {
  border: 0;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.danger-action.compact {
  min-width: 112px;
  height: 38px;
  padding: 0 16px;
}

.danger-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.detail-view {
  display: grid;
  gap: 24px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb strong {
  color: var(--primary);
}

.breadcrumb-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.detail-hero,
.summary-card,
.research-card {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 30px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.detail-title-row h2 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1.2;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 18px 28px;
  margin: 0;
}

.detail-meta div {
  display: grid;
  gap: 6px;
}

.detail-meta dt {
  color: #334155;
  font-weight: 800;
}

.detail-meta dd {
  margin: 0;
  color: #111827;
}

code {
  padding: 4px 8px;
  border-radius: 3px;
  background: #edf4ff;
  color: var(--primary);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
}

.detail-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary-action {
  border: 1px solid var(--line-strong);
  min-height: 44px;
  padding: 0 18px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.secondary-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-action.compact {
  min-width: 132px;
  height: 44px;
  padding: 0 18px;
  cursor: pointer;
}

.detail-tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line-strong);
}

.detail-tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  min-height: 52px;
  padding: 0 20px;
  background: transparent;
  color: #46556a;
  font-weight: 800;
  cursor: pointer;
}

.detail-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.detail-tabs button:disabled {
  color: #9aa5b4;
  cursor: not-allowed;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 18px;
}

.factor-definition-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 18px 22px;
  background: var(--surface);
}

.factor-definition-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.factor-definition-head > div {
  display: grid;
  gap: 6px;
}

.factor-definition-head strong {
  color: var(--primary);
  font-size: 17px;
}

.factor-definition-head span {
  color: #536174;
}

.factor-formula {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow-x: auto;
  color: #102033;
  background: #f7faff;
  font-size: 13px;
  line-height: 1.7;
}

.definition-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  margin: 0;
}

.definition-meta dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.definition-meta dd {
  margin: 4px 0 0;
  color: #102033;
  font-weight: 800;
}

.research-settings-card {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 20px 22px;
  background: var(--surface);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.settings-head > div {
  display: grid;
  gap: 6px;
  min-width: 280px;
}

.settings-head strong {
  color: var(--primary);
  font-size: 17px;
}

.settings-head span,
.settings-foot span {
  color: #536174;
  line-height: 1.7;
}

.settings-head dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 14px;
  margin: 0;
}

.settings-head dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-head dd {
  margin: 4px 0 0;
  color: #102033;
  font-weight: 800;
}

.research-mode-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.research-mode-head strong {
  color: var(--primary);
  font-size: 16px;
}

.research-mode-head span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px 18px;
}

.settings-grid label {
  display: grid;
  gap: 7px;
}

.settings-grid label span {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.settings-grid select {
  width: 100%;
  background: #fff;
}

.settings-grid select:disabled {
  color: #8a95a6;
  background: #eef2f8;
  cursor: not-allowed;
}

.settings-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-foot button {
  border: 0;
  min-width: 150px;
  height: 38px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.settings-foot button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.metric-card span {
  color: #536174;
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  color: #0f172a;
  font-size: 22px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.metric-card.good strong,
.text-green {
  color: var(--green);
}

.metric-card.warn strong,
.text-red {
  color: var(--red);
}

.metric-card.live {
  border-color: #93c5fd;
  background: #eff6ff;
}

.metric-card.live span {
  color: #1d4ed8;
}

.live-metrics {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 16px;
}

.chart-legend {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding: 8px 18px 14px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.legend-dot.backtest {
  background: #9ca3af;
}

.legend-dot.live {
  background: #3b82f6;
}

.research-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
}

.research-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.metrics-group {
  margin-bottom: 16px;
}

.metrics-group-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid;
}

.metrics-group-title.backtest-title {
  color: #374151;
  border-color: #9ca3af;
}

.metrics-group-title.live-title {
  color: #1d4ed8;
  border-color: #3b82f6;
}

.summary-card {
  overflow: hidden;
}

.summary-card > header,
.research-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line-strong);
  background: #eef4ff;
  color: #0f1f33;
  font-weight: 800;
}

.summary-body {
  padding: 24px 26px;
}

.summary-body p {
  margin: 0 0 22px;
  color: #273449;
  line-height: 1.8;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td {
  white-space: normal;
}

.summary-table td {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
}

.research-layout {
  display: grid;
  grid-template-columns: minmax(680px, 2fr) minmax(420px, 1fr);
  gap: 24px;
  align-items: stretch;
}

.research-card {
  overflow: hidden;
}

.research-card header span {
  color: #718096;
  font-size: 12px;
  white-space: nowrap;
}

.side-charts {
  display: grid;
  gap: 24px;
}

.chart-placeholder {
  min-height: 250px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px;
  color: #718096;
  text-align: center;
  background:
    linear-gradient(#e7edf7 1px, transparent 1px),
    linear-gradient(90deg, #e7edf7 1px, transparent 1px),
    #fbfdff;
  background-size: 40px 40px;
}

.chart-rendered {
  box-sizing: border-box;
  display: block;
  padding: 18px 22px 14px;
  background: #ffffff;
}

.chart-rendered.chart-large {
  height: 480px;
  padding: 18px 22px 16px;
}

.chart-rendered:not(.chart-large) {
  height: 295px;
  padding: 16px 18px 14px;
}

.chart-large {
  min-height: 480px;
}

@media (max-width: 1280px) {
  .research-layout {
    grid-template-columns: 1fr;
  }

  .side-charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .side-charts {
    grid-template-columns: 1fr;
  }
}

.placeholder-mark {
  color: #aab5c4;
  font-size: 34px;
  line-height: 1;
}

.chart-placeholder strong {
  color: #475569;
}

.chart-placeholder span {
  max-width: 420px;
  line-height: 1.7;
}

.info-strip {
  border-left: 4px solid #2b7fff;
  padding: 16px 20px;
  background: #edf5ff;
  color: #174272;
  font-size: 13px;
  line-height: 1.7;
}

.artifact-note {
  padding: 18px 22px 0;
  color: #56657a;
}

.artifact-alert {
  margin: 18px 22px 0;
  border: 1px solid #ffc1ba;
  border-left: 4px solid var(--red);
  border-radius: 4px;
  padding: 14px 16px;
  background: #fff5f5;
  color: #8a1f17;
  line-height: 1.7;
}

.artifact-table {
  margin-top: 12px;
}

.strategy-view {
  display: grid;
  gap: 18px;
}

.strategy-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px 24px;
  background: var(--surface);
}

.strategy-head h2 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 24px;
}

.strategy-head p {
  margin: 0;
  color: #536174;
  line-height: 1.7;
}

.strategy-note {
  display: grid;
  gap: 6px;
  width: min(460px, 44%);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: #edf5ff;
  color: #42526a;
  line-height: 1.6;
}

.strategy-note strong {
  color: var(--primary);
}

.contract-drawer {
  width: min(460px, 44%);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: #edf5ff;
  color: #42526a;
  line-height: 1.6;
}

.contract-drawer summary {
  color: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

.contract-drawer span {
  display: block;
  margin-top: 8px;
}

.strategy-table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  table-layout: fixed;
}

.strategy-table th,
.strategy-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: #0f2238;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  vertical-align: middle;
}

.strategy-table th {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.strategy-table .number {
  text-align: right;
}

.strategy-name {
  display: block;
}

.strategy-name strong {
  color: var(--primary);
  font-size: 15px;
}

.strategy-name small {
  display: none;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}

.strategy-table th:nth-child(1),
.strategy-table td:nth-child(1) {
  width: 250px;
}

.strategy-table th:nth-child(3),
.strategy-table td:nth-child(3) {
  width: 150px;
}

.strategy-table th:nth-child(5),
.strategy-table td:nth-child(5) {
  width: 130px;
}

.strategy-table th:nth-child(9),
.strategy-table td:nth-child(9) {
  width: 150px;
}

.strategy-universe-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-name-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-factors-cell {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.strategy-link:hover {
  text-decoration: underline;
}

.strategy-delete-check {
  display: inline-flex;
  margin-right: 8px;
  vertical-align: middle;
}

.strategy-delete-mode-row td:first-child {
  background: #f8fbff;
}

.strategy-board-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
}

.strategy-builder-view {
  display: grid;
  gap: 16px;
}

.builder-head {
  align-items: center;
}

.builder-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.builder-section header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.builder-section header strong {
  color: var(--text);
  font-size: 15px;
}

.builder-factor-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.builder-factor-table th,
.builder-factor-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.builder-factor-table .number {
  text-align: right;
}

.builder-template-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.builder-template-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbff;
  cursor: pointer;
}

.builder-template-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.builder-template-card span {
  display: grid;
  gap: 5px;
}

.builder-template-card small,
.builder-template-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.builder-param-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.builder-param,
.builder-name-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.builder-param input,
.builder-param select,
.builder-name-field input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

.builder-actions-section {
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
}

.builder-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.builder-result-card {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 0.9fr);
  gap: 18px;
  align-items: stretch;
}

.builder-curve {
  position: relative;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  overflow: hidden;
}

.curve-line {
  position: absolute;
  height: 3px;
  border-radius: 999px;
  transform-origin: left center;
}

.curve-line-backtest {
  left: 8%;
  top: 58%;
  width: 46%;
  background: repeating-linear-gradient(90deg, #7aa0c8 0 10px, transparent 10px 16px);
  transform: rotate(-13deg);
}

.curve-line-live {
  left: 55%;
  top: 45%;
  width: 36%;
  background: var(--green);
  transform: rotate(-10deg);
}

.curve-cutoff {
  position: absolute;
  left: 54%;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-left: 2px dashed #b7791f;
}

.curve-label {
  position: absolute;
  bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.curve-label.left {
  left: 16px;
}

.curve-label.right {
  right: 16px;
}

.builder-metrics {
  display: grid;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.builder-metric-head,
.builder-metric-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.builder-metric-head {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.builder-metric-row strong {
  text-align: right;
}

.builder-empty-result {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: #fbfdff;
}

@media (max-width: 1100px) {
  .builder-template-list,
  .builder-param-grid,
  .builder-result-card,
  .builder-actions-section {
    grid-template-columns: 1fr;
  }
}

.strategy-detail-view,
.task-view {
  display: grid;
  gap: 18px;
}

.research-settings {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px 24px;
  background: var(--surface);
}

.research-settings h3 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 18px;
}

.research-settings p {
  margin: 0;
  color: #536174;
  line-height: 1.65;
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px 18px;
}

.research-grid label {
  display: grid;
  gap: 7px;
  color: #526174;
  font-size: 13px;
  font-weight: 800;
}

.strategy-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.risk-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.risk-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 14px;
}

.risk-item span {
  color: var(--muted);
}

.risk-item strong {
  color: var(--primary);
}

.equity-svg {
  width: 100%;
  height: clamp(560px, 64vh, 760px);
  display: block;
  background: #ffffff;
}

.strategy-equity-chart {
  padding: 18px 18px 6px;
  background: #ffffff;
}

.chart-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.toggle-btn {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:hover {
  background: #f3f4f6;
}

.toggle-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.chart-card {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.chart-card.large-chart {
  grid-column: 1 / -1;
}

.chart-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #eef4ff;
}

.chart-card.large-chart header {
  min-height: 56px;
}

.chart-card.large-chart header strong {
  font-size: 18px;
}

.chart-card header span {
  color: #718096;
  font-size: 12px;
  font-weight: 800;
}

.strategy-factor-chip {
  display: inline-flex;
  margin: 20px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf5ff;
  color: var(--primary);
  font-weight: 800;
}

.trace-chip {
  display: inline-flex;
  align-items: center;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #eef4fb;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.trace-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.trace-chip:active {
  background: #bfdbfe;
}

.trace-chip.trace-strategy {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.trace-chip.trace-strategy:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.trace-chip:disabled,
.trace-chip.is-placeholder {
  cursor: default;
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
}

.trace-chip:disabled:hover,
.trace-chip.is-placeholder:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.task-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px 24px;
  background: var(--surface);
}

.task-head h2 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 24px;
}

.task-head p {
  margin: 0;
  color: #536174;
  line-height: 1.7;
}

.task-note {
  display: grid;
  gap: 6px;
  width: min(460px, 44%);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: #edf5ff;
  color: #42526a;
  line-height: 1.6;
}

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.task-table-card {
  min-height: 520px;
}

.table-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #eef4ff;
}

.table-card-head span {
  color: #718096;
  font-size: 12px;
  font-weight: 800;
}

.task-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.task-table th,
.task-table td {
  padding: 10px 14px;
}

.task-table th:nth-child(1),
.task-table td:nth-child(1) {
  width: 40%;
}

.task-table td strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monitor-table th,
.monitor-table td,
.strategy-table th,
.strategy-table td,
.task-table th,
.task-table td {
  padding: 10px 14px;
  line-height: 1.25;
}

.monitor-table tbody tr,
.strategy-table tbody tr,
.task-table tbody tr {
  height: 56px;
}

.progress-track {
  display: inline-flex;
  width: 110px;
  height: 8px;
  margin-right: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8f4;
  vertical-align: middle;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.task-stage-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.task-stage-panel header,
.task-stage-panel footer {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.task-stage-panel header {
  border-bottom: 1px solid var(--line);
  background: #eef4ff;
}

.task-stage-panel footer {
  border-top: 1px solid var(--line);
  color: #526174;
}

.task-stage-panel span,
.task-stage-panel small {
  color: #64748b;
  overflow-wrap: anywhere;
}

.task-stage-list {
  display: grid;
  gap: 10px;
  padding: 0 12px 4px;
}

.task-stage-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  border-left: 4px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 10px;
  background: #fbfcff;
}

.task-stage-card strong {
  display: block;
  margin-bottom: 3px;
}

.task-stage-card.stage-passed {
  border-left-color: var(--green);
}

.task-stage-card.stage-running,
.task-stage-card.stage-warning {
  border-left-color: var(--orange);
}

.gate-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border-radius: 999px;
  background: #eaf2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.settings-view {
  display: grid;
  gap: 18px;
}

.settings-page-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px 24px;
  background: var(--surface);
}

.settings-page-head h2 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 24px;
}

.settings-page-head p,
.settings-page-note span {
  margin: 0;
  color: #536174;
  line-height: 1.7;
}

.settings-page-note {
  display: grid;
  gap: 6px;
  width: min(460px, 42%);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: #edf5ff;
}

.settings-page-note strong {
  color: var(--primary);
}

.settings-page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.settings-page-card,
.settings-page-panel {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.settings-page-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-page-card-head,
.settings-page-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-page-card-head strong,
.settings-page-panel header strong {
  color: var(--primary);
  font-size: 17px;
}

.settings-page-panel header {
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #eef4ff;
}

.settings-page-panel header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-page-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.settings-page-pill.ok {
  background: var(--green-bg);
  color: var(--green);
}

.settings-page-pill.warn {
  background: var(--orange-bg);
  color: var(--orange);
}

.settings-page-pill.bad {
  background: var(--red-bg);
  color: var(--red);
}

.settings-page-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.settings-page-list div {
  display: grid;
  gap: 4px;
}

.settings-page-list dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-page-list dd {
  margin: 0;
  color: #102033;
  font-weight: 700;
  line-height: 1.55;
}

.settings-page-list code,
.settings-page-contracts code {
  border-radius: 4px;
  padding: 2px 6px;
  background: #edf5ff;
  color: var(--primary);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.settings-page-kv-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 0;
  padding: 18px;
}

.settings-page-kv-grid div {
  display: grid;
  gap: 7px;
  border-right: 1px solid var(--line);
  padding: 0 18px;
}

.settings-page-kv-grid div:first-child {
  padding-left: 0;
}

.settings-page-kv-grid div:last-child {
  border-right: 0;
  padding-right: 0;
}

.settings-page-kv-grid span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-page-kv-grid strong {
  color: #06152a;
  font-size: 22px;
}

.settings-page-contracts {
  display: grid;
  gap: 10px;
  padding: 18px;
  color: #334155;
  font-weight: 700;
}

.agent-task-view {
  display: grid;
  gap: 18px;
}

.agent-task-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.agent-task-pending-banner {
  display: grid;
  gap: 4px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 12px 14px;
  background: #eff6ff;
}

.agent-task-pending-banner strong {
  color: var(--primary);
  font-weight: 900;
}

.agent-task-pending-banner span {
  color: #334155;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

.agent-intake-mode {
  display: inline-flex;
  gap: 6px;
}

.agent-intake-mode button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: #334155;
  font-weight: 800;
  cursor: pointer;
}

.agent-intake-mode button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.intake-skill-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px 16px;
}

.intake-skill-card > div {
  display: grid;
  gap: 5px;
}

.intake-skill-card strong {
  color: var(--primary);
  font-weight: 900;
}

.intake-skill-card span {
  color: #64748b;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.5;
}

.skill-contract-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.skill-contract-panel {
  position: fixed;
  left: 50%;
  top: 52%;
  z-index: 81;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, calc(100vw - 36px));
  height: min(760px, calc(100vh - 48px));
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.skill-contract-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.skill-contract-panel header > div:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.skill-contract-panel header strong {
  color: #102033;
  font-size: 15px;
  font-weight: 900;
}

.skill-contract-panel header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.skill-contract-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.skill-contract-panel pre {
  overflow: auto;
  margin: 0;
  padding: 18px;
  background: #ffffff;
  color: #102033;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}

.agent-task-field {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.agent-task-field textarea {
  width: 100%;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px 14px;
  color: #102033;
  background: #f7faff;
  font: inherit;
  font-weight: 600;
  resize: vertical;
}

.agent-drop-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 112px;
  border: 1px dashed #9fb2c8;
  border-radius: 8px;
  padding: 18px;
  background: #f7faff;
  color: #536174;
  cursor: pointer;
}

.agent-drop-zone div:first-child {
  display: grid;
  gap: 5px;
}

.agent-drop-zone strong {
  color: var(--primary);
  font-size: 16px;
}

.agent-drop-zone span {
  font-weight: 700;
}

.agent-drop-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-drop-zone.drag-over {
  border-color: var(--primary);
  background: #edf5ff;
  color: var(--primary);
}

.agent-file-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.agent-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfdff;
}

.agent-file-item span {
  display: grid;
  gap: 3px;
}

.agent-file-item strong {
  overflow-wrap: anywhere;
}

.agent-file-item small {
  color: #64748b;
  font-weight: 700;
}

.agent-file-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.agent-task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: #536174;
  font-weight: 800;
}

.agent-task-foot code {
  border-radius: 4px;
  padding: 2px 6px;
  background: #edf5ff;
  color: var(--primary);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.agent-task-card .primary-action {
  border: 0;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.agent-task-card .primary-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.agent-task-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
}

.agent-task-table th,
.agent-task-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
}

.agent-task-table th:nth-child(1),
.agent-task-table td:nth-child(1) {
  width: 52px;
}

.agent-task-table th:nth-child(2),
.agent-task-table td:nth-child(2) {
  width: 280px;
}

.agent-task-table th:nth-child(3),
.agent-task-table td:nth-child(3) {
  width: auto;
}

.agent-task-table th:nth-child(4),
.agent-task-table td:nth-child(4),
.agent-task-table th:nth-child(5),
.agent-task-table td:nth-child(5),
.agent-task-table th:nth-child(6),
.agent-task-table td:nth-child(6) {
  width: 150px;
}

.agent-task-id {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-task-summary {
  overflow-wrap: anywhere;
}

.agent-task-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.app-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  transform: translateY(10px);
  opacity: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 16px;
  background: #061b33;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.app-toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.file-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.file-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
}

.file-preview-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(980px, calc(100vw - 40px));
  height: min(720px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.file-preview-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #eef4ff;
}

.file-preview-panel header div {
  display: grid;
  gap: 3px;
}

.file-preview-panel header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.file-preview-body {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.file-preview-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.file-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.file-preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.agent-wish-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  padding: 18px;
}

.agent-wish-form,
.agent-wish-contract {
  display: grid;
  gap: 14px;
}

.agent-wish-form label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.agent-wish-form textarea,
.agent-wish-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 12px;
  color: #102033;
  background: #f7faff;
  font: inherit;
  resize: vertical;
}

.agent-wish-form textarea:disabled,
.agent-wish-form select:disabled {
  color: #94a3b8;
  background: #f3f7fb;
  cursor: not-allowed;
}

.agent-wish-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.agent-wish-form .primary-action {
  justify-self: start;
}

.agent-wish-contract {
  align-content: start;
  border-left: 4px solid var(--primary);
  padding: 14px 16px;
  background: #edf5ff;
}

.agent-wish-contract strong {
  color: var(--primary);
  font-size: 15px;
}

.agent-wish-contract p {
  margin: 0;
  color: #536174;
  line-height: 1.7;
}

.agent-wish-contract dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.agent-wish-contract dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.agent-wish-contract dd {
  margin: 3px 0 0;
  color: #102033;
  font-weight: 700;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .brand,
  .brand-title,
  .nav-list,
  .nav-item,
  .nav-item span:not(.nav-icon),
  .collapse-label,
  .collapse-icon::after {
    transition: none;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .selection-bar {
    left: 0;
  }

  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    padding: 18px;
  }

  .research-period-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-note {
    text-align: left;
  }

  #categoryTabs {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .research-scope-panel,
  .scope-grid,
  .monitor-category-filters {
    grid-template-columns: 1fr;
  }

  .monitor-filter-row {
    grid-template-columns: 1fr;
  }

  .sub-filter-row {
    padding-left: 0;
  }

  .detail-hero,
  .research-layout {
    grid-template-columns: 1fr;
  }

  .detail-hero {
    flex-direction: column;
  }

  .detail-meta,
  .metric-grid,
  .strategy-detail-grid,
  .settings-head dl,
  .settings-grid,
  .settings-page-grid,
  .settings-page-kv-grid {
    grid-template-columns: 1fr;
  }

  .equity-svg {
    height: 420px;
  }

  .chart-card header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
  }

  .chart-toggle {
    margin-left: 0;
  }

  .settings-head,
  .settings-foot,
  .settings-page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-page-note {
    width: 100%;
  }

  .settings-page-kv-grid div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  .settings-page-kv-grid div:first-child {
    padding-top: 0;
  }

  .settings-page-kv-grid div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }
}

@media (max-width: 560px) {
  #categoryTabs {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.panel-badge {
  background: var(--green-bg);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.research-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  min-width: 180px;
}

.form-select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  min-width: 160px;
}

.form-separator {
  margin: 0 4px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 140ms ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--line);
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  gap: 12px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

.research-results {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
}

.job-id-badge {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.research-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.research-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--text);
}

.research-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.research-table td:nth-child(2),
.research-table td:nth-child(3),
.research-table td:nth-child(4),
.research-table td:nth-child(5),
.research-table td:nth-child(6),
.research-table td:nth-child(7),
.research-table td:nth-child(8) {
  text-align: right;
}
.truth-execution-panel { margin: 12px 0; padding: 12px 16px; border: 1px solid #d7e3f4; border-radius: 10px; background: #f8fbff; }
.truth-execution-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.truth-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; font-size: 13px; }

/* A failed strategy run shows this instead of invented numbers. */
.builder-result-error { border-color: #e6b8b8; background: #fff7f7; }
.builder-result-error .builder-error-title {
  font-weight: 700;
  color: #b42318;
  margin-bottom: 6px;
}
.builder-result-error p { margin: 6px 0; font-size: 13px; color: #4b5563; }
.builder-result-error ul { margin: 8px 0 8px 18px; font-size: 12px; color: #6b7280; }
.builder-result-error code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.builder-error-hint { color: #6b7280; }

/* ── Delivery evidence card (real eight-gate numbers) ─────────────── */
.delivery-evidence {
  margin: 14px 0 18px;
  padding: 16px 18px;
  border: 1px solid #d7e3f4;
  border-radius: 12px;
  background: #f8fbff;
}
.delivery-evidence > header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.delivery-evidence h3 { margin: 0; font-size: 15px; }
.delivery-evidence h4 {
  margin: 14px 0 6px;
  font-size: 12.5px;
  color: #6b7280;
  letter-spacing: 0.4px;
}
.delivery-badge-ok { color: #047857; border-color: #10b981; }
.delivery-badge-bad { color: #b42318; border-color: #ef4444; }
.delivery-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.delivery-table th {
  text-align: left;
  color: #6b7280;
  font-weight: 600;
  padding: 5px 6px;
  border-bottom: 1px solid #dbe6f5;
}
.delivery-table td { padding: 5px 6px; border-bottom: 1px solid #eef4fc; vertical-align: top; }
.delivery-mono { font-family: var(--mono, ui-monospace, monospace); font-size: 11.8px; }
.delivery-mono.muted { color: #9aa4b2; }
.delivery-ok { color: #047857; font-weight: 600; }
.delivery-bad { color: #b42318; font-weight: 600; }
.delivery-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 18px;
  font-size: 12.5px;
  margin: 0;
}
.delivery-kv > div { display: flex; justify-content: space-between; gap: 10px; }
.delivery-kv dt { color: #6b7280; }
.delivery-kv dd { margin: 0; text-align: right; }
.delivery-empty {
  font-size: 12.8px;
  color: #4b5563;
  padding: 10px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  margin: 0;
}
.delivery-reason {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11.8px;
  background: #fff7f7;
  border: 1px solid #f0c9c9;
  border-radius: 8px;
  padding: 8px 10px;
  color: #7f1d1d;
  word-break: break-all;
}
.delivery-note { font-size: 11.5px; color: #6b7280; margin: 10px 0 0; }
.delivery-note code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }
.delivery-chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
/* Data as-of banner: quiet when current, loud when the pipeline has stopped. */
.freshness-banner {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  padding: 9px 18px; margin: 0; border-bottom: 1px solid #e2e8f0;
  background: #f8fafc; font-size: 12.5px; color: #475569;
}
.freshness-banner.is-stale { background: #fef2f2; border-bottom-color: #fecaca; color: #991b1b; }
.freshness-banner strong { color: #0f172a; }
.freshness-banner.is-stale strong { color: #991b1b; }
.freshness-banner .freshness-item { white-space: nowrap; }
.freshness-banner .freshness-note { color: #64748b; }
.freshness-banner.is-stale .freshness-note { color: #b91c1c; }
/* A fit can legitimately take 10-30s; an unexplained pause reads as a hang. */
.builder-result-running {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px; border: 1px solid #bfdbfe; border-radius: 10px;
  background: #eff6ff; color: #1e3a8a; font-size: 13px;
}
.builder-result-running strong { font-size: 14px; }
.builder-result-running span { color: #3b6ba5; }


