/* ==========================================================================
   bot-trader Web Dashboard — Cyber-Quant Dark Terminal Theme
   ========================================================================== */

:root {
  /* 基礎深色系調色盤 */
  --bg-base: #0a0d14;
  --bg-sidebar: #0e121b;
  --bg-surface: #131826;
  --bg-card: #182032;
  --bg-card-hover: #1e2840;
  --border-color: #24304c;
  --border-highlight: #33446b;

  /* 文字層級 */
  --text-main: #f0f4fc;
  --text-muted: #8899b7;
  --text-dim: #546585;

  /* 系統常態醒目色 (例如總資產、非金融漲跌的數字)，保持綠色霓虹，不受台盤/國際色影響 */
  --color-accent: #00e676;
  --color-accent-glow: rgba(0, 230, 118, 0.25);

  /* 金融多空與品牌霓虹強調色 (預設為台盤色 tw: 紅漲綠跌、紅盈綠虧) */
  --color-profit: #ef4444;
  --color-profit-glow: rgba(239, 68, 68, 0.25);
  --color-loss: #10b981;
  --color-loss-glow: rgba(16, 185, 129, 0.25);
  --color-up: #ef4444;
  --color-up-glow: rgba(239, 68, 68, 0.25);
  --color-down: #10b981;
  --color-down-glow: rgba(16, 185, 129, 0.25);
  --badge-profit-bg: rgba(239, 68, 68, 0.15);
  --badge-profit-border: rgba(239, 68, 68, 0.35);
  --badge-loss-bg: rgba(16, 185, 129, 0.15);
  --badge-loss-border: rgba(16, 185, 129, 0.35);

  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-cyan: #06b6d4;
  --color-cyan-glow: rgba(6, 182, 212, 0.25);
  --color-amber: #f59e0b;
  --color-purple: #8b5cf6;

  /* 字體系統 */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, 'SF Mono', monospace;

  /* 圓角與陰影 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   配色模式切換體系 (Color Scheme Modes: TW vs Intl)
   ========================================================================== */
:root[data-color-scheme="tw"],
body[data-color-scheme="tw"] {
  --color-profit: #ef4444;
  --color-profit-glow: rgba(239, 68, 68, 0.25);
  --color-loss: #10b981;
  --color-loss-glow: rgba(16, 185, 129, 0.25);
  --color-up: #ef4444;
  --color-up-glow: rgba(239, 68, 68, 0.25);
  --color-down: #10b981;
  --color-down-glow: rgba(16, 185, 129, 0.25);
  --badge-profit-bg: rgba(239, 68, 68, 0.15);
  --badge-profit-border: rgba(239, 68, 68, 0.35);
  --badge-loss-bg: rgba(16, 185, 129, 0.15);
  --badge-loss-border: rgba(16, 185, 129, 0.35);
}

:root[data-color-scheme="intl"],
body[data-color-scheme="intl"] {
  --color-profit: #10b981;
  --color-profit-glow: rgba(16, 185, 129, 0.25);
  --color-loss: #ef4444;
  --color-loss-glow: rgba(239, 68, 68, 0.25);
  --color-up: #10b981;
  --color-up-glow: rgba(16, 185, 129, 0.25);
  --color-down: #ef4444;
  --color-down-glow: rgba(239, 68, 68, 0.25);
  --badge-profit-bg: rgba(16, 185, 129, 0.15);
  --badge-profit-border: rgba(16, 185, 129, 0.35);
  --badge-loss-bg: rgba(239, 68, 68, 0.15);
  --badge-loss-border: rgba(239, 68, 68, 0.35);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* 輔助 Typography 與常用 Utility */
.mono {
  font-family: var(--font-mono);
}
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-md { font-size: 1.05rem; }
.text-muted { color: var(--text-muted); }
.text-highlight { color: var(--color-accent); }
.text-profit,
.text-up,
.pnl-positive {
  color: var(--color-profit) !important;
}
.text-loss,
.text-down,
.pnl-negative {
  color: var(--color-loss) !important;
}
.text-cyan { color: var(--color-cyan); }
.text-amber { color: var(--color-amber); }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.p-0 { padding: 0 !important; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.justify-between { justify-content: space-between; }

/* 佈局容器 (App Layout) */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* 頂部 Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 1.25rem;
  background-color: rgba(14, 18, 27, 0.9);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(14px);
  z-index: 100;
  transition: all var(--transition-normal);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.brand-logo {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px var(--color-cyan-glow));
}
.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff, var(--color-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
}
.brand-subtitle {
  display: none; /* 隱藏冗長英文副標題，消除空間壓迫感 */
}

.badge-version {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-left: 0.45rem;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  margin: 0 1rem;
}
.account-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--bg-card);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.selector-icon {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}
.account-selector-wrap .select-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  width: auto;
  min-width: 140px;
  max-width: none; /* 自適應內容長度，不截斷帳戶名稱與代碼 */
  padding: 2px 4px;
}
.account-selector-wrap .select-input option {
  background: var(--bg-surface);
  color: var(--text-main);
}
.selector-label {
  display: none;
}
.header-account-status {
  display: inline-flex;
  gap: 5px;
  margin-left: 4px;
  align-items: center;
  flex-shrink: 0;
}
.header-account-status .status-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* ==========================================================================
   置頂盤中行情背景輪詢狀態膠囊 (Intraday Polling Status Pill)
   ========================================================================== */
.intraday-poll-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(18, 24, 38, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  font-family: inherit;
  outline: none;
  backdrop-filter: blur(8px);
}

.intraday-poll-pill:hover {
  background: rgba(28, 38, 60, 0.9);
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
  transform: translateY(-1px);
}

.intraday-poll-pill:active {
  transform: translateY(0);
}

.intraday-poll-pill .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 6px rgba(100, 116, 139, 0.5);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.intraday-poll-pill .poll-label {
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.intraday-poll-pill .poll-timer {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* 狀態：開盤即時監控 (Market Open) */
.intraday-poll-pill.market-open {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(6, 78, 59, 0.25);
}
.intraday-poll-pill.market-open .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  animation: pulse-dot 2s infinite ease-in-out;
}
.intraday-poll-pill.market-open .poll-label {
  color: #34d399;
}
.intraday-poll-pill.market-open .poll-timer {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.15);
}

/* 狀態：盤後待機 (Market Closed / Idle) */
.intraday-poll-pill.market-closed {
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.4);
}
.intraday-poll-pill.market-closed .status-dot {
  background: #94a3b8;
  box-shadow: 0 0 5px rgba(148, 163, 184, 0.4);
}
.intraday-poll-pill.market-closed .poll-label {
  color: #94a3b8;
}
.intraday-poll-pill.market-closed .poll-timer {
  color: #cbd5e1;
}

/* 狀態：正在拉取行情快照 (Polling in progress) */
.intraday-poll-pill.polling-now {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(120, 53, 15, 0.25);
}
.intraday-poll-pill.polling-now .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.9);
  animation: pulse-fast 0.6s infinite alternate;
}
.intraday-poll-pill.polling-now .poll-label {
  color: #fbbf24;
}
.intraday-poll-pill.polling-now .poll-timer {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.2);
}

/* 狀態：離線或異常 (Offline / Stopped) */
.intraday-poll-pill.offline {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(127, 29, 29, 0.2);
}
.intraday-poll-pill.offline .status-dot {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}
.intraday-poll-pill.offline .poll-label {
  color: #fca5a5;
}
.intraday-poll-pill.offline .poll-timer {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.3);
}

@keyframes pulse-fast {
  from { opacity: 0.4; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 768px) {
  .intraday-poll-pill .poll-label {
    display: none;
  }
}

/* ==========================================================================
   系統監控控制中心 Popover (System Sentinel Hub)
   ========================================================================== */
.system-hub-dropdown {
  position: relative;
  display: inline-block;
}

.system-hub-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(24, 32, 50, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  font-family: inherit;
  outline: none;
}

.system-hub-trigger:hover,
.system-hub-dropdown.active .system-hub-trigger {
  background: var(--bg-card-hover);
  border-color: var(--color-cyan);
  box-shadow: 0 0 12px var(--color-cyan-glow);
}

.system-hub-trigger .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.8);
  flex-shrink: 0;
}

.system-hub-trigger .status-dot.offline {
  background: #ff3366;
  box-shadow: 0 0 8px rgba(255, 51, 102, 0.8);
}

.hub-title {
  font-weight: 500;
  font-size: 0.76rem;
  color: var(--text-main);
}

.hub-summary-badge {
  font-size: 0.66rem;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 230, 118, 0.12);
  color: #00e676;
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.hub-summary-badge.badge-offline {
  background: rgba(255, 51, 102, 0.15);
  color: #ff3366;
  border-color: rgba(255, 51, 102, 0.3);
}

