:root {
  --bg-primary: #131722;
  --bg-secondary: #1e222d;
  --bg-tertiary: #2a2e39;
  --border: #363a45;
  --text-primary: #d1d4dc;
  --text-secondary: #787b86;
  --accent-green: #26a69a;
  --accent-red: #ef5350;
  --accent-blue: #2962ff;
  --accent-yellow: #f7c948;

  /* Semantic aliases — use these for state/signal indicators so future
     palette tweaks happen in one place. accent-* remain the raw tokens.
     語意別名：狀態 / 訊號類元素統一引用，方便未來調色一次到位。 */
  --bullish: var(--accent-green);
  --bearish: var(--accent-red);
  --neutral: var(--text-secondary);
  --alert:   var(--accent-yellow);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
}

.app-layout {
  display: grid;
  grid-template-columns: 320px 6px minmax(0, 1fr);
  grid-template-rows: 48px 1fr auto;
  height: 100vh;
}

.app-layout.left-collapsed {
  grid-template-columns: 0 0 minmax(0, 1fr) !important;
}

/* ===== Header ===== */
.header {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.header .symbol-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
  margin-left: 12px;
}

.header .price-display {
  font-size: 16px;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

.header .price-up { color: var(--accent-green); }
.header .price-down { color: var(--accent-red); }

.period-selector {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.layout-controls {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  position: relative;
}

/* Gear icon button — opens a small menu containing layout actions. */
/* 齒輪 icon 按鈕：打開含版面操作的小選單。 */
.layout-gear {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.layout-gear:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}
.layout-gear[aria-expanded="true"] {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.layout-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 100;
}
.layout-popover[hidden] { display: none; }
.layout-popover .layout-btn { width: 100%; text-align: center; }

.layout-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.layout-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* 收合狀態時按鈕高亮，讓使用者知道左欄被隱藏 */
.layout-btn.active {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* 重置按鈕較不突出，避免誤觸 */
.layout-btn-reset {
  opacity: 0.6;
}
.layout-btn-reset:hover {
  opacity: 1;
}

.period-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}

.period-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.period-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue), 0 2px 6px rgba(41, 98, 255, 0.4);
}

/* ===== Left Panel ===== */
.left-panel {
  grid-column: 1;
  grid-row: 2;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.side-resize-handle {
  grid-column: 2;
  grid-row: 2;
  background: var(--border);
  cursor: ew-resize;
  transition: background 0.15s;
}

.app-layout.left-collapsed .left-panel,
.app-layout.left-collapsed .side-resize-handle {
  display: none;
}

.side-resize-handle:hover,
.side-resize-handle.dragging {
  background: var(--accent-blue);
}

.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-section label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Collapsible filter groups — native <details>/<summary> styled to match dark theme.
   Reduces vertical density when many filters are present.
   可摺疊篩選群組：原生 details/summary，配合暗色主題樣式。 */
.filter-group {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.filter-group:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}
.filter-group > summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.filter-group > summary::-webkit-details-marker { display: none; }
.filter-group > summary::before {
  content: '▸';
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.15s;
  display: inline-block;
}
.filter-group[open] > summary::before { transform: rotate(90deg); }
.filter-group > summary:hover { color: var(--accent-blue); }
.filter-group > summary:hover::before { color: var(--accent-blue); }

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.filter-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent-blue);
}

.filter-row .value-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue);
  min-width: 36px;
  text-align: right;
}

.filter-row input[type="number"],
.filter-row select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  width: 70px;
}

.stock-list {
  flex: 1;
  overflow-y: auto;
}

.stock-list::-webkit-scrollbar { width: 6px; }
.stock-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.stock-list::-webkit-scrollbar-track { background: transparent; }

/* ── Stock item — two-row layout ── */
.stock-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(54, 58, 69, 0.4);
  cursor: pointer;
  transition: background 0.12s;
}
.stock-item:hover  { background: var(--bg-tertiary); }
.stock-item.active { background: rgba(41, 98, 255, 0.15); border-left: 3px solid var(--accent-blue); padding-left: 9px; }

