/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:    #0d1117;
  --bg-panel:   #161b22;
  --bg-card:    #21262d;
  --bg-hover:   #2d333b;
  --border:     #30363d;
  --text-prime: #e6edf3;
  --text-mute:  #ffffff;     /* V185: 改純白 */
  --text-dim:   #ffffff;     /* V184: 改白色 */
  --accent:     #58a6ff;
  --green:      #3fb950;
  --green-dim:  #1a4a23;
  --red:        #f85149;
  --red-dim:    #4a1a1a;
  --yellow:     #d29922;
  --purple:     #bc8cff;
  --font:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
  --radius:     8px;
  --radius-sm:  4px;
  --shadow:     0 4px 16px rgba(0,0,0,.4);
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-prime);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 240px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────── */
.header {
  grid-area: header;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  z-index: 10;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.header__brand-icon { font-size: 22px; }

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

/* ── Mode Badge ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.badge--sim  { background: rgba(88,166,255,.15); color: var(--accent); border: 1px solid rgba(88,166,255,.3); }
.badge--live { background: rgba(248,81,73,.15);  color: var(--red);    border: 1px solid rgba(248,81,73,.3); }
.badge--stopped { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); animation: pulse 1.2s infinite; }

.badge__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Connection Status ────────────────────────────────── */
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mute);
}

.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background .3s;
}

.conn-dot--on  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.conn-dot--off { background: var(--red); }

/* ── Emergency Stop Button ────────────────────────────── */
.btn-stop {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}

.btn-stop:hover  { background: rgba(248,81,73,.3); }
.btn-stop:active { transform: scale(.97); }
.btn-stop:disabled { opacity: .4; cursor: not-allowed; }

.btn-resume {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}

.btn-resume:hover { background: rgba(63,185,80,.25); }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

.nav-section {
  padding: 0 12px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-mute);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 8px;
  transition: background .15s, color .15s;
  font-size: 13px;
}

.nav-item:hover  { background: var(--bg-hover); color: var(--text-prime); }
.nav-item.active { background: rgba(88,166,255,.12); color: var(--accent); }
.nav-item__icon  { font-size: 16px; width: 20px; text-align: center; }

/* ── Main Content ─────────────────────────────────────── */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Page Title ───────────────────────────────────────── */
.page-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-subtitle { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ── Grid Layouts ─────────────────────────────────────── */
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
/* V127+ 全域把淡色次要文字改為白色（易讀）*/
.grid-stats .stat-card__sub,
.grid-stats .stat-card__change,
.page-subtitle {
  color: #fff !important;
}

/* V126+ 統計卡：強制水平一排（用 flex + overflow-x auto 防擠壓）*/
.grid-stats {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  width: 100% !important;
  overflow-x: auto;
}
.grid-stats > .stat-card {
  flex: 1 1 0 !important;
  min-width: 120px !important;
  padding: 10px 12px !important;
  box-sizing: border-box !important;
}
.grid-stats .stat-card__label { font-size: 10px !important; letter-spacing: .3px !important; }
.grid-stats .stat-card__value { font-size: 22px !important; margin: 2px 0 !important; line-height: 1.15 !important; }
.grid-stats .stat-card__sub   { font-size: 10px !important; }
.grid-stats .stat-card__change { font-size: 11px !important; }
/* 窄螢幕換行 */
@media (max-width: 900px) {
  .grid-stats { flex-wrap: wrap !important; }
  .grid-stats > .stat-card { flex: 1 1 45% !important; }
}
.stat-card--win     { border-left: 3px solid var(--green); background: rgba(38,208,124,.05); }
.stat-card--loss    { border-left: 3px solid var(--red);   background: rgba(255,92,92,.05); }
.stat-card--winrate { border-left: 3px solid var(--accent); background: rgba(90,167,255,.05); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid-chart { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }

/* ── Stat Card ────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card__label {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}

.stat-card__value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -.5px;
}

.stat-card__sub {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
}

.stat-card__change {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Panel ────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.panel__header-left { display: flex; align-items: center; gap: 8px; }
.panel__icon { font-size: 16px; }
.panel__body { padding: 0; }

/* ── Table ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-panel);
  color: var(--text-mute);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

td {
  padding: 10px 16px;
  vertical-align: middle;
  white-space: nowrap;
}

.td-mono { font-family: var(--mono); font-size: 12px; }

/* ── Colour helpers ───────────────────────────────────── */
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-mute); }
.accent   { color: var(--accent); }

