:root {
  --primary: #1890ff;
  --primary-deep: #096dd9;
  --buy: #e83e5b;
  --sell: #0aa875;
  --yellow: #c57a08;
  --red: #dc3545;
  --fg: #172033;
  --sub: #586174;
  --muted: #8a94a7;
  --border: #e7ebf1;
  --soft: #f5f8fc;
  --card: #fff;
  --shadow: 0 6px 24px rgba(30, 55, 90, 0.07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--fg);
  background:
    radial-gradient(circle at 90% -10%, rgba(24, 144, 255, 0.14), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #edf3fb 100%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
.hidden { display: none !important; }

.topbar {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--primary-deep);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.16);
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.phase-tag,
.muted-tag {
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--sub);
  font-size: 11px;
  font-weight: 750;
}
.secondary-btn {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--sub);
  font-weight: 700;
  cursor: pointer;
}
.secondary-btn:hover { border-color: var(--primary); color: var(--primary-deep); }
.secondary-btn:disabled { opacity: 0.6; cursor: wait; }
.push-btn {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff4d67, #cf203e);
  box-shadow: 0 6px 16px rgba(207, 32, 62, 0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}
.push-btn:hover { filter: brightness(1.04); }
.push-btn.push-active { background: #536175; box-shadow: none; }
.push-btn:disabled { background: #a7afbc; box-shadow: none; cursor: not-allowed; opacity: 0.72; }

.page-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 36px;
}
.page-hero { padding: 24px 0 20px; }
.back-link {
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}
.hero-row {
  margin-top: 15px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.eyebrow {
  margin-bottom: 5px;
  color: var(--primary-deep);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 1px;
}
.page-hero h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); line-height: 1.2; }
.page-hero h1 code {
  margin-left: 5px;
  color: var(--sub);
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 0.44em;
  vertical-align: middle;
}
.page-hero p { margin: 9px 0 0; color: var(--sub); font-size: 13px; line-height: 1.7; }
.status-pill {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: #edf1f7;
  color: var(--sub);
  font-size: 12px;
  font-weight: 800;
}
.status-live { background: rgba(10, 168, 117, 0.12); color: #087f5b; }
.status-offline { background: rgba(197, 122, 8, 0.13); color: #a25e00; }
.status-unavailable { background: rgba(100, 116, 139, 0.13); color: #64748b; }

.push-card {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(220, 53, 69, 0.19);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(255, 239, 242, 0.97));
  box-shadow: var(--shadow);
}
.push-card-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #dc3545;
  box-shadow: 0 6px 14px rgba(220, 53, 69, 0.2);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}
.push-card h2 { margin: 0; font-size: 14px; }
.push-card p { margin: 4px 0 0; color: var(--sub); font-size: 11px; line-height: 1.55; }

.state-panel,
.summary-card,
.content-section,
.risk-card {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}
.state-panel { color: var(--muted); font-size: 13px; }
.state-panel.unavailable { text-align: center; padding: 42px 24px; }
.state-panel.unavailable h2 { margin: 0 0 9px; color: var(--fg); font-size: 20px; }
.state-panel.unavailable p { margin: 0 auto 20px; max-width: 560px; line-height: 1.7; }
.primary-link {
  display: inline-flex;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.section-head {
  margin-bottom: 15px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}
.section-head.compact { align-items: center; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}
.metric {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--soft);
}
.metric span { display: block; color: var(--muted); font-size: 10px; }
.metric strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-change strong { font-size: 14px; }
.value-rise { color: var(--buy); }
.value-fall { color: var(--sell); }
.monitor-metrics {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.monitor-metric {
  min-width: 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: #fbfcfe;
  border: 1px solid var(--border);
}
.monitor-metric span { display: block; color: var(--muted); font-size: 9.5px; }
.monitor-metric strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--sub);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fundamental-details {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.fundamental-details summary {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--sub);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.fundamental-details summary small { color: var(--muted); font-size: 9.5px; font-weight: 500; }
.fundamental-grid {
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.fundamental-item { min-width: 0; padding: 9px; border-radius: 8px; background: var(--soft); }
.fundamental-item span { display: block; color: var(--muted); font-size: 9.5px; }
.fundamental-item strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fundamental-note {
  margin: 0;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: #fbfcfe;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.6;
}
.quality-strip {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(10, 168, 117, 0.07);
  color: #087f5b;
  font-size: 11px;
  line-height: 1.6;
}
.quality-strip.quality-paused { background: rgba(220, 53, 69, 0.07); color: #b42332; }

.flow-columns,
.history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.flow-panel,
.history-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.flow-panel-head,
.history-panel-head {
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}
.flow-panel.buy .flow-panel-head { color: var(--buy); }
.flow-panel.sell .flow-panel-head { color: var(--sell); }
.flow-list { margin: 0; padding: 0; list-style: none; }
.flow-row {
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.flow-rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-broker { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.flow-value { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-buy .flow-value { color: var(--buy); }
.flow-sell .flow-value { color: var(--sell); }
.flow-meta {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.45;
}
.flow-row.row-alert { background: rgba(220, 53, 69, 0.045); }
.flow-row.row-warming { background: rgba(197, 122, 8, 0.05); }

.empty-message {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.alert-timeline { display: grid; gap: 10px; }
.alert-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--yellow);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.alert-card.level-red { border-left-color: var(--red); }
.price-move-card { border-left-color: #1677ff; }
.price-move-card.price-alert,
.price-move-card.price-extreme { border-left-color: var(--red); }
.price-move-card.price-observation { border-left-color: var(--yellow); }
.price-move-card.price-rise .alert-level { background: rgba(220, 53, 69, 0.10); color: var(--red); }
.price-move-card.price-fall .alert-level { background: rgba(0, 153, 102, 0.10); color: var(--sell); }
.price-move-card.price-extreme { box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.12); }
.price-rule { background: rgba(22, 119, 255, 0.045); }
.alert-card summary {
  padding: 13px 15px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.alert-card summary::-webkit-details-marker { display: none; }
.alert-level {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(197, 122, 8, 0.11);
  color: var(--yellow);
  font-size: 10px;
  font-weight: 850;
}
.level-red .alert-level { background: rgba(220, 53, 69, 0.10); color: var(--red); }
.alert-title { min-width: 0; font-size: 13px; font-weight: 800; }
.alert-title small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.alert-amount { color: var(--buy); font-size: 14px; font-weight: 850; white-space: nowrap; }
.alert-amount.sell { color: var(--sell); }
.alert-detail { padding: 0 15px 15px; border-top: 1px solid var(--border); }
.legacy-note {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(197, 122, 8, 0.09);
  color: #8a5606;
  font-size: 11px;
  line-height: 1.55;
}
.detail-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.detail-item { padding: 9px; border-radius: 8px; background: var(--soft); }
.detail-item span { display: block; color: var(--muted); font-size: 9.5px; }
.detail-item strong { display: block; margin-top: 4px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.trigger-box {
  margin-top: 10px;
  padding: 11px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.65;
}
.trigger-box b { display: block; margin-bottom: 3px; }
.context-title { margin: 13px 0 8px; font-size: 11px; font-weight: 850; }
.alert-context .flow-row { padding-top: 7px; padding-bottom: 7px; }

.history-panel-head small { color: var(--muted); font-size: 9.5px; font-weight: 500; }
.history-panel .flow-columns { padding: 10px; gap: 8px; }
.history-panel .flow-panel-head { padding: 8px 9px; }
.history-panel .flow-row { padding: 7px 9px; }

.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rule-card { padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--soft); }
.rule-card h3 { margin: 0 0 6px; font-size: 13px; }
.rule-card p { margin: 0; color: var(--sub); font-size: 11px; line-height: 1.65; }

.risk-card { background: #fffdf7; border-color: #f0e4be; }
.risk-card h2 { margin: 0 0 10px; font-size: 15px; }
.risk-card ul { margin: 0; padding-left: 18px; color: var(--sub); font-size: 11px; line-height: 1.75; }

.footer {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
}

@media (max-width: 780px) {
  .summary-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monitor-metrics,
  .fundamental-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-columns,
  .history-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .topbar,
  .page-shell,
  .footer { width: min(100% - 22px, 1160px); }
  .page-hero { padding-top: 16px; }
  .top-actions .phase-tag,
  .top-actions #push-toggle { display: none; }
  .hero-row { display: block; }
  .status-pill { display: inline-flex; margin-top: 13px; }
  .state-panel,
  .summary-card,
  .content-section,
  .risk-card { padding: 15px; border-radius: 12px; }
  .section-head { display: block; }
  .section-head .muted-tag { display: inline-flex; margin-top: 8px; }
  .summary-metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 10px; }
  .metric strong { font-size: 14px; }
  .alert-card summary { grid-template-columns: auto minmax(0, 1fr); }
  .alert-amount { grid-column: 2; }
  .price-move-card .alert-amount { white-space: normal; }
  .detail-grid,
  .rule-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
  .push-card { grid-template-columns: auto minmax(0, 1fr); padding: 13px; }
  .push-card .push-btn { grid-column: 1 / -1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
