/* 数据看板 — 随中控亮/暗主题,卡片柔光 */
body.hub-page-dashboard {
  --dash-card-bg: var(--panel);
  --dash-card-border: var(--border-soft);
  --dash-card-glow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --dash-section-bg: var(--panel);
  --dash-muted: var(--muted);
  --dash-text: var(--text);
  --dash-accent: var(--accent);
  --dash-ok: var(--green);
  --dash-warn: var(--red);
}

html[data-theme="light"] body.hub-page-dashboard {
  --dash-card-glow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

html[data-theme="dark"] body.hub-page-dashboard {
  --dash-card-glow:
    0 4px 18px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.hub-page-dashboard .page#page-dashboard {
  position: relative;
}

.dash-bg-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background-image:
    linear-gradient(color-mix(in srgb, var(--border-soft) 55%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border-soft) 55%, transparent) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 85% 65% at 50% 0%, #000 15%, transparent 72%);
}

.dash-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 120px);
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-head h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--dash-text);
}

.dash-head-tag {
  display: inline-block;
  font-family: JetBrains Mono, monospace;
  font-size: 0.65rem;
  color: var(--dash-accent);
  border: 1px solid var(--dash-card-border);
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 10px;
  vertical-align: middle;
  letter-spacing: 0.1em;
}

.dash-head-meta {
  font-family: JetBrains Mono, monospace;
  font-size: 0.78rem;
  color: var(--dash-muted);
  text-align: right;
}

.dash-head-meta strong {
  color: var(--dash-text);
  font-weight: 600;
}

.dash-pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dash-ok);
  margin-right: 6px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--dash-ok) 25%, transparent);
  animation: dash-pulse 2s ease-in-out infinite;
}

@keyframes dash-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.65;
    transform: scale(0.9);
  }
}

.dash-kpi-row {
  display: block;
}

.dash-kpi-summary {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 0;
  width: 100%;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--dash-card-bg);
  border: 1px solid var(--dash-card-border);
  box-shadow: var(--dash-card-glow);
  overflow: hidden;
}

.dash-kpi-item {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  padding: 4px 8px;
  position: relative;
  text-align: center;
}

.dash-kpi-item + .dash-kpi-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: color-mix(in srgb, var(--dash-card-border) 85%, transparent);
}

.dash-kpi,
.dash-section,
.dash-ac-card {
  box-shadow: var(--dash-card-glow);
}

.dash-kpi {
  position: relative;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--dash-card-bg);
  border: 1px solid var(--dash-card-border);
  overflow: hidden;
}

.dash-kpi-label {
  font-size: 0.65rem;
  color: var(--dash-muted);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-kpi-value {
  font-family: JetBrains Mono, monospace;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--dash-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-kpi-value.pos {
  color: var(--dash-ok);
}

.dash-kpi-value.neg {
  color: var(--dash-warn);
}

.dash-kpi-sub {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--dash-muted);
}

.dash-alert-banner {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--dash-warn) 45%, var(--dash-card-border));
  background: color-mix(in srgb, var(--dash-warn) 8%, var(--dash-card-bg));
  font-size: 0.85rem;
  box-shadow: var(--dash-card-glow);
}

.dash-alert-banner.is-on {
  display: flex;
}

.dash-alert-banner strong {
  color: var(--dash-warn);
  letter-spacing: 0.02em;
}

.dash-section {
  border-radius: 14px;
  border: 1px solid var(--dash-card-border);
  background: var(--dash-section-bg);
  overflow: hidden;
}

.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--dash-card-border);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--dash-muted);
  font-weight: 600;
}

.dash-section-body {
  padding: 0;
}

.dash-ac-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
  padding: 14px;
}

