:root {
  --bg: #f4f1ea;
  --ink: #1f2426;
  --muted: #6d7474;
  --panel: #fffaf0;
  --panel-2: #e8efe7;
  --line: #d9d0c0;
  --charcoal: #263033;
  --teal: #057b77;
  --teal-soft: #d9efea;
  --amber: #c27a1a;
  --green: #168a54;
  --red: #c84c3c;
  --blue: #3268a8;
  --shadow: 0 18px 48px rgba(31, 36, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(232, 239, 231, 0.9), rgba(244, 241, 234, 0.92)),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  color: #f8f4ea;
  background: var(--charcoal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #f0b84f;
  color: #252c2e;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #afbbb8;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.34rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.42rem;
  line-height: 1.15;
}

.search-box {
  display: grid;
  gap: 8px;
  color: #c9d3d0;
  font-size: 0.82rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fffaf0;
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.search-box input:focus {
  border-color: #f0b84f;
}

.add-watch-button {
  min-height: 40px;
  border: 1px solid rgba(240, 184, 79, 0.7);
  border-radius: 8px;
  padding: 9px 12px;
  color: #252c2e;
  background: #f0b84f;
  font-weight: 900;
  cursor: pointer;
}

.add-watch-button:disabled {
  border-color: rgba(255, 255, 255, 0.12);
  color: #9aa7a2;
  background: rgba(255, 255, 255, 0.08);
  cursor: default;
}

.watchlist-header {
  display: flex;
  justify-content: space-between;
  color: #cbd4d0;
  font-size: 0.78rem;
  font-weight: 800;
}

.stock-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.stock-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  width: 100%;
  min-height: 132px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.stock-button:hover,
.stock-button.is-active {
  border-color: rgba(240, 184, 79, 0.85);
  background: rgba(255, 255, 255, 0.13);
}

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

.stock-name strong,
.stock-price strong {
  display: block;
  white-space: nowrap;
}

.stock-name span,
.stock-price span {
  display: block;
  margin-top: 4px;
  color: #adbbb7;
  font-size: 0.78rem;
}

.stock-price {
  text-align: right;
  line-height: 1.2;
}

.custom-tag,
.remove-watch {
  align-self: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.custom-tag {
  color: #252c2e;
  background: #f0b84f;
}

.remove-watch {
  justify-self: end;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffb4aa;
}

.mini-charts {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  padding-top: 4px;
}

.mini-charts canvas {
  display: block;
  width: 100%;
  height: 54px;
  border-radius: 4px;
}

.mini-price {
  background: rgba(255, 255, 255, 0.06);
}

.mini-volume {
  background: rgba(255, 255, 255, 0.04);
}

.change-up {
  color: var(--green) !important;
}

.change-down {
  color: var(--red) !important;
}

.sidebar .change-up {
  color: #8ee0ad !important;
}

.sidebar .change-down {
  color: #ff9c92 !important;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.section-head,
.chart-toolbar,
.breadth-panel,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.market-pulse {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.75);
  font-size: 0.84rem;
  font-weight: 800;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(22, 138, 84, 0.12);
}

.overview-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 18px;
  margin-top: 18px;
}

.market-card-panel,
.breadth-chart-panel,
.data-note-panel,
.roadmap-panel,
.chart-area,
.signal-panel,
.breadth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
}

.market-card-panel,
.breadth-chart-panel,
.data-note-panel,
.roadmap-panel {
  padding: 18px;
}

#sp500BreadthChart,
#csi300BreadthChart,
#priceChart {
  display: block;
  width: 100%;
}

#priceChart {
  height: clamp(500px, 52vw, 680px);
  cursor: crosshair;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.market-card-grid {
  display: grid;
  gap: 14px;
}

.market-group {
  display: grid;
  gap: 8px;
}

.market-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.market-group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.market-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.market-card.is-active {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.68);
}

.market-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.market-label,
.market-card em,
.market-values span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.market-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
}

.market-sparkline {
  display: block;
  width: min(148px, 100%);
  height: 34px;
  margin-top: 7px;
  border-radius: 4px;
  background: rgba(5, 123, 119, 0.06);
}

.market-values {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 5px;
  text-align: right;
}

.market-values strong {
  margin-top: 0;
  font-size: 1.08rem;
  white-space: nowrap;
}

.breadth-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  padding: 16px;
}

.breadth-chart-panel {
  margin-top: 18px;
  max-width: none;
  margin-right: 268px;
  margin-left: 0;
}

.data-note-panel {
  margin-top: 18px;
}

.roadmap-panel {
  margin-top: 18px;
}

.roadmap-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.roadmap-summary > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.roadmap-summary strong,
.backend-card strong,
.stage-item strong {
  display: block;
  margin-bottom: 7px;
}

