:root {
  --primary: #0f2744;
  --primary-mid: #1a3f6f;
  --accent: #f0a500;
  --accent-light: #fff8e6;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --bg: #f0f4f9;
  --card: #ffffff;
  --text: #0f1923;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow-sm: 0 2px 8px rgba(15,23,42,0.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,0.10);
}

:root[data-theme="dark"] {
  --primary-mid: #23496f;
  --accent-light: #2c2408;
  --green-bg: rgba(22,163,74,0.16);
  --red-bg: rgba(220,38,38,0.16);
  --bg: #0a1220;
  --card: #121b2d;
  --text: #e8edf5;
  --text-muted: #8b98ad;
  --border: #22314a;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 28px rgba(0,0,0,0.4);
}
:root[data-theme="dark"] .info-box { background: rgba(59,130,246,0.12); color: #93c5fd; }
:root[data-theme="dark"] .result-summary.profit { color: #86efac; }
:root[data-theme="dark"] .result-summary.loss { color: #fca5a5; }
:root[data-theme="dark"] .btn-use-price { color: #fbbf24; }
:root[data-theme="dark"] .hot-stock-btn { background: var(--card); color: var(--text); }
:root[data-theme="dark"] .breakdown tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans TC', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
}
.icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton {
  display: inline-block;
  min-width: 90px;
  height: 1em;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.08) 25%, rgba(255,255,255,0.18) 37%, rgba(255,255,255,0.08) 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* Header */
header {
  background: rgba(15,39,68,0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.header-inner {
  max-width: none;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
}
.logo-mark {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.logo-sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-left: 4px; }
nav { display: flex; gap: 22px; align-items: center; }
nav a { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 14px; transition: color 0.2s; position: relative; }
nav a:hover { color: white; }
.nav-group { position: relative; }
.nav-cat {
  background: none; border: none; color: rgba(255,255,255,0.75); font-size: 14px; font-family: inherit;
  cursor: pointer; padding: 0; display: flex; align-items: center; gap: 4px; transition: color 0.2s;
}
.nav-cat:hover { color: white; }
.nav-cat .chev { transition: transform 0.2s; }
.nav-group.open .nav-cat { color: white; }
.nav-group.open .nav-cat .chev { transform: rotate(180deg); }
.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 16px;
  background: var(--primary);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 6px;
  min-width: 190px;
  box-shadow: var(--shadow-md);
  flex-direction: column;
  z-index: 200;
}
.nav-group.open .nav-dropdown { display: flex; }
.nav-dropdown a { padding: 9px 12px; border-radius: 6px; font-size: 13px; }
.nav-dropdown a:hover { background: rgba(255,255,255,0.08); }
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: '';
  position: absolute;
  left: 9px;
  width: 18px;
  height: 2px;
  background: white;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle span { top: 17px; }
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.nav-toggle.open span { background: transparent; }
.nav-toggle.open span::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span::after { transform: translateY(-6px) rotate(-45deg); }
.auth-area { position: relative; }
.btn-login {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-login:hover { background: rgba(255,255,255,0.16); }
.btn-login .user-avatar { width: 20px; height: 20px; border-radius: 50%; }
.login-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 170px;
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.auth-area.open .login-dropdown { display: block; }
.login-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.login-option:hover { background: var(--bg); }

.theme-toggle {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.16); }
.theme-toggle .icon { width: 18px; height: 18px; vertical-align: 0; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Trust strip */
.trust-strip {
  background: var(--primary-mid);
  padding: 7px 20px;
}
.trust-strip-inner {
  max-width: none;
  margin: 0 auto;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}
.trust-strip-inner span { display: flex; align-items: center; gap: 5px; }

/* Layout */
.page {
  max-width: none;
  margin: 20px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

/* Market Hero */
.market-hero {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  overflow: hidden;
}
.mh-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
}
.mh-tab {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.mh-tab:hover { color: var(--text); }
.mh-tab.active { color: var(--primary); border-bottom-color: var(--accent); }
.mh-time { margin-left: auto; font-size: 12px; color: var(--text-muted); align-self: center; }

.mh-body { display: flex; }
.mh-list { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 6px; }
.mh-list-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.mh-list-item:hover { background: var(--bg); }
.mh-list-item.active { background: var(--accent-light); }
.mh-list-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mh-list-val { display: flex; align-items: baseline; gap: 8px; font-family: 'DM Mono', monospace; }
.mh-list-price { font-size: 14px; font-weight: 500; color: var(--text); }
.mh-list-chg { font-size: 12px; font-weight: 500; }
.mh-list-chg.up { color: var(--red); }
.mh-list-chg.down { color: var(--green); }

.mh-detail { flex: 1; min-width: 0; padding: 18px 22px; }
.mh-detail-head { margin-bottom: 4px; }
.mh-detail-name { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.mh-detail-value { font-family: 'DM Mono', monospace; font-size: clamp(30px, 5vw, 42px); font-weight: 700; color: var(--text); line-height: 1.1; }
.mh-detail-value.up { color: var(--red); }
.mh-detail-value.down { color: var(--green); }
.mh-detail-change { font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 600; margin-top: 4px; }
.mh-detail-change.up { color: var(--red); }
.mh-detail-change.down { color: var(--green); }
.mh-stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.mh-stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.mh-stat-value { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; color: var(--text); }
.mh-chart-wrap { width: 100%; height: 340px; margin-top: 10px; }
.mh-chart-wrap > div { width: 100%; height: 100%; }

@media (max-width: 700px) {
  .mh-body { flex-direction: column; }
  .mh-list { width: 100%; border-right: none; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; gap: 4px; }
  .mh-list-item { flex-shrink: 0; min-width: 140px; }
}

/* Quick search bar */
.quick-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
}
.qs-input {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.qs-btn {
  padding: 8px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.qs-btn:hover { background: var(--primary-mid); }
.qs-hot-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

/* Stock Search */
.stock-search-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}
.stock-search-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.09); }
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--primary-mid); background: white; }
.btn-search {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-search:hover { background: var(--primary-mid); }
.btn-search:active { transform: scale(0.98); }

.stock-result {
  display: none;
  background: var(--bg);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.stock-result.show { display: block; animation: fadeSlideIn 0.3s ease; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stock-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.stock-price-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stock-price {
  font-family: 'DM Mono', monospace;
  font-size: 28px;
  font-weight: 500;
}
.stock-price.up { color: var(--red); }
.stock-price.down { color: var(--green); }
.stock-change { font-family: 'DM Mono', monospace; font-size: 14px; }
.stock-change.up { color: var(--red); }
.stock-change.down { color: var(--green); }

.btn-use-price {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  color: #92400e;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-use-price:hover { background: #fde68a; }

/* K-line chart */
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 12px; position: relative; z-index: 20; }
.chart-range-btn, .chart-ind-btn {
  padding: 4px 11px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chart-range-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.chart-draw-tools { display: flex; gap: 4px; margin-left: auto; }
.chart-ind-btn { display: flex; align-items: center; justify-content: center; width: 30px; height: 28px; padding: 0; }
.chart-ind-btn.active { background: var(--accent); color: #78350f; border-color: var(--accent); }

.chart-dropdown { position: relative; }
.chart-dd-trigger {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.chart-dd-trigger .chev { transition: transform 0.15s; }
.chart-dropdown.open .chart-dd-trigger { border-color: var(--primary-mid); }
.chart-dropdown.open .chart-dd-trigger .chev { transform: rotate(180deg); }
.chart-dd-panel {
  display: none;
  position: absolute; top: 100%; left: 0; margin-top: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; min-width: 200px; box-shadow: var(--shadow-md); z-index: 50;
}
.chart-dropdown.open .chart-dd-panel { display: block; }
.chart-dd-group-label { font-size: 11px; color: var(--text-muted); padding: 8px 8px 4px; }
.chart-dd-item { display: block; width: 100%; text-align: left; padding: 8px; font-size: 13px; border: none; background: none; color: var(--text); border-radius: 6px; cursor: pointer; font-family: inherit; }
.chart-dd-item:hover { background: var(--bg); }
.chart-dd-item.active { background: var(--primary); color: white; }
.chart-dd-custom { padding: 6px 8px 2px; }
.chart-dd-custom select, .chart-dd-custom input { font-family: inherit; font-size: 12px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); width: 100%; margin-bottom: 6px; }
.chart-dd-custom-row { display: flex; gap: 6px; }
.chart-dd-custom-row select { flex: 1; }

.chart-ind-panel { min-width: 260px; }
.ind-row { display: flex; align-items: center; gap: 6px; padding: 7px 8px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.ind-row:hover { background: var(--bg); }
.ind-param { width: 42px; font-size: 12px; padding: 3px 4px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); font-family: inherit; margin-left: auto; }
.ind-row input[type="checkbox"] { margin-right: 2px; }

.lw-chart-wrap { position: relative; width: 100%; height: 340px; transition: height 0.2s ease; }
#chart-expand-btn.active { background: var(--accent); color: #78350f; border-color: var(--accent); }

/* K線圖放大：卡片本身留在原本的 DOM 位置不搬動（避免關閉後版面跑掉），
   只用 position:fixed 把它疊在畫面正中央、比整個版面小一圈，右上角叉叉關閉 */
.chart-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 999;
}
.chart-modal-backdrop.open { display: block; }

#chart-card { position: relative; }
#chart-card.chart-modal-active {
  position: fixed;
  top: 5vh;
  left: 5vw;
  right: 5vw;
  bottom: 5vh;
  margin: auto;
  max-width: 1200px;
  max-height: 880px;
  z-index: 1000;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.chart-modal-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 2;
  transition: background 0.15s, transform 0.15s, color 0.15s;
}
.chart-modal-close:hover { background: var(--accent); color: #78350f; transform: scale(1.08); }
#chart-card.chart-modal-active .chart-modal-close { display: flex; }

.chart-card-scroll { padding: 0; }
#chart-card.chart-modal-active .chart-card-scroll {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
}
.chart-modal-active .lw-chart-wrap { height: min(56vh, 620px); flex-shrink: 0; }
.chart-modal-active .lw-chart-sub { height: 140px; }

@media (max-width: 700px) {
  #chart-card.chart-modal-active { top: 3vh; left: 3vw; right: 3vw; bottom: 3vh; }
}

.lw-chart-main { position: relative; z-index: 1; width: 100%; height: 100%; }
.draw-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.draw-canvas.active { pointer-events: auto; cursor: crosshair; }
.lw-chart-sub { width: 100%; height: 110px; margin-top: 4px; }
.draw-hint { display: none; font-size: 12px; color: var(--primary-mid); background: var(--accent-light); padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.draw-hint.show { display: block; }

/* Stock detail page (stock.html) */
.sd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 0; flex-wrap: wrap; }
.sd-name { font-size: 20px; font-weight: 700; color: var(--text); }
.sd-code { font-size: 13px; color: var(--text-muted); margin-top: 2px; font-family: 'DM Mono', monospace; }
.sd-market-tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--accent-light); color: var(--primary-mid); margin-left: 8px; font-weight: 600; vertical-align: middle; }
.sd-price-block { text-align: right; }
.sd-price { font-family: 'DM Mono', monospace; font-size: clamp(28px, 5vw, 38px); font-weight: 700; line-height: 1.1; }
.sd-price.up { color: var(--red); }
.sd-price.down { color: var(--green); }
.sd-change { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; margin-top: 4px; }
.sd-change.up { color: var(--red); }
.sd-change.down { color: var(--green); }
.sd-stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 16px 22px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.sd-stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.sd-stat-value { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; color: var(--text); }
.sd-actions { display: flex; gap: 8px; padding: 0 22px 20px; }

.stock-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 860px) {
  .stock-detail-grid { grid-template-columns: 1fr; }
}

/* 五檔報價 (Order book) */
.orderbook-card { position: sticky; top: 16px; }
.orderbook-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; text-align: center; }
.orderbook { font-family: 'DM Mono', monospace; font-size: 13px; }
.ob-row { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; padding: 6px 4px; position: relative; }
.ob-row .ob-bar { position: absolute; top: 0; bottom: 0; z-index: 0; opacity: 0.14; }
.ob-row > * { position: relative; z-index: 1; }
.ob-label { color: var(--text-muted); font-size: 11px; text-align: center; }
.ob-vol { text-align: left; color: var(--text-muted); }
.ob-price { text-align: center; font-weight: 700; }
.ob-vol-r { text-align: right; color: var(--text-muted); }
.ob-ask .ob-price { color: var(--red); }
.ob-ask .ob-bar { background: var(--red); right: 0; }
.ob-bid .ob-price { color: var(--green); }
.ob-bid .ob-bar { background: var(--green); left: 0; }
.ob-mid { display: flex; justify-content: space-between; padding: 10px 4px; margin: 4px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); font-size: 12px; color: var(--text-muted); }

/* Institutional ranking */
.inst-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.inst-item:last-child { border-bottom: none; }
.inst-rank { width: 20px; color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.inst-name { flex: 1; min-width: 0; cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst-name:hover { color: var(--primary-mid); }
.inst-code { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.inst-net { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500; white-space: nowrap; }
.inst-net.buy { color: var(--red); }
.inst-net.sell { color: var(--green); }

/* Dividend calendar */
.div-cal-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.div-cal-item:last-child { border-bottom: none; }
.div-cal-date { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-muted); width: 54px; flex-shrink: 0; }
.div-cal-name { flex: 1; min-width: 0; cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.div-cal-name:hover { color: var(--primary-mid); }
.div-cal-badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: var(--accent-light); color: #92400e; flex-shrink: 0; }
.div-cal-soon { background: var(--red-bg); color: var(--red); font-weight: 600; }

/* Insight grid：自選股／法人排行／除權息 三欄並排 */
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.insight-card { margin-bottom: 0; padding: 16px; }
.insight-card .card-title { font-size: 13px; margin-bottom: 10px; }
.insight-scroll { max-height: 260px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.insight-scroll::-webkit-scrollbar { width: 6px; }
.insight-scroll::-webkit-scrollbar-track { background: transparent; }
.insight-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.insight-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
@media (max-width: 900px) {
  .insight-grid { grid-template-columns: 1fr; }
}

/* Watchlist */
.watchlist-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.watchlist-item:last-child { border-bottom: none; }
.wl-name { cursor: pointer; font-weight: 500; font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-name:hover { color: var(--primary-mid); }
.wl-code { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.wl-price { font-family: 'DM Mono', monospace; font-weight: 500; font-size: 14px; text-align: right; white-space: nowrap; }
.wl-price.up { color: var(--red); }
.wl-price.down { color: var(--green); }
.wl-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; flex-shrink: 0; }
.wl-remove:hover { color: var(--red); }
.watchlist-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }

/* LINE CTA (側邊欄精簡版，配色跟隨網站主題) */
.side-card.line-cta-card { background: linear-gradient(135deg, var(--primary) 0%, #17416f 100%); border: none; color: white; }
.line-cta-card .card-title { color: white; }
.line-cta-card .card-title::before { background: var(--accent); }
.line-cta-inner { display: flex; align-items: center; gap: 12px; margin: 12px 0 14px; }
.line-cta-desc { font-size: 12px; line-height: 1.6; color: rgba(255,255,255,0.8); margin: 0; }
.btn-line-add {
  display: block; text-align: center;
  background: var(--accent); color: #1a1200; text-decoration: none;
  padding: 9px 14px; border-radius: 8px; font-weight: 700; font-size: 13px;
  transition: filter 0.15s;
}
.btn-line-add:hover { filter: brightness(1.08); }
.line-cta-qr { flex-shrink: 0; border-radius: 8px; background: white; padding: 4px; width: 84px; height: 84px; }

/* Hot Stocks */
.hot-stocks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.hot-stock-btn {
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.hot-stock-btn:hover { border-color: var(--primary-mid); color: var(--primary-mid); background: var(--accent-light); transform: translateY(-1px); }
.hot-stock-btn:active { transform: translateY(0); }

/* Calculator Card */
.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}
.calc-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.09); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
}
.tab {
  flex: 1;
  padding: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: inherit;
}
.tab.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
input, select {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--primary-mid); background: white; }
.input-unit { position: relative; }
.input-unit input { padding-right: 36px; }
.unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text-muted); pointer-events: none; }

.btn-calc {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 6px;
}
.btn-calc:hover { background: var(--primary-mid); }
.btn-calc:active { transform: scale(0.98); }

/* Results */
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.result-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border);
}
.result-card.highlight { background: var(--accent-light); border-color: var(--accent); }
.result-label { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.result-value { font-family: 'DM Mono', monospace; font-size: 20px; font-weight: 500; }
.result-value.big { font-size: 26px; color: var(--primary); }
.result-value.positive { color: var(--green); }
.result-value.negative { color: var(--red); }

.result-summary { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: 14px; line-height: 1.7; display: none; }
.result-summary.show { display: block; animation: fadeSlideIn 0.3s ease; }
.result-summary.profit { background: var(--green-bg); color: #14532d; }
.result-summary.loss { background: var(--red-bg); color: #7f1d1d; }

.breakdown { margin-top: 16px; display: none; }
.breakdown.show { display: block; }
.breakdown table { width: 100%; border-collapse: collapse; font-size: 13px; }
.breakdown th { background: var(--primary); color: white; padding: 9px 12px; text-align: left; font-weight: 500; }
.breakdown th:last-child, .breakdown td:last-child { text-align: right; }
.breakdown td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-family: 'DM Mono', monospace; font-size: 12px; }
.breakdown tr:nth-child(even) td { background: var(--bg); }

/* Info box */
.info-box { background: #eff6ff; border-left: 4px solid #3b82f6; border-radius: 0 8px 8px 0; padding: 12px 14px; font-size: 13px; color: #1e40af; margin-top: 14px; line-height: 1.7; }

/* Tips */
.tips-list { list-style: none; }
.tips-list li { padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; display: flex; gap: 10px; line-height: 1.6; }
.tips-list li:last-child { border-bottom: none; }
.tips-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }

/* Sidebar */
.side-card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: box-shadow 0.2s; }
.side-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.09); }
.side-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.side-card td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.side-card tr:last-child td { border-bottom: none; }