/* ── Signal Badge ─────────────────────────────────────── */
.sig {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.sig--buy    { background: var(--green-dim); color: var(--green); }
.sig--sell   { background: var(--red-dim);   color: var(--red); }
.sig--hold   { background: rgba(139,148,158,.15); color: var(--text-mute); }
.sig--strong { outline: 1px solid currentColor; }

/* ── Price Ticker Row ─────────────────────────────────── */
.ticker-symbol { font-weight: 700; color: var(--text-prime); }
.ticker-price  { font-family: var(--mono); font-weight: 600; }

.ex-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  line-height: 1.6;
  margin-left: 4px;
}
.ex-badge--binance { background: rgba(240,185,11,.15); color: #F0B90B; border: 1px solid rgba(240,185,11,.35); }
.ex-badge--htx     { background: rgba(0,210,168,.15);  color: #00D2A8; border: 1px solid rgba(0,210,168,.35); }

/* ── Chart Container ──────────────────────────────────── */
#chart-container {
  height: 320px;
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 13px;
  flex-direction: column;
  gap: 8px;
}

.chart-placeholder-icon { font-size: 36px; opacity: .3; }

/* ── Positions Panel ──────────────────────────────────── */
.position-row td:first-child { font-weight: 700; }
.no-data { text-align: center; padding: 32px; color: var(--text-dim); font-size: 13px; }

/* ── Refresh info ─────────────────────────────────────── */
.refresh-info {
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Toast ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  min-width: 220px;
  box-shadow: var(--shadow);
  animation: slide-in .2s ease;
}

.toast--success { border-left-color: var(--green); }
.toast--error   { border-left-color: var(--red); }
.toast--warn    { border-left-color: var(--yellow); }

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

/* ── Settings Page ────────────────────────────────────── */
.settings-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(210,153,34,.08);
  border: 1px solid rgba(210,153,34,.3);
  border-left: 3px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--yellow);
}

/* ── Settings Section Group ───────────────────────────── */
.settings-section { margin-bottom: 32px; }

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.settings-section-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.settings-section-icon--exchange     { background: rgba(240,185,11,.14); }
.settings-section-icon--ai           { background: rgba(188,140,255,.14); }
.settings-section-icon--notification { background: rgba(88,166,255,.14); }
.settings-section-icon--system       { background: rgba(248,81,73,.12); }

.settings-section-meta { flex: 1; }

.settings-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-prime);
}

.settings-section-desc {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 3px;
}

.settings-section-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Settings Cards Grid ──────────────────────────────── */
.settings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 12px;
}

/* ── Key Card — Form-based Design ────────────────────── */
.key-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 22px 18px;
  transition: border-color .2s, box-shadow .2s;
}

.key-card:hover {
  border-color: rgba(88,166,255,.28);
  box-shadow: 0 3px 18px rgba(0,0,0,.3);
}

/* Header: icon + name + status badge */
.key-card__header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.key-card__icon {
  font-size: 28px;
  line-height: 1;
  margin-top: 1px;
  flex-shrink: 0;
}

.key-card__header-info,
.key-card__info { flex: 1; min-width: 0; }

.key-card__title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.key-card__name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-prime);
  letter-spacing: -.3px;
}

.key-card__desc {
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.5;
}

/* Status badge */
.key-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.key-status--set {
  background: rgba(63,185,80,.12);
  color: var(--green);
  border: 1px solid rgba(63,185,80,.3);
}

