:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
header {
  background: #111827;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
header h1 { font-size: 20px; margin: 0; }
header .sub { color: #9ca3af; font-size: 13px; }
header .nav-link {
  margin-left: auto;
  color: #fff;
  background: #2563eb;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
header .nav-link:hover { background: #1d4ed8; }
.layout { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.sidebar { width: 350px; flex: 0 0 350px; display: flex; flex-direction: column; gap: 12px; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2 { font-size: 15px; margin: 0 0 10px; }
.card h3 { font-size: 14px; margin: 0 0 8px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #1d4ed8; color: #fff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  margin: 0 4px 4px 0;
  cursor: pointer;
  background: #fff;
  user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.badge.sp { background: #dbeafe; color: #1d4ed8; }
.badge.ndx { background: #fef3c7; color: #92400e; }
.ticker-list {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 8px;
}
.ticker-group { border-bottom: 1px solid var(--border); }
.ticker-group:last-child { border-bottom: none; }
.ticker-group h4 {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  background: #f9fafb;
  position: sticky;
  top: 0;
}
.ticker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}
.ticker-item:hover { background: var(--accent-soft); }
.ticker-item.selected { background: var(--accent-soft); font-weight: 600; }
.ticker-item .sym { font-weight: 600; margin-right: 6px; }
.ticker-item .nm { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-item .left { display: flex; align-items: baseline; min-width: 0; }
.current-ticker { font-size: 13px; margin-top: 8px; color: var(--muted); }
.current-ticker b { color: var(--text); }
.hint { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.status { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; display: none; }
.status.show { display: block; }
.status.loading { background: #dbeafe; color: #1e40af; }
.status.error { background: #fee2e2; color: #991b1b; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.metric .label { font-size: 12px; color: var(--muted); }
.metric .value { font-size: 19px; font-weight: 700; margin: 2px 0; }
.metric .bh { font-size: 12px; color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.chart-box { width: 100%; height: 340px; }
.chart-box.tall { height: 380px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; background: #f9fafb; }
.table-wrap { max-height: 320px; overflow-y: auto; }
.cond-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #f9fafb;
}
.cond-row .cond-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cond-row .cond-head b { font-size: 13px; }
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.param-grid label { margin: 0; }
footer {
  padding: 14px 20px 22px;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; }
}
