:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-soft: #f0f4f2;
  --panel-warm: #f8f1e6;
  --panel-tint: #fbfcfb;
  --text: #15201d;
  --muted: #5d6b66;
  --faint: #899591;
  --line: #d6dfdc;
  --line-strong: #b7c5c0;
  --accent: #146b5d;
  --accent-dark: #0d3d36;
  --amber: #a76316;
  --red: #be3329;
  --green: #13764d;
  --blue: #2d5a8f;
  --purple: #615198;
  --shadow: 0 10px 24px rgba(21, 32, 29, 0.05);
  --shadow-soft: 0 1px 2px rgba(21, 32, 29, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 180px;
  background: #eaf0ec;
  border-bottom: 1px solid rgba(214, 223, 220, 0.65);
  pointer-events: none;
  z-index: -1;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.95);
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 300px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 9px;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

select,
button,
.nav-link {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}

select:hover,
button:hover,
.nav-link:hover {
  border-color: var(--line-strong);
  background: #f8faf9;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

#refreshBtn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 800;
}

#refreshBtn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

main {
  padding: 18px 24px 34px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.detail-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.panel {
  overflow: hidden;
  min-width: 0;
}

.panel-title {
  min-height: 66px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.map-title {
  min-height: 72px;
}

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

.hint {
  color: var(--faint);
  font-size: 12px;
}

.status,
.tier-badge,
.focus-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  color: var(--green);
  background: #e7f5ee;
}

.status.bad {
  color: var(--red);
  background: #fae8e6;
}

.chain-map {
  display: grid;
  grid-template-columns: repeat(8, minmax(142px, 1fr));
  gap: 0;
  padding: 14px;
  overflow-x: auto;
}

.chain-node {
  position: relative;
  min-width: 142px;
  min-height: 188px;
  height: auto;
  padding: 13px 12px;
  border-radius: 0;
  border: 1px solid var(--line);
  border-right: 0;
  background: #fff;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.chain-node:first-child {
  border-radius: 8px 0 0 8px;
}

.chain-node:last-child {
  border-radius: 0 8px 8px 0;
}

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

.chain-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 18px;
  height: 18px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: inherit;
  transform: translateY(-50%) rotate(45deg);
  z-index: 2;
}

.chain-node:last-child::after {
  display: none;
}

.chain-node.active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 4;
}

.chain-node:hover {
  background: #fbfcfb;
}

.chain-node.confirm {
  background: #fbf0ea;
}

.chain-node.latent {
  background: #eef6f3;
}

.chain-node.theme {
  background: #f2f0f8;
}

.chain-node.wait {
  background: #fbfcfc;
}

.node-order {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 10px;
}

.chain-node strong {
  min-height: 44px;
  font-size: 16px;
  line-height: 1.3;
}