.hub-caret {
  font-size: 0.62rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.system-hub-dropdown.active .hub-caret {
  transform: rotate(180deg);
}

.system-hub-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  min-width: 320px;
  max-width: min(92vw, 460px);
  background: rgba(14, 18, 27, 0.96);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  padding: 12px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.system-hub-dropdown.active .system-hub-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.hub-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hub-popover-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hub-popover-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hub-row-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.system-hub-popover .status-badge {
  white-space: nowrap;
  flex-shrink: 0;
}

.system-hub-popover .status-text,
#deployModeTag,
#instancePidTag {
  white-space: nowrap;
}

/* 狀態徽章 (Badges) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
/* 可互動開關徽章 (防誤觸按鈕樣式) */
button.status-badge,
.status-badge.clickable-badge,
.badge.clickable-badge {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  outline: none;
}
button.status-badge:hover,
.status-badge.clickable-badge:hover,
.badge.clickable-badge:hover {
  filter: brightness(1.25);
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.35);
}
button.status-badge:active,
.status-badge.clickable-badge:active,
.badge.clickable-badge:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* 持倉批次明細展開列與篩選介面樣式 */
.sub-row-details {
  background-color: rgba(13, 24, 41, 0.7) !important;
  border-left: 3px solid var(--color-primary);
}
.sub-row-table {
  width: 100%;
  font-size: 0.78rem;
  border-collapse: collapse;
}
.sub-row-table th {
  background-color: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sub-row-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.toggle-expand-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.2s ease, color 0.2s ease;
  padding: 2px 6px;
  border-radius: 4px;
}
.toggle-expand-btn:hover {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.12);
}
.toggle-expand-btn.expanded {
  transform: rotate(90deg);
  color: var(--color-primary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-primary {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}
.status-primary .status-dot {
  background-color: #60a5fa;
  box-shadow: 0 0 6px #60a5fa;
}
.status-online {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
}
.status-online .status-dot {
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 2s infinite;
}
.status-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}
.status-warning .status-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}
.status-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}
.status-danger .status-dot {
  background-color: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}
.status-secondary {
  background-color: rgba(136, 153, 183, 0.12);
  color: var(--text-muted);
  border-color: var(--border-color);
}
.status-secondary .status-dot {
  background-color: var(--text-muted);
}
.status-loading .status-dot {
  background-color: var(--color-amber);
  animation: pulse 1s infinite;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.clickable-badge {
  cursor: pointer;
  user-select: none;
}
.clickable-badge:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.clickable-badge:active {
  transform: translateY(0);
}

.text-cyan { color: #06b6d4 !important; }
.text-amber { color: #f59e0b !important; }
.text-highlight { color: #38bdf8 !important; }

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* 主體兩欄佈局 */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左側邊欄 */
.app-sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

/* 側邊欄收合模式 (Icon-only Compact Mode) */
.app-sidebar.collapsed {
  width: 68px;
}

.app-sidebar.collapsed .sidebar-account-card {
  margin: 0.6rem 0.35rem;
  padding: 0.5rem 0.25rem;
  text-align: center;
  align-items: center;
}

.app-sidebar.collapsed .sidebar-account-label span:first-child,
.app-sidebar.collapsed .sidebar-account-meta,
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-section-title,
.app-sidebar.collapsed .server-time-box .text-muted,
.app-sidebar.collapsed .collapse-text {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-account-name {
  font-size: 0.72rem;
  max-width: 58px;
  text-align: center;
}

.app-sidebar.collapsed .sidebar-nav {
  padding: 0.5rem 0.35rem;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.65rem 0;
  gap: 0;
}

.app-sidebar.collapsed .nav-icon {
  font-size: 1.25rem;
}

.app-sidebar.collapsed .sidebar-footer {
  padding: 0.75rem 0.25rem;
  text-align: center;
}

.app-sidebar.collapsed .server-time-box {
  justify-content: center;
}

.app-sidebar.collapsed .server-time-box #serverTimeText {
  font-size: 0.7rem;
}

.app-sidebar.collapsed .sidebar-collapse-toggle-btn .collapse-icon {
  transform: rotate(180deg);
}

.sidebar-collapse-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  margin-top: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.76rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sidebar-collapse-toggle-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-main);
  border-color: var(--color-primary);
}

.sidebar-collapse-toggle-btn .collapse-icon {
  display: inline-block;
  transition: transform 0.22s ease;
  font-size: 0.75rem;
}
.sidebar-account-card {
  margin: 0.85rem 0.75rem 0.25rem;
  padding: 0.65rem 0.8rem;
  background: rgba(13, 24, 41, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.sidebar-account-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-account-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-account-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.sidebar-nav {
  padding: 0.5rem 0.75rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* 佔滿帳戶卡片與頁尾之間的剩餘高度：讓選單內容自頂端起算 (top 對齊)，
     並使 overflow-y 真正生效 —— 選單過多時於此區內捲動而非把頁尾擠出側欄。
     父層 .app-sidebar 使用 justify-content: space-between，若 nav 未撐滿高度，
     多餘空間會被分配為間距，導致第一個選單項浮在側欄垂直中央而非頂端。 */
  flex: 1 1 auto;
  min-height: 0;
}
.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.75rem 0.75rem 0.25rem;
  letter-spacing: 0.08em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.08));
  color: var(--color-cyan);
  border-color: rgba(6, 182, 212, 0.3);
  font-weight: 600;
}
.nav-icon {
  font-size: 1.05rem;
}
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}
.server-time-box {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

/* 主內容面板 */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  background: radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.03) 0%, transparent 60%);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}
.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pane-header {
  margin-bottom: 1.5rem;
}
.pane-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}
.pane-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* 卡片與網格 */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-normal);
}
.card:hover {
  border-color: var(--border-highlight);
}
.card-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(255, 255, 255, 0.01);
}
.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
}
.card-body {
  padding: 1.25rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.kpi-card {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--color-cyan), transparent);
}
.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0.35rem 0;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* 緊湊型總覽狀態列 (Overview KPI Compact Status Bar) */
.kpi-compact-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.kpi-compact-strip::-webkit-scrollbar {
  height: 3px;
}
.kpi-compact-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.kpi-compact-strip .kpi-card {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  background: transparent;
  border: none;
  padding: 0 0.85rem;
  border-radius: 0;
  box-shadow: none;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.kpi-compact-strip .kpi-card:last-child {
  border-right: none;
  padding-right: 0;
}

.kpi-compact-strip .kpi-card::after {
  display: none;
}

.kpi-compact-strip .kpi-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
  margin: 0;
  text-transform: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.kpi-compact-strip .kpi-value {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.kpi-compact-strip .kpi-sub {
  font-size: 0.72rem;
  color: #64748b;
  margin: 0;
  white-space: nowrap;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
}
.order-execution-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}
.order-bar-card {
  width: 100%;
}
.order-console-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}
.order-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.order-estimate-panel {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  min-height: 38px;
  box-sizing: border-box;
}
.order-estimate-panel .estimate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

/* 按鈕系統 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}
.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
}
.btn-secondary {
  background-color: rgba(6, 182, 212, 0.15);
  color: var(--color-cyan);
  border-color: rgba(6, 182, 212, 0.35);
}
.btn-secondary:hover {
  background-color: rgba(6, 182, 212, 0.25);
}
.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--color-cyan);
  color: var(--color-cyan);
  background-color: rgba(6, 182, 212, 0.05);
}
.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}
.btn-amber {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--color-amber);
  border-color: rgba(245, 158, 11, 0.35);
}
.btn-amber:hover {
  background-color: rgba(245, 158, 11, 0.25);
}
.btn-danger {
  background-color: var(--color-loss);
  color: #fff;
}
.btn-danger-outline {
  background-color: transparent;
  border-color: rgba(255, 51, 102, 0.4);
  color: var(--color-loss);
}
.btn-danger-outline:hover {
  background-color: rgba(255, 51, 102, 0.1);
}
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.btn-group-vertical {
  display: flex;
  flex-direction: column;
}

/* 表單控制項 */
.form-group {
  margin-bottom: 0.85rem;
}
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.form-control, .select-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  font-family: inherit;
  transition: var(--transition-fast);
}
.form-control:focus, .select-input:focus {
  outline: none;
  border-color: var(--color-cyan);
  box-shadow: 0 0 0 2px var(--color-cyan-glow);
}
.select-input {
  width: auto;
  cursor: pointer;
}
.input-group {
  display: flex;
  gap: 0.5rem;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}
.divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 1rem 0;
}

/* 表格樣式 */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.83rem;
}
.data-table th {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}
.data-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* 高密度緊湊表格樣式 (Compact Quantitative Data Table) */
.data-table.table-compact th {
  padding: 0.45rem 0.65rem;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}