.roadmap-summary p,
.backend-card p,
.stage-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.backend-capability-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.stage-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stage-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 12px 12px;
  background: #fffdf7;
}

.stage-item span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
}

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

.data-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.48);
}

.data-note strong {
  display: block;
  margin-bottom: 7px;
}

.data-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.breadth-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.breadth-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf7;
}

.breadth-chart-card canvas {
  display: block;
  width: 100%;
  height: 240px;
  aspect-ratio: 9 / 4;
  border-radius: 6px;
}

#weightedBreadthSection .breadth-chart-card canvas {
  height: 240px;
}

#weightedBreadthSection {
  max-width: none;
  margin-right: 268px;
  margin-left: 0;
}

.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-title strong {
  font-size: 1rem;
}

.chart-title span {
  color: var(--teal);
  font-weight: 900;
}

.coverage-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.coverage-strip span {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.46);
}

.coverage-strip strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.breadth-samples {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.breadth-samples summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.sample-table {
  display: grid;
  max-height: 280px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sample-row {
  display: grid;
  grid-template-columns: 0.9fr 1.5fr 0.9fr 0.9fr 0.95fr;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border-bottom: 1px solid rgba(215, 202, 183, 0.68);
  font-size: 0.72rem;
}

.sample-table.has-weight .sample-row {
  grid-template-columns: 0.85fr 1.45fr 0.85fr 0.85fr 0.75fr 0.9fr;
}

.sample-row:last-child {
  border-bottom: 0;
}

.sample-head {
  position: sticky;
  top: 0;
  color: var(--muted);
  font-weight: 900;
  background: #fffdf7;
}

.metric-block {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.42);
}

.metric-block:last-child {
  padding-bottom: 12px;
}

.metric-block span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-block strong {
  font-size: 1.28rem;
  line-height: 1.15;
  word-break: break-word;
}

.metric-block em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.radar-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}

.radar-heading span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.radar-heading strong {
  font-size: 1.05rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.chart-area,
.signal-panel {
  min-width: 0;
  padding: 18px;
}

.quote-tile {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.quote-tile span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.quote-tile strong {
  font-size: 1.8rem;
}

.quote-tile em {
  font-style: normal;
  font-weight: 900;
}

.chart-toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 18px 0 12px;
}

.range-button,
.chart-range-label,
.indicator-toggle,
.chart-tool-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  font-weight: 900;
}

.range-button {
  cursor: pointer;
}

.chart-range-label {
  display: inline-flex;
  align-items: center;
  color: var(--teal);
  background: var(--teal-soft);
}

.range-button.is-active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.indicator-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.indicator-toggle input {
  accent-color: var(--teal);
}

.chart-tool-button {
  min-width: 38px;
  cursor: pointer;
}

.chart-tool-button:hover {
  border-color: var(--teal);
}

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.compact {
  align-items: flex-start;
}

.risk-badge {
  border-radius: 999px;
  padding: 7px 10px;
  color: #fff;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.risk-badge.buy {
  background: var(--green);
}

.risk-badge.sell {
  background: var(--red);
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

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

.indicator-card span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.indicator-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1.15rem;
}

.indicator-card em {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.indicator-card.wide {
  grid-column: 1 / -1;
}

.signal-list {
  display: grid;
  gap: 10px;
}

.analysis-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.signal-item {
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffdf7;
}

.signal-item.buy {
  border-left-color: var(--green);
}

.signal-item.sell {
  border-left-color: var(--red);
}

.signal-item strong {
  display: block;
  margin-bottom: 4px;
}

.signal-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.rule-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.44);
}

.rule-note strong {
  display: block;
  margin-bottom: 5px;
}

.rule-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

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

  .sidebar {
    min-height: auto;
  }

  .stock-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .overview-band,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .market-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .breadth-chart-grid {
    grid-template-columns: 1fr;
  }

  .breadth-chart-panel,
  #weightedBreadthSection {
    margin-right: 0;
  }

  .data-note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .roadmap-summary,
  .backend-capability-grid,
  .stage-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .breadth-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-block {
    padding: 10px;
  }

  .metric-block:last-child {
    border-right: 1px solid var(--line);
  }
}

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

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

  .stock-list,
  .breadth-panel,
  .market-group-grid,
  .coverage-strip,
  .data-note-grid,
  .roadmap-summary,
  .backend-capability-grid,
  .stage-track,
  .indicator-grid {
    grid-template-columns: 1fr;
  }

  .quote-tile {
    justify-items: start;
  }

  .sample-row {
    grid-template-columns: 1fr 1.4fr 0.8fr;
  }

  .sample-row span:nth-child(4),
  .sample-row span:nth-child(5),
  .sample-table.has-weight .sample-row span:nth-child(6) {
    display: none;
  }
}
