:root {
  --bg: #05080d;
  --surface: #0b1420;
  --ink: #d7e5ee;
  --muted: #7d95a3;
  --line: #1d3441;
  --up: #f87171;
  --down: #34d399;
  --amber: #fbbf24;
  --header: #060b12;
  --header-soft: #0f2230;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --glow: rgba(34, 211, 238, 0.35);
  --btn-text: #031016;
  --radius: 8px;
  --shadow: 0 0 0 1px rgba(34, 211, 238, 0.08), 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.045) 1px, transparent 1px);
  background-size: 30px 30px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
}

.topbar {
  background: var(--header);
  color: #e6f7ff;
  padding: 18px max(16px, env(safe-area-inset-left)) 18px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid #17324a;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}

.topbar .muted {
  color: #86a7b8;
  font-size: 13px;
  margin: 3px 0 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn {
  background: var(--accent);
  color: var(--btn-text);
  font-weight: 700;
  padding: 11px 18px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  box-shadow: 0 0 16px var(--glow);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.tabbar {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.tab-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 700;
  padding: 10px 16px;
  min-height: 42px;
  border-radius: var(--radius);
}

.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--glow);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kline-frame {
  width: 100%;
  height: calc(100vh - 190px);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #070b14;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #0d1c28;
  color: #9fd7e8;
  border: 1px solid #1f4256;
  font-size: 13px;
  font-weight: 700;
}

.badge.up {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.4);
}

.badge.down {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}

.summary-body p {
  margin: 0 0 10px;
}

.summary-body .lead {
  font-size: 15px;
  font-weight: 600;
}

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

.fact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.fact {
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.add-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
}

.add-row input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.secondary-btn {
  background: var(--header-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 700;
  padding: 11px 16px;
  min-height: 44px;
  white-space: nowrap;
}

.secondary-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow);
}

.feedback {
  min-height: 20px;
  font-size: 13px;
  margin: 0 0 10px;
}

.etf-type-note {
  margin: 0 0 10px;
  font-size: 13px;
}

.feedback.error {
  color: var(--down);
}

.stock-grid,
.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* 平板兩欄 */
@media (max-width: 1100px) {
  .stock-grid,
  .macro-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stock-card,
.macro-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  position: relative;
  min-width: 0;
}

.stock-card:hover,
.macro-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--glow);
}

.stock-card .remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stock-card .remove-btn:hover {
  background: rgba(248, 113, 113, 0.24);
}

.pro-box {
  margin: 10px 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.pro-box.up {
  border-left-color: var(--up);
}

.pro-box.dn {
  border-left-color: var(--down);
}

.pro-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.pro-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--txt-soft);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 36px 8px 0;
}

.card-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.card-title code {
  color: var(--muted);
  font-size: 12px;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.price {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.change {
  font-size: 14px;
  font-weight: 700;
}

.change.up,
.positive {
  color: var(--up);
}

.change.down,
.negative {
  color: var(--down);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 12px;
  min-width: 0;
}

.meta-grid span {
  color: var(--muted);
  display: block;
}

.meta-grid strong {
  color: var(--ink);
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.macro-card {
  min-height: 132px;
}

.macro-card .price {
  font-size: 19px;
}

.macro-card .card-title {
  margin-right: 0;
}

.checklist {
  display: grid;
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.check-item strong {
  font-size: 14px;
}

.check-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.check-item .badge {
  flex-shrink: 0;
}

.news-body {
  display: grid;
  gap: 14px;
}

.news-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #42585d;
}

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-list li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.news-list li:first-child {
  border-top: 0;
}

.news-list a {
  color: var(--ink);
  text-decoration: none;
}

.news-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.news-list time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 36px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--header);
  color: #ffffff;
  border: 1px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 16px var(--glow);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.toast.error {
  background: #8e312d;
}

.error-card {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(60, 15, 20, 0.35);
}

.error-text {
  color: var(--down);
  font-size: 13px;
}

@media (max-width: 640px) {
  .topbar {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar-inner {
    gap: 10px;
  }

  .primary-btn {
    padding: 10px 13px;
  }

  main {
    padding-left: 10px;
    padding-right: 10px;
  }

  .section {
    padding: 14px;
    margin: 10px 0;
  }

  .stock-grid,
  .macro-grid,
  .etf-grid,
  .ai-top3,
  .fund-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .check-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .add-row {
    flex-direction: column;
  }

  .secondary-btn {
    width: 100%;
  }

  .kline-frame {
    height: calc(100vh - 210px);
    min-height: 480px;
  }
}

/* Taiwan research workbench */
.research-hero {
  padding-bottom: 20px;
}

.research-health {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.research-health-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 20, 30, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.research-health-item::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
}

.research-health-item.ok::before { background: var(--down); }
.research-health-item.error::before { background: var(--up); }
.research-health-item.loading::before { animation: researchPulse 1s infinite alternate; }

@keyframes researchPulse {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

.research-subtabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: thin;
}

.research-subtab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 20, 30, 0.72);
  color: var(--muted);
  font-weight: 700;
}

.research-subtab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.research-panel {
  display: none;
}

.research-panel.active {
  display: block;
}

.research-toolbar,
.research-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.research-inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.research-toolbar label,
.research-form-grid label,
.research-inline-form label,
.research-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.research-toolbar input,
.research-form-grid input,
.research-form-grid select,
.research-inline-form input,
.research-card input,
.research-card select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #07121c;
  color: var(--ink);
}