/* Row 1: rank · ticker · price */
.si-row1 {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.si-rank   { color: var(--text-secondary); font-size: 11px; min-width: 26px; flex-shrink: 0; }
.si-ticker { font-weight: 700; font-size: 13px; color: var(--text-primary); flex: 1; letter-spacing: 0.2px; }
.si-price  { color: var(--text-secondary); font-size: 12px; text-align: right; flex-shrink: 0; }

/* Row 2: quant bar · score · upside · 52w · short */
.si-row2 {
  display: flex;
  align-items: center;
  gap: 5px;
}
.si-qbar-wrap {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  max-width: 72px;
}
.si-qbar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.si-qbar-fill.quant-high { background: var(--accent-green); }
.si-qbar-fill.quant-mid  { background: var(--accent-yellow); }
.si-qbar-fill.quant-low  { background: var(--accent-red); }

.si-qval   { font-size: 12px; font-weight: 700; min-width: 30px; flex-shrink: 0; }
.si-upside { font-size: 11px; font-weight: 600; flex-shrink: 0; }
.si-upside.up { color: #34d399; }
.si-upside.dn { color: #f87171; }
.si-pos52w { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.si-short  { font-size: 11px; color: #fb923c; flex-shrink: 0; }

/* Quant colour classes (reused by si-qval) */
.quant-high { color: var(--accent-green); }
.quant-mid  { color: var(--accent-yellow); }
.quant-low  { color: var(--accent-red); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-apply-filter {
  width: 100%;
  margin-top: 10px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-apply-filter:hover { opacity: 0.85; }

.filter-row input[type="text"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  flex: 1;
}

.filter-row select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  flex: 1;
}

/* ===== Stock search ===== */
.stock-search-wrap {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.stock-search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 5px 28px 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}

.stock-search-input:focus {
  border-color: var(--accent-blue);
}

.stock-search-input::placeholder {
  color: var(--text-secondary);
}

.stock-search-wrap::after {
  content: '⌕';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 15px;
  pointer-events: none;
}

.stock-search-results {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% - 8px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.stock-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.stock-search-item:last-child { border-bottom: none; }
.stock-search-item:hover { background: var(--bg-tertiary); }

.stock-search-item .si-ticker {
  font-weight: 700;
  color: var(--text-primary);
  min-width: 52px;
}

.stock-search-item .si-name {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-search-item .si-price {
  color: var(--text-secondary);
  font-size: 12px;
  min-width: 44px;
  text-align: right;
}

.stock-search-item .si-quant {
  font-weight: 600;
  font-size: 12px;
  min-width: 32px;
  text-align: right;
}

.stock-search-item .si-source {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
}

.stock-search-item .si-source.src-xlsx {
  background: rgba(41,98,255,0.15);
  color: var(--accent-blue);
}

.stock-search-item .si-source.src-yfinance {
  background: rgba(120,123,134,0.15);
  color: var(--text-secondary);
}

.stock-search-empty {
  padding: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.stock-search-loading {
  padding: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.stock-count {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

/* ===== Right main area ===== */
.main-area {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ===== Indicator toggles ===== */
.indicator-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 4px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  align-items: center;
}

.indicator-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
}

.indicator-toggle input { accent-color: var(--accent-blue); }
.indicator-toggle:hover { color: var(--text-primary); }

/* ===== Options, Fundamentals, Signal & Strategy bars ===== */
.options-bar,
.fundamentals-bar,
.signal-bar,
.strategy-bar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 3px 12px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-gutter: stable;
  /* 右側漸出陰影：提示使用者有內容被截斷，inset shadow 不隨捲動移動 */
  box-shadow: inset -32px 0 16px -12px var(--bg-primary);
}

/* When options-bar and fundamentals-bar both render, drop the divider between
   them so they read as a single Fundamentals band rather than two stacked rows.
   Uses :has() (Safari 15.4+, Chrome 105+) — falls back to the existing border
   on older browsers (acceptable: shows a slightly bolder divider).
   兩條 bar 同時出現時取消中間分隔線，讓視覺上合併為單一基本面條帶。 */
.options-bar:has(+ .fundamentals-bar:not([style*="display: none"])) {
  border-bottom-color: transparent;
}

.options-bar::-webkit-scrollbar,
.fundamentals-bar::-webkit-scrollbar,
.signal-bar::-webkit-scrollbar,
.strategy-bar::-webkit-scrollbar {
  height: 6px;
}

.options-bar::-webkit-scrollbar-thumb,
.fundamentals-bar::-webkit-scrollbar-thumb,
.signal-bar::-webkit-scrollbar-thumb,
.strategy-bar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.options-bar::-webkit-scrollbar-track,
.fundamentals-bar::-webkit-scrollbar-track,
.signal-bar::-webkit-scrollbar-track,
.strategy-bar::-webkit-scrollbar-track {
  background: transparent;
}

.options-item,
.signal-label,
.signal-regime,
.signal-item,
.signal-overall,
.strategy-item,
.strategy-sep {
  white-space: nowrap;
  flex-shrink: 0;
}

.options-label {
  font-weight: 600;
  color: var(--accent-yellow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.options-item strong {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Number columns in left-panel stock list / search results. */
/* 左欄股票列表 / 搜尋結果的數字欄。 */
.si-price,
.si-pos52w,
.filter-row .value-display,
.strategy-item strong,
.signal-overall {
  font-variant-numeric: tabular-nums;
}

/* ===== Analyst target range bar (Low — High with current/mean/median ticks) ===== */
.range-item { display: inline-flex; align-items: center; gap: 6px; }
.range-low,
.range-high {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.range-bar {
  position: relative;
  width: 120px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  flex-shrink: 0;
}
.range-tick {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: help;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px var(--bg-primary);
}
.range-tick.range-mean { background: var(--text-secondary); }
/* Hollow green ring so the gray mean tick stays visible when values overlap. */
.range-tick.range-median {
  width: 12px;
  height: 12px;
  background: transparent;
  border: 2px solid var(--accent-green);
}
.range-tick.range-current {
  background: var(--accent-yellow);
  width: 4px;
  height: 12px;
  border-radius: 1px;
}

/* Signal item tooltip — reuses tooltip positioning without .tip button constraints */
.signal-item[data-tooltip] { position: relative; cursor: default; }

.signal-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  white-space: pre;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  z-index: 1000;
  pointer-events: none;
  opacity: 1;
  min-width: 160px;
}

.signal-item[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--border);
  z-index: 1001;
  pointer-events: none;
}

.signal-label {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}

/* Chevron toggle for collapsing the signal-bar detail to just the Overall badge.
   收合 signal-bar 細項，只保留 Overall 徽章的小箭頭按鈕。 */
.signal-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
}
.signal-toggle:hover { color: var(--text-primary); }
.signal-bar.collapsed .signal-toggle { transform: rotate(-90deg); }

/* When collapsed, hide everything except label, toggle, divider, and Overall. */
/* 收合時隱藏所有細項，只保留 Label + Toggle + Overall。 */
.signal-bar.collapsed .signal-regime,
.signal-bar.collapsed .signal-divider-sm,
.signal-bar.collapsed .signal-item {
  display: none !important;
}

.signal-item {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
}

.signal-divider { flex: 1; }

.signal-divider-sm {
  width: 1px;
  height: 12px;
  background: var(--border);
  margin: 0 4px;
}

.signal-regime {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid currentColor;
  opacity: 0.85;
}

.signal-overall {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  position: relative;
  cursor: default;
}

.signal-overall[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  white-space: pre;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  transform: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  z-index: 1000;
  pointer-events: none;
  min-width: 260px;
}

.signal-overall[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: calc(100% + 2px);
  right: 20px;
  left: auto;
  transform: none;
  border: 5px solid transparent;
  border-bottom-color: var(--border);
  z-index: 1001;
  pointer-events: none;
}

.options-badge {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.options-badge.bearish  { background: #ef535030; color: var(--bearish); }
.options-badge.neutral  { background: #f7c94830; color: var(--alert); }
.options-badge.bullish  { background: #26a69a30; color: var(--bullish); }

.options-meta { color: var(--text-secondary); font-size: 11px; }
.options-error { color: var(--accent-red); font-size: 11px; }

.strategy-item { font-size: 12px; color: var(--text-secondary); }
.strategy-item strong { color: var(--text-primary); font-weight: 600; }
.strategy-sep { color: var(--border); margin: 0 6px; font-size: 12px; }

/* ===== Tooltip（? 圖示懸停說明）=====
   Visually de-emphasised: no background, no border, half-opacity glyph.
   The element remains hover/focus-able so the existing JS tip-portal logic
   still works; we only reduced visual weight to cut bar noise.
   視覺降噪：移除背景與邊框，僅保留半透明小字符；
   保留原本 hover/focus 行為，tip-portal JS 不受影響。 */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin: 0 2px;
  border: none;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.15s, color 0.15s;
}

.tip:hover,
.tip:focus-visible {
  color: var(--accent-yellow);
  opacity: 1;
  outline: none;
}

/* SAR 參數輸入列 */
.sar-params {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.sar-params input[type="number"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
  -moz-appearance: textfield;
}

.sar-params input[type="number"]::-webkit-inner-spin-button { opacity: 0.4; }
.sar-params input[type="number"]:focus { outline: none; border-color: #e040fb; }

/* tip 在 sub-tab button 內時縮小，不撐高按鈕 */
.sub-tab .tip {
  width: 11px;
  height: 11px;
  font-size: 9px;
  vertical-align: middle;
  margin-left: 2px;
}

/* ? 說明改由 JS portal（.tip-portal-popup）顯示，避免被 bar overflow 裁切 */
.tip::after,
.tip::before {
  content: none !important;
  display: none !important;
}

/* Fixed portal：掛在 body，全頁所有 ? 共用一個節點 */
.tip-portal-popup {
  position: fixed;
  z-index: 10000;
  background: #1a1e2e;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 6px;
  max-width: min(360px, calc(100vw - 16px));
  width: max-content;
  white-space: pre-line;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ===== Chart containers ===== */
.chart-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
}

#main-chart { width: 100%; height: 100%; }

.sub-charts {
  /* Height is driven by JS (applyPanelHeights) so sub-panels can grow
     independently and push content below downward. Remove the fixed value
     here so CSS breakpoint overrides are also removed. */
  /* 高度由 JS 控制，讓副圖面板可獨立成長並推動下方內容移動。*/
  min-height: 120px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sub-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sub-panel-header {
  height: 26px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.sub-panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}

.sub-select {
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  flex: 1;
}

.sub-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: normal;
}

.sub-panel-tip {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* Live readout shown in the sub-panel header (e.g. MACD/Signal/Hist values).
   副圖抬頭即時數值（如 MACD/Signal/Hist），跟著十字線游標更新。 */
.sub-panel-readout {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin-left: auto;
  white-space: nowrap;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}
.sub-panel-readout .label {
  color: var(--text-secondary);
  margin-right: 2px;
}
.sub-panel-readout .pos { color: #26a69a; }
.sub-panel-readout .neg { color: #ef5350; }

.sub-chart-el {
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.main-resize-handle,
.sub-resize-handle {
  height: 6px;
  background: var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
}

/* Grip indicator — three subtle dots centred horizontally, hinting drag affordance.
   抓握指示：水平置中的三個淡點，提示此處可拖曳。 */
.main-resize-handle::before,
.sub-resize-handle::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 2px;
  background-image: radial-gradient(circle, var(--text-secondary) 1px, transparent 1.2px);
  background-size: 6px 2px;
  background-repeat: repeat-x;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s;
}

.main-resize-handle:hover,
.main-resize-handle.dragging,
.sub-resize-handle:hover,
.sub-resize-handle.dragging {
  background: var(--accent-blue);
}

.main-resize-handle:hover::before,
.main-resize-handle.dragging::before,
.sub-resize-handle:hover::before,
.sub-resize-handle.dragging::before {
  opacity: 0.95;
}

/* ===== Backtest Panel — slide-in side drawer =====
   Anchored to the right edge as a fixed-position overlay; opens by adding
   .open class (translateX 0). Avoids squashing the main chart area.
   側邊抽屜：固定貼右邊；以 .open class 切換滑入動畫，不擠壓主圖。 */
.backtest-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 90vw);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.backtest-panel.open {
  transform: translateX(0);
}

.backtest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.backtest-header h3 {
  font-size: 13px;
  font-weight: 600;
}

.backtest-controls {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  flex-wrap: wrap;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.control-group label {
  font-size: 12px;
  color: var(--text-secondary);
}

.control-group input,
.control-group select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  width: 60px;
}

.control-group input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent-blue);
}

.btn-run-backtest {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-run-backtest:hover { opacity: 0.85; }
.btn-run-backtest:disabled { opacity: 0.4; cursor: not-allowed; }

.backtest-period-group {
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 4px 10px;
  border: 1px solid var(--accent-blue);
}
.backtest-period-group label { color: var(--accent-blue) !important; font-weight: 600; }
.bt-period-hint { font-size: 11px; color: var(--text-secondary); margin-left: 4px; }

.backtest-info {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--accent-yellow);
  background: rgba(247, 201, 72, 0.08);
  border-bottom: 1px solid var(--border);
}

.backtest-results {
  padding: 10px 16px;
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 10px 12px;
}

.metric-card .metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.metric-card .metric-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.trades-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.trades-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(54, 58, 69, 0.3);
}

.trades-table tr:hover { background: rgba(41, 98, 255, 0.05); }

/* ===== Loading spinner ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

/* ===== Toggle backtest ===== */
.toggle-backtest {
  grid-column: 1 / -1;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  padding: 4px 16px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  user-select: none;
}

.toggle-backtest:hover { color: var(--text-primary); }

/* ==========================================================================
   RWD — Desktop & Laptop Breakpoints
   1440px+ : 大螢幕（預設）
   1280px  : 標準筆電 (MacBook Pro 14/16、1080p 外接)
   1024px  : 小筆電 / 1024px 外接
   960px   : 最小支援寬度，低於此加水平捲軸
   ========================================================================== */

body { min-width: 960px; }

/* ── 1280px：縮左側 Panel，壓縮部分欄位 ── */
@media (max-width: 1439px) {
  .app-layout {
    grid-template-columns: 290px 6px minmax(0, 1fr);
  }
  .stock-item .si-short { display: none; }
}

@media (max-width: 1279px) {
  .app-layout {
    grid-template-columns: 240px 6px minmax(0, 1fr);
  }
  .header h1 { font-size: 14px; }
  .layout-controls { gap: 6px; }
  .layout-btn { padding: 4px 8px; font-size: 11px; }
  /* sub-charts height now driven by JS; remove breakpoint overrides */

  /* 左側 stock list：隱藏次要欄 */
  .stock-item .si-pos52w,
  .stock-item .si-short { display: none; }
  .stock-item .si-upside { display: none; }

  /* 各 info bar 縮間距 */
  .options-bar,
  .fundamentals-bar,
  .signal-bar,
  .strategy-bar {
    gap: 10px;
    padding: 4px 8px;
  }
  .strategy-sep { margin: 0 3px; }

  /* indicator bar 換行允許 */
  .indicator-bar { gap: 7px; }

  /* SAR 參數列縮字 */
  .sar-params { font-size: 11px; }
  .sar-params input[type="number"] { width: 46px; }
  .sar-params select { font-size: 11px; }
}

/* ── 1024px：更窄 sidebar，隱藏 header 品牌名 ── */
@media (max-width: 1023px) {
  .app-layout {
    grid-template-columns: 200px 1fr;
  }
  /* 2-column grid: left-panel col1, main-area col2 (no resize handle) */
  .left-panel  { grid-column: 1; }
  .main-area   { grid-column: 2; }
  .side-resize-handle { display: none; }
  .layout-controls { display: none; }
  .header h1 { display: none; }
  .header { gap: 10px; padding: 0 10px; }
  /* sub-charts height driven by JS */

  /* stock list 再隱藏 price */
  .stock-item .si-price  { display: none; }
  .stock-item .si-qval   { min-width: 28px; }
  .stock-item .si-ticker { min-width: 44px; }
  .stock-item .si-pos52w { display: none; }
  .stock-item { padding: 7px 8px; font-size: 12px; }

  /* signal bar 允許換行 */
  .signal-bar { flex-wrap: wrap; row-gap: 2px; }

  /* strategy bar 允許換行 */
  .strategy-bar { flex-wrap: wrap; row-gap: 2px; }

  /* 篩選器輸入縮小 */
  .filter-row input[type="number"],
  .filter-row select { width: 56px; font-size: 12px; }
  .panel-section { padding: 8px 8px; }
  .section-title { font-size: 12px; }
}

/* ===== Market Overview Page ===== */

/* 頁面導航（index.html 和 market.html 共用） */
.page-nav {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.page-nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  transition: all 0.15s;
}

.page-nav-link:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.page-nav-link.active { color: var(--accent-blue); border-color: var(--accent-blue); }

/* market page body layout */
.market-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.market-page .header {
  grid-column: unset;
  flex-shrink: 0;
}

.mkt-tabs {
  display: flex;
  gap: 4px;
  margin-left: 20px;
}

.mkt-tab {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.mkt-tab:hover { color: var(--text-primary); }
.mkt-tab.active {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: rgba(41, 98, 255, 0.08);
}

.mkt-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px;
}

.mkt-section { display: none; }
.mkt-section.active { display: block; }

/* toolbar row */
.mkt-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mkt-note {
  font-size: 11px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

.mkt-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.mkt-loading { color: var(--text-secondary); font-size: 13px; padding: 24px 0; }
.mkt-error   { color: var(--accent-red);     font-size: 13px; padding: 12px 0; }

/* period buttons */
.mkt-period-btns {
  display: flex;
  gap: 4px;
}

.mkt-period-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.mkt-period-btn.active {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.mkt-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
}

/* shared table */
.mkt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 16px;
}

.mkt-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.mkt-table th.num,
.mkt-table td.num { text-align: right; }

.mkt-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(54, 58, 69, 0.5);
  color: var(--text-primary);
}

.mkt-table tr:hover td { background: var(--bg-secondary); }

.mkt-table td.pos { color: var(--accent-green); }
.mkt-table td.neg { color: var(--accent-red); }

/* ── Sector Bars ── */
.sector-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.sector-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.sector-bar-label {
  width: 150px;
  flex-shrink: 0;
  color: var(--text-primary);
  white-space: nowrap;
  /* Clip overflow with ellipsis so long labels (e.g. 非必需消費 XLY) can never
     spill onto the bar track — the track creates a stacking context and would
     otherwise paint the fill on top of the leaking text.
     裁切溢位並加 ellipsis：避免長標籤（如 非必需消費 XLY）流到 track 區域，
     track 會建立新 stacking context、bar 填色會蓋住溢位文字。 */
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 6px;
}

.sector-bar-ticker {
  color: var(--text-secondary);
  font-size: 11px;
  margin-left: 4px;
}

.sector-bar-track {
  flex: 1;
  height: 14px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.sector-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.sector-bar-fill.pos { background: var(--accent-green); opacity: 0.8; }
.sector-bar-fill.neg { background: var(--accent-red);   opacity: 0.8; }

.sector-bar-val {
  width: 58px;
  text-align: right;
  font-size: 13px;
  flex-shrink: 0;
}

.sector-bar-val.pos { color: var(--accent-green); }
.sector-bar-val.neg { color: var(--accent-red); }

/* ── Correlation Heatmap ── */
.corr-preset-btns {
  display: flex;
  gap: 4px;
}

.corr-preset-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.corr-preset-btn.active {
  color: var(--accent-yellow);
  border-color: var(--accent-yellow);
}

.corr-heatmap-wrap { overflow-x: auto; margin-top: 8px; }

.corr-scroll { min-width: max-content; }

.corr-table {
  border-collapse: collapse;
  font-size: 12px;
}

.corr-table th {
  padding: 4px 8px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.corr-table .corr-row-label {
  text-align: right;
  padding-right: 10px;
  white-space: nowrap;
  color: var(--text-secondary);
}

.corr-cell {
  width: 52px;
  height: 36px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(0,0,0,0.2);
  cursor: default;
  transition: opacity 0.1s;
}

.corr-cell:hover { opacity: 0.85; }
.corr-diag { outline: 2px solid var(--text-secondary); outline-offset: -2px; }

/* ── Supply Chain ── */
.sc-theme-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sc-theme-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sc-theme-btn.active {
  color: var(--accent-green);
  border-color: var(--accent-green);
}

.sc-tier {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: top;
  padding-top: 10px;
  border-right: 2px solid var(--border);
  white-space: nowrap;
}

.sc-ticker       { font-weight: 700; color: var(--accent-blue); }
.sc-anchor-ticker { color: var(--accent-yellow) !important; }
.sc-region       { font-size: 16px; text-align: center; }
.sc-role         { color: var(--text-secondary); font-size: 12px; }

tr.sc-anchor td  { background: rgba(247, 201, 72, 0.04); }

/* Tier badges */
.tier-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.tier-0 { background: rgba(247,201,72,0.15); color: var(--accent-yellow); }
.tier-1 { background: rgba(79,195,247,0.12); color: var(--accent-blue); }
.tier-2 { background: rgba(100,100,120,0.15); color: var(--text-secondary); }
.tier-3 { background: rgba(80,80,90,0.12);   color: #6b7280; }

/* ── Subsector expand ── */
.sector-bar-row.has-sub .sector-bar-label { cursor: default; }
.sub-expand-btn {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.sub-expand-btn:hover { color: var(--accent-blue); }

.subsector-panel {
  background: var(--bg-secondary);
  border-left: 2px solid var(--border);
  margin: 2px 0 4px 16px;
  border-radius: 0 4px 4px 0;
  padding: 6px 8px;
}

.subsector-bars { display: flex; flex-direction: column; gap: 4px; }

.subsector-bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 56px;
  align-items: center;
  gap: 8px;
}

.subsector-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Rolling Correlation Chart ── */
.rolling-chart-wrap {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
}

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

.rolling-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.rolling-legend {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rolling-legend-item {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.rolling-dot {
  display: inline-block;
  width: 20px;
  height: 2px;
  border-radius: 1px;
}
.rolling-dot.w30 { background: #4fc3f7; }
.rolling-dot.w90 { background: #f0a500; border-top: 1px dashed #f0a500; }

.rolling-zone-high { color: rgba(239,83,80,0.7); }
.rolling-zone-low  { color: rgba(38,166,154,0.7); }

.rolling-chart { width: 100%; min-height: 120px; }
.rolling-svg   { display: block; width: 100%; }

/* Heatmap trend arrows */
.corr-trend-up { font-size: 10px; color: rgba(239,83,80,0.8);   margin-left: 2px; }
.corr-trend-dn { font-size: 10px; color: rgba(79,195,247,0.8);  margin-left: 2px; }

/* ── Market Pulse Bar ── */
.mkt-pulse-bar {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
  gap: 0;
}
.pulse-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  line-height: 1;
}
.pulse-item:first-child { padding-left: 0; }
.pulse-item:last-child  { border-right: none; }
.pulse-label { color: var(--text-secondary); font-weight: 600; letter-spacing: 0.03em; }
.pulse-price { color: var(--text-primary); }
.pulse-chg.pos { color: var(--accent-green); }
.pulse-chg.neg { color: var(--accent-red); }
.pulse-spacer  { flex: 1; }
.pulse-market-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  margin-right: 6px;
}
.pulse-status--open   { color: var(--accent-green);  border: 1px solid var(--accent-green); }
.pulse-status--pre    { color: var(--accent-yellow); border: 1px solid var(--accent-yellow); }
.pulse-status--after  { color: var(--text-secondary); border: 1px solid var(--border); }
.pulse-status--closed { color: var(--text-secondary); border: 1px solid var(--border); }
.pulse-time {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Regime Badge ── */
.regime-status { display: flex; align-items: center; }
.regime-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.regime-riskoff       { color: var(--accent-red); }
.regime-neutral       { color: var(--text-secondary); }
.regime-stock-picking { color: var(--accent-green); }

/* ── Heatmap Legend ── */
.corr-legend { margin-top: 10px; }
.corr-legend-bar {
  height: 10px;
  max-width: 240px;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(to right,
    hsl(215,75%,35%),
    hsl(215,20%,48%),
    var(--bg-tertiary),
    hsl(0,20%,48%),
    hsl(0,75%,35%)
  );
  border: 1px solid var(--border);
}
.corr-legend-labels {
  display: flex;
  justify-content: space-between;
  max-width: 240px;
  width: 100%;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Sector Sparkline ── */
.sector-sparkline {
  flex-shrink: 0;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 0;
}
.sector-bar-row:hover .sector-sparkline { opacity: 0.85; }

/* ── Sectors Grid Layout ── */
.sectors-layout {
  display: grid;
  grid-template-columns: 1fr 252px;
  gap: 20px;
  align-items: start;
  margin-bottom: 16px;
}
.sectors-main { min-width: 0; }

@media (max-width: 800px) {
  .sectors-layout { grid-template-columns: 1fr; }
  .sectors-sidebar { display: none; }
}

/* ── Investment Clock ── */
.investment-clock-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}
.investment-clock-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.investment-clock-phase {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.investment-clock-phase span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 4px;
}
.investment-clock-sectors {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

/* ── Supply Chain Tier Summary ── */
tr.sc-tier-summary td {
  background: var(--bg-tertiary);
  font-size: 11px;
  padding: 3px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tr.sc-tier-summary td.sc-summary-label { font-weight: 700; }
tr.sc-tier-summary td.pos { color: var(--accent-green); font-weight: 700; }
tr.sc-tier-summary td.neg { color: var(--accent-red);   font-weight: 700; }

/* ── 市場信心 Confidence ── */
.confidence-wrap { min-height: 200px; }

.conf-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

.conf-gauge-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.conf-score-box { text-align: center; margin-top: 2px; }

.conf-score-num {
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.conf-score-label {
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

.conf-score-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.conf-updated {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* Score color classes */
.conf-cls-very-bullish { color: #26a69a; }
.conf-cls-bullish      { color: #66bb6a; }
.conf-cls-mild-bullish { color: #aed581; }
.conf-cls-neutral      { color: #f7c948; }
.conf-cls-bearish      { color: #ff7043; }
.conf-cls-very-bearish { color: #ef5350; }

/* Signal Cards column */
.conf-signals-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conf-signal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color 0.15s;
}

.conf-signal-card:hover { border-color: var(--text-secondary); }

.conf-sig-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.conf-sig-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.conf-sig-weight {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.conf-sig-bar-wrap {
  background: var(--bg-tertiary);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

.conf-sig-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.conf-sig-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.conf-sig-score {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  min-width: 32px;
}

.conf-sig-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

.conf-sig-dir {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}
.conf-sig-dir.pos { color: var(--accent-green); }
.conf-sig-dir.neg { color: var(--accent-red); }

.conf-sig-detail {
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.conf-sig-source {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.conf-source-FRED     { background: rgba(41,98,255,0.15); color: #2962ff; }
.conf-source-yfinance { background: rgba(120,123,134,0.15); color: var(--text-secondary); }

/* Signal agreement badge */
.conf-agreement {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  margin-top: 8px;
  text-transform: uppercase;
}
.conf-agree-agree   { background: rgba(38,166,154,0.15); color: #26a69a; }
.conf-agree-mixed   { background: rgba(247,201,72,0.15);  color: #f7c948; }
.conf-agree-diverge { background: rgba(239,83,80,0.15);   color: #ef5350; }

/* Expandable signal cards */
.conf-card-expandable { cursor: pointer; }
.conf-card-expandable:hover { border-color: rgba(255,255,255,0.25); }
.conf-card-open { border-color: rgba(255,255,255,0.3) !important; }

.conf-sig-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conf-expand-btn {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1;
  transition: transform 0.2s;
  user-select: none;
}
.conf-card-open .conf-expand-btn { transform: rotate(90deg); }

/* Detail panel (hidden by default) */
.conf-detail-panel {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.conf-card-open .conf-detail-panel { display: block; }

/* Key-value breakdown for Fed / M2 */
.conf-breakdown-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 16px;
  font-size: 12px;
  margin-bottom: 10px;
}
.conf-kv-label { color: var(--text-secondary); }
.conf-kv-value { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Per-company capex table */
.conf-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 10px;
}
.conf-breakdown-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
  padding: 3px 8px 4px;
  border-bottom: 1px solid var(--border);
}
.conf-breakdown-table th:first-child { text-align: left; }
.conf-breakdown-table td {
  text-align: right;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.conf-breakdown-table td:first-child { text-align: left; font-weight: 600; }
.conf-breakdown-table tr.capex-total td {
  border-top: 1px solid var(--border);
  font-weight: 700;
  color: var(--text-primary);
}

/* Calculation steps */
.conf-calc-steps {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  line-height: 1.7;
}
.conf-calc-step::before { content: "▸ "; opacity: 0.5; }

@media (max-width: 860px) {
  .conf-layout { grid-template-columns: 1fr; }
  .conf-gauge-col { align-items: flex-start; }
}

/* ── Rolling Chart Tooltip ── */
.rolling-tooltip {
  position: absolute;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 9px;
  font-size: 11px;
  pointer-events: none;
  white-space: nowrap;
  color: var(--text-primary);
  display: none;
  z-index: 10;
  line-height: 1.7;
}

/* ── 淨流動性 / Net Liquidity Section ── */
.liquidity-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.liquidity-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.liquidity-formula {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
  background: var(--bg-secondary);
  padding: 2px 7px;
  border-radius: 4px;
}
.liquidity-updated {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}
.liquidity-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.liquidity-kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.liq-kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.liq-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}
.liq-kpi-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
}
.liq-signal-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans, inherit);
}
.liquidity-components {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.liq-comp-item { display: flex; align-items: center; gap: 5px; }
.liq-comp-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.liq-comp-walcl .liq-comp-dot { background: #38bdf8; }
.liq-comp-tga   .liq-comp-dot { background: #ef5350; }
.liq-comp-rrp   .liq-comp-dot { background: #f7c948; }
.liq-comp-sep { color: var(--text-secondary); font-weight: 600; }
.liquidity-chart-wrap {
  width: 100%;
  height: 290px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 4px;
}
/* Chart inside <details> — remove the section's default 14px padding so the
   chart container can use full width / height without being clipped. */
/* <details> 包裝的圖表 — 移除預設 padding，讓圖表能用滿空間。 */
.liq-detail-section > #liquidityChartEl {
  padding: 0 !important;
  margin: 0;
}
.liquidity-section-divider {
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
@media (max-width: 640px) {
  .liquidity-kpi-row { grid-template-columns: 1fr; }
}

/* ── Liquidity Tooltip / [?] Expandable Panels ── */
.liq-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
  margin-left: 4px;
  transition: background 0.15s, color 0.15s;
}
.liq-tip-btn:hover {
  background: var(--accent, #38bdf8);
  color: #fff;
  border-color: var(--accent, #38bdf8);
}
.liq-tip-panel {
  display: none;
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-left: 3px solid #38bdf8;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.liq-tip-panel.open { display: block; }
/* Semantic accents — risk tips (amber/red) vs definition/method tips (blue). */
/* 語意色條 — 風險類（琥珀/紅）vs 名詞/方法論類（藍）。 */
.liq-tip-danger { border-left-color: #ef5350; }
.liq-tip-danger .liq-tip-title { color: #ef5350; }
.liq-tip-warn { border-left-color: #f7c948; }
.liq-tip-warn .liq-tip-title { color: #f7c948; }
.liq-tip-info { border-left-color: #38bdf8; }
.liq-tip-info .liq-tip-title { color: #38bdf8; }
.liq-tip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.liq-tip-desc { margin-bottom: 8px; }
.liq-tip-caution {
  background: rgba(247, 201, 72, 0.1);
  border: 1px solid rgba(247, 201, 72, 0.3);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: #f7c948;
  margin: 6px 0;
}
.liq-tip-threshold {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.liq-tip-threshold:last-of-type { border-bottom: none; }
.liq-tip-range  { font-family: ui-monospace, monospace; color: #38bdf8; min-width: 60px; flex-shrink: 0; }
.liq-tip-tsig   { font-weight: 600; color: var(--text-primary); min-width: 70px; flex-shrink: 0; }
.liq-tip-tnote  { color: var(--text-secondary); }
.liq-tip-refs   { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.liq-tip-ref    { font-size: 11px; color: var(--text-secondary); padding: 2px 0; }
/* 四格卡片 RWD */
.liquidity-kpi-row { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .liquidity-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .liquidity-kpi-row { grid-template-columns: 1fr; } }

/* ── 流動性歷史解讀面板 (lctx) ── */
.lctx-wrap {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* 三燈號卡片列 */
.lctx-lights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.lctx-light-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lctx-card-alert {
  border-color: #ef535060;
  background: rgba(239,83,80,0.05);
}
.lctx-light-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lctx-light-icon  { font-size: 14px; }
.lctx-light-name  { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.lctx-light-badge { font-size: 12px; font-weight: 700; }
.lctx-light-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lctx-alert-tag {
  font-size: 11px;
  font-weight: 600;
  background: rgba(239,83,80,0.2);
  color: #ef5350;
  border: 1px solid #ef535050;
  border-radius: 4px;
  padding: 1px 6px;
}
.lctx-light-ctx {
  font-size: 12px;
  color: var(--text-secondary);
}
/* Range bar */
.lctx-range-bar {
  position: relative;
  height: 4px;
  background: var(--bg-tertiary, #1e293b);
  border-radius: 2px;
  margin: 6px 0 2px;
  overflow: visible;
}
.lctx-range-fill {
  position: absolute;
  height: 100%;
  border-radius: 2px;
  opacity: 0.4;
}
.lctx-range-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  top: -2px;
  transform: translateX(-50%);
}
.lctx-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.lctx-light-note {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.lctx-ref {
  font-size: 10px;
  color: #475569;
  font-style: italic;
}
/* 綜合判斷 */
.lctx-overall {
  border-radius: 10px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-left-width: 4px;
}
.lctx-overall-green { border-left-color: #26a69a; background: rgba(38,166,154,0.06); }
.lctx-overall-amber { border-left-color: #f7c948; background: rgba(247,201,72,0.06); }
.lctx-overall-red   { border-left-color: #ef5350; background: rgba(239,83,80,0.06); }
.lctx-overall-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.lctx-overall-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 10px;
}
.lctx-overall-factors {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
/* 歷史座標展開 */
.lctx-history-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.lctx-history-toggle {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  background: var(--bg-secondary);
  user-select: none;
}
.lctx-history-toggle::-webkit-details-marker { display: none; }
.lctx-history-toggle span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}
.lctx-history-table-wrap { padding: 0 0 12px; }
.lctx-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.lctx-history-table th {
  background: var(--bg-tertiary, #1e293b);
  padding: 8px 12px;
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
}
.lctx-history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.lctx-row-now td {
  background: rgba(56,189,248,0.05);
  color: var(--text-primary) !important;
  font-weight: 500;
}
.lctx-history-table .pos  { color: #26a69a; font-weight: 600; }
.lctx-history-table .neg  { color: #ef5350; font-weight: 600; }
.lctx-history-table .warn { color: #f7c948; font-weight: 600; }
.lctx-history-note {
  font-size: 11px;
  color: #475569;
  padding: 8px 12px 0;
  line-height: 1.6;
}
/* RWD */
@media (max-width: 860px) { .lctx-lights { grid-template-columns: 1fr; } }

/* ── RRP 獨立警示 & 雙欄佈局 ── */
.lctx-lights-2col { grid-template-columns: repeat(3, 1fr); }

.lctx-rrp-alert {
  display: flex;
  gap: 12px;
  background: rgba(239,83,80,0.08);
  border: 1px solid rgba(239,83,80,0.4);
  border-left: 4px solid #ef5350;
  border-radius: 10px;
  padding: 14px 16px;
  align-items: flex-start;
}
.lctx-rrp-alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.lctx-rrp-alert-body { flex: 1; }
.lctx-rrp-alert-title {
  font-size: 13px;
  font-weight: 700;
  color: #ef5350;
  margin-bottom: 6px;
}
.lctx-rrp-alert-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 6px;
}
.lctx-rrp-alert-desc strong { color: var(--text-primary); }
.lctx-rrp-alert-ref {
  font-size: 11px;
  color: #475569;
  font-style: italic;
}
.lctx-rrp-info-card {
  border-style: dashed;
  opacity: 0.85;
}
.lctx-rrp-independent-tag {
  font-size: 10px;
  font-weight: 700;
  background: rgba(100,116,139,0.2);
  color: #64748b;
  border: 1px solid #64748b40;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: auto;
}
.lctx-factor-rrp { color: #64748b; font-style: italic; }

/* ── Δ 變化量 chip ── */
.liq-delta {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}
.liq-delta-good { background: rgba(38,166,154,0.15); color: #26a69a; }
.liq-delta-bad  { background: rgba(239,83,80,0.15); color: #ef5350; }
.liq-delta-flat { background: rgba(100,116,139,0.15); color: #64748b; }

/* ── 持續時間顯示 ── */
.lctx-duration {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 4px;
  padding: 6px 10px;
  background: rgba(56,189,248,0.06);
  border-radius: 6px;
  border-left: 2px solid #38bdf8;
}
.lctx-duration strong { color: var(--text-primary); }

/* ── 行動建議卡片 ── */
.lctx-action-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lctx-action-green { border-top: 3px solid #26a69a; }
.lctx-action-amber { border-top: 3px solid #f7c948; }
.lctx-action-red   { border-top: 3px solid #ef5350; }

.lctx-action-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lctx-action-icon  { font-size: 18px; }
.lctx-action-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.lctx-action-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.4px;
}

/* 三個關鍵數字卡片 */
.lctx-action-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.lctx-action-num-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.lctx-action-num-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.lctx-action-num-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
}
.lctx-action-num-hint {
  font-size: 10px;
  color: var(--text-secondary);
}

/* RRP 修正警示 */
.lctx-action-rrp-alert {
  background: rgba(239,83,80,0.08);
  border: 1px solid rgba(239,83,80,0.3);
  border-left: 3px solid #ef5350;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.lctx-action-rrp-alert strong { color: #ef5350; }

/* 槓桿建議 */
.lctx-action-leverage {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 6px;
}
.lctx-action-leverage strong { color: var(--text-primary); }

/* 操作邏輯 / 板塊區塊 */
.lctx-action-section {
  font-size: 13px;
}
.lctx-action-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.lctx-sector-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}
.lctx-sector-tag {
  display: inline-block;
  background: rgba(38,166,154,0.15);
  color: #26a69a;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  min-width: 50px;
  text-align: center;
}
.lctx-sector-tag-avoid {
  display: inline-block;
  background: rgba(239,83,80,0.15);
  color: #ef5350;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  min-width: 50px;
  text-align: center;
  text-decoration: line-through;
}
.lctx-sector-name {
  color: var(--text-primary);
  font-weight: 500;
}
.lctx-sector-reason {
  color: var(--text-secondary);
}
.lctx-action-rationale {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.lctx-action-rationale li { margin-bottom: 4px; }

/* 學術依據展開 */
.lctx-action-refs {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.lctx-action-refs summary {
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  list-style: none;
}
.lctx-action-refs summary::-webkit-details-marker { display: none; }
.lctx-action-refs ul {
  margin: 0;
  padding: 4px 12px 10px 28px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.lctx-action-refs li { margin-bottom: 3px; }

.lctx-action-disclaimer {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

/* RWD */
@media (max-width: 640px) {
  .lctx-action-numbers { grid-template-columns: 1fr; }
}

/* ── Hero Summary（Layer 1：5 秒結論）── */
.liq-hero {
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-left: 4px solid;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  background: var(--bg-secondary);
}
.liq-hero-green { border-left-color: #26a69a; background: rgba(38,166,154,0.08); }
.liq-hero-amber { border-left-color: #f7c948; background: rgba(247,201,72,0.08); }
.liq-hero-red   { border-left-color: #ef5350; background: rgba(239,83,80,0.08); }
.liq-hero-row     { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; }
.liq-hero-icon    { font-size: 22px; }
.liq-hero-label   { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.liq-hero-duration {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(56,189,248,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(56,189,248,0.2);
}
.liq-hero-numbers { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.liq-hero-num     { font-size: 13px; color: var(--text-secondary); }
.liq-hero-num strong { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-left: 4px; }
.liq-hero-sep     { color: var(--text-secondary); opacity: 0.5; }
/* Risk-preference label — de-emphasises the playbook numbers as reference-only. */
/* 風險偏好參考標籤 — 弱化 playbook 數字，標明僅供參考。 */
.liq-hero-ref {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.75;
  letter-spacing: 0.02em;
  border: 1px dashed var(--border-color, rgba(148,163,184,0.4));
  border-radius: 8px;
  padding: 1px 7px;
}
/* Blind-spot marker on the hero badge — the green light is untrustworthy. */
/* Hero 燈號上的盲區標記 — 綠燈不可信。 */
.liq-hero-blindspot {
  font-size: 12px;
  font-weight: 700;
  color: #ef5350;
  background: rgba(239,83,80,0.12);
  border: 1px solid rgba(239,83,80,0.45);
  border-radius: 10px;
  padding: 2px 8px;
}
.liq-hero-blindspot-on { border-left-color: #ef5350 !important; }

/* Credit-crisis blind-spot banner (Layer 0). Mirrors .lctx-rrp-alert. */
/* 信用危機盲區警告橫幅（Layer 0），沿用 RRP 警示樣式。 */
.liq-blindspot-banner {
  display: flex;
  gap: 12px;
  background: rgba(239,83,80,0.10);
  border: 1px solid rgba(239,83,80,0.45);
  border-left: 4px solid #ef5350;
  border-radius: 10px;
  padding: 14px 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.liq-blindspot-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.liq-blindspot-body { flex: 1; }
.liq-blindspot-title { font-size: 13px; font-weight: 700; color: #ef5350; margin-bottom: 6px; }
.liq-blindspot-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 6px;
}
.liq-blindspot-ref { font-size: 11px; color: var(--text-secondary); opacity: 0.8; font-style: italic; }

/* Credit-stress overlay card (Baa−10Y). */
/* 信用壓力疊加卡（Baa−10Y）。 */
.liq-credit-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color, rgba(148,163,184,0.25));
  border-left: 4px solid #888;
}
.liq-credit-calm   { border-left-color: #26a69a; }
.liq-credit-watch  { border-left-color: #f7c948; }
.liq-credit-stress { border-left-color: #ff7043; }
.liq-credit-crisis { border-left-color: #ef5350; }
.liq-credit-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.liq-credit-icon { font-size: 15px; }
.liq-credit-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.liq-credit-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.liq-credit-pct { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.liq-credit-note { font-size: 10px; color: var(--text-secondary); opacity: 0.85; margin-top: 4px; line-height: 1.5; }

/* ── KPI Sparkline ── */
.liq-sparkline {
  display: inline-block;
  vertical-align: middle;
  opacity: 0.85;
  margin-left: 8px;
}

/* ── Inline citation chip ── */
.liq-citation {
  display: inline-block;
  font-size: 10px;
  color: var(--text-secondary);
  background: rgba(56,189,248,0.06);
  border: 1px solid rgba(56,189,248,0.15);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-style: italic;
  cursor: help;
  white-space: nowrap;
}

/* ── 複製狀態按鈕 ── */
.liq-copy-btn {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.liq-copy-btn:hover {
  color: var(--text-primary);
  border-color: #38bdf8;
  background: rgba(56,189,248,0.1);
}
.liq-copy-btn-done {
  background: rgba(38,166,154,0.15) !important;
  color: #26a69a !important;
  border-color: #26a69a !important;
}

/* ── Detail accordion sections ── */
.liq-detail-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  background: var(--bg-secondary);
  overflow: hidden;
}
.liq-detail-section[open] { background: transparent; }
.liq-detail-summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  list-style: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.liq-detail-summary::-webkit-details-marker { display: none; }
.liq-detail-summary::before { content: '▶ '; font-size: 10px; color: var(--text-secondary); transition: transform 0.15s; display: inline-block; }
.liq-detail-section[open] .liq-detail-summary::before { transform: rotate(90deg); }
.liq-detail-section[open] .liq-detail-summary { border-bottom-color: var(--border); }
.liq-detail-section > *:not(.liq-detail-summary) { padding: 14px; }

/* ── Mobile：折疊預設關閉，僅 hero 與 action 預設展開 ── */
@media (max-width: 640px) {
  .liq-hero-numbers { width: 100%; justify-content: space-around; }
  .liq-hero {
    padding: 12px 14px;
  }
  .liq-hero-label { font-size: 16px; }
  .liq-hero-num strong { font-size: 16px; }
  .liq-detail-section { open: false; }  /* 提示樣式（實際開關仍由 details element） */
  .liquidity-header { flex-wrap: wrap; }
  .liq-copy-btn { margin-left: 0; margin-top: 6px; }
}

/* ── Action 區塊（已移至底部，預設折疊）── */
/* Highlight summary when expanded; let action card keep its own padding/border
   so internal sections (槓桿 / 板塊 / 操作邏輯) retain their spacing. */
/* 展開時高亮 summary；action card 保留自身 padding/border 讓內部區塊保有正常間距。 */
.liq-action-section[open] > .liq-detail-summary {
  background: rgba(247,201,72,0.08);
  border-bottom-color: rgba(247,201,72,0.2);
}
/* Action card inside the wrapper section: drop its own border / radius /
   bg so it visually merges with the section, and force its inherent
   18px 20px padding so the section's default 14px doesn't replace it
   (otherwise inner blocks like 槓桿 / 板塊 lose their breathing room). */
/* 移除卡片自身邊框讓它和 section 視覺合一；強制保留 18px 20px padding，
   避免 section 預設 14px 取代後內部區塊失去留白。 */
.liq-action-section > .lctx-action-card {
  border: none;
  border-radius: 0;
  margin: 0;
  background: transparent;
  padding: 18px 20px !important;
}

/* ── Volume Profile / Market Depth Panel ── */
.depth-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 6px 0;
  overflow: hidden;
}
.depth-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-tertiary, #1e293b);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.depth-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.depth-type-badge {
  font-size: 11px;
  color: #f7c948;
  background: rgba(247,201,72,0.12);
  border: 1px solid rgba(247,201,72,0.25);
  padding: 1px 8px;
  border-radius: 10px;
}
.depth-spread {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
  font-family: ui-monospace, monospace;
}
.depth-body {
  padding: 8px 10px;
}
.depth-chart-wrap {
  position: relative;
}
.depth-axis-label {
  font-size: 10px;
  color: #475569;
  position: absolute;
  top: -14px;
}
.depth-axis-buy  { left: 0; color: #26a69a; }
.depth-axis-sell { right: 0; color: #ef5350; }
.depth-svg-container {
  margin-top: 14px;
  width: 100%;
  max-height: 480px;
  overflow-y: auto;
}
.depth-svg {
  display: block;
  width: 100%;
}

/* ── Chart + Depth side-panel row ── */
.chart-area-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  /* TradingView renders into <canvas> so overflow:hidden does NOT clip its
     internal price labels or crosshair. Keep hidden so depth panel slide-in
     doesn't cause horizontal scrollbar. */
  /* TradingView 用 canvas 渲染，overflow:hidden 不影響其內部標籤。
     保持 hidden 避免側欄開啟時出現水平捲軸。*/
  overflow: hidden;
}

/* K-line takes full width by default; shrinks when depth panel opens. */
.chart-area-row .chart-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  /* No transition — TradingView chart must resize instantly with JS. */
  /* 不設 transition，讓 TradingView 即時 resize。*/
}

/* ── Depth side panel ── */
.depth-side-panel {
  position: relative;          /* needed for resize-handle positioning */
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.22s ease;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;      /* padding included in width */
  padding-left: 6px;           /* space for resize handle */
}
.depth-side-panel--open {
  width: 214px;                /* 6px handle + 208px content */
}

.depth-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-tertiary, #1e293b);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.depth-side-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.depth-side-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.depth-side-close:hover { color: var(--text-primary); }

.depth-side-spread {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.depth-side-legend {
  display: flex;
  justify-content: space-between;
  padding: 2px 10px;
  font-size: 10px;
  flex-shrink: 0;
}
.depth-legend-buy  { color: #26a69a; }
.depth-legend-sell { color: #ef5350; }

.depth-side-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 6px;
}
.depth-loading {
  color: #64748b;
  font-size: 12px;
  padding: 12px 4px;
  text-align: center;
}
.depth-side-footer {
  font-size: 10px;
  color: #475569;
  padding: 4px 10px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
  flex-shrink: 0;
}


/* ── Depth toggle button in indicator bar ── */
.indicator-sep {
  display: inline-block;
  width: 1px;
  background: var(--border);
  height: 14px;
  vertical-align: middle;
  margin: 0 6px;
}
.depth-toggle-btn {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}


.depth-toggle-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.depth-toggle-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: #38bdf8;
}
.depth-toggle-btn--active {
  background: rgba(56,189,248,0.15) !important;
  color: #38bdf8 !important;
  border-color: #38bdf8 !important;
}

/* ── Depth SVG inside side panel ── */
.depth-svg {
  display: block;
  width: 100%;
}

/* Override old depth-panel styles (now unused) */
.depth-panel { display: none !important; }

/* ── Depth panel resize handle (left edge) ── */
.depth-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.depth-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 28px;
  border-radius: 1px;
  background: var(--border);
  transition: background 0.15s, height 0.15s;
}
.depth-resize-handle:hover::after,
.depth-resize-handle.dragging::after {
  background: #38bdf8;
  height: 40px;
}
.depth-resize-handle:hover,
.depth-resize-handle.dragging {
  background: rgba(56,189,248,0.06);
}
/* position, padding-left, box-sizing are now in the main .depth-side-panel rule above. */

/* ── Depth panel mode tabs & period buttons ── */
.depth-mode-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}
.depth-mode-tab {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.depth-mode-tab--active {
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
  border-color: #38bdf840;
}
.depth-period-row {
  display: flex;
  gap: 3px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary, #1e293b);
  flex-shrink: 0;
}
.depth-period-btn {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
  flex: 1;
}
.depth-period-btn--active {
  background: rgba(38,166,154,0.2);
  color: #26a69a;
  border-color: #26a69a60;
}
.depth-period-btn:hover:not(.depth-period-btn--active) {
  color: var(--text-primary);
  border-color: #475569;
}

/* ── Chip distribution key levels badges ── */
.depth-key-levels {
  display: flex;
  gap: 3px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.chip-key {
  font-size: 10px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid;
  cursor: help;
  white-space: nowrap;
}
.chip-key-support {
  color: #34d399;
  background: rgba(52,211,153,0.1);
  border-color: rgba(52,211,153,0.3);
}
.chip-key-avg {
  color: #fbbf24;
  background: rgba(251,191,36,0.1);
  border-color: rgba(251,191,36,0.3);
}
.chip-key-resist {
  color: #f87171;
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.3);
}

/* ── 債市雷達 (Yield Curve Radar) ─────────────────────────────────────────── */

.yield-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 0 12px;
}
@media (max-width: 800px) {
  .yield-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.yield-kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.yield-kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.yield-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.1;
}
.yield-kpi-updated {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.yield-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid;
  margin-top: 4px;
  width: fit-content;
}
.yield-badge.red    { color: var(--accent-red);    background: rgba(239,83,80,0.12);  border-color: rgba(239,83,80,0.35); }
.yield-badge.yellow { color: var(--accent-yellow); background: rgba(247,201,72,0.12); border-color: rgba(247,201,72,0.35); }
.yield-badge.green  { color: var(--accent-green);  background: rgba(38,166,154,0.12); border-color: rgba(38,166,154,0.35); }
.yield-badge.neutral{ color: var(--text-secondary); background: transparent;          border-color: var(--border); }

/* Main two-column layout: curve shape (left) + signal card (right) */
.yield-main-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 800px) {
  .yield-main-layout { grid-template-columns: 1fr; }
}

.yield-curve-panel,
.yield-signal-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.yield-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.yield-curve-svg-wrap { width: 100%; }

/* Signal card */
.yield-signal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 160px;
  text-align: center;
}
.yield-signal-dot {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
}
.yield-signal-label {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.yield-signal-action {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 280px;
}
.yield-inv-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(239,83,80,0.08);
  border: 1px solid rgba(239,83,80,0.25);
  border-radius: 6px;
  padding: 8px 12px;
  width: 100%;
  text-align: left;
}
.yield-inv-row strong { color: var(--text-primary); }

/* Spread history chart */
.yield-spread-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.yield-spread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.yield-spread-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.yield-spread-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
}
.yield-legend-item { display: flex; align-items: center; gap: 5px; }
.yield-dot {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
}
.yield-dot.y2y { background: #38bdf8; }
.yield-dot.y3m { background: #f7c948; }
.yield-zone-inv { color: rgba(239,83,80,0.8); }
.yield-spread-chart-el {
  height: 240px;
  width: 100%;
}

/* Historical table */
.yield-hist-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.yield-history-table { margin-bottom: 4px; }
.yield-hist-note {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 240px;
}

/* ── 籌碼壓力 / Positioning (CTA + Sector Vol) ────────────────────────────── */
.cta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.cta-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.cta-subtitle {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}
.cta-danger-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.cta-danger-badge {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  padding: 6px 15px;
  border-radius: 16px;
}
/* Hero interpretation line — plain-language "what it means now". */
/* 英雄解讀句 — 白話「現在代表什麼」。 */
.cta-hero-hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.cta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.cta-metric {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.cta-metric-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.cta-gauge { display: flex; justify-content: center; }
.cta-metric-num {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cta-metric-unit {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}
.cta-metric-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.cta-bp-bar {
  height: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  margin: 22px 0 10px;
}
.cta-bp-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.cta-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 6px 0 8px;
}
/* Roomier, more scannable tables scoped to the positioning tab. */
/* 籌碼壓力分頁的表格：加大字級、行高與等寬數字，利於掃視。 */
#tab-positioning .mkt-table th,
#tab-positioning .mkt-table td {
  font-size: 13px;
  padding: 10px 12px;
}
#tab-positioning .mkt-table td.num,
#tab-positioning .mkt-table th.num { font-variant-numeric: tabular-nums; }
.cta-trig-table td, .sv-table td { vertical-align: middle; }
.cta-tk {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 6px;
}
.cta-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.cta-val-label { color: var(--text-secondary); }
.cta-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 9px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.cta-chip-muted { color: var(--text-secondary); }
.cta-updated {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
}
/* Sector volatility table */
.sv-pctcell { min-width: 150px; }
.sv-pctbar {
  display: inline-block;
  width: 96px;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
}
.sv-pctfill { height: 100%; border-radius: 4px; }
.sv-pctnum {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
  vertical-align: middle;
}
.sv-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
}
.sv-tag-iv { background: rgba(41, 98, 255, 0.18); color: var(--accent-blue); }
.sv-tag-rv { background: rgba(120, 123, 134, 0.18); color: var(--text-secondary); }
/* The provenance footnote is readable, not squinting-small. */
/* 出處註腳字級加大到可讀，不再瞇眼。 */
#tab-positioning .mkt-note {
  font-size: 12.5px;
  line-height: 1.7;
}
@media (max-width: 640px) {
  .cta-grid { grid-template-columns: 1fr; }
}
