:root {
  --bg: #f4f5f0;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #1d211f;
  --muted: #68706b;
  --line: #d9ded6;
  --green: #127a4a;
  --green-soft: #dff3e7;
  --red: #b73535;
  --red-soft: #f7dfdc;
  --blue: #285d95;
  --blue-soft: #dceaf6;
  --amber: #9a6a12;
  --amber-soft: #f5ead0;
  --purple: #6f4d8b;
  --shadow: 0 12px 32px rgba(41, 45, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 34px;
  border-radius: 7px;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:hover {
  border-color: #b9c2b6;
  background: #f9faf7;
  transform: translateY(-1px);
}

button.primary {
  border-color: #1f6d4b;
  background: #1f6d4b;
  color: white;
}

button.icon {
  width: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 93, 149, 0.13);
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 520px) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 122, 74, 0.95), rgba(40, 93, 149, 0.92)),
    #1f6d4b;
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 18px;
  height: 2px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow:
    6px -7px 0 rgba(255, 255, 255, 0.72),
    14px 5px 0 rgba(255, 255, 255, 0.64);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand .sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.search {
  position: relative;
}

.search input {
  width: 100%;
  padding-left: 38px;
}

.search::before {
  content: "⌕";
  position: absolute;
  left: 13px;
  top: 8px;
  color: var(--muted);
  z-index: 1;
}

.search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
  display: none;
  max-height: min(420px, 70vh);
  overflow-y: auto;
}

.search-results.open {
  display: block;
}

.search-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.14s ease;
}

.search-summary {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: #f8faf6;
  display: grid;
  gap: 7px;
}

.search-summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-status {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--green);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-filter {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
}

.search-filter.active {
  border-color: #9eb8d1;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 650;
}

.search-main {
  min-width: 0;
}

.search-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.search-item:hover,
.search-item:focus,
.search-item.selected {
  background: #f6f9f3;
  outline: none;
}

.search-item.selected {
  box-shadow: inset 3px 0 0 var(--green);
}

.search-item:last-child {
  border-bottom: 0;
}

.search-item strong {
  display: block;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-symbol {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.search-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 4px;
}

.search-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-market {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue) !important;
  font-weight: 650;
}

.search-empty {
  display: grid;
  gap: 4px;
  text-align: left;
}

.search-empty strong {
  color: var(--text);
}