/* Loading */
.loading { display: none; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.loading.show { display: flex; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.stock-error { display: none; color: var(--red); font-size: 13px; padding: 8px 0; }
.stock-error.show { display: block; }

/* Footer */
footer { background: var(--primary); color: rgba(255,255,255,0.6); text-align: center; padding: 24px 16px; font-size: 13px; margin-top: 40px; }
footer a { color: rgba(255,255,255,0.8); text-decoration: none; }

@media (max-width: 768px) {
  .page { grid-template-columns: 1fr; }
  /* 側邊欄在 HTML 裡本來就排在主內容之後，手機版就讓它自然落到最下面。
     原本這裡有 order: -1 把它拉到最上面，結果使用者一進站先看到 LINE 邀請
     而不是網站在做什麼。 */
  .form-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .nav-toggle { display: block; }
  nav {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--primary);
    box-shadow: 0 8px 16px rgba(0,0,0,0.25);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  nav.open { max-height: 500px; overflow-y: auto; }
  nav a { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
  .nav-cat { width: 100%; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); justify-content: space-between; }
  .nav-dropdown { position: static; margin-top: 0; box-shadow: none; border: none; background: rgba(0,0,0,0.15); border-radius: 0; padding: 0; }
  .nav-dropdown a { padding: 10px 20px 10px 34px; border-radius: 0; border-top: 1px solid rgba(255,255,255,0.05); }
  .trust-strip-inner { font-size: 11px; gap: 12px; }
}
@media (max-width: 480px) {
  .result-grid { grid-template-columns: 1fr; }
}

/* Member page (member.html) */
.member-wrap { max-width: none; margin: 28px auto; padding: 0 16px; }
.member-profile-card { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.member-avatar, .member-avatar-placeholder { width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; }
.member-avatar { object-fit: cover; background: var(--bg); }
.member-avatar-placeholder { background: var(--accent-light); color: var(--primary-mid); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.member-info { flex: 1; min-width: 160px; }
.member-name { font-size: 19px; font-weight: 700; color: var(--text); }
.member-provider-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 20px; background: var(--accent-light); color: var(--primary-mid); margin-top: 6px; font-weight: 600; }
.member-actions { display: flex; gap: 8px; }
.btn-outline {
  padding: 9px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--red); color: var(--red); }

.member-empty-state { text-align: center; padding: 44px 24px; }
.member-empty-state .icon-lg { width: 44px; height: 44px; color: var(--text-muted); margin-bottom: 14px; }
.member-empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.member-empty-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.6; }
.member-empty-state .btn-line-add { max-width: 240px; margin: 0 auto; }

/* ── 登入 / 註冊彈窗 ── */
.auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8,14,26,0.55);
  backdrop-filter: blur(3px);
  padding: 20px;
  overflow-y: auto;
}
.auth-modal.open { display: flex; align-items: flex-start; justify-content: center; }
.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 26px 24px 22px;
  position: relative;
}
.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
}
.auth-close:hover { background: var(--bg); color: var(--text); }
.auth-title { font-size: 19px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.auth-social { display: flex; flex-direction: column; gap: 9px; }
.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.auth-social-btn:hover { background: var(--bg); border-color: var(--text-muted); }
.auth-social-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.auth-social-btn.google svg { width: 17px; height: 17px; }
.auth-social-btn.line { background: #06c755; border-color: #06c755; color: #fff; }
.auth-social-btn.line:hover { background: #05b34c; border-color: #05b34c; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-field { margin-bottom: 13px; }
.auth-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}
.auth-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }

.auth-submit {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.auth-submit:hover { opacity: 0.9; }
.auth-submit:disabled { opacity: 0.55; cursor: default; }
:root[data-theme="dark"] .auth-submit { background: var(--accent); color: #1a1200; }

.auth-msg {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 9px;
  margin-bottom: 14px;
  display: none;
  line-height: 1.55;
}
.auth-msg.show { display: block; }
.auth-msg.error { background: var(--red-bg); color: var(--red); }
.auth-msg.ok { background: var(--green-bg); color: var(--green); }
:root[data-theme="dark"] .auth-msg.error { color: #fca5a5; }
:root[data-theme="dark"] .auth-msg.ok { color: #86efac; }

.auth-foot {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary-mid);
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}
:root[data-theme="dark"] .auth-link { color: var(--accent); }
.auth-forgot { text-align: right; margin: -6px 0 12px; }

.auth-pane { display: none; }
.auth-pane.active { display: block; }

@media (max-width: 480px) {
  .auth-box { padding: 22px 18px 18px; }
}

/* 大盤走勢圖下方的資料說明（哪一天、日線或盤中） */
.mh-chart-note {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  padding: 4px 8px 0;
}

/* ── 自選股清單頁 ── */
.wl-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.wl-page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.wl-page-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.btn-upgrade {
  padding: 9px 16px;
  border-radius: 9px;
  background: var(--accent);
  color: #1a1200;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.btn-upgrade:hover { opacity: 0.9; }

.wl-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.wl-tab {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}
.wl-tab:hover { border-color: var(--text-muted); }
.wl-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .wl-tab.active { background: var(--accent); border-color: var(--accent); color: #1a1200; }
.wl-tab-count {
  font-size: 11.5px;
  background: rgba(128,128,128,0.22);
  border-radius: 20px;
  padding: 1px 7px;
}
.wl-tab-add { border-style: dashed; color: var(--text-muted); }
.wl-tab-add.locked { cursor: pointer; opacity: 0.75; }

.wl-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.wl-detail-name { font-size: 17px; font-weight: 700; color: var(--text); }
.wl-detail-actions { display: flex; gap: 8px; }
.wl-mini-btn {
  padding: 6px 11px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.wl-mini-btn:hover { color: var(--text); border-color: var(--text-muted); }
.wl-mini-btn.danger:hover { color: var(--red); border-color: var(--red); }

.wl-add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.wl-add-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.wl-add-input:focus { outline: none; border-color: var(--accent); background: var(--card); }
.wl-count { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

.wl-msg { font-size: 13px; padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; display: none; }
.wl-msg.show { display: block; }
.wl-msg.error { background: var(--red-bg); color: var(--red); }
.wl-msg.ok { background: var(--green-bg); color: var(--green); }
:root[data-theme="dark"] .wl-msg.error { color: #fca5a5; }

.wl-local-hint {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ── 升級會員頁 ── */
.upgrade-wrap { max-width: none; margin: 26px auto 50px; padding: 0 16px; }
.upgrade-hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 34px 24px 28px;
  text-align: center;
}
.upgrade-badge {
  display: inline-block;
  background: var(--accent);
  color: #1a1200;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.upgrade-title { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.upgrade-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 22px; }
.upgrade-price { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin-bottom: 22px; }
.up-currency { font-size: 18px; color: var(--text-muted); font-weight: 600; }
.up-amount { font-size: 52px; font-weight: 700; color: var(--text); line-height: 1; font-family: 'DM Mono', monospace; }
.up-period { font-size: 15px; color: var(--text-muted); }
.btn-subscribe {
  padding: 13px 40px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-subscribe:hover { opacity: 0.9; }
.btn-subscribe:disabled { opacity: 0.55; cursor: default; }
:root[data-theme="dark"] .btn-subscribe { background: var(--accent); color: #1a1200; }
.upgrade-note {
  display: none;
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 9px;
  padding: 12px 14px;
}
.upgrade-note.show { display: block; }

.plan-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  position: relative;
}
.plan-card.featured { border-color: var(--accent); box-shadow: var(--shadow-md); }
.plan-card-flag {
  position: absolute;
  top: -10px;
  right: 18px;
  background: var(--accent);
  color: #1a1200;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 20px;
}
.plan-card-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.plan-card-price { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 16px; font-family: 'DM Mono', monospace; }
.plan-card-price span { font-size: 13px; color: var(--text-muted); font-weight: 400; font-family: inherit; }
.plan-list { list-style: none; }
.plan-list li {
  font-size: 13.5px;
  color: var(--text);
  padding: 7px 0 7px 24px;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.plan-list li:last-child { border-bottom: none; }
.plan-list li::before { position: absolute; left: 0; top: 7px; font-weight: 700; }
.plan-list li.yes::before { content: '✓'; color: var(--green); }
.plan-list li.todo::before { content: '…'; color: var(--text-muted); }
.plan-list li.todo { color: var(--text-muted); }
.plan-tbd {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}

.faq-card { margin-top: 22px; }
.faq-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.faq-a { font-size: 13px; color: var(--text-muted); line-height: 1.7; }

@media (max-width: 700px) {
  .plan-compare { grid-template-columns: 1fr; }
  .up-amount { font-size: 42px; }
  .upgrade-title { font-size: 21px; }
}

/* 首頁自選股卡片：依清單分組 */
.wl-group + .wl-group { margin-top: 12px; }
.wl-group-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  padding: 4px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* 未登入的功能閘門卡片 */
.auth-gate {
  text-align: center;
  padding: 34px 22px;
}
.auth-gate-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  opacity: 0.75;
  margin-bottom: 10px;
}
.auth-gate-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-gate-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.7; }
.auth-gate-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.auth-gate-btn:hover { opacity: 0.9; }
:root[data-theme="dark"] .auth-gate-btn { background: var(--accent); color: #1a1200; }

/* ── 手機版跑版修正 ── */

/* 水平溢出的根因：grid / flex 的子項 min-width 預設是 auto，
   內容擠不下時不會縮小，而是把整個版面往外推，於是整頁可以左右滑。
   把可能被撐開的容器都放行縮小。 */
.page > *,
.insight-grid > *,
.stock-detail-grid > *,
.mh-body > *,
.main-col,
.side-col { min-width: 0; }

/* 最後一道防線：就算還有漏網的元素，也不該讓整頁能左右滑。
   用 clip 而不是 hidden —— hidden 會產生捲動容器，讓 sticky 的導覽列失效。 */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100%; }

/* 圖片與向量圖不要超出容器（canvas 交給圖表函式庫自己管，不要動） */
img, svg:not(.icon) { max-width: 100%; }

/* 表格太寬時讓表格自己橫向捲，而不是把頁面撐爆 */
.breakdown { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.breakdown table { min-width: 320px; }
.rate-table-wrap { overflow-x: auto; }

@media (max-width: 480px) {
  .page { padding: 0 12px; margin-top: 14px; gap: 14px; }
  .mh-detail { padding: 14px 14px; }
  .mh-stats { gap: 14px; margin: 12px 0; }
  /* 大盤數字在窄螢幕會頂到邊，縮一級 */
  .mh-detail-value { font-size: 28px; }
  .mh-chart-wrap { height: 220px; }
  .insight-card { padding: 13px; }
  /* 計算機四個分頁在 375 寬會擠成兩行又對不齊，改成可橫向捲 */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs .tab { flex-shrink: 0; }
  .wl-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .wl-tab { flex-shrink: 0; }
  .wl-add-row { flex-wrap: wrap; }
  .wl-add-input { flex-basis: 100%; }
}

/* 資料進來之前先把高度佔住，否則載入完成的瞬間整頁會往下推，
   手指剛好要點的東西就從眼前跑掉了 */
.mh-list { min-height: 264px; }
.mh-stats { min-height: 44px; }
#inst-list, #dividend-cal-list { min-height: 210px; }

@media (max-width: 700px) {
  /* 這個寬度下 .mh-list 變成橫向一列，高度需求完全不同 */
  .mh-list { min-height: 62px; }
}

/* ── 到價提醒頁 ── */
.al-bind { padding: 16px 18px; }
.al-bind-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.al-bind-row .icon { width: 22px; height: 22px; flex-shrink: 0; }
.al-bind-row.ok .icon { color: var(--green); }
.al-bind-row.warn .icon { color: var(--accent); }
.al-bind-row > div { flex: 1; min-width: 180px; }
.al-bind-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.al-code-box {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
}
.al-code {
  font-family: 'DM Mono', monospace;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 5px;
  color: var(--text);
  text-align: center;
  padding: 6px 0 12px;
}
.al-code-steps { font-size: 13px; line-height: 2; color: var(--text); }
.al-code-expire { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

.al-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 8px; }
.al-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.al-field-stock { flex: 1; min-width: 190px; }
.al-field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.al-field input, .al-field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.al-field input:focus, .al-field select:focus { outline: none; border-color: var(--accent); background: var(--card); }
.al-submit { flex-shrink: 0; }

.al-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.al-item:last-child { border-bottom: none; }
.al-item.fired { opacity: 0.72; }
.al-item-main { flex: 1; min-width: 150px; }
.al-item-name { font-weight: 500; font-size: 14.5px; }
.al-item-cond { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.al-dir { font-size: 12.5px; font-weight: 600; }
.al-dir.up { color: var(--red); }
.al-dir.down { color: var(--green); }
.al-target { font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 500; color: var(--text); }
.al-item-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.al-badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}
.al-badge.watching { background: var(--accent-light); color: #7a5a00; }
:root[data-theme="dark"] .al-badge.watching { color: var(--accent); }

@media (max-width: 560px) {
  .al-form { gap: 8px; }
  .al-field-stock { flex-basis: 100%; }
  .al-submit { flex: 1; }
  .al-code { font-size: 26px; letter-spacing: 4px; }
}

/* ── 會員中心 ── */
.mc-block { margin-top: 16px; }

.mc-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mc-hero .member-avatar, .mc-hero .member-avatar-placeholder {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
}
.mc-hero .member-avatar-placeholder {
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 24px; font-weight: 700;
}
:root[data-theme="dark"] .mc-hero .member-avatar-placeholder { background: var(--accent); color: #1a1200; }
.mc-hero-info { flex: 1; min-width: 0; }
.mc-name { font-size: 19px; font-weight: 700; }
.mc-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.mc-days { font-size: 12.5px; color: var(--text-muted); }
.mc-hero-actions { flex-shrink: 0; }

/* 今日看盤 */
.mc-verdict { font-size: 15px; margin-bottom: 14px; line-height: 1.7; }
.mc-verdict b.up { color: var(--red); }
.mc-verdict b.down { color: var(--green); }
.mc-stat-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.mc-stat {
  flex: 1; min-width: 66px; text-align: center; padding: 10px 6px;
  background: var(--bg); border-radius: 10px;
}
.mc-stat-val { font-size: 22px; font-weight: 700; font-family: 'DM Mono', monospace; }
.mc-stat-val.up { color: var(--red); }
.mc-stat-val.down { color: var(--green); }
.mc-stat-label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.mc-movers { display: flex; gap: 10px; flex-wrap: wrap; }
.mc-mover {
  flex: 1; min-width: 96px; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 10px;
}
.mc-mover-label { font-size: 11px; color: var(--text-muted); }
.mc-mover-name {
  font-size: 13.5px; font-weight: 500; margin: 3px 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.mc-mover-val { font-size: 15px; font-weight: 700; font-family: 'DM Mono', monospace; }
.mc-mover-val.up { color: var(--red); }
.mc-mover-val.down { color: var(--green); }

/* 方案用量進度條 */
.mc-bar-row { margin-bottom: 12px; }
.mc-bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.mc-bar-num { color: var(--text-muted); font-family: 'DM Mono', monospace; }
.mc-bar { height: 7px; background: var(--bg); border-radius: 20px; overflow: hidden; }
.mc-bar-fill { height: 100%; background: var(--accent); border-radius: 20px; transition: width 0.3s; }
.mc-bar-fill.full { background: var(--red); }
.mc-line-state {
  font-size: 12.5px; color: var(--text-muted); background: var(--bg);
  border-radius: 8px; padding: 9px 12px; margin: 6px 0 14px;
}
.mc-line-state.ok { color: var(--green); }
.mc-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.mc-quick-btn {
  flex: 1; min-width: 110px; text-align: center; padding: 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.mc-quick-btn:hover { border-color: var(--text-muted); }
.mc-quick-btn.highlight { background: var(--accent); border-color: var(--accent); color: #1a1200; }

/* 持股 */
.mc-hold-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mc-hold-form .wl-add-input { flex: 1; min-width: 130px; }
.mc-num {
  width: 100px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
}
.mc-num:focus { outline: none; border-color: var(--accent); background: var(--card); }
.mc-hold-summary { margin-bottom: 8px; }
.mc-hold-total {
  display: flex; gap: 12px; flex-wrap: wrap; padding: 13px; background: var(--bg);
  border-radius: 10px;
}
.mc-hold-total > div { flex: 1; min-width: 90px; }
.mc-total-val { font-size: 16px; font-weight: 700; font-family: 'DM Mono', monospace; margin-top: 2px; }
.mc-total-val.up { color: var(--red); }
.mc-total-val.down { color: var(--green); }
.mc-hold-hint { font-size: 12.5px; color: var(--text-muted); padding: 4px 0; }
.mc-hold-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.mc-hold-item:last-child { border-bottom: none; }
.mc-hold-main { flex: 1; min-width: 0; }
.mc-hold-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.mc-hold-pnl { text-align: right; font-family: 'DM Mono', monospace; white-space: nowrap; }
.mc-hold-pnl.up { color: var(--red); }
.mc-hold-pnl.down { color: var(--green); }
.mc-pnl-amt { font-size: 14.5px; font-weight: 700; }
.mc-pnl-pct { font-size: 12px; }

/* 徽章 */
.mc-badge-count { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.mc-badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mc-badge {
  text-align: center; padding: 14px 8px; border: 1px solid var(--border);
  border-radius: 12px; opacity: 0.4; filter: grayscale(1); transition: opacity 0.2s;
}
.mc-badge.earned { opacity: 1; filter: none; background: var(--bg); }
.mc-badge-icon { font-size: 28px; line-height: 1; }
.mc-badge-name { font-size: 12.5px; font-weight: 700; margin: 6px 0 2px; }
.mc-badge-desc { font-size: 10.5px; color: var(--text-muted); line-height: 1.4; }

/* 帳號設定 */
.mc-setting { margin-bottom: 14px; }
.mc-setting > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.mc-setting-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mc-setting-row .wl-add-input { flex: 1; min-width: 130px; }
.mc-setting-row.mc-pw { align-items: stretch; }
.mc-readonly { font-size: 14px; color: var(--text); }
.mc-tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.mc-tag.ok { background: var(--green-bg); color: var(--green); }
.mc-tag.warn { background: var(--accent-light); color: #8a6d00; }
:root[data-theme="dark"] .mc-tag.warn { color: var(--accent); }
.mc-danger { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.mc-danger-desc { font-size: 12.5px; color: var(--text-muted); margin: 10px 0; }

@media (max-width: 480px) {
  .mc-badges { grid-template-columns: repeat(2, 1fr); }
  .mc-num { width: 100%; }
}

/* ── 個股頁：全寬版面，左右兩欄各自獨立堆疊，長度互不牽制 ── */
.page-stock { max-width: none; grid-template-columns: 1fr 340px; align-items: start; }
/* 搜尋列與錯誤訊息橫跨兩欄，下面才分左右，讓兩欄頂部對齊 */
.page-stock > .sd-span { grid-column: 1 / -1; }
.page-stock > .stock-error.sd-span { margin: 0; }
/* 五檔搬到右欄後，K 線圖那排改成整欄寬 */
.page-stock .stock-detail-grid { grid-template-columns: 1fr; }
/* 大螢幕把 K 線圖加高，看起來更有份量 */
@media (min-width: 1100px) {
  .page-stock .lw-chart-wrap { height: 460px; }
}

/* 桌機：左欄（個股資訊＋K線）、右欄（五檔＋快捷/補充）各自為 flex column，
   獨立堆疊，不再用網格列對齊，就不會為了對齊而把矮的卡片撐高留白。 */
@media (min-width: 900px) {
  .page-stock > .sd-col-main { grid-column: 1; }
  .page-stock > .sd-col-side { grid-column: 2; }
  .page-stock > .sd-col-main,
  .page-stock > .sd-col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; align-self: start; }
  .page-stock .sd-col-main > *,
  .page-stock .sd-col-side > * { margin-top: 0 !important; }
  .page-stock #orderbook-card { position: static; top: auto; width: 100%; }
  .page-stock .ob-row { min-height: 30px; }
}

/* 右下角把快捷與補充兩張卡疊起來 */
.page-stock .sd-right-lower { display: flex; flex-direction: column; gap: 16px; }
.page-stock .sd-right-lower > * { margin-top: 0 !important; }

@media (max-width: 900px) {
  /* 窄螢幕收回單欄；兩個欄位容器內部照常堆疊 */
  .page-stock { grid-template-columns: 1fr; }
  .page-stock > .sd-col-main,
  .page-stock > .sd-col-side { display: flex; flex-direction: column; gap: 16px; }
}

/* ── 個股頁補充區塊 ── */
/* 技術指標數值列（報價卡下方） */
.sd-indicators {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sd-ind { text-align: center; }
.sd-ind-label { display: block; font-size: 11px; color: var(--text-muted); }
.sd-ind-val { display: block; font-size: 15px; font-weight: 700; font-family: 'DM Mono', monospace; margin-top: 2px; }
.sd-ind-val.up { color: var(--red); }
.sd-ind-val.down { color: var(--green); }

/* 快捷操作卡 */
.sd-quick-card { margin-top: 16px; }
.sd-quick-btn {
  display: block; width: 100%; text-align: left; margin-top: 8px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.sd-quick-btn:first-of-type { margin-top: 0; }
.sd-quick-btn:hover { border-color: var(--accent); background: var(--card); }

/* 補充資料卡 */
.sd-extra-loading { color: var(--text-muted); font-size: 13px; padding: 6px 0; }
.sd-extra-group-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  margin: 12px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.sd-extra-group-title:first-child { margin-top: 0; }
.sd-extra-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; }
.sd-extra-label { color: var(--text-muted); }
.sd-extra-val { font-weight: 500; font-family: 'DM Mono', monospace; }
.sd-extra-val.up { color: var(--red); }
.sd-extra-val.down { color: var(--green); }

@media (max-width: 480px) {
  .sd-indicators { grid-template-columns: repeat(3, 1fr); gap: 12px 8px; }
}

/* ── 股市熱力圖（深色科技風，固定深底不隨主題） ── */
.heatmap-wrap {
  max-width: none;
  margin: 20px auto 0;
  padding: 0 16px;
}
.heatmap-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.heatmap-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 17px; font-weight: 700; color: var(--text);
}
.hm-live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #16c784;
  box-shadow: 0 0 0 0 rgba(22,199,132,0.6); animation: hmPulse 2s infinite;
}
@keyframes hmPulse {
  0% { box-shadow: 0 0 0 0 rgba(22,199,132,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(22,199,132,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,199,132,0); }
}
.heatmap-sub { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.hm-select {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; font-family: inherit; cursor: pointer;
}

/* 畫布：固定深色，像專業看盤軟體 */
.heatmap-canvas {
  position: relative;
  width: 100%;
  height: 460px;
  background: #0a0e17;
  border: 1px solid #1c2637;
  border-radius: var(--radius);
  overflow: hidden;
}
.hm-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #64748b; font-size: 14px;
}
.hm-sector { position: absolute; overflow: hidden; }
.hm-sector-label {
  position: absolute; top: 0; left: 0; right: 0; height: 18px; z-index: 3;
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.82);
  padding: 2px 6px; letter-spacing: 0.5px; cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hm-sector-label:hover { color: #fff; text-decoration: underline; }

.hm-tile {
  position: absolute;
  border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  transition: filter 0.12s, transform 0.12s, box-shadow 0.12s;
  color: #fff; text-align: center; line-height: 1.15;
}
.hm-tile:hover {
  filter: brightness(1.18);
  transform: scale(1.015);
  z-index: 5;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.7), 0 4px 14px rgba(0,0,0,0.5);
}
.hm-name { font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.45); padding: 0 2px; }
.hm-pct { font-size: 11px; font-family: 'DM Mono', monospace; opacity: 0.92; text-shadow: 0 1px 2px rgba(0,0,0,0.45); }

.heatmap-legend {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--text-muted);
}
.hm-legend-bar {
  width: 120px; height: 8px; border-radius: 20px;
  background: linear-gradient(90deg, #16965a 0%, #3a4658 50%, #d62828 100%);
}
.heatmap-legend-note { margin-left: auto; }

/* 滑鼠提示卡（深色，浮在最上層） */
.hm-tip {
  position: fixed; z-index: 9999; display: none; pointer-events: none;
  background: #0f1826; border: 1px solid #2a3a4f; border-radius: 10px;
  padding: 10px 12px; min-width: 150px; box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  color: #e4ebf2;
}
.hm-tip-name { font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
.hm-tip-name span { color: #8b98ad; font-weight: 400; font-size: 12px; }
.hm-tip-row { display: flex; justify-content: space-between; gap: 18px; font-size: 12.5px; padding: 2px 0; }
.hm-tip-row span { color: #8b98ad; }
.hm-tip-row b { font-family: 'DM Mono', monospace; }
.hm-tip-row b.up { color: #ff5c5c; }
.hm-tip-row b.down { color: #16c784; }

@media (max-width: 700px) {
  .heatmap-canvas { height: 380px; }
  .heatmap-legend-note { display: none; }
}

/* ── 熱力圖獨立頁 ── */
.heatmap-page { max-width: none; margin: 20px auto 40px; padding: 0 16px; }
/* 獨立頁的畫布吃滿視窗高度，看起來更有份量 */
.heatmap-canvas-full { height: calc(100vh - 220px); min-height: 460px; }
@media (max-width: 700px) {
  .heatmap-canvas-full { height: calc(100vh - 200px); min-height: 380px; }
}

/* 熱力圖控制項橫排 */
.hm-controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 排行榜頁 ── */
.rk-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.rk-tab {
  padding: 9px 18px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px; font-family: inherit;
  cursor: pointer;
}
.rk-tab:hover { border-color: var(--text-muted); }
.rk-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .rk-tab.active { background: var(--accent); border-color: var(--accent); color: #1a1200; }
.rk-table-wrap { overflow-x: auto; }
.rk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rk-table th {
  font-size: 12px; color: var(--text-muted); font-weight: 500; text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.rk-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.rk-table tbody tr { cursor: pointer; }
.rk-table tbody tr:hover { background: var(--bg); }
.rk-table tbody tr:last-child td { border-bottom: none; }
.rk-right { text-align: right; }
.rk-rank { color: var(--text-muted); font-family: 'DM Mono', monospace; width: 40px; }
.rk-name { font-weight: 500; }
.rk-code { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.rk-price { font-family: 'DM Mono', monospace; }
.rk-metric { font-family: 'DM Mono', monospace; font-weight: 700; white-space: nowrap; }
.rk-metric.up { color: var(--red); }
.rk-metric.down { color: var(--green); }
.rk-loading { color: var(--text-muted); text-align: center; padding: 30px 0; }

/* ──────────────────────────────────────────────
   視覺精緻化：卡片微互動、配色點綴、大盤區
   ────────────────────────────────────────────── */

/* 1) 卡片微互動：hover 微微浮起 + 陰影加深，靜態頁面有回饋感 */
.insight-card, .side-card:not(.line-cta-card) {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.insight-card:hover, .side-card:not(.line-cta-card):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* 排行榜、清單列點擊回饋更明顯 */
.rk-table tbody tr, .watchlist-item, .mc-hold-item { transition: background 0.15s ease; }

/* 2) 配色點綴：三張資訊卡各給不同的標題色條，打破全白同一個樣 */
#watchlist-card .card-title::before      { background: var(--accent); }
#institutional-card .card-title::before  { background: #3b82f6; }
#dividend-cal-card .card-title::before   { background: var(--green); }
/* hover 時卡片邊框帶一點該卡的顏色 */
#watchlist-card:hover     { border-color: var(--accent); }
#institutional-card:hover { border-color: #3b82f6; }
#dividend-cal-card:hover  { border-color: var(--green); }

/* 卡片標題在深色模式原本用 --primary（深藍）會糊在深底上，改用會隨主題變的文字色 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card-title { color: var(--text); }
}
:root[data-theme="dark"] .card-title { color: var(--text); }

/* 3) 大盤區：頂部指數列加一條漸層底，數字區更有份量；全寬時圖表不要拉太寬 */
.market-hero .mh-detail {
  background: linear-gradient(180deg, var(--accent-light) 0%, transparent 55%);
}
:root[data-theme="dark"] .market-hero .mh-detail {
  background: linear-gradient(180deg, rgba(240,165,0,0.06) 0%, transparent 55%);
}
.mh-detail-value { letter-spacing: -0.5px; }
/* 走勢圖補滿整個詳情區寬度，並加高一點讓 K 線有更大空間 */
.mh-chart-wrap { max-width: none; }

/* 標籤化的小色塊（漲跌badge），比純文字有精神 */
.mh-list-chg.up, .mh-detail-change.up { font-weight: 700; }
.mh-list-chg.down, .mh-detail-change.down { font-weight: 700; }

/* ── 個股頁：尚未查詢時的落地頁 ── */
/* 空狀態隱藏個股價格列與左右兩欄（跨兩欄的落地頁自己撐版） */
.page-stock.stock-empty > #stock-header,
.page-stock.stock-empty > .sd-col-main,
.page-stock.stock-empty > .sd-col-side { display: none; }

/* 方案 A：全寬價格列 */
#stock-header.sd-span { margin-bottom: 0; padding-bottom: 18px; }
#stock-header .sd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 12px 18px; }
#stock-header .sd-indicators { margin-left: 22px; margin-right: 22px; }

.stock-landing { display: flex; flex-direction: column; gap: 16px; }
.sl-hero { text-align: center; padding: 36px 22px; }
.sl-hero-icon { width: 44px; height: 44px; color: var(--accent); margin-bottom: 10px; }
.sl-hero-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.sl-hero-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; }
.sl-hot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.sl-focus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sl-loading { color: var(--text-muted); font-size: 13px; padding: 10px 0; }
.sl-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.sl-row:last-child { border-bottom: none; }
.sl-row:hover { background: var(--bg); }
.sl-row-name { font-size: 14px; font-weight: 500; color: var(--text); }
.sl-row-code { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.sl-row-val { font-family: 'DM Mono', monospace; font-weight: 700; font-size: 14px; }
.sl-row-val.up { color: var(--red); }
.sl-row-val.down { color: var(--green); }

@media (max-width: 700px) {
  .sl-focus-grid { grid-template-columns: 1fr; }
}

/* ──────────────────────────────────────────────
   開盤晨曦 Hero
   ────────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  /* 深藍夜空 → 破曉，晨曦主題；淺色/深色都用這個深色 hero（刻意單一視覺） */
  background:
    radial-gradient(120% 140% at 88% -20%, #f0a500 0%, rgba(240,165,0,0.0) 42%),
    linear-gradient(180deg, #123056 0%, #0d2038 60%, #0b1a2e 100%);
  color: #fff;
  padding: 0 20px;
}
.hero-sun {
  position: absolute; top: -90px; right: 6%;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,196,80,0.55) 0%, rgba(255,150,60,0.18) 45%, rgba(255,150,60,0) 70%);
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 2;
  max-width: 1280px; margin: 0 auto;
  padding: 60px 0 46px;
}
.hero-eyebrow {
  font-size: 13px; letter-spacing: 2px; color: var(--accent);
  font-weight: 600; margin-bottom: 12px;
}
.hero-title {
  font-size: clamp(26px, 3.4vw, 40px); font-weight: 700; line-height: 1.25;
  margin: 0 0 12px; letter-spacing: 0.5px; text-wrap: balance;
}
.hero-sub {
  font-size: 15px; line-height: 1.8; color: rgba(255,255,255,0.72);
  margin: 0 0 18px; max-width: 46ch;
}
.hero-trust { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,0.85); }
.hero-trust i { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.35); }

/* 裝飾用 K 線背景（靜態、非即時） */
.hero-chart {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  opacity: 0.6;
  pointer-events: none;
  /* 左側淡出，讓標題文字清楚可讀 */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.25) 30%, #000 62%);
          mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.25) 30%, #000 62%);
}

/* 強勢股跑馬燈 */
.hero-ticker {
  position: relative; z-index: 2;
  border-top: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  max-width: 1280px; margin: 0 auto;
}
.tk-track {
  display: inline-flex; gap: 28px; padding: 10px 0;
  white-space: nowrap; will-change: transform;
  animation: tk-scroll 55s linear infinite;
}
.hero-ticker:hover .tk-track { animation-play-state: paused; }
@keyframes tk-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tk-item { font-size: 13px; color: rgba(255,255,255,0.85); text-decoration: none; font-family: 'DM Mono', monospace; }
.tk-item b { font-family: 'Noto Sans TC', sans-serif; font-weight: 500; }
.tk-item .up { color: #ff6b6b; }
.tk-item .down { color: #35d07f; }
.tk-item:hover { color: #fff; }

@media (prefers-reduced-motion: reduce) { .tk-track { animation: none; } }
@media (max-width: 760px) {
  .hero-inner { padding: 40px 0 30px; }
  .hero-chart { opacity: 0.42; -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 55%); mask-image: linear-gradient(180deg, transparent 0%, #000 55%); }
}

/* ──────────────────────────────────────────────
   個股 AI 健檢
   ────────────────────────────────────────────── */
.ai-intro { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin: 0 0 16px; }
.ai-usage { font-size: 12px; color: var(--text-muted); margin-top: 8px; min-height: 16px; }
.ai-report {
  margin-top: 16px; padding: 20px 22px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  font-size: 14.5px; line-height: 1.85; color: var(--text);
  max-height: 620px; overflow-y: auto;
}
.ai-report-head {
  font-weight: 700; font-size: 15px; color: var(--text);
  padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.ai-report h4 {
  font-size: 15px; font-weight: 700; color: var(--accent-strong, var(--accent));
  margin: 18px 0 8px; padding-left: 10px; border-left: 3px solid var(--accent);
}
.ai-report h4:first-child { margin-top: 0; }
.ai-report p { margin: 8px 0; }
.ai-report ul { margin: 8px 0; padding-left: 20px; }
.ai-report li { margin: 5px 0; }
.ai-report strong { color: var(--text); font-weight: 700; }
.ai-disclaimer {
  margin-top: 12px; font-size: 12px; line-height: 1.6; color: var(--text-muted);
  background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px;
}
.ai-actions { margin-top: 12px; display: flex; gap: 8px; }
.ai-mini-btn {
  flex: 1; padding: 9px 12px; font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ai-mini-btn:hover { background: var(--bg); border-color: var(--accent); }

/* ──────────────────────────────────────────────
   個股每日研判：智能評分卡
   ────────────────────────────────────────────── */
.score-card { padding: 0; overflow: hidden; }
.sc-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: 0; cursor: pointer; font-family: inherit; color: inherit; text-align: left;
  padding: 16px 20px; }
.sc-head:hover { background: var(--bg); }
.sc-head-right { display: flex; align-items: center; gap: 12px; }
.sc-mini { font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.sc-mini b { color: var(--accent); font-family: 'DM Mono', monospace; }
.sc-chev { width: 18px; height: 18px; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; }
.score-card:not(.collapsed) .sc-chev { transform: rotate(180deg); }
.sc-body { padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.score-card.collapsed .sc-body { display: none; }
.score-card.collapsed .sc-head:hover { background: var(--accent-light); }
.sc-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text); }
.sc-title .icon { width: 20px; height: 20px; color: var(--primary-mid); }
.sc-date { font-size: 12px; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; }

.sc-top { display: flex; align-items: center; gap: 22px; padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.sc-gauge { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.sc-gauge-svg { width: 108px; height: 108px; }
.sc-gauge-track { fill: none; stroke: var(--border); stroke-width: 10; }
.sc-gauge-fill { fill: none; stroke: var(--primary-mid); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 0.8s ease, stroke 0.4s; }
.sc-gauge-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 34px; font-weight: 700; color: var(--text); }
.sc-top-right { flex: 1; min-width: 0; }
.sc-eval { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.sc-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.sc-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; color: var(--text); }
.sc-badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.sc-badge-dot.conf { background: var(--primary-mid); }
.sc-badge-dot.risk-low { background: #35c07f; }
.sc-badge-dot.risk-mid { background: #f0a500; }
.sc-badge-dot.risk-high { background: #ef4444; }
.sc-verdict { margin-top: 10px; font-size: 13px; font-weight: 600; }
.sc-verdict.pos { color: var(--red); }
.sc-verdict.neg { color: var(--green); }
.sc-verdict.neu { color: var(--text-muted); }

.sc-dims { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.sc-dim-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.sc-dim-val { font-family: 'DM Mono', monospace; font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.sc-bar { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.sc-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--primary-mid); width: 0; transition: width 0.7s ease; }

.sc-summary-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
#sc-summary-body { font-size: 13.5px; line-height: 1.9; color: var(--text); }
#sc-summary-body p { margin: 0 0 8px; }
#sc-summary-body p:last-child { margin-bottom: 0; }
#sc-summary-body b { font-weight: 700; }
#sc-summary-body .up { color: var(--red); font-weight: 700; }
#sc-summary-body .down { color: var(--green); font-weight: 700; }
.sc-disclaimer { margin-top: 14px; font-size: 11.5px; line-height: 1.6; color: var(--text-muted); }

@media (max-width: 640px) {
  .sc-dims { grid-template-columns: 1fr 1fr; }
}

/* ──────────────────────────────────────────────
   每日研判 + 事件提醒：並排收合卡 + 事件時間軸
   ────────────────────────────────────────────── */
.sd-summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .sd-summary-row { grid-template-columns: 1fr; } }

.ev-group { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; margin: 14px 0 6px; }
.ev-group:first-child { margin-top: 0; }
.ev-item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.ev-date { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-muted); width: 62px; flex-shrink: 0; margin-top: 1px; }
.ev-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; box-shadow: 0 0 0 3px var(--card); }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.ev-item.future .ev-title { color: var(--primary-mid); }
.ev-detail { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.ev-empty { font-size: 13px; color: var(--text-muted); padding: 8px 0; }