.research-inline-form input {
  min-width: min(320px, 70vw);
}

.research-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.research-kpi {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 18, 28, 0.74);
}

.research-kpi span,
.research-kpi small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.research-kpi strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0;
}

.research-kpi strong.up { color: var(--up); }
.research-kpi strong.down { color: var(--down); }

.research-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
}

.research-list-item {
  padding: 9px 11px;
  border-left: 3px solid var(--amber);
  background: rgba(251, 191, 36, 0.08);
  color: var(--ink);
  font-size: 13px;
}

.research-list-item.ok {
  border-left-color: var(--down);
  background: rgba(52, 211, 153, 0.08);
}

.research-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.research-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.research-table th,
.research-table td {
  padding: 10px 11px;
  border-bottom: 1px solid rgba(120, 140, 150, 0.16);
  text-align: left;
  white-space: nowrap;
}

.research-table th {
  position: sticky;
  top: 0;
  background: #09151f;
  color: var(--muted);
  font-size: 11px;
  z-index: 1;
}

.research-table tr:last-child td {
  border-bottom: 0;
}

.research-actions {
  display: flex;
  gap: 6px;
}

.research-action-btn {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.research-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.research-year {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 18, 28, 0.74);
}

.research-year h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.research-metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(120, 140, 150, 0.12);
  font-size: 12px;
}

.research-metric-row:last-child {
  border-bottom: 0;
}

.research-metric-row span {
  color: var(--muted);
}

.research-bar {
  height: 5px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(120, 140, 150, 0.15);
  overflow: hidden;
}

.research-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.research-tax-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.research-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 18, 28, 0.62);
}

.research-card h3 {
  margin: 0;
  font-size: 16px;
}

.research-error {
  padding: 14px;
  border: 1px solid rgba(248, 113, 113, 0.38);
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
}

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

  .research-inline-form {
    align-items: stretch;
  }

  .research-inline-form label {
    width: 100%;
  }

  .research-inline-form input {
    min-width: 0;
  }
}

.theme-select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  min-height: 40px;
  font-weight: 700;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(112, 20, 20, 0.96), rgba(60, 8, 8, 0.98)),
    repeating-linear-gradient(45deg, rgba(255, 215, 100, 0.06) 0 2px, transparent 2px 10px);
}

.login-overlay.hidden {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #3a0d0d, #240606);
  border: 2px solid #d4a73c;
  border-radius: 12px;
  padding: 34px 28px;
  text-align: center;
  color: #f6e7c1;
  box-shadow: 0 0 0 6px rgba(212, 167, 60, 0.15), 0 24px 70px rgba(0, 0, 0, 0.6);
}

.login-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #e3c46b;
  border-radius: 50%;
  background: #8f1d1d;
  color: #ffe9a8;
  font-size: 32px;
  font-weight: 900;
  font-family: "Hiragino Mincho ProN", "Songti TC", serif;
  box-shadow: 0 0 24px rgba(227, 196, 107, 0.45);
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 6px;
  color: #ffe9a8;
}

.login-sub {
  margin: 0 0 22px;
  color: #d9b96b;
  letter-spacing: 2px;
}

.login-panel form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.login-panel label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #e8d29b;
}

.login-panel input {
  border: 1px solid #b08a35;
  border-radius: 8px;
  background: rgba(20, 4, 4, 0.75);
  color: #ffe9a8;
  padding: 12px;
  font-size: 15px;
}

.login-panel input:focus {
  outline: 2px solid #e3c46b;
}

.login-panel .primary-btn {
  width: 100%;
  margin-top: 4px;
  background: #c49a2f;
  color: #2b0707;
  box-shadow: 0 0 18px rgba(227, 196, 107, 0.35);
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: #ffb3a7;
  font-size: 13px;
}

