:root {
  color-scheme: light;
  --ink: #142235;
  --muted: #647184;
  --line: #dce3eb;
  --panel: #ffffff;
  --canvas: #f4f6f8;
  --navy: #15375f;
  --blue: #2467a9;
  --green: #087a59;
  --green-soft: #e8f5ef;
  --red: #b33a3a;
  --red-soft: #fbeaea;
  --amber: #9a6200;
  --amber-soft: #fff3d7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; }

.topbar {
  min-height: 76px;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  font-size: 23px;
  font-weight: 800;
}

.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; font-size: 23px; line-height: 1.25; }
.brand-copy p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.brand-copy p.quote-live { color: #16734a; }
.brand-copy p.quote-mixed { color: #0f5f9f; }
.brand-copy p.quote-delayed { color: #9a6700; }
.brand-copy p.quote-stale,
.brand-copy p.quote-unavailable { color: #b42318; }

.icon-button {
  width: 42px;
  height: 42px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font-size: 24px;
}

.icon-button:hover { border-color: var(--blue); }
.icon-button[disabled] { opacity: .5; cursor: wait; }

main { padding: 18px clamp(12px, 2.5vw, 34px) 28px; }

.signal-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.signal-strip > div { padding: 14px 18px; border-right: 1px solid var(--line); }
.signal-strip > div:last-child { border-right: 0; }
.signal-strip span { display: block; color: var(--muted); font-size: 13px; }
.signal-strip strong { display: block; margin-top: 5px; font-size: 24px; }

.filters {
  margin: 14px 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 210px 210px;
  gap: 10px;
}

.filters input, .filters select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.filters input:focus, .filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #2467a91c; }

.workspace {
  display: grid;
  grid-template-columns: minmax(580px, 1.45fr) minmax(360px, .75fr);
  gap: 14px;
  align-items: start;
}

.ranking, .detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.section-heading {
  min-height: 62px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.section-heading > span { color: var(--muted); font-size: 13px; }

.stock-list { max-height: calc(100vh - 260px); min-height: 510px; overflow: auto; }

.stock-row {
  width: 100%;
  min-height: 92px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 58px minmax(150px, 1.25fr) minmax(118px, .8fr) 92px minmax(145px, 1fr);
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.stock-row:last-child { border-bottom: 0; }
.stock-row:hover { background: #f8fafc; }
.stock-row.selected { background: #edf4fb; box-shadow: inset 3px 0 0 var(--blue); }
.score { font-size: 22px; font-weight: 800; color: var(--navy); }
.stock-name { display: block; font-size: 17px; font-weight: 750; }
.stock-code, .subline { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.price { font-size: 17px; font-weight: 700; }
.metric-up { color: var(--red); }
.metric-down { color: var(--green); }

.timing-pill {
  display: inline-block;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  background: #edf1f5;
  color: #4d5a68;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}
.timing-pill.watch, .timing-banner.watch { background: var(--amber-soft); color: var(--amber); }
.timing-pill.confirm, .timing-banner.confirm { background: var(--green-soft); color: var(--green); }
.timing-pill.risk, .timing-banner.risk { background: var(--red-soft); color: var(--red); }

.detail-panel { position: sticky; top: 14px; min-height: 620px; overflow: hidden; }
.detail-placeholder { min-height: 620px; display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }

.detail-head { padding: 18px; display: flex; align-items: flex-start; gap: 14px; border-bottom: 1px solid var(--line); }
.detail-head .identity { min-width: 0; flex: 1; }
.detail-head h2 { margin: 0; font-size: 23px; }
.detail-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.detail-score { min-width: 64px; text-align: right; font-size: 26px; font-weight: 800; color: var(--navy); }

.timing-banner { padding: 12px 18px; font-weight: 800; border-bottom: 1px solid var(--line); }
.detail-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.detail-section h3 { margin: 0 0 11px; font-size: 15px; }

.timing-grid, .fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.timing-grid > div, .fact-grid > div { padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.timing-grid > div:nth-child(even), .fact-grid > div:nth-child(even) { border-right: 0; }
.timing-grid > div:nth-last-child(-n+2), .fact-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.timing-grid span, .fact-grid span { display: block; color: var(--muted); font-size: 11px; }
.timing-grid strong, .fact-grid strong { display: block; margin-top: 4px; font-size: 15px; }

.evidence-list, .risk-list { margin: 0; padding-left: 18px; color: #344154; font-size: 13px; line-height: 1.65; }
.evidence-list li + li, .risk-list li + li { margin-top: 4px; }
.risk-list li::marker { color: var(--red); }

.business-summary { margin: 0; color: #344154; font-size: 13px; line-height: 1.65; }
.profit-sources { margin-top: 10px; display: grid; gap: 7px; }
.profit-source { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; font-size: 12px; }
.profit-source span:last-child { color: var(--muted); }

.empty-state { min-height: 320px; place-items: center; color: var(--muted); }
.empty-state:not([hidden]) { display: grid; }
.disclaimer { margin: 14px 2px 0; color: var(--muted); font-size: 12px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .detail-panel { position: static; min-height: 0; }
  .detail-placeholder { min-height: 220px; }
  .stock-list { max-height: none; min-height: 0; }
}

@media (max-width: 680px) {
  .topbar { min-height: 66px; padding: 10px 12px; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; font-size: 20px; }
  .brand-copy h1 { font-size: 19px; }
  main { padding: 10px; }
  .signal-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .signal-strip > div { padding: 11px 12px; }
  .signal-strip > div:nth-child(2) { border-right: 0; }
  .signal-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .signal-strip strong { font-size: 21px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .stock-row {
    min-height: 106px;
    padding: 12px;
    grid-template-columns: 48px minmax(0, 1fr) 106px;
    gap: 8px;
  }
  .stock-row .market-cell { display: none; }
  .stock-row .timing-cell { grid-column: 2 / 4; }
  .detail-head { padding: 15px; }
  .detail-section { padding: 14px; }
}
