/* ==========================================================================
   Football Polymarket Predictor - Modern Responsive UI (PC & Mobile)
   ========================================================================== */

/* 历史分页按钮：突出点击入口，兼容键盘与加载状态。 */
#history-load-more {
  display: block;
  min-height: 46px;
  width: min(100%, 320px);
  margin: 24px auto;
  padding: 12px 24px;
  border: 1px solid #047857;
  border-radius: 10px;
  background: #047857;
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .15);
  transition: background .15s, box-shadow .15s;
}
#history-load-more[hidden] { display: none; }
#history-load-more:hover:not(:disabled) {
  background: #065f46;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .22);
}
#history-load-more:focus-visible { outline: 3px solid #60a5fa; outline-offset: 3px; }
#history-load-more:disabled { opacity: .65; cursor: wait; }

.live-recommendation { padding: 18px 0; border-bottom: 1px solid var(--border-subtle); overflow-wrap: anywhere; }
.live-recommendation p { margin: 8px 0; }
.live-confirm-dialog { margin: auto; width: min(520px, 92vw); color: var(--text-primary); background: var(--bg-card); border: 1px solid var(--border-card); }
.live-confirm-dialog::backdrop { background: rgba(0,0,0,.55); }
.live-confirm-actions { display: flex; justify-content: flex-end; gap: 16px; margin-top: 20px; }

.balance-chart { margin: 10px 0; width: 100%; }
.balance-chart svg { display: block; width: 100%; height: 76px; }
.balance-chart.up { color: var(--color-primary); }
.balance-chart.down { color: var(--color-danger); }
.balance-chart-caption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-muted); }
.balance-chart-empty { padding: 16px 0; font-size: 12px; color: var(--text-muted); }
.live-account-card > div { width: 100%; }

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  /* 浅色主题变量 */
  --bg-canvas: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-surface: #f1f5f9;
  --bg-subtle: #e2e8f0;
  --bg-accent-soft: rgba(16, 185, 129, 0.08);
  --bg-danger-soft: rgba(239, 68, 68, 0.08);
  --bg-warning-soft: rgba(245, 158, 11, 0.08);
  --bg-info-soft: rgba(59, 130, 246, 0.08);

  --border-subtle: #e2e8f0;
  --border-card: #cbd5e1;
  --border-active: #10b981;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --color-primary: #10b981;
  --color-primary-hover: #059669;
  --color-draw: #64748b;
  --color-away: #f59e0b;
  --color-accent: #3b82f6;
  --color-danger: #ef4444;
  --color-success: #10b981;
  --color-warning: #f59e0b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 深色模式变量（默认优先） */
[data-theme="dark"],
:root:not([data-theme="light"]) {
  --bg-canvas: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-surface: #1e293b;
  --bg-subtle: #243147;
  --bg-accent-soft: rgba(16, 185, 129, 0.12);
  --bg-danger-soft: rgba(239, 68, 68, 0.12);
  --bg-warning-soft: rgba(245, 158, 11, 0.12);
  --bg-info-soft: rgba(59, 130, 246, 0.12);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.11);
  --border-active: #10b981;
  --border-focus: #60a5fa;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #090d16;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);
}

/* 全局重置与防横向溢出 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  color-scheme: dark;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  overflow-x: hidden;
}

[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.45;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: 
    radial-gradient(circle at 15% 0%, rgba(16, 185, 129, 0.07) 0%, transparent 35%),
    radial-gradient(circle at 85% 15%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  outline: none;
}

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

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  color: var(--color-primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ==========================================================================
   Tooltip & Popover 气泡轻量提示 (防右边缘溢出)
   ========================================================================== */

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  transition: var(--transition-fast);
}

.info-tip:hover {
  color: var(--text-primary);
  border-color: var(--color-primary);
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 400;
  white-space: normal;
  word-break: break-word;
  max-width: min(260px, 75vw);
  width: max-content;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: 0.18s ease;
  z-index: 999;
}

.info-tip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* ==========================================================================
   Header & Top Navigation (避免使用 100vw 导致的滚动条溢出)
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  width: 100%;
  max-width: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(17, 24, 39, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-normal);
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.9);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-weight: 900;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.brand-mark.small {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.top-nav a {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

.top-nav a:hover {
  color: var(--text-primary);
}

.top-nav a.active {
  background: var(--bg-card);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--bg-accent-soft);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-full);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 6px var(--color-primary);
  animation: pulse-dot 2.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.status-text {
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 600;
}

.icon-btn, .icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.icon-btn:hover, .icon-button:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border-card);
}