.dash-ac-card {
  position: relative;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--dash-card-border);
  background: var(--dash-card-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dash-ac-card.is-alert {
  border-color: color-mix(in srgb, var(--dash-warn) 55%, var(--dash-card-border));
  box-shadow:
    var(--dash-card-glow),
    0 0 0 1px color-mix(in srgb, var(--dash-warn) 18%, transparent);
}

.dash-ac-card.is-unmon {
  opacity: 0.6;
}

.dash-ac-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.dash-ac-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--dash-text);
}

.dash-ac-top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dash-ac-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.dash-ac-badge.alert {
  color: #fff;
  background: var(--dash-warn);
}

.dash-ac-badge.ok {
  color: var(--dash-accent);
  border: 1px solid var(--dash-card-border);
  background: color-mix(in srgb, var(--dash-accent) 8%, var(--dash-card-bg));
}

.dash-ac-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  font-family: JetBrains Mono, monospace;
  font-size: 0.76rem;
}

.dash-ac-metrics-3col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dash-ac-section-label {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--dash-accent);
  margin-top: 2px;
  padding-bottom: 2px;
  border-bottom: 1px dashed color-mix(in srgb, var(--dash-card-border) 80%, transparent);
}

.dash-ac-section-label:not(:first-child) {
  margin-top: 8px;
}

.dash-ac-metric-empty {
  visibility: hidden;
  min-height: 0;
  padding: 0;
  margin: 0;
}

.dash-ac-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--dash-card-border);
  background: color-mix(in srgb, var(--dash-accent) 6%, var(--dash-card-bg));
  font-family: JetBrains Mono, monospace;
  font-size: 0.76rem;
}

.dash-ac-total-row span {
  color: var(--dash-muted);
  font-size: 0.68rem;
}

.dash-ac-total-row strong {
  color: var(--dash-text);
  font-size: 0.88rem;
}

.dash-ac-card-options .dash-ac-remark {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed color-mix(in srgb, var(--dash-card-border) 80%, transparent);
}

.dash-options-block {
  margin-top: 8px;
}

.dash-options-block .dash-ac-section-label {
  margin-bottom: 4px;
}

.dash-options-table-wrap {
  overflow-x: auto;
}

.dash-options-table th,
.dash-options-table td {
  font-size: 0.68rem;
  white-space: nowrap;
}

.dash-ac-card-pos-only {
  gap: 8px;
}

.dash-ac-pos-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-pos-block .dash-ac-section-label {
  margin-bottom: 4px;
}