.data-table.table-compact td {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.25;
}
.data-table.table-compact tr:hover {
  background-color: rgba(56, 189, 248, 0.04);
}
.pos-row-compact {
  min-height: 44px;
}

/* 持倉管理表格專屬固定比例排版 (Account Positions Table Proportional Layout) */
.positions-table {
  width: 100%;
}
.positions-table th,
.positions-table td {
  box-sizing: border-box;
}
.positions-table th.col-pos-batch,
.positions-table td.col-pos-batch {
  width: 3.5%;
  min-width: 38px;
  text-align: center;
  white-space: nowrap;
}
.positions-table th.col-pos-symbol,
.positions-table td.col-pos-symbol {
  width: 13.5%;
  min-width: 130px;
  white-space: nowrap;
}
.positions-table th.col-pos-qty,
.positions-table td.col-pos-qty {
  width: 7.5%;
  min-width: 75px;
  text-align: right;
  white-space: nowrap;
}
.positions-table th.col-pos-price,
.positions-table td.col-pos-price {
  width: 9.5%;
  min-width: 95px;
  text-align: right;
  white-space: nowrap;
}
.positions-table th.col-pos-mktval,
.positions-table td.col-pos-mktval {
  width: 10.5%;
  min-width: 105px;
  text-align: right;
  white-space: nowrap;
}
.positions-table th.col-pos-pnl,
.positions-table td.col-pos-pnl {
  width: 11.5%;
  min-width: 115px;
  text-align: right;
  white-space: nowrap;
}
.positions-table th.col-pos-risk,
.positions-table td.col-pos-risk {
  width: 25.0%;
  min-width: 240px;
}
.positions-table th.col-pos-date,
.positions-table td.col-pos-date {
  width: 8.0%;
  min-width: 95px;
  white-space: nowrap;
}
.positions-table th.col-pos-actions,
.positions-table td.col-pos-actions {
  width: 11.0%;
  min-width: 175px;
  text-align: center;
  white-space: nowrap;
}
.pos-actions-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.pos-actions-group .btn-xs {
  padding: 3px 6px;
  font-size: 0.72rem;
  line-height: 1.15;
  border-radius: 4px;
}

/* 標籤 (Horizon Badges) */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-hybrid { background-color: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-long { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-short { background-color: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-danger { background-color: rgba(244, 63, 94, 0.15); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-success { background-color: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-profit { background-color: var(--badge-profit-bg) !important; color: var(--color-profit) !important; border: 1px solid var(--badge-profit-border) !important; }
.badge-loss { background-color: var(--badge-loss-bg) !important; color: var(--color-loss) !important; border: 1px solid var(--badge-loss-border) !important; }

/* 子頁籤導航 (Subnav) */
.tab-subnav {
  display: flex;
  gap: 0.5rem;
  background-color: var(--bg-surface);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.subnav-btn {
  flex: 1;
  padding: 0.45rem 0.5rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}
.subnav-btn.active {
  background-color: var(--bg-card);
  color: var(--color-cyan);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.subnav-btn.active-buy {
  background-color: rgba(0, 230, 118, 0.15);
  color: var(--color-profit);
  font-weight: 600;
}

/* 估價看板與資訊列表 */
.order-estimate-box {
  background-color: var(--bg-surface);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.estimate-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}
.spec-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.83rem;
}
.spec-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
  padding-bottom: 0.35rem;
}
.spec-label {
  color: var(--text-muted);
}
.card-header-compact {
  padding: 0.55rem 1.15rem;
}
.card-body-compact {
  padding: 0.75rem 1.15rem;
}
.ssot-two-col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0.5rem 2.5rem;
  font-size: 0.83rem;
}
@media (max-width: 860px) {
  .ssot-two-col {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}
.ssot-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ssot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  padding-bottom: 0.35rem;
  gap: 0.75rem;
}
.ssot-row .spec-label {
  white-space: nowrap;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ssot-row .mono {
  word-break: break-all;
  white-space: normal;
  text-align: right;
}
.config-display-box {
  background-color: var(--bg-surface);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: #a5b4fc;
}

/* 規劃候選卡片樣式 */
.plan-target-card {
  background: linear-gradient(145deg, var(--bg-surface), var(--bg-card));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: var(--transition-fast);
}
.plan-target-card:hover {
  border-color: var(--color-cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.15);
}
.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.plan-card-symbol {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-cyan);
}
.plan-card-price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.8rem;
  margin: 0.5rem 0;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* 工作流步驟條 */
.workflow-steps {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.wf-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.83rem;
}
.wf-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

/* 模態視窗 (Modals) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  box-sizing: border-box;
}
.modal-overlay.active {
  display: flex;
}
.modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 520px;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text-main); }
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  background-color: rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* 任務進度條 */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--bg-surface);
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-cyan), var(--color-primary));
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--color-cyan-glow);
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.task-log-box {
  background-color: var(--bg-base);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* Toast 通知系統 */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}
.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: slideInRight 0.25s ease;
  min-width: 260px;
  max-width: 420px;
}
.toast-success { border-left: 4px solid var(--color-profit); }
.toast-error { border-left: 4px solid var(--color-loss); }
.toast-info { border-left: 4px solid var(--color-cyan); }
.toast-warning { border-left: 4px solid var(--color-amber); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* 響應式微調 */
@media (max-width: 900px) {
  .app-sidebar {
    width: 72px;
  }
  .nav-label, .nav-section-title, .brand-text, .selector-label {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 0.75rem;
  }
  .app-content {
    padding: 1rem;
  }
}

/* ==========================================================================
   安全認證閘道專用樣式 (Auth Gate & Security Styles)
   ========================================================================== */

.auth-gate-wrapper {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, #161e33 0%, #0a0d14 85%);
  padding: 1.5rem;
}

.auth-gate-card {
  width: 100%;
  max-width: 480px;
  background: rgba(19, 24, 38, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8), 0 0 50px rgba(59, 130, 246, 0.15);
  overflow: hidden;
  animation: authCardFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-gate-header {
  text-align: center;
  padding: 2.25rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
}

.auth-gate-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--color-cyan);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  font-weight: 600;
}

.auth-gate-logo {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.45));
}

.auth-gate-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.auth-gate-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.auth-gate-body {
  padding: 1.75rem 2rem;
}

.auth-gate-alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  margin-bottom: 1.25rem;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  animation: slideInDown 0.2s ease;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-gate-alert.error {
  background: rgba(255, 51, 102, 0.12);
  border: 1px solid rgba(255, 51, 102, 0.4);
  color: #ff6b8b;
}

.auth-gate-alert.info {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #38bdf8;
}

.auth-gate-alert.success {
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.4);
  color: #4ade80;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 2.75rem;
}

.btn-toggle-eye {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  opacity: 0.65;
  transition: opacity 0.2s, transform 0.15s;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
}

.btn-toggle-eye:hover {
  opacity: 1;
  transform: scale(1.1);
}

.auth-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  line-height: 1.45;
}

.auth-hint code {
  color: var(--color-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: var(--font-mono);
}

.auth-gate-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 13, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-server-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(255, 51, 102, 0.35);
  color: #ff4d79;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-outline-danger:hover {
  background: rgba(255, 51, 102, 0.15);
  border-color: var(--color-loss);
  color: #ff3366;
  box-shadow: 0 0 12px var(--color-loss-glow);
}

/* ==========================================================================
   報表與圖卡管理模組 (Reports & Visualization Hub)
   ========================================================================== */

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

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-surface);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.filter-tab.active {
  color: #ffffff;
  background-color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
}

.search-input-wrap {
  min-width: 220px;
}