.text-button {
  padding: 5px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

.text-button:hover {
  color: var(--text-primary);
  border-color: var(--border-card);
}

.link-button {
  text-decoration: none;
}

/* ==========================================================================
   Main Shell & Compact Header
   ========================================================================== */

.shell {
  width: min(1380px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.analytics-hero, .hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.analytics-hero h1, .hero h1 {
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.analytics-hero > p, .hero-copy {
  display: none;
}

/* ==========================================================================
   Market Browser (dashboard.html)
   ========================================================================== */

.analytics-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
}

.market-tabs, .history-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.market-tabs::-webkit-scrollbar,
.history-tabs::-webkit-scrollbar {
  display: none;
}

.history-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  transition: var(--transition-fast);
}

.history-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-card);
}

.history-tab.active {
  background: var(--bg-card);
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.history-tab small {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.history-tab.active small {
  background: var(--bg-accent-soft);
  color: var(--color-primary);
}

.market-toolbar, .history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  max-width: 100%;
}

.market-search, .search-box {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: var(--transition-fast);
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}

.market-search:focus-within, .search-box:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--bg-accent-soft);
}

.market-search input, .search-box input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  font-size: 0.82rem;
  padding: 0 6px;
}

label select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  font-size: 0.8rem;
  margin-left: 4px;
  max-width: 100%;
}

.market-freshness {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.market-freshness strong {
  color: var(--text-primary);
  font-size: 0.82rem;
}

.refresh-button {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

.refresh-button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-card);
}

.refresh-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.market-source {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* 市场卡片网格 */
.market-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 14px;
}

.market-event-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition-fast);
  max-width: 100%;
}

.market-event-card:hover {
  border-color: var(--border-card);
  background: var(--bg-card-hover);
}

.market-event-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.market-league {
  display: inline-block;
  color: var(--color-primary);
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.market-event-card header strong {
  font-size: 0.92rem;
  font-weight: 700;
  display: block;
}

.market-event-card header time {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.market-volume {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.7rem;
}

.market-volume strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.market-quotes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.market-quote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.76rem;
  gap: 6px;
  flex-wrap: wrap;
}

.market-type {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 4px;
}

.market-outcomes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.market-outcomes span, .sporttery-odds span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

.market-outcomes span i, .sporttery-odds span i {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.market-book {
  display: flex;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.sporttery-odds-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  gap: 6px;
  flex-wrap: wrap;
}

.sporttery-odds-row span {
  font-size: 0.76rem;
  font-weight: 700;
}

.sporttery-odds-row small {
  display: block;
  color: var(--text-muted);
  font-size: 0.65rem;
}

.market-empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ==========================================================================
   Prediction Ledger (history.html)
   ========================================================================== */

.daily-pick-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.25);
  margin-bottom: 14px;
  font-size: 0.8rem;
}

.daily-pick-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 6px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.data-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-surface);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.prediction-row {
  cursor: pointer;
  transition: var(--transition-fast);
}

.match-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.competition-pill {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-accent-soft);
  color: var(--color-primary);
  font-size: 0.65rem;
  font-weight: 700;
}

.lottery-pill {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-danger-soft);
  color: var(--color-danger);
  font-size: 0.65rem;
  font-weight: 700;
}

.record-pill {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 600;
}

.record-pill.live, .record-pill.trade-live { background: var(--bg-info-soft); color: var(--color-accent); }
.record-pill.simulation, .record-pill.trade-simulation { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.record-pill.daily { background: var(--bg-accent-soft); color: var(--color-primary); }
.record-pill.upset { background: var(--bg-warning-soft); color: var(--color-warning); }
.record-pill.single { background: rgba(245, 158, 11, 0.16); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); font-weight: 700; }
.record-pill.historical { background: var(--bg-subtle); color: var(--text-muted); }
.record-pill.update { background: var(--bg-warning-soft); color: var(--color-warning); }

.single-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.22));
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.12);
}

.single-highlight {
  color: #f59e0b !important;
  font-weight: 700 !important;
}

.status-pill {
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
}

.status-pill.settled { background: var(--bg-info-soft); color: var(--color-accent); }
.status-pill.pending { background: var(--bg-subtle); color: var(--text-muted); }