body.theme-ukiyoe {
  --bg: #efe3c9;
  --surface: #fff6e5;
  --ink: #1f2340;
  --muted: #7d6f57;
  --line: #d4b98a;
  --up: #c9382f;
  --down: #2f7d4f;
  --header: #24315e;
  --header-soft: #33406e;
  --accent: #d64545;
  --accent-soft: rgba(214, 69, 69, 0.14);
  --glow: rgba(214, 69, 69, 0.25);
  --btn-text: #fff6e5;
  background-image: repeating-linear-gradient(0deg, rgba(36, 49, 94, 0.07) 0 2px, transparent 2px 30px);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Songti TC", serif;
}

body.theme-ukiyoe .topbar {
  background: var(--header);
  border-bottom: 3px solid #d64545;
}

body.theme-ukiyoe .primary-btn {
  background: var(--accent);
}

body.theme-ukiyoe .stock-card,
body.theme-ukiyoe .macro-card {
  border-width: 2px;
}

body.theme-muji {
  --bg: #f4f1eb;
  --surface: #fbfaf7;
  --ink: #3d3a36;
  --muted: #9a9187;
  --line: #ddd6cb;
  --up: #b25c4f;
  --down: #5f7f68;
  --header: #4c4a45;
  --header-soft: #5f5c56;
  --accent: #8f8a80;
  --accent-soft: rgba(120, 114, 104, 0.14);
  --glow: rgba(120, 114, 104, 0.18);
  --btn-text: #fbfaf7;
  background-image: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif;
}

body.theme-muji .section,
body.theme-muji .stock-card,
body.theme-muji .macro-card,
body.theme-muji .tab-btn {
  box-shadow: none;
  border-radius: 2px;
}

body.theme-muji .primary-btn,
body.theme-muji .secondary-btn {
  border-radius: 2px;
}

body.theme-wabisabi {
  --bg: #e9e0d3;
  --surface: #f3ecdf;
  --ink: #3f352c;
  --muted: #8d7f6f;
  --line: #cbb9a0;
  --up: #a34a3d;
  --down: #5f7a5c;
  --header: #51453a;
  --header-soft: #66584a;
  --accent: #9a4f3d;
  --accent-soft: rgba(154, 79, 61, 0.14);
  --glow: rgba(154, 79, 61, 0.2);
  --btn-text: #f3ecdf;
  background-image: repeating-linear-gradient(45deg, rgba(120, 100, 80, 0.03) 0 2px, transparent 2px 7px);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Songti TC", serif;
}

body.theme-wabisabi .section,
body.theme-wabisabi .stock-card,
body.theme-wabisabi .macro-card {
  border-color: #c2ad90;
  box-shadow: 2px 3px 0 rgba(120, 100, 80, 0.12);
}

body.theme-zen {
  --bg: #f7f5f0;
  --surface: #fdfcf9;
  --ink: #222222;
  --muted: #8a8a85;
  --line: #d8d5cc;
  --up: #8e3b34;
  --down: #3f6b52;
  --header: #262626;
  --header-soft: #3a3a3a;
  --accent: #a63d33;
  --accent-soft: rgba(166, 61, 51, 0.12);
  --glow: rgba(166, 61, 51, 0.18);
  --btn-text: #fdfcf9;
  background-image: none;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "PingFang TC", sans-serif;
}

body.theme-zen .section {
  border: 0;
  border-top: 3px solid #262626;
  box-shadow: none;
  border-radius: 0;
}

body.theme-zen .topbar {
  background: #ffffff;
  color: #222222;
  border-bottom: 1px solid #d8d5cc;
  box-shadow: none;
}

body.theme-zen .topbar h1 {
  text-shadow: none;
}

body.theme-zen .primary-btn {
  background: #a63d33;
}

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

.etf-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.etf-summary-grid > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.etf-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.etf-summary strong {
  font-size: 18px;
}

.etf-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}

.etf-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 36px 10px 0;
  flex-wrap: wrap;
}

.etf-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.etf-head code {
  color: var(--muted);
  font-size: 12px;
}

.etf-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.etf-inputs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.etf-inputs label {
  flex: 1;
  min-width: 110px;
  color: var(--muted);
  font-size: 12px;
}

.etf-inputs input {
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.etf-inputs input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.etf-inputs select {
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.quick-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.quick-row button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  min-height: 32px;
}

.quick-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.report-wrap {
  margin-top: 6px;
}

.report-wrap h3 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 0;
}

