:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #f9fbfc;
  --ink: #17202a;
  --muted: #637083;
  --line: #d9e0e7;
  --green: #168a53;
  --green-soft: #e5f5ed;
  --red: #c8413b;
  --red-soft: #fae9e7;
  --amber: #a56700;
  --amber-soft: #fff1d4;
  --blue: #256ec1;
  --blue-soft: #e7f0fc;
  --violet: #7254bf;
  --cyan: #158096;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(37, 110, 193, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(22, 138, 83, 0.035) 1px, transparent 1px), var(--bg);
  background-size: 34px 34px;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100vh;
  min-width: 0;
  padding: 28px 22px;
  background: #11181f;
  color: #eff4f8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #eaf7f0;
  color: var(--green);
  font-size: 22px;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand span {
  margin-top: 2px;
  color: #aebbc8;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #cbd6df;
  text-decoration: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.side-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.panel-title-row,
.section-head,
.topbar,
.topbar-actions,
.watchlist-band,
.backtest-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title-row h2,
.section-head h2,
.watchlist-band h2,
.backtest-band h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 138, 83, 0.18);
}

.temperature-meter {
  height: 12px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.temperature-meter span {
  display: block;
  width: var(--meter);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #36b37e, #f0a202, #d64545);
}

.temperature-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: #aebbc8;
  font-size: 12px;
}

.temperature-labels strong {
  color: #ffffff;
}

.microcopy {
  margin: 14px 0 0;
  color: #c4d0db;
  font-size: 13px;
  line-height: 1.6;
}

.workspace {
  min-width: 0;
  max-width: 100%;
  padding: 28px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.market-clock,
.icon-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(31, 45, 61, 0.05);
}

