:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --panel: #f1f3f7;
  --line: #d8dde8;
  --line-soft: #edf1f6;
  --text: #1f2633;
  --muted: #667085;
  --accent: #1f4fbf;
  --accent-soft: #1f4fbf;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  padding: 16px;
}

button,
input {
  font: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

.app-shell {
  width: min(1240px, 100%);
  height: calc(100vh - 32px);
  margin: 0 auto;
  background: var(--surface);
  border: 6px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 54px;
  min-height: 68px;
  padding: 0 24px;
  border-bottom: 4px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
}

.simple-brand {
  flex: 0 0 auto;
  min-width: 220px;
  text-align: left;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.brand-subtitle {
  display: none;
}

.nav-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 44px;
}

.nav-tab {
  position: relative;
  padding: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: #1f1f1f;
  white-space: nowrap;
}

.nav-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--accent);
}

.page-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px;
}

.section-block,
.market-index-block,
.stock-card-block {
  width: 100%;
}

.section-card,
.stock-entry-card,
.recommendation-card,
.market-index-block,
.stock-card-block {
  border: 1px solid var(--line-soft);
  background: #fff;
}

.section-head,
.index-title-row,
.stock-card-name {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 16px;
  font-weight: 700;
}

.section-head h2,
.index-title-row h2,
.stock-card-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.text-link-btn {
  padding: 0;
  color: var(--accent);
  font-size: 14px;
  text-decoration: underline;
  white-space: nowrap;
}

.market-index-list,
.stock-list,
.sector-list,
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.index-content-row {
  display: grid;
  grid-template-columns: 1fr 1.65fr;
  gap: 12px;
  padding: 12px;
}

.stock-content-row {
  display: grid;
  grid-template-columns: 1fr 0.95fr 1.55fr;
  gap: 12px;
  padding: 12px;
}

.index-left-card,
.index-right-card,
.stock-left-card,
.stock-middle-card,
.stock-right-card,
.sector-card,
.pick-card {
  min-height: 168px;
  padding: 16px;
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
}

.index-left-card,
.stock-left-card,
.stock-middle-card,
.stock-right-card,
.index-right-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.index-right-card,
.stock-middle-card,
.stock-right-card {
  justify-content: flex-start;
}

.index-left-card > *,
.index-right-card > *,
.stock-left-card > *,
.stock-middle-card > *,
.stock-right-card > * {
  align-self: stretch;
}

.index-date,
.stock-date,
.metric-title,
.index-reason-title,
.index-analysis-title,
.stock-reason-title,
.stock-advice-title,
.stock-middle-item strong {
  min-height: 22px;
  height: 22px;
  display: flex;
  align-items: flex-start;
  padding-top: 0;
  margin-top: 0;
  line-height: 22px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.index-date,
.stock-date {
  width: 100%;
  text-align: left;
}

.index-main-value,
.stock-main-value {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px;
  white-space: nowrap;
}

.index-left-card,
.index-right-card,
.stock-left-card,
.stock-middle-card,
.stock-right-card {
  position: relative;
  padding-top: 16px;
}

.index-date,
.metric-title,
.stock-date,
.stock-middle-item:nth-child(1) strong,
.stock-middle-item:nth-child(2) strong,
.stock-advice-title {
  margin-top: 0;
}

.stock-right-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stock-right-card > div:first-child {
  width: 100%;
}

.main-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.delta {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.up {
  color: #d44a3a;
}

.down {
  color: var(--accent);
}

.index-reason-title,
.stock-reason-title,
.metric-title,
.index-analysis-title,
.sector-reason-title,
.focus-stock-title,
.stock-advice-title {
  width: 100%;
  text-align: left;
}

.index-reason-title,
.index-analysis-title,
.stock-reason-title,
.stock-middle-item:nth-child(3) strong,
.stock-middle-item:nth-child(4) strong {
  margin-top: 38px;
}

.stock-reason-title,
.stock-middle-item:nth-child(3) strong,
.stock-middle-item:nth-child(4) strong {
  margin-top: 38px !important;
}

.index-reason-text,
.stock-reason-text,
.index-analysis-text,
.stock-strategy-text,
.sector-reason-text,
.focus-stock-list,
.stock-middle-item,
.metric-value {
  width: 100%;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--text);
  text-align: left;
  word-break: break-word;
}

.index-left-card,
.index-right-card,
.stock-left-card,
.stock-middle-card,
.stock-right-card {
  padding-top: 16px;
}

.index-right-card {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.index-right-card > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.metric-analysis,
.metric-block,
.index-right-card > div {
  text-align: center;
}

.metric-title,
.metric-value,
.index-analysis-title,
.index-analysis-text {
  text-align: left;
}

.search-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 12px;
}

.search-row input {
  width: 180px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #ececec;
  outline: none;
  text-align: left;
}

.primary-btn {
  min-width: 68px;
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.empty-stock-state {
  min-height: 360px;
  border-top: 1px solid var(--line-soft);
}

.stock-middle-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  align-content: start;
}

.stock-middle-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stock-middle-item {
  margin-top: 0;
}

.stock-middle-item + .stock-middle-item {
  margin-top: 0;
}

.stock-middle-item strong {
  margin-bottom: 8px;
}

.stock-action-links {
  width: 100%;
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 20px;
}

.stock-action-links button {
  color: var(--accent);
  font-size: 14px;
  text-decoration: underline;
  white-space: nowrap;
}

.sector-card,
.pick-card {
  min-height: 160px;
}

.sector-card-title,
.pick-card-title {
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.focus-stock-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.focus-stock-row {
  display: block;
  line-height: 1.9;
}

.focus-stock-row + .focus-stock-row {
  margin-top: 0;
}

.reason-label {
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    gap: 14px;
    padding: 14px;
  }

  .simple-brand {
    min-width: auto;
  }

  .nav-tabs {
    gap: 28px;
    flex-wrap: wrap;
  }

  .index-content-row,
  .stock-content-row,
  .index-right-card {
    grid-template-columns: 1fr;
  }

  .search-row {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .app-shell {
    border-width: 3px;
  }

  .content-stack {
    padding: 8px;
  }

  .nav-tab,
  .brand-title,
  .section-head h2,
  .index-title-row h2,
  .stock-card-name {
    font-size: 15px;
  }

  .main-number {
    font-size: 26px;
  }

  .delta {
    font-size: 14px;
  }
}