.etf-chart {
  width: 100%;
  height: auto;
  max-height: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* 全市場 ETF 年度排行 */
.active-etf-ranking-root {
  margin: 14px 0 18px;
}
.active-etf-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}
.active-etf-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.active-etf-head h3 {
  margin: 0;
  font-size: 15px;
}
.active-etf-head p,
.active-etf-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}
.active-etf-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.active-etf-segment {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(5, 8, 13, 0.45);
}
.active-etf-segment button {
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.active-etf-segment button:hover,
.active-etf-segment button.active {
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
}
.active-etf-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 10px;
}
.active-etf-table-wrap {
  overflow-x: auto;
}
.active-etf-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 11px;
}
.active-etf-table th,
.active-etf-table td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(120, 140, 150, 0.16);
  text-align: left;
  vertical-align: middle;
}
.active-etf-table th {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}
.active-etf-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.06);
}
.active-etf-toggle-row {
  display: flex;
  justify-content: center;
  padding-top: 10px;
}
.active-etf-toggle {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(5, 8, 13, 0.45);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.active-etf-toggle::after {
  display: inline-block;
  margin-left: 7px;
  content: "⌄";
  transition: transform 160ms ease;
}
.active-etf-toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}
.active-etf-toggle:hover {
  background: rgba(34, 211, 238, 0.12);
}
.active-etf-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.active-etf-rank {
  width: 42px;
  color: var(--accent);
  font-weight: 800;
}
.active-etf-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.active-etf-mobile-stats,
.active-etf-mobile-notes {
  display: none;
}
.active-etf-table code {
  color: var(--muted);
  font-size: 9px;
}
.active-etf-frequency {
  display: inline-block;
  padding: 3px 6px;
  border: 1px solid rgba(125, 149, 163, 0.28);
  border-radius: 999px;
  color: var(--ink);
  white-space: nowrap;
}
.active-etf-yield strong {
  color: #fbbf24;
}
.active-etf-return strong {
  color: #67e8f9;
}
.active-etf-notes {
  min-width: 130px;
}
.active-etf-note {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}
.active-etf-note.dividend {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
.active-etf-note.growth {
  background: rgba(34, 211, 238, 0.14);
  color: #67e8f9;
}
.active-etf-note.muted {
  color: var(--muted);
}

/* ETF 配息儀表板 */
.etf-dashboard {
  margin: 14px 0 18px;
}
.etfd {
  display: grid;
  gap: 12px;
}
.etfd-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.etfd-summary > div,
.etfd-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}
.etfd-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.etfd-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}
.etfd-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 0.8fr);
  gap: 12px;
}
.etfd-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(300px, 1.2fr);
  gap: 12px;
}
.etfd-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.etfd-panel-head h3 {
  margin: 0;
  font-size: 14px;
}
.etfd-panel-head span {
  color: var(--muted);
  font-size: 10px;
}
.etfd-canvas {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid rgba(120, 140, 150, 0.16);
  border-radius: 6px;
  background: #08131c;
}
.etfd-canvas-small { height: 180px; }
.etfd-legend {
  display: flex;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}
.etfd-legend .cyan { color: #67e8f9; }
.etfd-legend .gold { color: #fbbf24; }
.etfd-core {
  display: grid;
  align-content: start;
  gap: 7px;
}
.etfd-core-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.06);
}
.etfd-core-price span { color: var(--muted); font-size: 11px; }
.etfd-core-price strong { font-size: 24px; }
.etfd-core-price em { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 700; }
.etfd-core-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(120, 140, 150, 0.16);
  font-size: 11px;
}
.etfd-core-stat span { color: var(--muted); }
.etfd-gauge-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.etfd-gauge {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}
.etfd-ring {
  width: 86px;
  height: 86px;
  padding: 7px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct), rgba(120, 140, 150, 0.18) 0);
}
.etfd-ring > div {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  border-radius: 50%;
  background: #08131c;
}
.etfd-ring strong { font-size: 18px; }
.etfd-ring span,
.etfd-gauge > span {
  color: var(--muted);
  font-size: 9px;
}
.etfd-ranking {
  overflow: auto;
}
.etfd-rank-head,
.etfd-rank-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.5fr) repeat(4, minmax(62px, 0.7fr));
  gap: 6px;
  align-items: center;
}
.etfd-rank-head {
  padding: 4px 6px 7px;
  color: var(--muted);
  font-size: 9px;
}
.etfd-rank-row {
  width: 100%;
  padding: 7px 6px;
  border: 0;
  border-top: 1px solid rgba(120, 140, 150, 0.14);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 10px;
}
.etfd-rank-row:hover,
.etfd-rank-row.active {
  background: rgba(34, 211, 238, 0.07);
}
.etfd-rank-row > span:first-child {
  display: grid;
  min-width: 0;
}
.etfd-rank-row strong,
.etfd-rank-row code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.etfd-rank-row code { color: var(--muted); font-size: 9px; }
.etfd-empty {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1000px) {
  .etfd-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .etfd-main-grid,
  .etfd-chart-grid { grid-template-columns: 1fr; }
  .etfd-gauge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .active-etf-head { display: grid; }
  .active-etf-controls { justify-content: flex-start; }
  .active-etf-segment button { padding-inline: 7px; }
  .active-etf-table { min-width: 0; }
  .active-etf-hide-mobile { display: none; }
  .active-etf-col-mobile,
  .active-etf-notes { display: none; }
  .active-etf-mobile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    color: var(--muted);
  }
  .active-etf-mobile-stats em {
    font-style: normal;
  }
  .active-etf-mobile-notes {
    display: block;
    margin-top: 4px;
  }
  .etfd-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .etfd-canvas { height: 230px; }
  .etfd-rank-head,
  .etfd-rank-row { grid-template-columns: minmax(100px, 1.4fr) repeat(2, 58px); }
  .etfd-rank-head span:nth-child(4),
  .etfd-rank-head span:nth-child(5),
  .etfd-rank-row > span:nth-child(4),