.search-empty span {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

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

.status-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.status-pill .market {
  font-weight: 700;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.open,
.badge.positive {
  color: var(--green);
  background: var(--green-soft);
}

.badge.closed,
.badge.negative {
  color: var(--red);
  background: var(--red-soft);
}

.badge.neutral,
.badge.unknown {
  color: var(--amber);
  background: var(--amber-soft);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 16px;
  align-items: start;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.market-card,
.panel,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.market-card {
  padding: 14px;
  min-height: 142px;
}

.market-card h2,
.panel h2,
.table-panel h2 {
  font-size: 15px;
  margin: 0;
  letter-spacing: 0;
}

.market-card .change {
  margin: 12px 0 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
}

.positive-text {
  color: var(--green);
}

.negative-text {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
  cursor: pointer;
  transition: color 0.14s ease;
}

.leader-row:hover {
  color: var(--blue);
}

.panel {
  padding: 14px;
  margin-bottom: 16px;
}

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

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

.heat-cell {
  min-height: 56px;
  border-radius: 7px;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  overflow: hidden;
  transition:
    box-shadow 0.16s ease,
    transform 0.16s ease,
    border-color 0.16s ease;
}

.heat-cell:hover {
  border-color: rgba(40, 93, 149, 0.2);
  box-shadow: 0 8px 18px rgba(41, 45, 40, 0.1);
  transform: translateY(-1px);
}

.heat-cell strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-cell span {
  display: block;
  margin-top: 5px;
  font-weight: 800;
}

.heat-cell small {
  display: block;
  margin-top: 3px;
  color: rgba(29, 33, 31, 0.62);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.mover-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.mover-row:hover {
  background: #f8faf5;
  box-shadow: 0 7px 18px rgba(41, 45, 40, 0.08);
  transform: translateY(-1px);
}

.mover-row strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.mover-row span {
  color: var(--muted);
  font-size: 12px;
}

.table-panel {
  overflow: hidden;
}

.table-title {
  padding: 14px 14px 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  background: #f8f9f5;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: background 0.14s ease;
}

tbody tr:hover {
  background: #fbfcf8;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.detail-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.detail-header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.detail-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.quote-box {
  text-align: right;
  min-width: 180px;
}

.quote-price {
  font-size: 28px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 16px;
}

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

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 8px;
}

.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0 10px;
}

.segmented button.active {
  background: var(--surface);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.09);
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.summary-tile {
  background: var(--surface-2);
  border-radius: 7px;
  padding: 9px 10px;
  min-width: 0;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-line {
  width: 20px;
  height: 3px;
  display: inline-block;
  border-radius: 99px;
  background: var(--blue);
}

.legend-line.ma50 {
  background: var(--amber);
}

.legend-line.boll {
  background: rgba(40, 93, 149, 0.35);
  border-top: 1px dashed var(--blue);
}

.legend-line.last {
  background: repeating-linear-gradient(90deg, #1d211f 0 4px, transparent 4px 8px);
}

canvas {
  display: block;
  width: 100%;
  border-radius: 7px;
  cursor: crosshair;
  touch-action: pan-y;
}

#priceChart {
  height: 430px;
}

#indicatorChart {
  height: 180px;
}

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

.technical-readout {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.readout-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  min-height: 94px;
  background: #fbfcf8;
}

.readout-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.readout-top span {
  color: var(--muted);
  font-size: 12px;
}

.readout-top strong {
  font-size: 13px;
  white-space: nowrap;
}

.readout-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric {
  background: var(--surface-2);
  border-radius: 7px;
  padding: 10px;
  min-height: 70px;
}

.metric .label {
  color: var(--muted);
  font-size: 12px;
}

.metric .value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

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

.indicator-stack div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fbfcf8;
}

.indicator-stack span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.indicator-stack strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.news-insights {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  margin-bottom: 12px;
}

.sentiment-card {
  border-radius: 8px;
  padding: 11px;
  background: var(--surface-2);
}

.sentiment-card.positive {
  background: var(--green-soft);
  color: var(--green);
}

.sentiment-card.negative {
  background: var(--red-soft);
  color: var(--red);
}

.sentiment-card.neutral {
  background: var(--amber-soft);
  color: var(--amber);
}

.sentiment-card span,
.sentiment-card small {
  display: block;
  font-size: 12px;
}

.sentiment-card strong {
  display: block;
  margin: 5px 0;
  font-size: 18px;
}

.topic-cloud {
  display: flex;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 7px;
}

.topic-cloud span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #303631;
  font-size: 12px;
}

.topic-cloud b {
  color: var(--muted);
  font-size: 11px;
}

.news-meta-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.news-item {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.news-item h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.news-item p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.analysis-block {
  display: grid;
  gap: 10px;
}

.analysis-block p {
  margin: 0;
  line-height: 1.55;
  color: #303631;
  font-size: 13px;
}

.risk-list {
  margin: 0;
  padding-left: 18px;
  color: #303631;
  font-size: 13px;
  line-height: 1.5;
}

.source-bar {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.loading {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.loading-card {
  min-width: min(320px, 100%);
  min-height: 128px;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 22px;
  color: var(--muted);
}

.loading-orbit {
  width: 48px;
  height: 48px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-right-color: var(--blue);
  border-radius: 50%;
  position: relative;
  animation: spin 0.9s linear infinite;
}

.loading-orbit span {
  position: absolute;
  inset: 9px;
  border: 2px solid transparent;
  border-bottom-color: var(--amber);
  border-radius: 50%;
  animation: spin 1.4s linear infinite reverse;
}

.loading-copy {
  display: grid;
  place-items: center;
  gap: 8px;
}

.loading-copy strong {
  color: var(--text);
  font-size: 14px;
}

.loading-dots {
  display: flex;
  gap: 5px;
  height: 10px;
  align-items: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.35;
  animation: pulse-dot 1.1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  45% {
    transform: translateY(-4px);
    opacity: 0.9;
  }
}

.error {
  border: 1px solid #e0aca4;
  background: #fff3f1;
  color: #843024;
  border-radius: 8px;
  padding: 14px;
}

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

  .dashboard-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

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

  .search-item {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding: 10px;
  }

  .status-strip,
  .overview-grid,
  .heatmap,
  .chart-summary,
  .technical-readout,
  .indicator-stack,
  .news-insights,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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

  .quote-box {
    text-align: left;
  }

  .table-panel {
    overflow-x: auto;
  }

  table {
    min-width: 720px;
  }

  #priceChart {
    height: 340px;
  }
}
