:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #eef2f6;
  --ink: #17202d;
  --ink-soft: #344155;
  --muted: #687386;
  --muted-2: #8a95a5;
  --line: #dfe5ec;
  --line-strong: #c8d1dc;
  --blue: #1f6feb;
  --green: #168457;
  --red: #c24137;
  --amber: #9a6400;
  --teal: #0f7280;
  --violet: #635bff;
  --shadow: 0 12px 30px rgba(20, 31, 46, 0.055);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 22px 16px;
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  background: var(--surface-muted);
  outline: none;
}

.side-nav a.active {
  background: #e8f0fe;
  color: var(--blue);
}

.side-status {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-status span,
.side-status small {
  color: var(--muted);
  font-size: 12px;
}

.side-status strong {
  font-size: 14px;
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 248, 0.92);
  padding: 18px 24px;
  backdrop-filter: blur(12px);
}

.page-heading {
  min-width: 0;
}

.eyebrow,
.panel-kicker,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-heading h1 {
  margin-bottom: 0;
  overflow: hidden;
  font-size: 24px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-badge,
.pill,
.tag {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  white-space: nowrap;
}

.connection-badge {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.connection-badge.live {
  border-color: rgba(22, 132, 87, 0.25);
  background: rgba(22, 132, 87, 0.1);
  color: var(--green);
}

.connection-badge.mock {
  border-color: rgba(154, 100, 0, 0.3);
  background: rgba(154, 100, 0, 0.12);
  color: var(--amber);
}

.connection-badge.error {
  border-color: rgba(194, 65, 55, 0.28);
  background: rgba(194, 65, 55, 0.1);
  color: var(--red);
}

.market-clock {
  display: grid;
  gap: 2px;
  min-width: 154px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: right;
}

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

.market-clock strong,
.mono {
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--blue);
  color: var(--blue);
  outline: none;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.page-content {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px 24px 0;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  width: min(1500px, 100%);
  margin: auto auto 0;
  padding: 18px 24px 22px;
  color: var(--muted);
  font-size: 12px;
}

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

.metric-card,
.panel,
.instrument-card,
.alert-item,
.timeline-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 15px 16px;
}

.metric-card span,
.metric-card small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card span {
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  overflow: hidden;
  font-size: 25px;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card small {
  font-size: 12px;
}

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

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

.panel-title {
  min-width: 0;
}

.panel-title h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

.panel-title p:not(.panel-kicker) {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.pill,
.tag {
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.pill {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.tag {
  background: var(--surface-muted);
  color: var(--ink-soft);
}

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

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

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

.tone-warning {
  color: var(--amber);
}

.tone-blue {
  color: var(--blue);
}

.pill.positive,
.tag.positive {
  background: rgba(22, 132, 87, 0.1);
  color: var(--green);
}

.pill.negative,
.tag.negative {
  background: rgba(194, 65, 55, 0.1);
  color: var(--red);
}

.pill.warning,
.tag.warning {
  background: rgba(154, 100, 0, 0.13);
  color: var(--amber);
}

.pill.blue,
.tag.blue {
  background: rgba(31, 111, 235, 0.1);
  color: var(--blue);
}

.pill.teal,
.tag.teal {
  background: rgba(15, 114, 128, 0.11);
  color: var(--teal);
}

.stack {
  display: grid;
  gap: 12px;
}

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

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

.instrument-card {
  display: grid;
  min-width: 0;
  gap: 13px;
  padding: 15px;
}

.instrument-head,
.instrument-row,
.inline-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

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

.instrument-name strong,
.instrument-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instrument-name strong {
  font-size: 15px;
}

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

.sparkline {
  width: 100%;
  height: 58px;
  color: var(--blue);
}

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

.metric-cell {
  min-width: 0;
}

.metric-cell span,
.metric-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.metric-cell strong {
  margin-top: 2px;
  font-size: 14px;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.data-table td {
  font-size: 14px;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fbfcfd;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(116px, 1fr) 72px;
  gap: 12px;
  align-items: center;
}

.bar-label {
  min-width: 0;
}

.bar-label strong,
.bar-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label strong {
  font-size: 13px;
}

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

.bar-value {
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9edf2;
}

.bar-fill {
  width: clamp(0%, var(--bar), 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--blue));
}

.score-block {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.score-ring {
  --score: 0%;
  --score-color: var(--blue);
  display: grid;
  width: 128px;
  height: 128px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 59%, transparent 60%),
    conic-gradient(var(--score-color) var(--score), #e8edf3 0);
}

.score-ring strong {
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-ring span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.alert-list,
.timeline,
.event-list {
  display: grid;
  gap: 10px;
}

.alert-item,
.timeline-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  box-shadow: none;
}

.alert-item strong,
.timeline-item strong {
  font-size: 14px;
}

.alert-item span,
.timeline-item span {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item {
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.heat-cell {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.heat-cell strong,
.heat-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heat-cell strong {
  font-size: 14px;
}

.heat-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.detail-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.detail-box span,
.detail-box strong,
.detail-box small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-box span,
.detail-box small {
  color: var(--muted);
  font-size: 12px;
}

.detail-box strong {
  margin: 4px 0;
  font-size: 18px;
}

.section-card {
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 18px 28px;
}

.section-card-header h2,
.market-heat-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.section-card-body {
  padding: 24px 28px;
}

.section-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.section-title-row span {
  color: var(--ink-soft);
  font-size: 16px;
}

.section-title-row span:first-of-type {
  color: var(--blue);
  font-weight: 800;
}

.help-button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #d5d9de;
  color: var(--ink);
  cursor: default;
  font-weight: 800;
}

.latest-data-frame {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 30px 36px 26px;
}

.latest-data-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  min-width: 850px;
  gap: 26px 18px;
  align-items: center;
  text-align: center;
}

.latest-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.latest-data-grid strong {
  font-size: 19px;
  line-height: 1.2;
}

.latest-value {
  border-radius: 6px;
  background: #eef8ff;
  color: var(--blue);
  padding: 13px 18px;
}

.chart-shell {
  overflow-x: auto;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

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

.legend-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
}

.legend-dot.blue {
  border: 3px solid #1e90ff;
}

.legend-dot.red {
  border: 3px solid #ff5a5f;
}

.line-chart {
  display: block;
  width: 100%;
  min-width: 1040px;
  height: auto;
}

.chart-grid-line {
  stroke: #d8dde3;
  stroke-width: 1;
}

.chart-axis {
  stroke: #c8d1dc;
  stroke-width: 1.2;
}

.chart-area {
  fill: rgba(30, 144, 255, 0.11);
}

.chart-line {
  fill: none;
  stroke: #1e90ff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.chart-warning-line {
  stroke: #ff5a5f;
  stroke-dasharray: 7 8;
  stroke-width: 2;
}

.chart-x-label,
.chart-y-label,
.chart-axis-title {
  fill: #424c5c;
  font-size: 14px;
}

.chart-axis-title {
  font-weight: 700;
}

.market-heat-section {
  margin: 8px 0 28px;
}

.market-heat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.heat-title-icon {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.heat-title-icon::before,
.heat-title-icon::after {
  position: absolute;
  bottom: 5px;
  width: 5px;
  border-radius: 2px 2px 0 0;
  content: "";
}

.heat-title-icon::before {
  left: 6px;
  height: 15px;
  background: #67b7ff;
  box-shadow:
    7px -4px 0 #ff6b77,
    14px 3px 0 #76c893;
}

.market-heat-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.market-heat-grid {
  display: grid;
  grid-template-columns: 64px repeat(var(--heat-cols), 40px);
  min-width: max-content;
  gap: 6px;
  align-items: center;
}

.heat-corner,
.heat-head {
  height: 132px;
}

.heat-head {
  display: grid;
  place-items: end center;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.05;
}

.heat-head span {
  display: inline-block;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

.heat-head.total-head {
  border-right: 1px solid var(--line-strong);
}

.heat-date,
.heat-value {
  display: grid;
  height: 32px;
  place-items: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.heat-date {
  background: var(--surface);
  color: var(--ink-soft);
}

.heat-value {
  font-weight: 800;
}

.heat-value.total-cell {
  border-right: 1px solid var(--line-strong);
}

.empty-state,
.error-state {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.error-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--red);
}

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

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 6;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px 16px;
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .side-nav a {
    flex: 0 0 auto;
  }

  .side-status {
    display: none;
  }

  .topbar {
    top: 0;
  }
}

@media (max-width: 760px) {
  .topbar,
  .topbar-actions,
  .panel-header,
  .instrument-head,
  .inline-between {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .connection-badge,
  .market-clock,
  .icon-button {
    width: 100%;
  }

  .market-clock {
    text-align: left;
  }

  .page-content {
    padding: 16px 16px 0;
  }

  .page-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .summary-grid,
  .instrument-grid,
  .two-column,
  .split-detail,
  .heatmap-grid {
    grid-template-columns: 1fr;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: 1 / -1;
  }

  .score-block {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}