.etfd-rank-row > span:nth-child(5) { display: none; }
}

/* 單股決策台 */
.dashboard-action {
  margin-top: 9px;
}

.dashboard-btn {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 7px;
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--glow);
}

.sd-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.sd-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

.sd-toolbar input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(5, 8, 13, 0.5);
  color: var(--ink);
  font-weight: 700;
}

.sd-toolbar input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sd-toolbar .secondary-btn {
  min-height: 42px;
}

.sd-root {
  margin-top: 12px;
}

.sd-dashboard {
  display: grid;
  gap: 12px;
}

.sd-hero,
.sd-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}

.sd-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.7fr) minmax(170px, 0.55fr);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-color: rgba(34, 211, 238, 0.28);
}

.sd-eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.sd-identity h2 {
  margin: 2px 0 3px;
  font-size: 22px;
}

.sd-identity code {
  color: var(--muted);
  font-size: 12px;
}

.sd-price-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}

.sd-price-row strong {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.sd-price-row span {
  font-size: 14px;
  font-weight: 700;
}

.sd-status {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted) !important;
  font-size: 10px !important;
}

.sd-hero-meta,
.sd-hero-verdict {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 70px;
  padding-left: 14px;
  border-left: 1px solid rgba(34, 211, 238, 0.2);
}

.sd-hero-meta span,
.sd-hero-meta strong,
.sd-hero-verdict span,
.sd-hero-verdict small {
  color: var(--muted);
  font-size: 10px;
}

.sd-hero-meta strong {
  color: var(--ink);
  font-size: 11px;
}

.sd-hero-verdict strong {
  font-size: 21px;
}

.sd-hero-verdict b {
  color: var(--accent);
  font-size: 12px;
}

.sd-top-grid,
.sd-indicator-grid,
.sd-detail-grid,
.sd-bottom-grid {
  display: grid;
  gap: 12px;
}

.sd-top-grid { grid-template-columns: minmax(0, 2.1fr) minmax(280px, 0.8fr); }
.sd-indicator-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-bottom-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }

.sd-panel {
  padding: 12px;
}