.dash-pos-source {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dash-pos-source.is-hedge {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.dash-pos-source.is-roll {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.dash-pos-source.is-trend {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.dash-pos-source.is-order {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.dash-pos-source.is-key {
  color: #fdba74;
  background: rgba(249, 115, 22, 0.16);
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.dash-pos-source.is-none {
  color: var(--dash-muted);
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.dash-target-monitor {
  color: var(--dash-muted);
}

.dash-target-monitor.is-on {
  color: #4ade80;
  font-weight: 600;
}

.dash-pos-source.is-perp {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.dash-pos-source.is-opt {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.dash-pos-table th,
.dash-pos-table td {
  font-size: 0.72rem;
  white-space: nowrap;
}

.dash-ac-metrics-3col .dash-ac-metric {
  text-align: center;
}

.dash-ac-metrics-3col .dash-ac-metric span,
.dash-ac-metrics-3col .dash-ac-metric strong {
  text-align: center;
}

.dash-ac-metric span {
  display: block;
  color: var(--dash-muted);
  font-size: 0.65rem;
  margin-bottom: 2px;
}

.dash-ac-metric strong {
  color: var(--dash-text);
}

.dash-ac-metric strong.pos {
  color: var(--dash-ok);
}

.dash-ac-metric strong.neg {
  color: var(--dash-warn);
}

.dash-loss-bar {
  margin-top: 10px;
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--dash-muted) 18%, transparent);
  overflow: hidden;
}

.dash-loss-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--dash-warn);
  transition: width 0.6s ease;
}

.dash-ac-remark {
  margin-top: 10px;
  font-size: 0.7rem;
  color: var(--dash-muted);
  line-height: 1.4;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-ac-monitor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.dash-monitor-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.3;
  border: 1px solid transparent;
  font-weight: 600;
}

.dash-monitor-chip.dash-monitor-key {
  color: #b8a0ff;
  background: rgba(123, 97, 255, 0.18);
  border-color: rgba(123, 97, 255, 0.42);
}

.dash-monitor-chip.dash-monitor-order {
  color: var(--dash-accent);
  background: rgba(0, 212, 255, 0.14);
  border-color: rgba(0, 212, 255, 0.38);
}

.dash-monitor-chip.dash-monitor-trend {
  color: var(--dash-ok);
  background: rgba(0, 255, 157, 0.1);
  border-color: rgba(0, 255, 157, 0.38);
}

.dash-monitor-chip.dash-monitor-roll {
  color: #ffb020;
  background: rgba(255, 176, 32, 0.14);
  border-color: rgba(255, 176, 32, 0.42);
}

.dash-ac-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--dash-card-border);
  background: color-mix(in srgb, var(--dash-accent) 8%, var(--dash-card-bg));
  color: var(--dash-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.dash-ac-expand-btn:hover {
  border-color: var(--dash-accent);
  background: color-mix(in srgb, var(--dash-accent) 14%, var(--dash-card-bg));
}

.dash-ac-positions {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dash-ac-remark-line {
  margin: 0;
  padding: 3px 0;
  border-top: 1px solid color-mix(in srgb, var(--dash-card-border) 65%, transparent);
}

.dash-ac-remark-line:first-child {
  border-top: none;
  padding-top: 0;
}

.dash-ac-remark-mon {
  color: var(--dash-muted);
}

.dash-ac-remark-pos {
  color: var(--dash-text);
}

.dash-ac-remark-pos .pos,
.dash-ac-remark-pos .neg {
  font-weight: 600;
}

.dash-ac-remark-pos .pos {
  color: var(--dash-ok);
}

.dash-ac-remark-pos .neg {
  color: var(--dash-warn);
}

.dash-ac-remark-empty {
  color: var(--dash-muted);
}

.dash-ac-remark-issue {
  color: var(--dash-warn);
}

html[data-theme="light"] .dash-monitor-chip.dash-monitor-key {
  color: #5b4fc7;
  background: rgba(91, 79, 199, 0.1);
  border-color: rgba(91, 79, 199, 0.28);
}

html[data-theme="light"] .dash-monitor-chip.dash-monitor-trend {
  background: rgba(10, 143, 92, 0.1);
  border-color: rgba(10, 143, 92, 0.28);
}

.dash-table-wrap {
  overflow: auto;
  max-height: min(52vh, 480px);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-family: JetBrains Mono, monospace;
  font-size: 0.74rem;
}

.dash-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 12px;
  background: var(--inset-surface);
  color: var(--dash-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--dash-card-border);
}

.dash-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--dash-card-border);
  color: var(--dash-text);
}

.dash-table tr:hover td {
  background: color-mix(in srgb, var(--dash-accent) 6%, transparent);
}

.dash-table tr.is-alert-row td {
  background: color-mix(in srgb, var(--dash-warn) 10%, transparent);
}

.dash-table .pos {
  color: var(--dash-ok);
}

.dash-table .neg {
  color: var(--dash-warn);
}

.dash-empty {
  padding: 32px;
  text-align: center;
  color: var(--dash-muted);
  font-size: 0.85rem;
}

.dash-status {
  font-family: JetBrains Mono, monospace;
  font-size: 0.75rem;
  color: var(--dash-muted);
}

.dash-status.err {
  color: var(--dash-warn);
}

@media (max-width: 720px) {
  .dash-ac-grid {
    grid-template-columns: 1fr;
  }
  .dash-head-meta {
    text-align: left;
    width: 100%;
  }
}