.market-clock {
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.ghost-button {
  padding: 0 14px;
  font-weight: 800;
}

.icon-button:hover,
.ghost-button:hover {
  border-color: #b9c5d0;
  transform: translateY(-1px);
}

.market-clock svg,
.icon-button svg,
.ghost-button svg,
.search-field svg {
  width: 18px;
  height: 18px;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto 160px 160px;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.search-field,
.select-field {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-field {
  gap: 10px;
  padding: 0 12px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.select-field {
  gap: 8px;
  padding: 0 10px;
}

.select-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.select-field select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f6;
}

.segment {
  min-width: 52px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(31, 45, 61, 0.08);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.stock-card,
.detail-panel,
.model-panel,
.watchlist-band,
.backtest-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 126px;
  padding: 18px;
}

.metric-kicker {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 18px;
  align-items: start;
}

.recommendation-area {
  min-width: 0;
}

.section-head {
  margin-bottom: 12px;
}

.section-head.compact {
  margin-bottom: 14px;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.stock-card {
  display: grid;
  grid-template-rows: auto auto 94px auto;
  min-height: 326px;
  padding: 16px;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.stock-card:hover,
.stock-card.is-selected {
  border-color: rgba(37, 110, 193, 0.45);
  box-shadow: 0 20px 50px rgba(37, 110, 193, 0.12);
  transform: translateY(-2px);
}

.stock-topline,
.stock-meta,
.score-row,
.tag-row,
.recommendation-line,
.detail-heading,
.detail-stats,
.watchlist-chips,
.backtest-grid {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-topline {
  justify-content: space-between;
  min-width: 0;
}

.stock-name {
  min-width: 0;
}

.stock-name h3 {
  margin: 0;
  overflow: hidden;
  font-size: 19px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-name span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.watch-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
}

.watch-button svg {
  width: 18px;
  height: 18px;
}

.watch-button.is-saved {
  border-color: rgba(165, 103, 0, 0.25);
  background: var(--amber-soft);
  color: var(--amber);
}

.stock-meta {
  justify-content: space-between;
  margin-top: 14px;
}

.price {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.change {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.change.up {
  background: var(--green-soft);
  color: var(--green);
}

.change.down {
  background: var(--red-soft);
  color: var(--red);
}

.sparkline {
  width: 100%;
  height: 94px;
  margin-top: 12px;
  overflow: visible;
}

.sparkline path.area {
  opacity: 0.14;
}

.sparkline path.line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.recommendation-line {
  justify-content: space-between;
  margin-top: 14px;
}

.score-row {
  gap: 8px;
}

.score-ring {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 57%, transparent 59%),
    conic-gradient(var(--score-color) calc(var(--score) * 1%), #e4e9ee 0);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.score-copy strong,
.score-copy span {
  display: block;
}

.score-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.empty-state {
  display: none;
  min-height: 160px;
  margin: 0;
  padding: 52px 18px;
  border: 1px dashed #b9c5d0;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

.insight-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.detail-panel,
.model-panel {
  padding: 18px;
}

.detail-panel {
  min-height: 420px;
}

.placeholder-detail {
  display: grid;
  min-height: 384px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.placeholder-detail svg {
  width: 32px;
  height: 32px;
}

.detail-heading {
  align-items: flex-start;
  justify-content: space-between;
}

.detail-heading h2 {
  margin: 0;
  font-size: 23px;
}

.detail-heading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-grade {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 8px;
  background: #11181f;
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.detail-stats div,
.backtest-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.detail-stats span,
.backtest-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-stats strong,
.backtest-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.reason-list,
.risk-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reason-list li,
.risk-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: #303b46;
  font-size: 14px;
  line-height: 1.5;
}

.reason-list i,
.risk-list i {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.reason-list i {
  color: var(--green);
}

.risk-list i {
  color: var(--amber);
}

.weight-row {
  display: grid;
  grid-template-columns: minmax(98px, 1fr) minmax(120px, 1.4fr) 46px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
}

.weight-row label {
  color: #303b46;
  font-size: 13px;
  font-weight: 800;
}

.weight-row input {
  width: 100%;
  accent-color: var(--blue);
}

.weight-row strong {
  text-align: right;
}

.watchlist-band,
.backtest-band {
  margin-top: 18px;
  padding: 18px;
}

.watchlist-chips {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.watch-chip,
.muted-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.watch-chip {
  background: #11181f;
  color: #ffffff;
}

.muted-chip {
  background: #eef3f6;
  color: var(--muted);
}

.backtest-grid {
  justify-content: flex-end;
}

.backtest-grid div {
  width: 130px;
}

.disclaimer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    min-height: 0;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-panel {
    margin-top: 0;
  }

  .control-strip {
    grid-template-columns: 1fr 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .insight-column {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
  }
}

@media (max-width: 820px) {
  .workspace {
    width: 100vw;
    max-width: 100vw;
    padding: 18px;
    overflow-x: hidden;
  }

  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  .topbar,
  .panel-title-row,
  .watchlist-band,
  .backtest-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 10px;
  }

  .market-clock {
    flex: 1;
    justify-content: flex-start;
    min-width: 0;
  }

  .nav-list,
  .control-strip,
  .metric-grid,
  .stock-grid,
  .insight-column {
    grid-template-columns: 1fr;
  }

  .nav-item {
    min-height: 40px;
  }

  .control-strip {
    padding: 10px;
  }

  .segmented {
    grid-auto-flow: initial;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible;
  }

  .segment {
    min-width: 0;
    padding: 0 6px;
  }

  .metric-card {
    min-height: 108px;
  }

  .stock-card {
    min-height: 312px;
  }

  .watchlist-chips,
  .backtest-grid,
  .tag-row {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 34px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  .stock-card {
    grid-template-rows: auto auto 86px auto;
    padding: 14px;
  }

  .stock-meta,
  .recommendation-line,
  .detail-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .sparkline {
    height: 86px;
  }

  .detail-stats {
    grid-template-columns: 1fr;
  }

  .weight-row {
    grid-template-columns: 1fr 52px;
  }

  .weight-row input {
    grid-column: 1 / -1;
  }

  .backtest-grid {
    width: 100%;
  }

  .backtest-grid div {
    width: 100%;
  }
}