.sd-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.sd-panel-head > div {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.sd-panel-head h3 {
  margin: 0;
  font-size: 14px;
}

.sd-panel-head > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sd-number {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.sd-canvas {
  display: block;
  width: 100%;
  height: 250px;
  border: 1px solid rgba(120, 140, 150, 0.16);
  border-radius: 6px;
  background: #08131c;
}

.sd-kline { height: 310px; }
.sd-small { height: 170px; }

.sd-decision {
  display: grid;
  gap: 10px;
}

.sd-decision-score {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 7px;
  background: rgba(34, 211, 238, 0.05);
}

.sd-decision-score strong {
  color: var(--accent);
  font-size: 30px;
}

.sd-decision-score span,
.sd-decision-score em {
  color: var(--muted);
  font-size: 10px;
}

.sd-decision-score em {
  font-style: normal;
}

.sd-reasons {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sd-reasons li {
  position: relative;
  padding-left: 12px;
  color: var(--ink);
  font-size: 11px;
}

.sd-reasons li::before {
  position: absolute;
  left: 0;
  color: var(--accent);
  content: "·";
}

.sd-levels,
.sd-mini-stats,
.sd-stat-grid {
  display: grid;
  gap: 7px;
}

.sd-levels,
.sd-mini-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sd-mini-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
.sd-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sd-wide-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.sd-stat {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(120, 140, 150, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
}

.sd-stat span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.sd-stat strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sd-score-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.sd-score {
  display: grid;
  justify-items: center;
}

.sd-ring {
  width: 72px;
  height: 72px;
  padding: 6px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct), rgba(120, 140, 150, 0.18) 0);
}

.sd-ring > div {
  display: grid;
  width: 100%;
  height: 100%;
  place-content: center;
  justify-items: center;
  border-radius: 50%;
  background: #08131c;
}

.sd-ring strong {
  font-size: 17px;
}

.sd-ring span {
  color: var(--muted);
  font-size: 9px;
}

.sd-verdict {
  display: grid;
  gap: 7px;
}

.sd-verdict > span {
  color: var(--muted);
  font-size: 11px;
}

.sd-verdict > strong {
  color: var(--ink);
  font-size: 25px;
}

.sd-verdict > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sd-source {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.sd-empty,
.sd-loading {
  min-height: 180px;
  display: grid;
  place-content: center;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.sd-loading > div:first-child {
  display: grid;
  gap: 3px;
}

.sd-loading strong {
  color: var(--ink);
  font-size: 18px;
}

.sd-loading-bar {
  width: min(320px, 70vw);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(120, 140, 150, 0.18);
}

.sd-loading-bar i {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: sd-loading 1s ease-in-out infinite alternate;
}

@keyframes sd-loading {
  from { transform: translateX(0); }
  to { transform: translateX(120%); }
}

@media (max-width: 1000px) {
  .sd-hero { grid-template-columns: 1fr 1fr; }
  .sd-identity { grid-column: 1 / -1; }
  .sd-hero-verdict { border-left: 0; }
  .sd-top-grid,
  .sd-bottom-grid { grid-template-columns: 1fr; }
  .sd-indicator-grid,
  .sd-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .sd-toolbar,
  .sd-toolbar label,
  .sd-toolbar .primary-btn,
  .sd-toolbar .secondary-btn { width: 100%; }
  .sd-hero { grid-template-columns: 1fr; padding: 13px; }
  .sd-hero-meta,
  .sd-hero-verdict { padding: 9px 0 0; border-top: 1px solid rgba(34, 211, 238, 0.2); border-left: 0; }
  .sd-identity h2 { font-size: 19px; }
  .sd-price-row strong { font-size: 24px; }
  .sd-indicator-grid,
  .sd-detail-grid { grid-template-columns: 1fr; }
  .sd-kline { height: 250px; }
  .sd-levels,
  .sd-wide-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sd-score-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ai-top3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.ai-card {
  position: relative;
}

.ai-rank {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--btn-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
}

.ai-rank.rank-1 {
  background: #e6b31e;
  color: #1a1403;
  box-shadow: 0 0 18px rgba(230, 179, 30, 0.55);
}

.ai-rank.rank-2 {
  background: #b8c4cc;
  color: #10151a;
}

.ai-rank.rank-3 {
  background: #c98d3e;
  color: #1c1204;
}

.ai-note {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.fund-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.fund-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0;
}

/* 持股風控總覽 */
.portfolio-summary {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--panel, #2a3a44);
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.04);
}
.portfolio-summary .etf-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

/* 停利/停損警報按鈕 */
.stock-alerts {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.alert-btn {
  border: 1px solid var(--panel, #3a4b56);
  background: rgba(34, 211, 238, 0.08);
  color: var(--txt, #d7e5ee);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.alert-btn.up { border-color: rgba(52, 211, 153, 0.5); color: #34d399; }
.alert-btn.dn { border-color: rgba(248, 113, 113, 0.5); color: #f87171; }
.alert-btn:active { transform: scale(0.96); }

/* 個股持股輸入 */
.stock-card { min-width: 0; }
.stock-hold {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(120, 140, 150, 0.25);
  font-size: 12px;
}
.stock-hold label { display: flex; align-items: center; gap: 6px; color: var(--t2, #7d95a3); min-width: 0; }
.stock-hold input {
  flex: 1 1 56px;
  min-width: 0;
  max-width: 84px;
  background: var(--panel, #1d2b33);
  color: var(--txt, #d7e5ee);
  border: 1px solid var(--panel, #3a4b56);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}
.stock-hold-profit {
  margin-left: auto;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 基本面融資券增減 */
.fund-card em { font-style: normal; font-size: 11px; margin-left: 4px; }

/* 明日趨勢回測 */
.backtest-card {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--panel, #2a3a44);
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.03);
}
.bt-summary {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}
.bt-summary strong { font-size: 22px; margin: 0 4px; }
.bt-latest {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 13px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.07);
}
.bt-latest strong { font-size: 20px; margin: 0 2px; }
.bt-group {
  padding: 9px 0;
  border-top: 1px solid rgba(120, 140, 150, 0.16);
}
.bt-group:first-of-type { border-top: 0; }
.bt-group-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  min-height: 26px;
}
.bt-group-head h3 {
  margin: 0 6px 0 0;
  font-size: 15px;
}
.bt-stage {
  padding: 2px 7px;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(120, 140, 150, 0.3);
  color: #9db3c0;
}
.bt-stage.ok {
  border-color: rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
}
.bt-row.stock {
  align-items: center;
  min-height: 28px;
}
.bt-stock { flex: 1 1 150px; }
.bt-stock code { opacity: 0.65; font-size: 10px; }
.bt-list { max-height: 180px; overflow-y: auto; }
.bt-row {
  display: flex;
  gap: 14px;
  padding: 3px 0;
  font-size: 12px;
  border-bottom: 1px dashed rgba(120, 140, 150, 0.15);
}
.bt-note { font-size: 11px; margin-top: 8px; }

/* 明日趨勢回測儀表板 */
.bt-dash {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.bt-dash-top {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.09), rgba(7, 18, 28, 0.72));
}
.bt-dash-top h2 {
  margin: 2px 0 4px;
  font-size: 22px;
}
.bt-dash-top p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.bt-eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.bt-latest-panel {
  min-width: 220px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding-left: 14px;
  border-left: 1px solid rgba(34, 211, 238, 0.22);
}
.bt-latest-panel > span:first-child,
.bt-latest-panel small {
  color: var(--muted);
  font-size: 11px;
}
.bt-latest-panel strong {
  font-size: 24px;
}
.bt-latest-panel strong.up,
.up { color: #6ee7b7; }
.bt-latest-panel strong.down,
.down { color: #fb923c; }
.bt-main-grid,
.bt-middle-grid,
.bt-bottom-grid {
  display: grid;
  gap: 12px;
}
.bt-main-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 0.8fr); }
.bt-middle-grid { grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.8fr) minmax(220px, 0.8fr); }
.bt-bottom-grid { grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr); }
.bt-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}
.bt-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.bt-panel-head h3 {
  margin: 0;
  font-size: 14px;
}
.bt-panel-head span {
  color: var(--muted);
  font-size: 10px;
}
.bt-canvas {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid rgba(120, 140, 150, 0.16);
  border-radius: 6px;
  background: #08131c;
}
.bt-canvas-small { height: 180px; }
.bt-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}
.bt-chart-legend .hit { color: #6ee7b7; }
.bt-chart-legend .miss { color: #fb923c; }
.bt-core-panel {
  display: grid;
  align-content: start;
  gap: 8px;
}
.bt-core-direction {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.06);
}
.bt-core-direction span,
.bt-core-direction small { color: var(--muted); font-size: 11px; }
.bt-core-direction strong { font-size: 24px; }
.bt-core-stat {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(120, 140, 150, 0.16);
  font-size: 12px;
}
.bt-core-stat span { color: var(--muted); }
.bt-core-panel h4,
.bt-stock-groups h4 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.bt-checklist {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bt-checklist li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}
.bt-gauge-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.bt-gauge {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.72);
}
.bt-gauge-ring {
  width: 88px;
  height: 88px;
  padding: 7px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct), rgba(120, 140, 150, 0.18) 0);
}
.bt-gauge-center {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  border-radius: 50%;
  background: #08131c;
}
.bt-gauge-center strong { font-size: 20px; }
.bt-gauge-center span,
.bt-gauge-label {
  color: var(--muted);
  font-size: 10px;
}
.bt-window-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}
.bt-window {
  display: inline-flex;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
}
.bt-window.ready { color: #9fd7e8; border-color: rgba(34, 211, 238, 0.36); }
.bt-matrix {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) repeat(2, minmax(52px, 0.7fr));
  gap: 4px;
  align-items: center;
  font-size: 11px;
}
.bt-matrix > span,
.bt-matrix > strong { color: var(--muted); font-weight: 500; }
.bt-matrix > b {
  padding: 12px 6px;
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 6px;
  text-align: center;
  font-size: 18px;
}
.bt-gap-list {
  display: grid;
  gap: 7px;
}
.bt-gap-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}
.bt-gap-row > span { color: var(--muted); }
.bt-gap-row > strong { text-align: right; }
.bt-gap-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(120, 140, 150, 0.16);
}
.bt-gap-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f97316, #22d3ee);
}
.bt-table-wrap {
  max-height: 320px;
  overflow: auto;
}
.bt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.bt-table th,
.bt-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(120, 140, 150, 0.14);
  text-align: left;
  white-space: nowrap;
}
.bt-table th {
  position: sticky;
  top: 0;
  background: #0a1b27;
  color: var(--muted);
}
.bt-result {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
}
.bt-result.hit { color: #6ee7b7; background: rgba(34, 197, 94, 0.1); }
.bt-result.miss { color: #fb923c; background: rgba(249, 115, 22, 0.1); }
.bt-stock-groups {
  max-height: 440px;
  overflow: auto;
}
.bt-stock-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.2fr) minmax(56px, 0.8fr) 42px auto;
  gap: 7px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(120, 140, 150, 0.14);
  font-size: 11px;
}
.bt-stock-row > div:first-child {
  display: grid;
  min-width: 0;
}
.bt-stock-row > div:first-child span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
}
.bt-stock-meter {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(120, 140, 150, 0.16);
}
.bt-stock-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.bt-stage {
  display: inline-flex;
  width: fit-content;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}