.key-status--unset {
  background: rgba(139,148,158,.08);
  color: var(--text-dim);
  border: 1px solid rgba(139,148,158,.2);
}

/* Input row: full-width input + eye toggle */
.key-card__input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.key-card__input {
  flex: 1;
  height: 44px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-prime);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--mono);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  letter-spacing: 1px;
}

.key-card__input[type="password"] { letter-spacing: 3px; }
.key-card__input[type="text"]     { letter-spacing: 0; }

.key-card__input::placeholder {
  letter-spacing: 0;
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font);
}

.key-card__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.12);
}

/* Eye toggle button */
.key-card__eye {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-mute);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
  padding: 0;
}

.key-card__eye svg { width: 16px; height: 16px; stroke: currentColor; }

.key-card__eye:hover {
  background: rgba(88,166,255,.1);
  border-color: rgba(88,166,255,.35);
  color: var(--accent);
}

.key-card__eye--active {
  background: rgba(88,166,255,.12);
  border-color: rgba(88,166,255,.4);
  color: var(--accent);
}

/* Action buttons */
.key-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ks {
  height: 36px;
  padding: 0 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  border: 1px solid;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-ks svg { width: 13px; height: 13px; stroke: currentColor; flex-shrink: 0; }

.btn-ks--save {
  background: rgba(63,185,80,.12);
  color: var(--green);
  border-color: rgba(63,185,80,.35);
  transition: all .2s;
}
.btn-ks--save:hover    { background: rgba(63,185,80,.22); }
.btn-ks--save:disabled { opacity: .45; cursor: not-allowed; }

/* ── 模擬執行中狀態（按鈕凹陷 + 脈動 + 跑馬燈）── */
.btn-ks--running {
  background: linear-gradient(135deg, rgba(63,185,80,.35), rgba(63,185,80,.18));
  color: #fff;
  border-color: rgba(63,185,80,.8);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,.35),
    inset 0 -1px 0 rgba(63,185,80,.3),
    0 0 0 3px rgba(63,185,80,.15),
    0 0 20px rgba(63,185,80,.35);
  transform: translateY(1px);
  cursor: default;
  font-weight: 700;
  animation: btn-running-pulse 1.8s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}
.btn-ks--running:hover { background: linear-gradient(135deg, rgba(63,185,80,.4), rgba(63,185,80,.22)); }
.btn-ks--running::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  animation: btn-running-sweep 2.2s linear infinite;
}
.btn-ks--running .btn-ks-icon {
  display: inline-block;
  animation: btn-running-arrow 1.2s ease-in-out infinite;
}

@keyframes btn-running-pulse {
  0%, 100% { box-shadow:
    inset 0 2px 4px rgba(0,0,0,.35),
    inset 0 -1px 0 rgba(63,185,80,.3),
    0 0 0 3px rgba(63,185,80,.15),
    0 0 20px rgba(63,185,80,.35); }
  50%      { box-shadow:
    inset 0 2px 4px rgba(0,0,0,.45),
    inset 0 -1px 0 rgba(63,185,80,.4),
    0 0 0 5px rgba(63,185,80,.22),
    0 0 28px rgba(63,185,80,.55); }
}
@keyframes btn-running-sweep {
  0%   { left: -100%; }
  100% { left: 200%; }
}
@keyframes btn-running-arrow {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3px); }
}

/* 運行中小指示點（放 header 或面板角落） */
.running-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(63,185,80,.12);
  border: 1px solid rgba(63,185,80,.35);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
}
.running-indicator::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: running-dot 1.4s ease-in-out infinite;
}
@keyframes running-dot {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%      { opacity: .35; transform: scale(1.35); }
}

.btn-ks--quick {
  background: rgba(88,166,255,.08);
  color: var(--accent);
  border-color: rgba(88,166,255,.25);
}
.btn-ks--quick:hover { background: rgba(88,166,255,.16); }

