:root {
  --bg: #0e1014;
  --panel: #161a21;
  --line: #232a35;
  --fg: #e8eaf0;
  --muted: #8b93a7;
  --up: #ef232a;
  --down: #14b143;
  --accent: #f5a623;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.5;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; gap: .6rem;
}
.brand { font-size: 1.25rem; font-weight: 700; }
.brand span { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: .4rem; }
.hint { font-size: .8rem; color: var(--muted); }

/* 搜尋框 */
.search { display: flex; gap: .5rem; align-items: center; }
.search input {
  padding: .5rem .8rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--fg); min-width: 240px; font-size: .9rem;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  padding: .5rem 1.1rem; border: none; border-radius: 10px;
  background: var(--accent); color: #1a1205; font-weight: 600; cursor: pointer; font-size: .9rem;
}
.search button:hover { filter: brightness(1.08); }

.ticker {
  display: flex; gap: .5rem; flex-wrap: wrap; padding: .9rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.chart-wrap { padding: 0 1.5rem; }
.chart { width: 100%; height: 520px; }
.chip {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--fg); padding: .45rem .8rem; border-radius: 999px;
  cursor: pointer; font-size: .9rem; transition: .15s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .8rem; padding: 1.2rem 1.5rem;
}
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: .9rem 1rem;
}
.stat .label { font-size: .75rem; color: var(--muted); }
.stat .value { font-size: 1.3rem; font-weight: 700; margin-top: .2rem; }
.up { color: var(--up); } .down { color: var(--down); }

.chart-wrap { padding: 0 1.5rem; }
.chart { width: 100%; height: 520px; }

.panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem; padding: 1.2rem 1.5rem;
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.2rem;
}
.card h3 { font-size: .95rem; margin-bottom: .8rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; }
.kv div { display: flex; justify-content: space-between; font-size: .9rem; }
.kv .k { color: var(--muted); }

/* 量化建議面板 */
.quant .score-row { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.quant .score { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.quant .score-max { font-size: .9rem; font-weight: 400; color: var(--muted); margin-left: .2rem; }
.quant .advice { font-size: 1.1rem; font-weight: 700; padding: .35rem .9rem; border-radius: 999px; background: #232a35; }
.quant .advice.up { background: rgba(239,35,42,.15); color: var(--up); }
.quant .advice.down { background: rgba(20,177,67,.15); color: var(--down); }
.quant .reasons { list-style: none; font-size: .82rem; color: var(--muted); }
.quant .reasons li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.quant .reasons li:last-child { border-bottom: none; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
tr.curr { background: rgba(245,166,35,.12); }

footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: .8rem; }

/* 手機適配 */
@media (max-width: 640px) {
  .topbar { padding: .8rem 1rem; }
  .brand { font-size: 1.05rem; }
  .brand span { display: none; }
  .search { width: 100%; }
  .search input { flex: 1; min-width: 0; }
  .ticker { padding: .7rem 1rem; }
  .stats { padding: 1rem; gap: .6rem; }
  .stat .value { font-size: 1.1rem; }
  .chart-wrap { padding: 0 1rem; }
  .chart { height: 380px; }
  .panel { padding: 1rem; grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr 1fr; }
  .quant .score { font-size: 2rem; }
  table { font-size: .82rem; }
  th, td { padding: .4rem .3rem; }
}