.result-pills {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.result-pill {
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 700;
}

.result-pill.hit { background: var(--bg-accent-soft); color: var(--color-primary); }
.result-pill.miss { background: var(--bg-danger-soft); color: var(--color-danger); }
.result-pill.pending { background: var(--bg-subtle); color: var(--text-muted); }

/* 预测列内直接并排显示预测值与赛后核验值；只改变文字色，不铺设刺眼的区域底色。 */
.prediction-compare {
  display: grid;
  gap: 2px;
  min-width: 96px;
}

.prediction-forecast,
.prediction-actual {
  line-height: 1.35;
}

.prediction-forecast strong,
.prediction-actual {
  font-weight: 700;
}

.prediction-compare.hit .prediction-forecast strong,
.prediction-compare.hit .prediction-actual {
  color: var(--color-primary);
}

.prediction-compare.miss .prediction-forecast strong,
.prediction-compare.miss .prediction-actual {
  color: var(--color-danger);
}

.prediction-compare.pending .prediction-forecast strong,
.prediction-compare.pending .prediction-actual {
  color: var(--color-warning, #d97706);
}

/* ==========================================================================
   Prediction Detail Drawer (抽屉侧边栏/底部抽屉 - 严格隐藏防溢出)
   ========================================================================== */

.prediction-detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 200;
}

.prediction-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--bg-card);
  border-left: 1px solid var(--border-card);
  box-shadow: var(--shadow-lg);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
  overflow-y: auto;
  padding: 20px;
}

.prediction-detail-drawer:not([inert]) {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.prediction-detail-drawer header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.detail-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 1rem;
  display: grid;
  place-items: center;
}

/* ==========================================================================
   Trading & Simulation (simulation.html)
   ========================================================================== */

.trading-mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  max-width: 100%;
}

.trading-mode-tabs button {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: var(--transition-fast);
}