.modal-dialog.modal-xl {
  max-width: 1000px;
  width: 95%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.report-preview-text {
  max-height: 68vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  background-color: #0b0f19;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.65;
  padding: 1.25rem;
  border: 1px solid var(--border-color);
}

.report-preview-iframe {
  width: 100%;
  height: 70vh;
  border: none;
  background-color: #ffffff;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.html-preview-notice {
  background: rgba(59, 130, 246, 0.12);
  border-bottom: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.65rem 1.25rem;
  font-size: 0.825rem;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.report-preview-img-container {
  height: 72vh;
  max-height: 72vh;
  position: relative;
  overflow: hidden;
  background-color: #080c14;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}

.svg-zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  background: rgba(14, 18, 27, 0.95);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

.svg-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

.svg-viewport.dragging {
  cursor: grabbing;
}

.report-preview-img {
  max-width: none;
  max-height: none;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  pointer-events: none;
  border-radius: 4px;
}

.report-preview-svg-host {
  width: 1000px;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.report-preview-svg-host svg {
  display: block;
  width: 1000px;
  height: auto;
  pointer-events: auto;
}

.badge-format {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge-format-html { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.badge-format-svg { background: rgba(0, 230, 118, 0.2); color: #4ade80; border: 1px solid rgba(0, 230, 118, 0.4); }
.badge-format-md { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-format-json { background: rgba(139, 92, 246, 0.2); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.4); }
.badge-format-text { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }

/* ==========================================================================
   帳戶績效與過往交易圖表 (Performance Analytics)
   ========================================================================== */
.perf-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.perf-stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition-fast);
  min-width: 0;
  overflow: hidden;
}

.perf-stat-card:hover {
  border-color: var(--color-cyan);
}

.perf-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.perf-stat-value {
  font-size: 0.96rem;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.perf-chart-container {
  position: relative;
  background-color: #121826;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  min-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.5rem;
}

.perf-chart-container svg {
  width: 100%;
  max-width: 900px;
  height: auto;
  display: block;
}

/* ==========================================================================
   AI 庫存趨勢診斷卡片牆 (Portfolio Advisory Cards)
   ========================================================================== */
.advisory-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.advisory-item-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.15rem;
  transition: var(--transition-fast);
}

.advisory-item-card:hover {
  border-color: var(--color-cyan);
}

.advisory-item-card.category-loss {
  border-left: 4px solid var(--color-loss);
}

.advisory-item-card.category-profit {
  border-left: 4px solid var(--color-profit);
}

.advisory-item-card.category-breakeven {
  border-left: 4px solid var(--color-amber);
}

.advisory-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.advisory-meta-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.advisory-decision-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  margin-top: 0.4rem;
}

.advisory-decision-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.advisory-remedial-text {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-main);
}

.advisory-actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

/* ==========================================================================
   隔日交易規劃 (Tab 4) 推薦卡片牆與觸價單樣式
   ========================================================================== */

.plan-card-featured {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.plan-card-featured:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.45);
}

.plan-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.plan-card-sym-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.plan-card-sym-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.plan-price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.plan-price-item {
  display: flex;
  flex-direction: column;
}

.plan-price-item .item-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.plan-price-item .item-val {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.touch-order-banner {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  color: #a7f3d0;
  margin: 0.65rem 0;
  line-height: 1.45;
}

.touch-order-banner b {
  color: #34d399;
}

/* 隔日交易規劃：資金池與部位購買力試算盒 */
.plan-capital-box {
  background: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin: 0.65rem 0;
  font-size: 0.82rem;
}

.plan-capital-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-top: 0.45rem;
}

.plan-capital-item {
  display: flex;
  flex-direction: column;
}

.plan-capital-item .cap-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.plan-capital-item .cap-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ==========================================================================
   盤後自動快軌流水線 (Tab 7) 成果摘要網格
   ========================================================================== */

.pipeline-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.pipeline-step-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.pipeline-step-card.success {
  border-left: 4px solid var(--color-profit);
}

.pipeline-step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.pipeline-step-metric {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* ==========================================================================
   帳戶資產與持倉管理 (Tab 6) 空間優化：迷你快覽條、分頁與收合手風琴
   ========================================================================== */

.cursor-pointer {
  cursor: pointer;
  user-select: none;
}

.acct-mini-kpi-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.65rem 1rem;
  background: rgba(13, 20, 35, 0.75);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.mini-kpi-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.mini-kpi-label {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.mini-kpi-val {
  font-weight: 600;
  font-size: 0.85rem;
}

.mini-kpi-item-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(10, 15, 26, 0.65);
  border-top: 1px solid var(--border-color);
  gap: 0.6rem;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pagination-size-select {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pagination-size-select select {
  height: 26px;
  padding: 2px 6px;
  background: rgba(20, 27, 45, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-size: 0.75rem;
}

.pagination-bar .btn-group .btn {
  padding: 2px 8px;
  font-size: 0.75rem;
  height: 26px;
  line-height: 20px;
}

.pagination-bar .btn-group .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* ==========================================================================
   技術 K 線與策略點位圖表模組 (klineChart Module)
   ========================================================================== */

.kline-module {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.kline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.8rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
  overflow: visible;
  position: relative;
  z-index: 50;
  gap: 0.5rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.kline-header::-webkit-scrollbar {
  height: 2px;
}

.kline-header-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.kline-header-right {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-left: auto;
}

.kline-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.kline-current-badge {
  font-size: 0.82rem;
  padding: 2px 7px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
}

.kline-sentiment-badge,
.kline-fundamental-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.2;
  transition: all 0.15s ease;
}

.hud-sentiment-item {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  line-height: 1.2;
}

.kline-pills {
  display: flex;
  gap: 4px;
  align-items: center;
}

.kline-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kline-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.kline-pill.active {
  background: #3b82f6;
  border-color: #60a5fa;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.kline-toggles {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 圖層下拉選單：將 5 個圖層開關自標題列移入，避免右側控制項過多而換行擁擠 */
.kline-layer-menu {
  position: relative;
  display: inline-flex;
}

.kline-layer-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  min-width: 165px;
  white-space: nowrap;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), 0 0 12px rgba(56, 189, 248, 0.15);
}

.kline-layer-panel[hidden] {
  display: none !important;
}

.kline-check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
  padding: 1px 0;
}

.kline-check-label input {
  accent-color: #38bdf8;
  cursor: pointer;
}

/* 圖層選單區段標題與分隔線 */
.kline-layer-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
  margin-bottom: 2px;
}

.kline-layer-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

/* 成交量均線 (VMA) 快捷微調膠囊按鈕 */
.kline-vma-pills {
  display: flex;
  gap: 4px;
}

.kline-sub-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kline-sub-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.25);
}

.kline-sub-pill.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
  font-weight: 600;
}

.hud-vma-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  margin-left: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* 十字游標跟隨浮動提示框 (Crosshair Tooltip) */
.kline-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  min-width: 210px;
  max-width: 290px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  box-shadow: 0 14px 35px -4px rgba(0, 0, 0, 0.75), 0 0 16px rgba(56, 189, 248, 0.2);
  font-size: 0.75rem;
  line-height: 1.45;
  color: #e2e8f0;
  transition: left 0.1s ease-out, opacity 0.1s ease-out;
}

.kline-tt-dock-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.3;
  cursor: pointer;
  transition: all 0.15s ease;
  pointer-events: auto;
}

.kline-tt-dock-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

.kline-tooltip .tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-weight: 600;
  color: #94a3b8;
}

.kline-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 3px;
}

.kline-tooltip .tooltip-lbl {
  color: #94a3b8;
  font-size: 0.7rem;
}

.kline-tooltip .tooltip-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
}

.kline-tooltip .tooltip-mas {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 5px;
  padding-top: 5px;
}

.kline-tooltip .tooltip-ma-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

.kline-tooltip .tooltip-signal {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  font-size: 0.7rem;
}

.kline-symbol-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.9rem;
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.kline-mode-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kline-mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.kline-mode-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.kline-mode-tab.active {
  background: rgba(14, 165, 233, 0.2);
  border-color: #0ea5e9;
  color: #38bdf8;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.35);
}

