:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #182235;
  --muted: #68748a;
  --line: #e2e7f0;
  --primary: #2d6cdf;
  --primary-soft: #eaf2ff;
  --attention: #d97706;
  --build: #15803d;
  --alloc: #15803d;
  --reduce: #b45309;
  --dca: #0f766e;
  --clear: #b91c1c;
  --watch: #475569;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(28, 39, 70, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 28px;
  background: #111b2e;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: #fff; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: #c8d3e6;
  padding: 8px 12px;
  border-radius: 8px;
}
.topbar nav a.active, .topbar nav a:hover { background: #263654; color: #fff; text-decoration: none; }
.searchbar { margin-left: auto; display: flex; gap: 6px; }
.searchbar input {
  width: 220px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #263654;
  color: #fff;
}
.searchbar button { padding: 8px 12px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; }
main { max-width: 1500px; margin: 0 auto; padding: 28px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -8px 0 18px; }
.filterbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.filterbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.page-head h1 { margin: 0 0 6px; font-size: 28px; }
.section-head { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.indicator-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.indicator-bar p { margin: 0; }
.indicator-bar button { margin-left: auto; }
.muted { color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button, button:not(.small-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 15px;
  border: 1px solid var(--primary);
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
button.ghost, .button.ghost { background: #fff; color: var(--primary); }
button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.small-button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
.small-button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 14px; font-size: 19px; }
.zones { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 860px) { .zones { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .zones { grid-template-columns: 1fr; } }
.zone { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; }
.zone-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; border-left: 5px solid var(--zone-color); padding-left: 10px; }
.zone-head h2 { margin: 0; font-size: 18px; }
.zone-head span { color: var(--muted); font-size: 12px; }
.cards { display: grid; gap: 10px; }
.cards.compact { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 13px; background: #fff; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-top h3 { margin: 0; font-size: 16px; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 11px;
}
.badge.active { background: #e4f6ee; color: #0f766e; }
.badge.triggered { background: #fdeceb; color: #b91c1c; font-weight: 600; }
.signal-marker {
  margin-right: 6px;
  font-size: 18px;
  line-height: 1;
}
.signal-marker.buy { color: #ef4444; }
.signal-marker.sell { color: #22c55e; }
.signal-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.signal-badge.buy { background: #fdeceb; color: #b91c1c; }
.signal-badge.sell { background: #e4f6ee; color: #0f766e; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv span { color: var(--muted); }
.summary { font-size: 13px; line-height: 1.5; color: #35425a; margin: 10px 0; }
.observations-mini { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.observations-mini span {
  font-size: 12px;
  color: var(--muted);
  background: #f7f9fc;
  border-left: 3px solid var(--attention);
  padding: 4px 7px;
  border-radius: 5px;
}
.criteria-list { margin: 8px 0 0; padding-left: 18px; line-height: 1.8; font-size: 14px; color: #35425a; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 20px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.detail-layout {
  display: grid;
  grid-template-columns: 15% minmax(0, 85%);
  gap: 18px;
  align-items: start;
}
.target-sidebar {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 110px);
  padding: 16px;
}
.detail-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.target-sidebar h2 {
  font-size: 16px;
  margin-bottom: 10px;
}
.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #c6d4f2 transparent;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  cursor: grab;
  min-width: 0;
}
.sidebar-item:hover { border-color: #c6d4f2; }
.sidebar-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.sidebar-item.dragging { opacity: .55; cursor: grabbing; }
.sidebar-item .badge { flex: 0 0 auto; }
.sidebar-item a {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item.active a { font-weight: 700; }
.time-controls button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
@media (max-width: 900px) { .grid-two { grid-template-columns: 1fr; } main { padding: 16px; } .topbar { flex-wrap: wrap; } }
@media (max-width: 860px) { .change-summary, .form-grid.summary-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .change-summary, .form-grid.summary-form { grid-template-columns: 1fr; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid textarea, .form-grid select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
}
.form-grid textarea { resize: vertical; }
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.checkbox input { width: auto; }
.indicator-prefs { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.field-label { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
td.entity-id { max-width: 8ch; min-width: 4ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.inline-form input, .inline-form textarea, .inline-form select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; }
.inline-form textarea { flex: 1; min-width: 180px; resize: vertical; }
.observation { align-items: flex-start; }
.raw-row pre { white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; background: #f8fafc; padding: 12px; border-radius: 8px; }
.raw-pre { white-space: pre-wrap; word-break: break-word; max-height: 760px; overflow: auto; background: #f8fafc; padding: 14px; border-radius: 8px; line-height: 1.55; }
.report-summary textarea { min-height: 60px; }
.summary-form textarea { min-height: 72px; }
.diff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.diff-block h4 { margin: 0 0 8px; }
.diff { display: block; padding: 5px 7px; border-radius: 6px; margin-bottom: 4px; font-size: 12px; line-height: 1.45; }
.diff.add { background: #e9f8ef; color: #0f766e; }
.diff.del { background: #fdeceb; color: #b91c1c; text-decoration: line-through; }
.change-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.form-grid.summary-form { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.change-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fbfcfe; }
.change-block h4 { margin: 0 0 8px; font-size: 14px; color: #182235; }
.change-block ul { margin: 0; padding-left: 18px; line-height: 1.65; font-size: 13px; color: #35425a; }
.change-block li { margin-bottom: 3px; }
/* 总览仪表盘：异常/风险观察项触发的标的名称标红 */
.obs-alert, a.obs-alert, a.obs-alert:visited { color: var(--clear); font-weight: 700; }
/* 对比行整行只加粗不再整行标红：红/黑区分交给新版/旧版标记 */
.change-line.changed { font-weight: 600; }
.version-new { color: #b91c1c; font-weight: 600; }
.version-old { font-weight: 600; }
.raw-diff { margin-top: 8px; font-size: 12px; color: var(--muted); }
.raw-diff .diff-list { margin-top: 6px; max-height: 400px; overflow-y: auto; }
.raw-diff .diff { display: block; padding: 4px 8px; border-radius: 4px; margin-bottom: 3px; line-height: 1.5; word-break: break-word; }
.raw-diff .diff.add { background: #e9f8ef; color: #0f766e; }
.raw-diff .diff.del { background: #fdeceb; color: #b91c1c; }
.chart { height: 960px; background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; }
.signals { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.window-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
}
.window-controls label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text); }
.window-controls input { width: auto; }
.time-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
}
.time-controls button {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}
.time-controls label { display: inline-flex; align-items: center; gap: 4px; }
.time-controls input { width: auto; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; }
.signal { padding: 6px 10px; border-radius: 999px; background: #eef2f8; color: var(--muted); font-size: 12px; }
.signal.bullish { background: #e4f6ee; color: #0f766e; }
.signal.bearish { background: #fdeceb; color: #b91c1c; }

/* 任务日志弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 50;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 860px;
  width: 100%;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body {
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.modal-body h2, .modal-body h3, .modal-body h4 { margin: 14px 0 6px; }
.modal-body h2 { font-size: 16px; }
.modal-body h3 { font-size: 15px; }
.modal-body h4 { font-size: 14px; }
.modal-body p { margin: 4px 0; }
.modal-body li { margin-left: 18px; }
.modal-body blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.scan-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.scan-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
}
.scan-item p {
  margin: 6px 0;
  color: #35425a;
}

.list { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; font-size: 14px; }
.status-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; }
.status-grid dt { color: var(--muted); }
.status-grid dd { margin: 0; word-break: break-all; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f1f4f9; padding: 2px 5px; border-radius: 5px; }