.chain-node em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.node-stats {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.node-market {
  margin-top: auto;
  font-size: 18px;
  font-weight: 900;
}

.chain-node small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(540px, 1.55fr) minmax(340px, 0.9fr);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.layout-grid > * {
  min-width: 0;
}

.layer-focus,
.quadrant-panel,
.detail-panel {
  min-height: 650px;
}

.layer-focus-body {
  padding: 14px;
}

.focus-lead {
  padding: 14px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.focus-lead p,
.focus-sections p,
.detail-panel p,
.detail-panel ul {
  margin: 0;
  color: #303936;
  font-size: 13px;
  line-height: 1.62;
}

.focus-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.focus-metrics span {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.focus-metrics b {
  display: block;
  color: var(--accent-dark);
  font-size: 18px;
}

.focus-sections {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.focus-sections article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.focus-sections h3 {
  margin-bottom: 7px;
}

.focus-company-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.focus-company {
  height: auto;
  min-height: 54px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.focus-company:hover,
.company-chip:hover {
  border-color: var(--line-strong);
  background: #fbfcfb;
}

.focus-company.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.focus-company span {
  font-weight: 900;
}

.focus-company b {
  font-size: 13px;
}

.focus-company em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

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

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot.confirm,
.dot.hot {
  background: var(--red);
}

.dot.latent,
.dot.core {
  background: var(--accent);
}

.dot.theme {
  background: var(--purple);
}

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

.quadrant {
  min-height: 276px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.quadrant header {
  min-height: 58px;
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.quadrant h3 {
  font-size: 15px;
}

.quadrant p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quadrant header span {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel-soft);
  font-weight: 900;
}

.quadrant.confirm header {
  background: #fbefeb;
}

.quadrant.latent header {
  background: #eef6f3;
}

.quadrant.theme header {
  background: #f2f0f8;
}

.quadrant.wait header {
  background: #f7f9f8;
}

.company-chips {
  display: grid;
  gap: 7px;
  padding: 10px;
  max-height: 218px;
  overflow: auto;
}

.company-chip {
  height: auto;
  min-height: 50px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  text-align: left;
}

.company-chip.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.company-chip strong,
.company-chip small {
  display: block;
}

.company-chip strong {
  font-size: 13px;
}

.company-chip small,
.company-chip i {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.company-chip b {
  font-size: 13px;
}

.company-chip i {
  grid-column: 1 / -1;
}

.empty {
  color: var(--faint);
  font-size: 13px;
  font-style: normal;
}

.price-line {
  padding: 14px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.price-line strong {
  font-size: 30px;
}

.sparkline {
  height: 112px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.sparkline svg {
  width: 100%;
  height: 88px;
  display: block;
}

.detail-meta {
  margin: 0;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.detail-meta dd {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.detail-panel section {
  padding: 12px 16px 0;
}

.detail-panel h3 {
  margin-bottom: 8px;
}

.detail-panel ul {
  padding-left: 18px;
}

.updown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-breakdown {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

.score-row strong {
  display: block;
  font-size: 12px;
}

.score-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.score-row em {
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.score-row i {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--panel-soft);
  overflow: hidden;
}

.score-row b {
  display: block;
  height: 100%;
  background: var(--accent);
}

.table-panel {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f0f4f2;
  color: #35413d;
  font-weight: 900;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #edf6f3;
}

.rank {
  width: 34px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--panel-soft);
  font-weight: 900;
}

.name-cell strong {
  display: block;
  font-size: 14px;
}

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

.tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 24px;
  border-radius: 6px;
  font-weight: 900;
  background: var(--panel-soft);
}

.tier.s {
  background: #f7ead6;
  color: #8a4d07;
}

.tier.a {
  background: #e4f2ee;
  color: var(--accent);
}

.tier.b {
  background: #e9eef6;
  color: var(--blue);
}

.num-up {
  color: var(--red);
  font-weight: 900;
}

.num-down {
  color: var(--green);
  font-weight: 900;
}

.context-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(540px, 1.35fr);
  gap: 14px;
  margin-top: 14px;
}

.top-context {
  margin-top: 0;
  margin-bottom: 14px;
}

.context-panel {
  min-height: 256px;
  box-shadow: var(--shadow);
}

.compact-title {
  min-height: 58px;
}

.timeline-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
}

.timeline-item {
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.timeline-item:hover,
.market-metric:hover,
.supernode-card:hover {
  border-color: var(--line-strong);
}

.timeline-item.current {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.timeline-item span,
.market-block span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.timeline-item strong,
.market-block strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.timeline-item em,
.market-block em {
  display: block;
  margin-top: 5px;
  color: var(--amber);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.market-block em {
  color: var(--faint);
  font-weight: 700;
  line-height: 1.35;
}

.timeline-item p,
.market-block p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.market-blocks {
  display: grid;
  grid-template-columns: minmax(190px, 0.78fr) minmax(260px, 1fr);
  grid-template-areas:
    "hero metrics"
    "nodes nodes";
  gap: 10px;
  padding: 12px;
}

.market-hero,
.market-metric,
.supernode-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.market-hero {
  grid-area: hero;
  background: var(--accent-dark);
  color: #fff;
}

.market-hero span,
.market-metric span,
.supernode-card span {
  display: block;
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
}

.market-hero span {
  color: rgba(255, 255, 255, 0.72);
}

.market-hero strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.05;
}

.market-hero small {
  font-size: 13px;
}

.market-hero p,
.supernode-card p,
.market-metric p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.market-hero p {
  color: rgba(255, 255, 255, 0.76);
}

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

.market-metric strong {
  display: inline-block;
  margin-top: 6px;
  font-size: 21px;
  line-height: 1.1;
}

.market-metric em {
  margin-left: 3px;
  color: var(--faint);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

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

.supernode-card strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
  overflow-wrap: anywhere;
}

@media (max-width: 1280px) {
  .layout-grid {
    grid-template-columns: minmax(280px, 0.9fr) minmax(560px, 1.6fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  h1 {
    font-size: 23px;
    overflow-wrap: anywhere;
  }

  .toolbar,
  .search {
    width: 100%;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar select,
  .toolbar button,
  .toolbar .nav-link {
    flex: 1 1 auto;
  }

  .layout-grid,
  .context-grid,
  .quadrant-grid {
    grid-template-columns: 1fr;
  }

  .chain-map {
    grid-template-columns: repeat(8, 160px);
  }

  .timeline-list,
  .market-metrics,
  .supernode-grid {
    grid-template-columns: 1fr;
  }

  .market-blocks {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "metrics"
      "nodes";
  }
}