.kline-mode-tab .badge-count {
  display: inline-block;
  padding: 0 5px;
  font-size: 0.65rem;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

.kline-mode-tab.active .badge-count {
  background: #0284c7;
  color: #ffffff;
}

.kline-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.kline-subfilters {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kline-sub-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kline-sub-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.kline-sub-btn.active {
  background: #3b82f6;
  border-color: #60a5fa;
  color: #ffffff;
}

.kline-chart-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kline-search-box {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.kline-search-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  padding: 2px 6px;
  font-size: 0.72rem;
  border-radius: 4px;
  outline: none;
  width: 90px;
  transition: all 0.2s ease;
}

.kline-search-input:focus {
  width: 125px;
  border-color: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

.kline-search-btn {
  padding: 2px 7px !important;
  font-size: 0.72rem !important;
  height: 22px !important;
  line-height: 18px !important;
}

.kline-hdr-btn {
  padding: 2px 7px !important;
  font-size: 0.72rem !important;
  height: 22px !important;
  line-height: 18px !important;
  white-space: nowrap !important;
}

.kline-quick-bar {
  flex: 1;
  overflow: hidden;
}

.kline-sidebar-toggle-btn {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.kline-sidebar-toggle-btn.active {
  background: rgba(14, 165, 233, 0.2);
  border-color: #0ea5e9;
  color: #38bdf8;
}

.kline-pills-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 2px;
}

.kline-pills-wrap::-webkit-scrollbar {
  height: 4px;
}

.kline-pills-wrap::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.kline-pills-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.kline-pills-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 雙欄工作區 (主繪圖區 + 側邊標的欄) */
.kline-workspace {
  display: flex;
  position: relative;
  background: #0f172a;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  height: 520px;
  max-height: 520px; /* 嚴格限制最大高度，防止垂直撐開頁面 */
}

.kline-main-panel {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kline-hud {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap; /* 允許盤口膠囊在窄寬時自動換行，不再硬釘右緣吃掉行情列寬度 */
  align-items: center;
  gap: 0.6rem;
  container: klinehud / inline-size;
  padding: 0.35rem 0.9rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
}

/* HUD 左欄：雙行數據容器 (佔滿剩餘寬度，可收縮) */
.kline-hud-rows {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
}

.kline-hud-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem 0.65rem;
  min-width: 0;
  line-height: 1.4;
}

.kline-hud-row::-webkit-scrollbar {
  height: 2px;
}

.kline-hud-row::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.hud-item {
  color: #64748b;
  flex-shrink: 0;
  white-space: nowrap;
}

.hud-lbl {
  color: #94a3b8;
  margin-right: 2px;
}

.hud-val {
  color: #f1f5f9;
  transition: color 0.1s ease;
}

.hud-sym {
  font-weight: 700;
  color: #38bdf8;
}

.hud-time {
  color: #94a3b8;
}

/* ==========================================================================
   技術 K 線頂部微型盤口膠囊與毛玻璃 5 檔 HUD 浮動面板 (方案 B)
   ========================================================================== */
.hud-ob-capsule {
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 1px 6px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  flex: 0 0 auto; /* 寬螢幕不壓縮 chips，避免買賣價被擠成兩行 */
  min-width: 0;
}

/* 窄寬時盤口膠囊獨佔一行 (垂直堆疊於行情/均線雙行之下)，維持主圖高度不被寫死行數綁住 */
@container klinehud (max-width: 960px) {
  .hud-ob-capsule {
    flex: 1 1 100%; /* basis 100% 觸發換行，shrink 1 收斂至容器寬避免溢出 */
    margin-left: 0;
    border-radius: 6px;
    justify-content: flex-start;
  }
}

@container klinehud (max-width: 720px) {
  .hud-ob-capsule .hud-ob-tag,
  .hud-ob-capsule .chip-vol {
    display: none;
  }
}

/* 五檔顯示切換鈕 (位於頂部工具列，屬顯示開關而非週期切換) */
#btnToggleOrderBook {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

#btnToggleOrderBook.active {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: #38bdf8 !important;
  color: #e0f2fe !important;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.hud-ob-capsule:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.hud-ob-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.hud-ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  padding: 0 4px;
}

.hud-ob-chip .chip-lbl {
  color: #94a3b8;
  font-size: 0.68rem;
}

.hud-ob-chip .chip-vol {
  color: #64748b;
  font-size: 0.68rem;
}

/* 毛玻璃即時 5 檔 HUD 浮動看板 (全工作台自由拖曳與位置記憶) */
.kline-orderbook-popover {
  position: fixed;
  top: 180px;
  left: 240px;
  width: 300px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.7), 0 0 12px rgba(56, 189, 248, 0.12);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  color: #f1f5f9;
  font-size: 0.75rem;
  overflow: hidden;
  user-select: none;
  animation: obFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 僅在總覽儀表板工作台為作用中時顯示，離開總覽自動隱藏避免污染其他工作台 */
body:not(:has(#tab-overview.active)) #klineOrderBookPopover {
  display: none !important;
}

.kline-orderbook-popover.is-dragging {
  opacity: 0.96;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), 0 0 20px rgba(56, 189, 248, 0.35);
  border-color: #38bdf8;
  cursor: grabbing !important;
  transition: none !important;
}

@keyframes obFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ob-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(30, 41, 59, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  user-select: none;
}

.ob-popover-header:active {
  cursor: grabbing;
}

.ob-drag-handle {
  color: #64748b;
  font-size: 0.78rem;
  letter-spacing: -1px;
  margin-right: 2px;
  cursor: grab;
}

.ob-header-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.ob-title-sym {
  font-weight: 700;
  color: #e2e8f0;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}

.ob-title-tag {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-weight: 600;
  flex-shrink: 0;
}

.ob-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ob-status-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ob-status-badge.open {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.ob-status-badge.closed {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

.ob-icon-btn, .ob-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s ease;
}

.ob-icon-btn:hover {
  color: #38bdf8;
  background: rgba(255, 255, 255, 0.06);
}

.ob-close-btn:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.ob-popover-body {
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ob-table-header {
  display: grid;
  grid-template-columns: 46px 1fr 60px;
  padding: 2px 6px;
  font-size: 0.68rem;
  color: #64748b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ob-col-side { text-align: left; }
.ob-col-price { text-align: center; }
.ob-col-vol { text-align: right; }

.ob-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ob-empty-tip {
  text-align: center;
  padding: 8px 0;
  color: #64748b;
  font-size: 0.7rem;
}

.ob-row {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr 60px;
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 0.72rem;
  line-height: 1.2;
}

.ob-row:hover {
  background: rgba(255, 255, 255, 0.08);
  outline: 1px solid rgba(56, 189, 248, 0.4);
}

.ob-bar-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  pointer-events: none;
  opacity: 0.22;
  border-radius: 2px;
  transition: width 0.25s ease-out;
}

.ask-bar {
  background: linear-gradient(90deg, transparent, #ef4444);
}

.bid-bar {
  background: linear-gradient(90deg, transparent, #10b981);
}

.ob-spread-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  margin: 2px 0;
  background: rgba(30, 41, 59, 0.85);
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.ob-last-price-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.ob-last-price-box .ob-lbl {
  font-size: 0.65rem;
  color: #94a3b8;
}

.ob-last-price-box .ob-price {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
}

.ob-spread-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
}

.ob-spread-info .ob-lbl {
  color: #64748b;
}

.ob-spread-info .ob-spread {
  color: #cbd5e1;
}

.ob-power-bar-wrap {
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ob-power-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  margin-bottom: 3px;
}

.ob-bid-power-txt { color: #10b981; }
.ob-ask-power-txt { color: #ef4444; }

.ob-power-progress {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: #334155;
}

.ob-power-bid-bar {
  background: #10b981;
  transition: width 0.3s ease;
}

.ob-power-ask-bar {
  background: #ef4444;
  transition: width 0.3s ease;
}

.ob-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 0.65rem;
  color: #64748b;
  background: rgba(30, 41, 59, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ob-footer-hint {
  color: #94a3b8;
}

.ob-footer-time {
  font-family: monospace;
}

.kline-canvas-box {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  background: #0f172a;
  overflow: hidden;
}

.kline-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ==========================================================================
   技術 K 線行情加載與自動補全動態遮罩 (Kline Loading & Backfilling Overlay)
   ========================================================================== */
.kline-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  animation: fadeInFast 0.15s ease-out;
}

.kline-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  background: rgba(24, 32, 50, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), 0 0 20px rgba(14, 165, 233, 0.25);
  text-align: center;
  max-width: 320px;
}

.kline-loading-spinner-ring {
  position: relative;
  width: 34px;
  height: 34px;
}

.kline-spinner-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.15);
  border-top-color: #38bdf8;
  border-right-color: #00e676;
  animation: kline-spin 0.8s linear infinite;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.kline-loading-text {
  font-size: 0.86rem;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: 0.3px;
}

.kline-loading-subtext {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.35;
}

@keyframes kline-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeInFast {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* 週期按鈕切換載入中微動態 */
.kline-pill.loading-pill {
  position: relative;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
  animation: pulse-fast 0.6s infinite alternate;
}

/* 右側標的導覽側邊欄 (Side Target Watchlist) */
.kline-sidebar {
  position: relative;
  min-width: 260px;
  max-width: 650px;
  flex-shrink: 0;
  height: 100%;
  max-height: 520px; /* 嚴格限制側邊欄最大高度，與畫布高度一致 */
  background: rgba(13, 20, 36, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease;
  overflow: hidden;
}

.kline-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  opacity: 0;
  pointer-events: none;
  border-left: none;
}

/* 側邊欄手動拖曳調整寬度手柄 (Resize Handle) */
.kline-sidebar-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s ease;
}

.kline-sidebar-resizer::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 36px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.15s ease;
}

.kline-sidebar-resizer:hover,
.kline-sidebar.resizing .kline-sidebar-resizer {
  background: rgba(14, 165, 233, 0.25);
}

.kline-sidebar-resizer:hover::after,
.kline-sidebar.resizing .kline-sidebar-resizer::after {
  background: #38bdf8;
  height: 48px;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

body.kline-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.kline-sidebar.resizing {
  transition: none !important;
}

.kline-sidebar-header {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* 側邊欄頂部頁籤欄 */
.sidebar-tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.kline-side-nav-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  /* 頁籤由 3 個擴充為 5 個 (標的池/圖卡/推薦/持倉/計劃)，可自動換行 */
  flex-wrap: wrap;
}

.kline-side-tab {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.kline-side-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.kline-side-tab.active {
  background: rgba(14, 165, 233, 0.2);
  border-color: #0ea5e9;
  color: #38bdf8;
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.3);
}

.sidebar-search-row {
  width: 100%;
}

.kline-sidebar-filter {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #f1f5f9;
  font-size: 0.74rem;
  padding: 3px 8px;
  outline: none;
  transition: border-color 0.15s ease;
}

.kline-sidebar-filter:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.3);
}

.sidebar-subfilters {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.sidebar-sub-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-sub-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-sub-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.kline-sidebar-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kline-sidebar-list::-webkit-scrollbar {
  width: 4px;
}
.kline-sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.sidebar-empty-tip {
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
}

/* 標的項目 (自適換行至多 3 行) */
.kline-sidebar-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.12s ease;
  user-select: none;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.015);
  flex-shrink: 0; /* 關鍵：絕對不可被 flex 父容器高度壓縮！ */
  box-sizing: border-box;
  height: auto;
  min-height: auto;
  max-height: none;
  overflow: visible;
}

.kline-sidebar-item.single-line {
  min-height: 29px;
  padding: 4px 8px;
}

.kline-sidebar-item.has-details {
  min-height: 52px;
  padding: 5px 8px;
}

.kline-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.kline-sidebar-item.active {
  background: rgba(14, 165, 233, 0.18);
  border-color: #0ea5e9;
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.25);
}

.side-item-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  flex-wrap: wrap;
}

.side-item-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  font-size: 0.7rem;
  line-height: 1.35;
  box-sizing: border-box;
  min-width: 0;
  flex-wrap: wrap;
}

