:root {
  --bg: #0e1116;
  --fg: #e6edf3;
  --muted: #8b949e;
  --up: #2ea043;
  --down: #f85149;
  --neutral: #c9d1d9;
  --card: #161b22;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--fg);
}

.container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 16px;
  background: transparent;
  border-radius: 0;
}

h1 {
  margin: 8px 0 12px 0;
  padding: 0 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  background-color: var(--bg);
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #30363d;
  background-color: var(--bg) !important;
}

tr {
  background-color: var(--bg) !important;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.up {
  color: var(--up) !important;
  font-weight: 700 !important;
}

.down {
  color: var(--down) !important;
  font-weight: 700 !important;
}

.neutral {
  color: var(--neutral) !important;
  font-weight: 700 !important;
}

#score {
  margin-top: 16px;
  font-size: 18px;
}

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

#status {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 8px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

#status span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 旧的提示框样式已废弃 */

/* Summary grid */
#controls {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid #30363d;
  padding: 8px;
  z-index: 10;
}

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
  padding: 8px;
}

.card {
  background: var(--card);
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 10px 10px 6px;
}

.card h2 {
  margin: 6px 4px 2px;
  font-size: 16px;
  color: var(--fg);
}

.card table th,
.card table td {
  font-size: 13px;
}

/* Staleness highlighting */
tr.stale,
.stale {
  background-color: var(--bg) !important;
}

tr.stale td,
.stale td {
  border-bottom-color: #f85149 !important;
  background-color: var(--bg) !important;
}

/* Mini charts */
.score-cell {
  min-width: 160px;
}

.score-rail {
  position: relative;
  height: 8px;
  background: #30363d;
  border-radius: 999px;
  margin-top: 4px;
}

.score-rail .baseline {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #555;
}

.score-rail .marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  border-radius: 1px;
  background: var(--neutral);
}

.segbar {
  display: flex;
  width: 140px;
  height: 8px;
  background: #30363d;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.segbar .seg {
  height: 100%;
}

.segbar .up {
  background: var(--up);
}

.segbar .down {
  background: var(--down);
}

.segbar .neutral {
  background: #6e768166;
}

.spark {
  width: 140px;
  height: 28px;
  display: block;
}

/* Timeframe chips */
.chip {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid #30363d;
  border-radius: 999px;
  margin: 4px 6px 0 0;
  cursor: pointer;
  color: var(--fg);
}

.chip.active {
  background: var(--card);
  border-color: var(--up);
  color: var(--fg);
}

.chip:hover {
  border-color: #8b949e;
}

/* Detail responsive cards */
.tf-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
  padding: 8px;
}

.tf-card {
  background: var(--card);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 12px;
}

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

.pill {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #30363d;
  border-radius: 999px;
  font-weight: 600;
}

.kpis {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 8px;
}

.badge {
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid #30363d;
  font-weight: 600;
  background: transparent !important;
}

.badge.up {
  border-color: var(--up);
  color: var(--up);
  background: transparent !important;
}

.badge.down {
  border-color: var(--down);
  color: var(--down);
  background: transparent !important;
}

.badge.neutral {
  border-color: #6e7681;
  color: #c9d1d9;
  background: transparent !important;
}

@media (max-width: 768px) {
  #table-wrapper { display: none !important; }
  #cards-wrapper { display: none !important; } /* 确保旧的 cards-wrapper 不干扰 */
  #card-view { display: block !important; }   /* 强制显示新的 card-view */
  
  .symbol-card {
    background: var(--card);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
  }
  .symbol-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #30363d;
  }
  .symbol-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
  }
  .symbol-card-price {
    font-size: 14px;
    color: var(--fg);
  }
  .symbol-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }
  .symbol-card-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .symbol-card-label {
    font-size: 11px;
    color: var(--muted);
  }
  .symbol-card-value {
    font-size: 13px;
    font-weight: 600;
  }
  .symbol-card-mtf {
    grid-column: 1 / -1;
    margin-top: 8px;
  }
  .mtf-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
  }
}

.spark-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spark-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

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

/* 列表页：隐藏指标列(EMA/MACD/RSI) */
.hide-ind th.col-ind,
.hide-ind td.col-ind {
  display: none;
}

/* 手机默认隐藏指标列 */
@media (max-width: 480px) {

  body.hide-ind-mobile #list thead th.col-ind,
  body.hide-ind-mobile #list tbody td.col-ind {
    display: none;
  }
}

/* Symbol link styling - 交易对名称：固定白色粗体 */
a.symbol-link {
  color: #ffffff !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  background-color: transparent !important;
}

a.symbol-link:link,
a.symbol-link:visited {
  color: #ffffff !important;
  font-weight: 700 !important;
}

a.symbol-link:hover,
a.symbol-link:active {
  color: #ffffff !important;
  text-decoration: underline !important;
  opacity: 0.9 !important;
  font-weight: 700 !important;
}

