:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #18211f;
  --muted: #68716e;
  --line: #dfe5df;
  --accent: #0f766e;
  --accent-2: #a83246;
  --warn: #b7791f;
  --soft: #eef6f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

#statusText {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.button.secondary {
  color: var(--accent);
  background: #fff;
}

main {
  padding: 22px 28px 34px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div,
.filters,
.radar,
.ideas,
.tableWrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  padding: 14px 16px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.radar {
  padding: 16px;
  margin-bottom: 16px;
}

.radarHead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.radar h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.radar p {
  margin: 0;
}

#radarStatus,
.newsMeta,
.newsDigest,
.sectorRisk p,
.hitLine {
  color: var(--muted);
  font-size: 13px;
}

#manualNewsText {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  font-family: inherit;
  line-height: 1.5;
}

.secondaryAction {
  color: var(--accent);
  background: #fff;
}

.radarResults {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.radarCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.radarTitle {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.radarTitle h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.riskBadge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.riskHigh {
  color: #9b1c1c;
  background: #fee2e2;
}

.riskMid {
  color: #92400e;
  background: #fef3c7;
}

.riskLow {
  color: #166534;
  background: #dcfce7;
}

.sectorRisk {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.sectorLine {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.leaderLine {
  margin-top: 8px;
  font-size: 13px;
}

.stockPill {
  height: 26px;
  margin: 0 6px 6px 0;
  padding: 0 8px;
  border-color: #cbd5e1;
  background: #fff;
  color: #334155;
}

.sourceLink {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-size: 13px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 36px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 16px;
}

.ideas {
  padding: 16px;
  align-self: start;
}

.ideas h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.ideas ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

.tableWrap {
  overflow: auto;
  max-height: calc(100vh - 270px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1260px;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #21302c;
  color: #fff;
  text-align: left;
  padding: 10px;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
}

tbody tr {
  background: #fff;
}

tbody tr:hover {
  background: var(--soft);
}

.code {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: Consolas, monospace;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.up {
  color: #c53030;
}

.down {
  color: #1f7a4d;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 5px;
  background: #edf2f7;
  color: #334155;
  margin: 0 4px 4px 0;
  white-space: nowrap;
}

.leader {
  background: #fff1f2;
  color: var(--accent-2);
  font-weight: 700;
}

.unknown {
  color: var(--warn);
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 42px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  padding: 0;
  justify-content: center;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-size: 20px;
}

.detailGrid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  line-height: 1.6;
}

.detailGrid b {
  color: var(--muted);
}

@media (max-width: 980px) {
  .topbar,
  .workspace {
    display: block;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .metrics,
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .ideas {
    margin-bottom: 16px;
  }
}

@media (max-width: 620px) {
  main,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .metrics,
  .filters {
    grid-template-columns: 1fr;
  }
}