.side-item-bias-row {
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  gap: 4px !important;
  margin-top: 2px;
}

.side-item-muted-row {
  color: #94a3b8;
  font-size: 0.67rem;
  margin-top: 2px;
}

.side-item-fund-row {
  margin-top: 3px;
  padding: 1px 2px;
  font-size: 0.7rem;
  line-height: 1.3;
  box-sizing: border-box;
  min-width: 0;
  transition: background var(--transition-fast);
}
.side-item-fund-row:hover {
  background: rgba(56, 189, 248, 0.07);
  border-radius: 3px;
}

.side-item-meta {
  color: #94a3b8;
  font-size: 0.68rem;
  white-space: nowrap;
}

.side-item-reason {
  color: #cbd5e1;
  font-size: 0.67rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-item-note {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
  color: #e2e8f0;
}

/* 🌟 精選推薦卡片 (高資訊密度排版，對齊 Tab 4) */
.kline-sidebar-item.recommended-card,
.kline-sidebar-item.plan-card,
.kline-sidebar-item.position-card {
  height: auto;
  max-height: none;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(245, 158, 11, 0.22);
  padding: 6px 8px;
  gap: 4px;
}

.kline-sidebar-item.plan-card {
  border-color: rgba(56, 189, 248, 0.22);
}

.kline-sidebar-item.position-card {
  border-color: rgba(16, 185, 129, 0.22);
}

.kline-sidebar-item.recommended-card:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(245, 158, 11, 0.45);
}

.kline-sidebar-item.recommended-card.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}

.side-rec-badge-sentiment {
  font-size: 0.64rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.side-rec-badge-level {
  font-size: 0.64rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.side-rec-prices-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.67rem;
  width: 100%;
  box-sizing: border-box;
}

.side-rec-price-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
}

.side-rec-touch-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.67rem;
  color: #34d399;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.side-item-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
  flex-wrap: wrap;
}

.side-item-sym {
  color: #38bdf8;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.kline-sidebar-item.active .side-item-sym {
  color: #7dd3fc;
}

.side-item-name {
  color: #cbd5e1;
  font-size: 0.72rem;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-item-tag {
  font-size: 0.62rem;
  padding: 0 4px;
  border-radius: 2px;
  white-space: nowrap;
}

.tag-gray {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.tag-gold {
  background: rgba(234, 179, 8, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.tag-blue {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-amber {
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.tag-cyan {
  background: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* 策略審核通過 / 未達標標籤 */
.tag-pass {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tag-fail {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* 圖卡清單高權重判斷膠囊標籤 (位階評級、AI多空力道等) */
.side-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.63rem;
  line-height: 1.25;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}

/* 位階評級膠囊：自適應吃滿整行剩餘寬度，側邊欄拉寬時完全展開 */
.side-badge-pill.pill-level {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

/* AI多空評級膠囊：固定寬度不折行、不壓縮 */
.side-badge-pill.pill-sentiment {
  flex: 0 0 auto;
}

/* 持倉標籤 (綠) */
.tag-emerald {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* 側邊欄未實現損益數值 (紅漲綠跌 / 台盤) */
.side-item-pnl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
}

.side-item-pnl.text-up {
  color: var(--color-profit) !important;
}

.side-item-pnl.text-down {
  color: var(--color-loss) !important;
}

/* 側邊欄交易計劃股數 */
.side-item-qty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  color: #94a3b8;
  white-space: nowrap;
}

.side-item-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.side-item-price {
  font-size: 0.72rem;
  color: #94a3b8;
}

.btn-side-svg {
  padding: 1px 4px !important;
  font-size: 0.75rem !important;
  line-height: 1 !important;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.btn-side-svg:hover {
  opacity: 1;
  transform: scale(1.1);
}

.kline-sidebar-footer {
  padding: 0.45rem 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
}

/* 側邊欄委託計畫快捷審核操作列 */
.side-plan-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  width: 100%;
}

.btn-side-plan-action {
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  line-height: 1.2 !important;
}

.btn-side-plan-approve {
  background: rgba(16, 185, 129, 0.2) !important;
  border: 1px solid rgba(16, 185, 129, 0.5) !important;
  color: #34d399 !important;
}

.btn-side-plan-approve:hover {
  background: #059669 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
}

.btn-side-plan-reject {
  background: rgba(244, 63, 94, 0.12) !important;
  border: 1px solid rgba(244, 63, 94, 0.4) !important;
  color: #fb7185 !important;
}

.btn-side-plan-reject:hover {
  background: #e11d48 !important;
  color: #ffffff !important;
  border-color: #f43f5e !important;
}

/* ============================================================================
 * ☕ [杯柄策略] 佈局切換與微調專屬美學樣式 (Cup and Handle Strategy UI)
 * ============================================================================ */

.modal-dialog.modal-lg {
  max-width: 820px;
  width: 95%;
}

.ch-summary-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.ch-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ch-summary-label {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ch-section {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.9rem;
}

.ch-section-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ch-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.ch-toggle-card {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ch-toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ch-toggle-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
}

.ch-toggle-desc {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.4;
  margin: 0;
}

/* 專業深色 Switch Toggle 開關 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
  background-color: #f59e0b;
  border-color: #d97706;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* 三階梯加碼動態權重進度條 */
.ch-weights-bar-container {
  display: flex;
  width: 100%;
  height: 22px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.ch-weight-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  color: #ffffff;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.bar-s1 {
  background: linear-gradient(90deg, #059669 0%, #10b981 100%);
}

.bar-s2 {
  background: linear-gradient(90deg, #0284c7 0%, #0ea5e9 100%);
}

.bar-s3 {
  background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}

/* 三階梯卡片 */
.three-col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.ch-stage-card {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ch-stage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ch-stage-name {
  font-size: 0.78rem;
  font-weight: 600;
}

/* 幾何微調容器 */
.ch-geometry-container {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.75rem;
}

/* 持倉表格中的杯柄標籤與按鈕樣式 */
.badge-ch-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  margin-left: 4px;
}

.badge-ch-tag:hover {
  background: rgba(245, 158, 11, 0.32);
  border-color: #f59e0b;
  color: #fef08a;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.btn-ch-active {
  background: rgba(245, 158, 11, 0.2) !important;
  border: 1px solid #f59e0b !important;
  color: #fbbf24 !important;
  font-weight: 600 !important;
}

.btn-ch-active:hover {
  background: #f59e0b !important;
  color: #0f172a !important;
}

.kline-ch-btn {
  background: rgba(245, 158, 11, 0.15) !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  color: #fbbf24 !important;
  font-weight: 600 !important;
  transition: all 0.15s ease;
}

.kline-ch-btn:hover {
  background: #f59e0b !important;
  color: #0f172a !important;
}

/* 🤖 AI 多因子杯柄風險評估與達成機率卡片 */
.ch-ai-eval-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.65) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.9rem;
  margin-bottom: 1.2rem;
  position: relative;
  overflow: hidden;
}

.ch-ai-eval-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #38bdf8 0%, #10b981 100%);
}

.ch-ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ch-ai-title {
  font-size: 0.85rem;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.ch-ai-prob-row {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 0.75rem;
}

.ch-ai-prob-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.ch-ai-prob-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #10b981 0%, #38bdf8 100%);
  transition: width 0.5s ease-out;
}

.ch-ai-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ch-ai-metric-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ch-ai-metric-label {
  font-size: 0.68rem;
  color: #94a3b8;
}

.ch-ai-metric-val {
  font-size: 0.82rem;
  font-weight: 700;
}

.ch-ai-factor-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.ch-ai-advice-box {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.3);
  border-radius: 6px;
  color: #e0f2fe;
}

.ch-ai-advice-icon {
  font-size: 1rem;
  line-height: 1.2;
}

.ch-ai-advice-text {
  line-height: 1.45;
  color: #bae6fd;
}

/* ==========================================================================
   通用行動下拉折疊工具 (Action Dropdown)
   ========================================================================== */
.action-dropdown {
  position: relative;
  display: inline-block;
}

.action-dropdown summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.action-dropdown summary::-webkit-details-marker {
  display: none;
}

.action-dropdown summary:focus {
  outline: none;
}

.action-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 250px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
  padding: 6px;
  z-index: 1000;
  animation: fadeInDown 0.15s ease-out;
}

.action-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.82rem;
  font-family: inherit;
}

.action-dropdown .dropdown-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-cyan);
}

.action-dropdown .dropdown-item .item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.action-dropdown .dropdown-item .item-text {
  display: flex;
  flex-direction: column;
}

.action-dropdown .dropdown-item .item-text b {
  font-size: 0.82rem;
  line-height: 1.25;
}

.action-dropdown .dropdown-item .item-text small {
  font-size: 0.7rem;
  margin-top: 2px;
  line-height: 1.2;
}

.action-dropdown .dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

.action-dropdown .dropdown-header {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 10px 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   系統狀態備份還原模式選擇卡片 (Restore State Option Cards)
   ========================================================================== */
.restore-option-card:hover {
  border-color: rgba(6, 182, 212, 0.6) !important;
  background-color: rgba(6, 182, 212, 0.04) !important;
}

/* ==========================================================================
   帳戶專屬黑天鵝與極端避險策略配置樣式 (Account Strategy Overrides)
   ========================================================================== */
.strategy-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.strat-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}

.strat-card:hover {
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.strat-card.strat-active {
  border-left: 3px solid #10b981;
}

.strat-card.strat-disabled {
  opacity: 0.75;
  border-left: 3px solid #64748b;
}

.strat-card.strat-custom {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, rgba(15, 23, 42, 0.8) 100%);
  border-color: rgba(245, 158, 11, 0.3);
}

.strat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.strat-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 0.85rem 0;
  flex-grow: 1;
}

.strat-specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 8px 10px;
}

.spec-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spec-k {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.spec-v {
  font-size: 0.82rem;
}

.strat-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
  gap: 6px;
}

/* ==========================================================================
   認售權證極端避險雷達模組 (Warrant Radar & Black Swan Hedge)
   ========================================================================== */

.warrant-pills-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

.warrant-target-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: inherit;
}