.trading-mode-tabs button.active {
  background: var(--bg-card);
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.trading-mode-tabs button small {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
}

.simulation-notice {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border-left: 3px solid var(--color-primary);
  color: var(--text-secondary);
  font-size: 0.76rem;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.simulation-notice.live-notice {
  border-left-color: var(--color-warning);
}

.simulation-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.simulation-account {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  transition: var(--transition-fast);
}

.simulation-account:hover {
  border-color: var(--border-card);
}

.simulation-account.active {
  border-color: var(--color-primary);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.simulation-account-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.simulation-account-head em {
  font-style: normal;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.65rem;
}

.simulation-equity small {
  display: block;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.simulation-equity strong {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.simulation-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.simulation-metrics strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.simulation-metrics strong.profit { color: var(--color-primary); }
.simulation-metrics strong.loss { color: var(--color-danger); }

.simulation-account-foot {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

/* 当前决策卡片 */
.current-decision-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}

.simulation-plan-pill {
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
}

.simulation-plan-pill.pending { background: var(--bg-subtle); color: var(--text-muted); }
.simulation-plan-pill.won { background: var(--bg-accent-soft); color: var(--color-primary); }
.simulation-plan-pill.lost { background: var(--bg-danger-soft); color: var(--color-danger); }
.simulation-plan-pill.rest { background: var(--bg-subtle); color: var(--text-muted); }

.confidence-rating {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   Model Performance & Confidence Analysis (performance.html)
   ========================================================================== */

.channel-performance {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

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

.performance-grid.performance-grid-secondary {
  margin-top: 0;
  margin-bottom: 12px;
}

.performance-stat {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.performance-stat span {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.performance-stat strong {
  margin-top: 4px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.performance-stat small.metric-detail {
  font-size: 0.68rem;
  margin-top: 2px;
}

/* 色彩级别 */
.metric-good, .performance-stat.metric-good strong { color: var(--color-primary); }
.warning, .performance-stat.warning strong { color: var(--color-warning); }
.metric-bad, .performance-stat.metric-bad strong { color: var(--color-danger); }
.insufficient, .performance-stat.insufficient strong { color: var(--text-muted); }

.confidence-analysis {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.confidence-analysis-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.confidence-analysis-heading strong {
  font-size: 0.8rem;
}

.confidence-stars-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  max-width: 100%;
}

.confidence-star-stat {
  min-width: 0;
  padding: 8px 3px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  text-align: center;
}

.confidence-star-stat span {
  display: block;
  color: var(--color-away);
  font-size: 0.62rem;
  white-space: nowrap;
  letter-spacing: -1px;
}

.confidence-star-stat strong {
  display: block;
  margin: 3px 0;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.confidence-star-stat small {
  display: block;
  color: var(--text-muted);
  font-size: 0.6rem;
  white-space: nowrap;
}

.confidence-summary {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.confidence-summary.positive { color: var(--color-success); }
.confidence-summary.negative { color: var(--color-danger); }
.confidence-summary.flat { color: var(--color-warning); }

.score-footnote {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dimension-analysis-card {
  margin-top: 16px;
  overflow: hidden;
}

.dimension-analysis-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.dimension-analysis-heading h2 {
  margin: 2px 0 4px;
  font-size: 1.1rem;
}

.dimension-analysis-description {
  max-width: 780px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.55;
}

.dimension-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.dimension-controls label {
  display: grid;
  gap: 3px;
  min-width: 120px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.dimension-controls select,
.dimension-controls input {
  box-sizing: border-box;
  height: 32px;
  min-width: 0;
  margin: 0;
  padding: 0 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  font-size: 0.75rem;
}

.dimension-controls select:focus,
.dimension-controls input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--bg-accent-soft);
}

.dimension-search-label {
  flex: 1 1 180px;
}

.dimension-table-meta {
  margin: 10px 0 6px;
  font-size: 0.7rem;
  line-height: 1.4;
}

.dimension-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.dimension-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.dimension-table th,
.dimension-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.dimension-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.dimension-table tbody tr:last-child th,
.dimension-table tbody tr:last-child td {
  border-bottom: none;
}

.dimension-table tbody tr:hover {
  background: var(--bg-surface);
}

.dimension-group-cell {
  min-width: 150px;
  color: var(--text-primary);
}

.dimension-group-cell strong {
  display: block;
  font-size: 0.78rem;
}

.dimension-group-cell small,
.dimension-table td > small,
.dimension-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 400;
}

.dimension-number {
  display: inline-block;
  color: var(--text-primary);
  font-weight: 700;
}

.dimension-number.metric-good { color: var(--color-primary); }
.dimension-number.warning { color: var(--color-warning); }
.dimension-number.metric-bad { color: var(--color-danger); }
.dimension-number.insufficient,
.dimension-number.neutral { color: var(--text-secondary); }

.dimension-line {
  display: block;
  line-height: 1.35;
}

.dimension-line + .dimension-line {
  margin-top: 3px;
}

/* ==========================================================================
   Login Page (login.html)
   ========================================================================== */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(16, 185, 129, 0.12) 0%, transparent 60%), var(--bg-canvas);
}

.login-card {
  width: min(380px, 100%);
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 2px 0 6px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form label {
  display: grid;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

.login-form input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.login-form input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--bg-accent-soft);
}

.primary-button {
  height: 40px;
  margin-top: 4px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: var(--transition-fast);
}

.primary-button:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.security-note {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.68rem;
  text-align: center;
}

.alert {
  padding: 8px 12px;
  margin-top: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  animation: slide-in 0.25s ease forwards;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.toast-fadeout {
  animation: fade-out 0.25s ease forwards;
}

@keyframes fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

.prediction-decision-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

/* ==========================================================================
   📱 移动端深度适配与卡片流 (Mobile Responsive < 768px)
   ========================================================================== */

@media (max-width: 768px) {
  html {
    font-size: 13.5px;
  }

  .shell {
    padding: 12px 10px 32px;
  }

  .topbar {
    height: 52px;
    padding: 0 10px;
  }

  .brand span:not(.brand-mark) {
    display: none;
  }

  .status-text {
    display: none;
  }

  .status-indicator {
    padding: 3px 5px;
  }

  .top-nav {
    padding: 2px;
    gap: 1px;
  }

  .top-nav a {
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .analytics-hero, .hero {
    margin-bottom: 12px;
  }

  .analytics-hero h1, .hero h1 {
    font-size: 1.35rem;
  }

  .analytics-card {
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .prediction-decision-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-toolbar, .history-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .market-search, .search-box {
    max-width: none;
  }

  .market-freshness {
    justify-content: space-between;
  }

  .market-list-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* 移动端表格卡片化重构（Table to Card Stream） */
  .data-table thead {
    display: none;
  }

  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    margin-bottom: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
  }

  .data-table td {
    padding: 4px 0;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    word-break: break-word;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
  }

  .data-table td.match-cell {
    display: block;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
    margin-bottom: 6px;
  }

  .data-table td.match-cell::before {
    display: none;
  }

  /* 移动端抽屉：底部滑出面板 (Bottom Sheet) */
  .prediction-detail-drawer {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-left: none;
    border-top: 1px solid var(--border-card);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    padding: 16px;
    visibility: hidden;
    pointer-events: none;
  }

  .prediction-detail-drawer:not([inert]) {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    justify-content: center;
  }
}
.statistics-insight p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
