:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #17211b;
  --muted: #66736b;
  --line: #dfe5dc;
  --accent: #1f7a4d;
  --bull: #1f8f5b;
  --bear: #c94b4b;
  --flat: #68716a;
  --mixed: #b88316;
  --unknown: #222222;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  padding-bottom: 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(246, 247, 244, 0.96);
  border-bottom: 1px solid var(--line);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 720; }
h2 { font-size: 16px; margin-bottom: 10px; }
h3 { font-size: 15px; }

#statusLine {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.date-picker {
  display: grid;
  gap: 4px;
  min-width: 132px;
  color: var(--muted);
  font-size: 12px;
}

select, input, button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

select, input { padding: 7px 9px; }
button {
  padding: 7px 11px;
  cursor: pointer;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 10px 0;
  max-width: 1040px;
  margin: 0 auto;
}

.tab {
  background: #ebefe9;
  border-color: transparent;
  color: #38443d;
  white-space: nowrap;
}

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

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 10px 32px;
}

.panel { display: none; }
.panel.active { display: block; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.card, .chain, .result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.card summary, .chain summary {
  cursor: pointer;
  list-style: none;
}

.card summary::-webkit-details-marker,
.chain summary::-webkit-details-marker { display: none; }

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
}

.偏多 { background: var(--bull); }
.偏空 { background: var(--bear); }
.中性 { background: var(--flat); }
.分歧 { background: var(--mixed); }
.未明确 { background: var(--unknown); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail {
  margin-top: 10px;
  color: #263029;
  line-height: 1.55;
}

.detail ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.stack {
  display: grid;
  gap: 10px;
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  padding: 10px;
  border-left: 3px solid var(--accent);
  background: var(--panel);
  border-radius: 6px;
}

.searchbar {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(246, 247, 244, 0.96);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 27, 0.46);
}

.modal[hidden] {
  display: none;
}

.modal-box {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.checkline {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.checkline input {
  min-height: auto;
}

.error {
  min-height: 18px;
  color: var(--bear);
  font-size: 13px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(88px, 1fr));
  }

  .split,
  .searchbar {
    grid-template-columns: 1fr;
  }
}