.warrant-target-pill:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.warrant-target-pill.pill-active {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--color-primary, #38bdf8);
  box-shadow: 0 0 0 1px var(--color-primary, #38bdf8), 0 2px 10px rgba(56, 189, 248, 0.2);
}

.warrant-target-pill .pill-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.warrant-target-pill .pill-sym {
  font-size: 0.95rem;
  color: var(--color-primary, #38bdf8);
}

.warrant-target-pill .pill-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.warrant-target-pill .pill-cat {
  margin-left: auto;
  font-size: 0.72rem;
}

.warrant-target-pill .pill-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 0.25rem;
}

.warrant-target-pill .pill-price {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-white, #fff);
}

/* 緊湊型權證表格與雷達樣式 */
.warrant-table th,
.warrant-table td {
  padding: 0.45rem 0.6rem !important;
  font-size: 0.82rem;
}

.warrant-card-compact {
  padding: 0.75rem 1rem !important;
}

.warrant-toggle-header {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.warrant-toggle-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* 權證表格欄位表頭 Tooltip 與微提示樣式 */
.warrant-th-tip {
  cursor: help;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
}

.warrant-th-tip:hover {
  color: var(--primary, #3b82f6);
  border-bottom-color: var(--primary, #3b82f6);
}

.warrant-th-tip .tip-icon {
  font-size: 0.68rem;
  opacity: 0.65;
  margin-left: 2px;
}

/* 權證表格點擊排序表頭樣式 */
.warrant-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.warrant-table th.sortable:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--primary, #3b82f6);
}

.warrant-sort-arrow {
  display: inline-block;
  margin-left: 3px;
  font-size: 0.65rem;
  opacity: 0.4;
  vertical-align: middle;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.warrant-sort-arrow.active {
  opacity: 1;
  color: var(--primary, #3b82f6);
  font-weight: bold;
}

/* ==========================================================================
   緊湊模式、折疊收合 (Accordion/Collapse) 與多維工具列強化
   ========================================================================== */

/* 折疊收合面板 (Collapse Card) */
details.collapse-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 1rem;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
details.collapse-card[open] {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
details.collapse-card > summary {
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  transition: background 0.15s ease;
}
details.collapse-card > summary::-webkit-details-marker {
  display: none;
}
details.collapse-card > summary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-cyan);
}
details.collapse-card > summary::after {
  content: '▾';
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
details.collapse-card[open] > summary::after {
  transform: rotate(180deg);
  color: var(--color-cyan);
}
details.collapse-card > .collapse-body {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  animation: fadeIn 0.2s ease;
}

/* 緊湊按鈕小群組 */
.btn-group-compact {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}
.btn-group-compact .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-color);
  padding: 4px 10px;
  font-size: 0.78rem;
  height: 28px;
}
.btn-group-compact .btn:last-child {
  border-right: none;
}

/* 緊湊表單控制列 */
.scan-filter-toolbar {
  transition: background 0.2s ease;
}
.scan-filter-toolbar:focus-within {
  background: rgba(15, 23, 42, 0.65) !important;
}

/* ==========================================================================
   工作台頂部子分頁導航條 (Hub Segmented Subnav Bar)
   ========================================================================== */
.hub-subnav-bar {
  display: inline-flex;
  align-items: center;
  background: rgba(10, 15, 26, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
  margin-bottom: 1.15rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-wrap: wrap;
}

.hub-subnav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.hub-subnav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.hub-subnav-item.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(59, 130, 246, 0.28));
  color: #fff;
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   核心組態管理器 (Config Studio)
   ========================================================================== */
.config-studio-card {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.config-file-pills {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.config-file-pill {
  padding: 4px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  cursor: pointer;
  transition: all 0.15s ease;
}

.config-file-pill:hover {
  color: var(--text-main);
  border-color: var(--color-cyan);
}

.config-file-pill.active {
  background: rgba(6, 182, 212, 0.18);
  color: var(--color-cyan);
  border-color: rgba(6, 182, 212, 0.5);
  font-weight: 600;
}

.yaml-editor-textarea {
  width: 100%;
  min-height: 380px;
  max-height: 600px;
  background: #080d1a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 1rem;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
  outline: none;
  transition: border-color 0.15s ease;
}

.yaml-editor-textarea:focus {
  border-color: var(--color-cyan);
  box-shadow: 0 0 0 2px var(--color-cyan-glow);
}

.yaml-editor-textarea[readonly] {
  background: #060a14;
  color: #94a3b8;
  cursor: default;
}

/* ==========================================================================
   SQLite 資料表標籤與 Tooltip 提示系統
   ========================================================================== */

/* SQLite 資料表標籤 (DB Table Tag) */
.db-table-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--color-cyan, #06b6d4);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-weight: 500;
  vertical-align: middle;
  cursor: help;
  line-height: 1.4;
  white-space: nowrap;
}

.db-table-tag:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.6);
  color: #38bdf8;
}

/* 通用提示小圖標 (UI Tooltip Icon) */
.ui-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: help;
  opacity: 0.75;
  margin-left: 4px;
  transition: opacity 0.15s ease, color 0.15s ease;
  vertical-align: middle;
}

.ui-tip:hover {
  opacity: 1;
  color: var(--color-cyan);
}

/* 下拉選單安全內距與高度修正（徹底解決文字垂直置中與上下被切斷問題） */
select.form-control,
select.select-input {
  min-height: 36px !important;
  height: 36px !important;
  padding: 4px 28px 4px 10px !important;
  line-height: normal !important;
  font-size: 0.82rem !important;
  box-sizing: border-box !important;
  vertical-align: middle;
}







/* ==========================================================================
   ROIC 護城河色彩分級精簡懸浮提示卡 (Rich Floating Tooltip) 與標的池參考數據標籤
   ========================================================================== */
.roic-floating-tooltip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  min-width: 265px;
  max-width: 340px;
  padding: 9px 12px;
  background: rgba(10, 16, 30, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.72), 0 0 14px rgba(16, 185, 129, 0.16);
  font-size: 0.75rem;
  line-height: 1.5;
  color: #e2e8f0;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.roic-floating-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.roic-tip-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 5px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
  font-size: 0.78rem;
}