@media (max-width: 520px) {
  .tf-cards {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 480px) {
  #grid {
    grid-template-columns: 1fr;
  }

  .card table th,
  .card table td {
    font-size: 12px;
  }
}

/* 多周期共振迷你热力图 - 仅在有共振时显示 */
.mtf-mini-resonance {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.mtf-mini-grid {
  display: inline-flex;
  gap: 1px;
  align-items: center;
}

.mtf-mini-cell {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  line-height: 1;
}

.mtf-mini-cell:hover {
  transform: scale(1.3);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.mtf-mini-cell.bull-strong {
  background: #10b981;
  color: #000000;
  border: 0.5px solid #059669;
}

.mtf-mini-cell.bull-light {
  background: #a7f3d0;
  color: #000000;
  border: 0.5px solid #6ee7b7;
}

.mtf-mini-cell.bear-strong {
  background: #ef4444;
  color: #000000;
  border: 0.5px solid #dc2626;
}

.mtf-mini-cell.bear-light {
  background: #fecaca;
  color: #000000;
  border: 0.5px solid #fca5a5;
}

.mtf-mini-cell.neutral {
  background: #d1d5db;
  color: #000000;
  border: 0.5px solid #9ca3af;
}

/* 连续共振脉冲动画 */
[style*="📈"],
[style*="📉"] {
  animation: pulse-streak 1s ease-in-out infinite;
}

@keyframes pulse-streak {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* 骨架屏加载动画 */
.skeleton-row {
  background: var(--card);
}

.skeleton-text,
.skeleton-box,
.skeleton-badge {
  height: 16px;
  background: linear-gradient(90deg, #1a1f2a 25%, #252b38 50%, #1a1f2a 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  width: 80%;
  margin: 2px 0;
}

.skeleton-text.short {
  width: 50%;
}

.skeleton-box {
  width: 30px;
  height: 30px;
  border-radius: 2px;
}

.skeleton-badge {
  width: 60px;
  height: 24px;
  border-radius: 12px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* 加载中状态 */
.loading-overlay {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  color: var(--fg);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   响应式设计 - 手机优化
   ========================================== */

/* 小屏幕：表格横向滚动 */
@media (max-width: 768px) {
  .container {
    padding: 12px 8px;
  }

  h1 {
    font-size: 18px;
    margin: 4px 0 8px 0;
    padding: 0 4px;
  }

  #status {
    gap: 8px;
    margin: 4px 4px 0 4px;
    font-size: 12px;
  }

  .info-box {
    margin: 8px 4px;
    padding: 10px;
    font-size: 12px;
  }

  /* 表格横向滚动容器 */
  #table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -8px;
  }

  table {
    min-width: 640px;
    /* 保证表格完整显示 */
    font-size: 13px;
  }

  th,
  td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  /* 热力图在手机上略小 */
  .mtf-mini-cell {
    width: 20px;
    height: 20px;
    font-size: 7px;
  }

  .mtf-mini-cell:hover {
    transform: scale(1.5);
  }
}

/* 超小屏幕：进一步优化 */
@media (max-width: 480px) {
  h1 {
    font-size: 16px;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 6px 4px;
  }

  /* 热力图更紧凑 */
  .mtf-mini-cell {
    width: 16px;
    height: 16px;
    font-size: 6px;
  }

  .mtf-mini-grid {
    gap: 0.5px;
  }

  /* 状态栏在小屏上换行 */
  #status {
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
  }

  #status button {
    width: 100%;
    padding: 8px 12px !important;
  }
}

/* Default hidden for desktop */
#card-view {
  display: none;
}

/* 确保在大于 768px 的屏幕上显示表格，隐藏卡片 */
@media (min-width: 769px) {
    #table-wrapper { display: block !important; }
    #card-view { display: none !important; }
    #cards-wrapper { display: none !important; }
}

/* 超超小屏幕（窄手机）：卡片布局 */
@media (max-width: 480px) {

  /* 隐藏表格，显示卡片 */
  #list {
    display: none;
  }

  #card-view {
    display: block;
  }

  .symbol-card {
    background: var(--card);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
  }

  .symbol-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #30363d;
  }

  .symbol-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
  }

  .symbol-card-price {
    font-size: 14px;
    color: var(--fg);
  }

  .symbol-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }

  .symbol-card-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .symbol-card-label {
    font-size: 11px;
    color: var(--muted);
  }

  .symbol-card-value {
    font-size: 13px;
    font-weight: 600;
  }

  .symbol-card-heatmap {
    grid-column: 1 / -1;
    margin-top: 4px;
    overflow-x: auto;
  }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
  h1 {
    font-size: 16px;
    margin: 2px 0 6px 0;
  }

  #status {
    font-size: 11px;
    gap: 6px;
  }

  .info-box {
    margin: 6px 4px;
    padding: 8px;
    font-size: 11px;
  }

  th,
  td {
    padding: 6px 4px;
  }
}