.btn-ks--clear {
  background: rgba(248,81,73,.08);
  color: var(--red);
  border-color: rgba(248,81,73,.25);
}
.btn-ks--clear:hover { background: rgba(248,81,73,.16); }

.btn-ks--danger {
  background: rgba(248,81,73,.08);
  color: var(--red);
  border-color: rgba(248,81,73,.35);
}
.btn-ks--danger:hover { background: rgba(248,81,73,.2); }

/* Status message */
.key-card__msg {
  margin-top: 10px;
  font-size: 12px;
  display: none;
  padding: 7px 12px;
  border-radius: 6px;
}

.key-card__msg:not(:empty) { display: block; }
.key-card__msg--ok    { background: rgba(63,185,80,.08);  color: var(--green); border: 1px solid rgba(63,185,80,.2); }
.key-card__msg--error { background: rgba(248,81,73,.08); color: var(--red);   border: 1px solid rgba(248,81,73,.2); }

/* ── 跳轉目標高亮動畫 ─────────────────────────────── */
@keyframes nav-flash {
  0%   { box-shadow: 0 0 0 0 rgba(88,166,255,.6); }
  40%  { box-shadow: 0 0 0 6px rgba(88,166,255,.35), 0 0 25px rgba(88,166,255,.5); }
  100% { box-shadow: 0 0 0 0 rgba(88,166,255,0); }
}
.nav-flash {
  animation: nav-flash 1.4s ease-out;
  border-radius: 8px;
}

/* ── 幣池輪動表格（全寬橫向顯示，每欄自動伸展）───── */
.rotation-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}
.rotation-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-panel);
  color: var(--text-mute);
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.rotation-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.rotation-table tbody td:last-child {
  white-space: normal;              /* 最後「理由」欄位可換行 */
  color: var(--text-mute);
  font-size: 12px;
}
.rotation-table tbody tr:hover { background: rgba(88,166,255,.05); }

/* 依訊號上色整列 */
.rotation-table tbody tr.sig-buy  { background: linear-gradient(90deg, rgba(63,185,80,.1) 0%, transparent 60%); border-left: 3px solid var(--green); }
.rotation-table tbody tr.sig-sell { background: linear-gradient(90deg, rgba(248,81,73,.1) 0%, transparent 60%); border-left: 3px solid var(--red); }
.rotation-table tbody tr.sig-hold { border-left: 3px solid transparent; }

.rotation-table tbody tr.sig-buy:hover  { background: linear-gradient(90deg, rgba(63,185,80,.18) 0%, rgba(63,185,80,.03) 70%, transparent 100%); }
.rotation-table tbody tr.sig-sell:hover { background: linear-gradient(90deg, rgba(248,81,73,.18) 0%, rgba(248,81,73,.03) 70%, transparent 100%); }