.roic-tip-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 0.73rem;
}

.roic-tip-lbl {
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}

.roic-tip-foot {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  color: #64748b;
  font-size: 0.68rem;
}

.pool-sub-tag {
  display: inline-block;
  font-size: 0.66rem;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.22);
  margin-left: 4px;
  vertical-align: middle;
}

.pool-metric-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}

.pool-metric-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.73rem;
}

/* 🛡️ 階梯式風控防線盒 (自適應折行、零水平卷軸、高度自動撐開) */
.side-item-ladder {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 4px !important;
  margin-top: 2px !important;
  font-size: 10.5px !important;
  line-height: 1.4 !important;
  background: rgba(15, 23, 42, 0.5) !important;
  border: 1px solid rgba(56, 189, 248, 0.15) !important;
  border-radius: 4px !important;
  padding: 3px 6px !important;
  overflow: visible !important;
  white-space: normal !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.side-item-ladder-tag {
  color: #38bdf8;
  font-weight: 700;
  margin-right: 2px;
  flex-shrink: 0;
}

.side-item-ladder-pill {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
}

.side-item-ladder-arrow {
  color: #64748b;
  font-size: 9px;
  margin: 0 1px;
}

/* ==========================================================================
   審核中心精美與緊湊樣式 (Trade Plan Review Gate Polish)
   ========================================================================== */

.btn-success {
  background-color: #10b981;
  color: #ffffff;
  border: 1px solid #059669;
}
.btn-success:hover {
  background-color: #059669;
}
.btn-outline-success {
  background-color: transparent;
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #10b981;
}
.btn-outline-success:hover {
  background-color: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #34d399;
}
.btn-cyan-outline {
  background-color: transparent;
  border: 1px solid rgba(6, 182, 212, 0.45);
  color: var(--color-cyan);
}
.btn-cyan-outline:hover {
  background-color: rgba(6, 182, 212, 0.15);
  border-color: var(--color-cyan);
  color: #22d3ee;
}

.plan-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(10, 15, 26, 0.75);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.plan-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.plan-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.plan-tab-btn.active {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.4);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.plan-tab-btn#btnPlanReviewPending.active {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.plan-tab-btn#btnPlanReviewExecuted.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.plan-tab-btn#btnPlanReviewRejected.active {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.plan-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-weight: 700;
}

.plan-filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: rgba(13, 18, 30, 0.9);
  border-bottom: 1px solid var(--border-color);
  gap: 0.5rem;
}

.plan-filter-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 1;
}

.plan-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.plan-filter-select {
  height: 28px;
  padding: 2px 8px;
  background: rgba(20, 27, 45, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-size: 0.76rem;
  cursor: pointer;
  outline: none;
}

.plan-filter-select:focus {
  border-color: var(--color-cyan);
}

.plan-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 210px;
  max-width: 360px;
  flex: 1;
}

.plan-search-icon {
  position: absolute;
  left: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  pointer-events: none;
}

.plan-filter-input {
  width: 100%;
  height: 28px;
  padding: 2px 24px 2px 26px;
  background: rgba(20, 27, 45, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-size: 0.76rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.plan-filter-input:focus {
  border-color: var(--color-cyan);
  box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.25);
}

.plan-search-clear {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

.plan-search-clear:hover {
  color: var(--text-main);
}

/* 緊湊審核表格 */
.table-review-gate {
  border-collapse: collapse;
}

.table-review-gate th {
  padding: 0.45rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(10, 15, 26, 0.85);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  white-space: nowrap;
}

.table-review-gate td {
  padding: 0.42rem 0.65rem;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.table-review-gate tr:hover td {
  background: rgba(56, 189, 248, 0.035);
}

.review-pid {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.review-pid:hover {
  color: var(--color-cyan);
  border-color: rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.1);
}

.review-pid-prefix {
  color: #64748b;
}

.review-account-tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  white-space: nowrap;
}

.review-stock-box {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.review-stock-name {
  font-weight: 600;
  font-size: 0.84rem;
  color: #f1f5f9 !important;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dotted rgba(56, 189, 248, 0.6);
  transition: color var(--transition-fast);
}

.review-stock-name:hover {
  color: var(--color-cyan) !important;
  border-bottom-color: var(--color-cyan);
}

.review-stock-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94a3b8;
}

.btn-chart-mini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  font-size: 0.7rem;
  line-height: 1.2;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--color-cyan);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-chart-mini:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--color-cyan);
}

.review-warrant-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  cursor: pointer;
}

.sl-tp-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  white-space: nowrap;
}

.sl-text {
  color: var(--color-loss);
  font-weight: 600;
}

.tp-text {
  color: var(--color-profit);
  font-weight: 600;
}

.review-time-wrap {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.review-time-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.reason-box {
  max-width: 380px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
  word-break: break-all;
}

.reason-box.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.reason-box.collapsed:hover {
  color: var(--text-main);
}

.reason-chip {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-right: 3px;
  line-height: 1.25;
  vertical-align: baseline;
  white-space: nowrap;
}

.reason-chip-boll {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
}

.reason-chip-strategy {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

.reason-chip-pick {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.reason-chip-expired {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.reason-chip-signal {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: #22d3ee;
}

.reason-chip-rejected {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.review-actions-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   統一乖離率標籤樣式 (Standardized Bias Pill Badges)
   [委託(乖)] / [目標(乖)] / [防守(乖)] / [短均(乖)] / [年線(乖)]
   ========================================================================== */
.bias-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
  letter-spacing: -0.01em;
}

/* 目標(乖) - 預期獲利空間 (自動對齊台盤/國際盤動態盈利色) */
.bias-pill.bias-tp {
  background: var(--badge-profit-bg, rgba(239, 68, 68, 0.15));
  border: 1px solid var(--badge-profit-border, rgba(239, 68, 68, 0.35));
  color: var(--color-profit, #ef4444);
}

/* 防守(乖) - 下檔停損防守緩衝 (自動對齊台盤/國際盤動態防守色) */
.bias-pill.bias-sl {
  background: var(--badge-loss-bg, rgba(16, 185, 129, 0.15));
  border: 1px solid var(--badge-loss-border, rgba(16, 185, 129, 0.35));
  color: var(--color-loss, #10b981);
}

/* 委託(乖) - 現價緊貼委託價 (甜蜜買點) */
.bias-pill.bias-near {
  background: rgba(6, 182, 212, 0.18);
  border: 1px solid rgba(6, 182, 212, 0.45);
  color: #22d3ee;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.2);
}

/* 委託(乖) - 現價偏離/追高警示 */
.bias-pill.bias-warn {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

/* 委託(乖) - 中性常規 */
.bias-pill.bias-neutral {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

/* 短均(乖) / 年線(乖) - 均線位階 */
.bias-pill.bias-ma {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.bias-pill.bias-ma-near {
  background: rgba(234, 179, 8, 0.2);
  border: 1px solid rgba(234, 179, 8, 0.5);
  color: #facc15;
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.25);
}

/* 動停(乖) - 動態鎖利 */
.bias-pill.bias-trailing {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
}

/* ==========================================================================
   策略訊號與混合權重階梯 (Strategy Signals & Weight Ladder Flow)
   ========================================================================== */
.strat-signals-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.35;
}

.strat-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
  cursor: help;
  letter-spacing: -0.01em;
  transition: var(--transition-fast);
}

/* 主策略色彩階梯 */
.strat-pill.strat-ma {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.strat-pill.strat-boll {
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(14, 165, 233, 0.45);
  color: #38bdf8;
}

.strat-pill.strat-bias {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #f87171;
}

.strat-pill.strat-box {
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #c084fc;
}

.strat-pill.strat-annual {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.strat-pill.strat-cup {
  background: rgba(249, 115, 22, 0.18);
  border: 1px solid rgba(249, 115, 22, 0.45);
  color: #fb923c;
}

.strat-pill.strat-twin {
  background: rgba(236, 72, 153, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.45);
  color: #f472b6;
}

.strat-pill.strat-pick {
  background: rgba(6, 182, 212, 0.18);
  border: 1px solid rgba(6, 182, 212, 0.45);
  color: #22d3ee;
}

/* 因子加成色彩 */
.strat-pill.boost-roic {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.strat-pill.boost-tech {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

/* 混合權重階梯色彩 */
.strat-pill.weight-active {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
}

.strat-pill.weight-caution {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.strat-pill-arrow {
  color: var(--text-muted);
  font-size: 0.72rem;
  user-select: none;
  margin: 0 1px;
}

.strat-pill.weight-watermark {
  background: rgba(6, 182, 212, 0.22);
  border: 1px solid rgba(6, 182, 212, 0.5);
  color: #22d3ee;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.25);
  font-weight: 700;
}