.bt-stage.ok { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.42); }
.bt-stage.watch { color: #9fd7e8; border-color: rgba(34, 211, 238, 0.36); }
.bt-stage.early { color: #fbbf24; border-color: rgba(251, 191, 36, 0.36); }
.bt-empty {
  padding: 14px 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

@media (max-width: 960px) {
  .bt-main-grid,
  .bt-middle-grid,
  .bt-bottom-grid { grid-template-columns: 1fr; }
  .bt-gauge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .bt-dash-top { flex-direction: column; }
  .bt-latest-panel {
    min-width: 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(34, 211, 238, 0.22);
    border-left: 0;
  }
  .bt-gauge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bt-canvas { height: 230px; }
  .bt-stock-row { grid-template-columns: minmax(88px, 1fr) 50px 38px; }
  .bt-stock-row .bt-stage { display: none; }
}

/* 配息估值 */
.dividend-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.dividend-summary > .etf-summary-grid {
  display: contents;
}
.dividend-summary .etf-summary-grid > div {
  background: rgba(7, 18, 28, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.dividend-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.dividend-summary strong {
  font-size: 18px;
}
.dividend-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.dividend-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}
.dividend-table th,
.dividend-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(120, 140, 150, 0.16);
  white-space: nowrap;
}
.dividend-table th {
  background: rgba(10, 27, 39, 0.92);
  color: var(--muted);
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.dividend-table tbody tr {
  cursor: pointer;
}
.dividend-table tbody tr:hover,
.dividend-table tbody tr.selected {
  background: rgba(34, 211, 238, 0.07);
}
.dividend-table tbody tr:last-child td {
  border-bottom: 0;
}
.dividend-table td strong,
.dividend-table td span {
  display: block;
}
.dividend-table td span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.dividend-table .symbol {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.dividend-sort {
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
}
.dividend-sort::after {
  content: "↕";
  margin-left: 5px;
  color: var(--muted);
}
.dividend-sort.active[data-direction="desc"]::after {
  content: "↓";
  color: var(--accent);
}
.dividend-sort.active[data-direction="asc"]::after {
  content: "↑";
  color: var(--accent);
}
.valuation-badge {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: #9fd7e8;
  font-size: 11px;
  font-weight: 700;
}
.valuation-badge.valuation-low {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
}
.valuation-badge.valuation-high {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.08);
}
.dividend-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.dividend-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dividend-detail-head h3 {
  margin: 0;
  font-size: 16px;
}
.dividend-detail-head p {
  margin: 3px 0 0;
}
.dividend-history {
  margin-top: 16px;
}
.dividend-history h3 {
  margin: 0 0 8px;
  font-size: 14px;
}
.dividend-history-scroll {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.dividend-record-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
}
.dividend-record-table th,
.dividend-record-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(120, 140, 150, 0.14);
  white-space: nowrap;
}
.dividend-record-table th:first-child,
.dividend-record-table td:first-child {
  text-align: left;
}
.dividend-record-table th {
  position: sticky;
  top: 0;
  background: #0a1b27;
  color: var(--muted);
}

@media (max-width: 640px) {
  .dividend-table-wrap {
    overflow: visible;
    border: 0;
  }
  .dividend-table {
    min-width: 0;
    display: block;
  }
  .dividend-table thead {
    display: none;
  }
  .dividend-table tbody {
    display: grid;
    gap: 10px;
  }
  .dividend-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(7, 18, 28, 0.72);
  }
  .dividend-table tbody tr.selected {
    border-color: var(--accent);
  }
  .dividend-table td {
    display: block;
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .dividend-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10px;
    margin-bottom: 3px;
  }
  .dividend-detail-head {
    flex-direction: column;
  }
}