.rotation-rank {
  display: inline-block; min-width: 32px;
  padding: 2px 6px; border-radius: 4px;
  text-align: center; font-weight: 700;
  font-size: 11px;
}
.rotation-rank--1 { background: linear-gradient(135deg, #ffd700, #ffb300); color: #000; }
.rotation-rank--2 { background: linear-gradient(135deg, #c0c0c0, #9e9e9e); color: #000; }
.rotation-rank--3 { background: linear-gradient(135deg, #cd7f32, #a15e1f); color: #fff; }
.rotation-rank--n { background: rgba(139,148,158,.15); color: var(--text-mute); }

.rotation-sig-badge {
  display: inline-block; padding: 2px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 600; text-align: center; min-width: 54px;
}
.rotation-sig-badge--buy  { background: rgba(63,185,80,.3);  color: #7ee787; }
.rotation-sig-badge--sell { background: rgba(248,81,73,.3);  color: #ff8686; }
.rotation-sig-badge--hold { background: rgba(139,148,158,.15); color: var(--text-mute); }

.rotation-score {
  display: inline-block; padding: 2px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.06); color: var(--text-prime);
}

.rotation-tf-leds {
  display: inline-flex; gap: 6px; align-items: center;
}
.rotation-tf-leds > span {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
}
.rotation-tf-leds .led     { font-size: 14px; line-height: 1; }
.rotation-tf-leds .led-lbl { font-size: 8px; color: var(--text-dim); }
.rotation-tf-leds .led--buy  { color: var(--green); text-shadow: 0 0 6px rgba(63,185,80,.6); }
.rotation-tf-leds .led--sell { color: var(--red);   text-shadow: 0 0 6px rgba(248,81,73,.6); }
.rotation-tf-leds .led--hold { color: var(--text-dim); }

.rotation-news {
  display: inline-block; padding: 2px 6px; border-radius: 3px; font-size: 10px;
}
.rotation-news--bearish_alert { background: rgba(248,81,73,.5);  color: #fff; font-weight: 700; }
.rotation-news--bearish       { background: rgba(248,81,73,.2);  color: var(--red); }
.rotation-news--bullish_alert { background: rgba(63,185,80,.5);  color: #fff; font-weight: 700; }
.rotation-news--bullish       { background: rgba(63,185,80,.2);  color: var(--green); }
.rotation-news--neutral       { color: var(--text-dim); }

.rotation-resonance-tag {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  font-size: 10px; font-weight: 700; margin-left: 4px;
}

/* ── 模擬設定表單 ─────────────────────────────────────── */
.sim-settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px 22px;
  background: var(--bg-panel);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.sim-settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sim-settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: .4px;
  text-transform: uppercase;
}

.sim-settings-input {
  height: 44px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-prime);
  font-size: 14px;
  font-family: var(--mono);
  width: 100%;
  box-sizing: border-box;
}

.sim-settings-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
select.sim-settings-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2358a6ff' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.sim-settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  grid-column: 1 / -1;
  padding-top: 4px;
}

/* ── Target Achievement Card ──────────────────────────── */
.stat-card--target {
  background: linear-gradient(135deg, var(--bg-card) 60%, rgba(88,166,255,.06));
  border-color: rgba(88,166,255,.25);
}

/* ── Target Progress Panel ────────────────────────────── */
.target-progress-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.target-progress-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.target-progress-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.target-progress-bar-wrap {
  position: relative;
  background: var(--bg-panel);
  border-radius: 6px;
  height: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.target-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3fb950, #58a6ff);
  border-radius: 6px;
  transition: width .6s ease;
  min-width: 2px;
}

.target-progress-bar.over-target {
  background: linear-gradient(90deg, #58a6ff, #bc8cff);
}

.target-progress-label {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-prime);
  font-family: var(--mono);
}

.target-progress-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-mute);
}

.target-progress-stats b {
  color: var(--text-prime);
  font-family: var(--mono);
}

/* ── Why Button ───────────────────────────────────────── */
.why-btn {
  background: rgba(88,166,255,.08);
  color: var(--accent);
  border: 1px solid rgba(88,166,255,.25);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.why-btn:hover {
  background: rgba(88,166,255,.18);
  border-color: var(--accent);
}

.why-btn--manual {
  color: var(--text-dim);
  border-color: var(--border);
  background: transparent;
  cursor: default;
  opacity: .6;
}

/* ── Trade Reason Modal ───────────────────────────────── */
.trade-reason-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.trade-reason-overlay.active {
  display: flex;
}

.trade-reason-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.trade-reason-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}

.trade-reason-modal__close {
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}

.trade-reason-modal__close:hover { color: var(--text-prime); }

.trade-reason-modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.reason-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 16px;
}

.reason-row:last-child { border-bottom: none; }

.reason-row__label {
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.reason-row__value {
  color: var(--text-prime);
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  word-break: break-word;
}

.reason-text {
  color: var(--text-mute);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 0;
  font-family: var(--font);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .sidebar { display: none; }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-chart { grid-template-columns: 1fr; }
  .settings-cards { grid-template-columns: 1fr; }
  .key-card__value-area { padding-left: 16px; }
}
