/* ============================================================
   設計系統：包浩斯 Bauhaus — 純 CSS 變數實作，零建置流程。
   色票刻意只有三原色（紅/藍/黃）+ 純黑/純白，兩處例外見下方註解。
   ============================================================ */
:root {
  /* 色票 */
  --bg: #f0f0f0;
  --fg: #121212;
  --white: #ffffff;
  --red: #d02020;
  --blue: #1040c0;
  --yellow: #f0c020;
  --muted: #e0e0e0;
  --muted-ink: #5a5a5a;

  /* 例外①：台股「紅漲綠跌」是金融慣例，不能套用包浩斯三原色機械式取代。
     漲用包浩斯紅（本來就有），跌額外定義一個深綠，只准用在數字文字色，
     不得用於背景色塊，避免稀釋整體紅藍黃黑白的識別系統。 */
  --gain: var(--red);
  --loss: #1b7a3b;

  /* 例外②：純黃 #f0c020 畫在 --bg 淺色背景上對比度太低，圖表線條/文字
     看不清楚。UI 元件（按鈕、警示色塊）的黃色都有黑色粗框頂著對比，
     不受影響；只有「純靠色相辨識」的圖表線條改用這個深金色。 */
  --chart-benchmark: #a87900;
  --chart-strategy: var(--blue);
  --chart-grid: rgba(18, 18, 18, 0.14);
  --accordion-open-bg: #fff9c4;

  /* 邊框與陰影：手機用較細/較短，桌面放大（媒體查詢覆寫） */
  --bw: 2px;
  --bw-lg: 3px;
  --sh-sm: 3px 3px 0 0 var(--fg);
  --sh-md: 4px 4px 0 0 var(--fg);
  --sh-lg: 6px 6px 0 0 var(--fg);
}

@media (min-width: 620px) {
  :root {
    --bw: 3px;
    --bw-lg: 4px;
    --sh-sm: 4px 4px 0 0 var(--fg);
    --sh-md: 6px 6px 0 0 var(--fg);
    --sh-lg: 8px 8px 0 0 var(--fg);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Outfit", -apple-system, "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
  font-weight: 500;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 16px 14px 60px; }

/* ---------- 頁首：幾何標誌 + 大標 ---------- */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0 18px;
  border-bottom: var(--bw-lg) solid var(--fg);
  margin-bottom: 16px;
}
.logo-mark { flex: none; width: 42px; height: 42px; }
.logo-mark circle { fill: var(--red); }
.logo-mark rect { fill: var(--blue); }
.logo-mark polygon { fill: var(--yellow); stroke: var(--fg); stroke-width: 2; }

.head-text { min-width: 0; }
h1 {
  font-size: clamp(20px, 5.5vw, 30px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 8px;
}
.sub {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
  background: var(--white);
  border: var(--bw) solid var(--fg);
  box-shadow: var(--sh-sm);
  padding: 3px 9px;
}

/* ---------- 導覽 ---------- */
nav { display: flex; gap: 10px; margin: 0 0 18px; }
nav a {
  flex: 1;
  text-align: center;
  padding: 11px 6px;
  background: var(--white);
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: var(--bw) solid var(--fg);
  box-shadow: var(--sh-sm);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}
nav a.on { background: var(--blue); color: var(--white); }
nav a:active { transform: translate(2px, 2px); box-shadow: none; }

/* ---------- 控制項（切換按鈕群組）---------- */
.controls { display: grid; gap: 14px; margin-bottom: 18px; }
.ctl-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-ink); margin-bottom: 6px;
}
.seg { display: flex; gap: 7px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 76px; padding: 9px 8px; font-size: 13px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  background: var(--white); color: var(--fg);
  border: var(--bw) solid var(--fg); box-shadow: var(--sh-sm);
  cursor: pointer; font-family: inherit;
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}
.seg button:active { transform: translate(2px, 2px); box-shadow: none; }
/* 三組控制項各自輪值一個原色，強化「這是不同分類」的視覺語言 */
.controls > div:nth-child(1) .seg button.on { background: var(--blue); color: var(--white); }
.controls > div:nth-child(2) .seg button.on { background: var(--red); color: var(--white); }
.controls > div:nth-child(3) .seg button.on { background: var(--yellow); color: var(--fg); }

/* ---------- 警示色塊（斜紋警示條）---------- */
.warn {
  position: relative;
  background: var(--yellow);
  border: var(--bw-lg) solid var(--fg);
  box-shadow: var(--sh-md);
  color: var(--fg);
  padding: 13px 15px 13px 20px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
  overflow: hidden;
}
.warn::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 8px;
  background: repeating-linear-gradient(
    -45deg, var(--fg) 0 4px, transparent 4px 8px
  );
}
.warn b { font-weight: 900; }

/* ---------- 對決卡（策略 vs 0050）---------- */
.verdict {
  position: relative;
  background: var(--white);
  border: var(--bw-lg) solid var(--fg);
  box-shadow: var(--sh-lg);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.verdict::after {
  content: ""; position: absolute; top: -10px; right: 16px;
  width: 18px; height: 18px; background: var(--red);
  border: 2px solid var(--fg); transform: rotate(45deg);
}
.verdict-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted-ink); margin-bottom: 12px;
}
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.vs .side { text-align: center; padding-top: 10px; border-top: 4px solid transparent; }
.vs .side:first-child { border-top-color: var(--blue); }
.vs .side:last-child { border-top-color: var(--chart-benchmark); }
.vs .nm { font-size: 12px; font-weight: 700; color: var(--muted-ink); margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 5px; }
.vs .val { font-size: clamp(24px, 6vw, 32px); font-weight: 900; letter-spacing: -0.02em; }
.vs .amt { font-size: 12px; color: var(--muted-ink); margin-top: 3px; font-weight: 600; }
.vs .mid { color: var(--fg); font-size: 13px; font-weight: 900; }

/* 圖形雙重編碼：形狀 + 顏色，色弱使用者也能分辨 */
.dot { display: inline-block; width: 9px; height: 9px; flex: none; border: 2px solid var(--fg); }
.d-s { background: var(--blue); border-radius: 50%; }
.d-b { background: var(--chart-benchmark); border-radius: 0; }

.gap {
  margin-top: 14px; padding-top: 14px; border-top: var(--bw) solid var(--fg);
  font-size: 14px; font-weight: 700; text-align: center;
}

/* ---------- 圖表卡 ---------- */
.chart-card {
  background: var(--white); border: var(--bw-lg) solid var(--fg);
  box-shadow: var(--sh-lg); padding: 16px 10px 10px; margin-bottom: 16px;
}
svg { width: 100%; height: auto; display: block; }
.legend {
  display: flex; gap: 18px; justify-content: center; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--fg); padding: 8px 0 2px;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- 統計卡片（8 格）---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.card {
  position: relative; background: var(--white); border: var(--bw) solid var(--fg);
  box-shadow: var(--sh-sm); padding: 12px 13px; overflow: hidden;
  transition: transform 0.15s ease-out;
}
.card:hover { transform: translateY(-2px); }
.card::before { content: ""; position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; }
.card:nth-child(6n+1)::before { background: var(--red); border-radius: 50%; }
.card:nth-child(6n+2)::before { background: var(--blue); border-radius: 0; }
.card:nth-child(6n+3)::before { background: var(--yellow); clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.card:nth-child(6n+4)::before { background: var(--blue); border-radius: 50%; }
.card:nth-child(6n+5)::before { background: var(--yellow); border-radius: 0; }
.card:nth-child(6n+6)::before { background: var(--red); clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.card .k { font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-ink); padding-right: 14px; }
.card .v { font-size: 19px; font-weight: 900; margin-top: 3px; }
.card .n { font-size: 11px; color: var(--muted-ink); margin-top: 2px; font-weight: 500; }

/* ---------- 區塊標題 ---------- */
h2 {
  font-size: 15px; font-weight: 900; text-transform: uppercase;
  letter-spacing: 0.02em; margin: 24px 0 10px; padding-left: 12px;
  border-left: 6px solid var(--red); line-height: 1.3;
}

/* ---------- 手風琴（這些數字怎麼看）---------- */
details {
  background: var(--white); border: var(--bw-lg) solid var(--fg);
  box-shadow: var(--sh-sm); margin-bottom: 14px; overflow: hidden;
}
details summary {
  cursor: pointer; padding: 13px 16px; font-size: 14px; font-weight: 700;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  transition: background 0.15s, color 0.15s;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: ""; flex: none; width: 12px; height: 12px; margin-left: 10px;
  background:
    linear-gradient(var(--fg), var(--fg)) center / 100% 2px no-repeat,
    linear-gradient(var(--fg), var(--fg)) center / 2px 100% no-repeat;
  transition: transform 0.2s ease-out;
}
details[open] summary::after { transform: rotate(45deg); }
details[open] summary { background: var(--red); color: var(--white); }
details[open] summary::after { background:
    linear-gradient(var(--white), var(--white)) center / 100% 2px no-repeat,
    linear-gradient(var(--white), var(--white)) center / 2px 100% no-repeat; }
details .body {
  padding: 14px 16px 15px; font-size: 13px; color: var(--fg);
  border-top: var(--bw-lg) solid var(--fg);
}
details[open] .body { background: var(--accordion-open-bg); }
details .body li { margin-bottom: 6px; }
details .body ul { padding-left: 18px; margin: 6px 0; }

/* ---------- 交易明細表 ---------- */
.tbl-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: var(--bw-lg) solid var(--fg); box-shadow: var(--sh-lg); background: var(--white);
}
table { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 560px; }
th, td { padding: 10px 11px; text-align: right; white-space: nowrap; }
th {
  color: var(--white); background: var(--fg); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0;
}
td { border-bottom: 2px solid var(--muted); font-weight: 500; }
td:first-child, th:first-child { text-align: left; }
tbody tr:hover { background: #fdf6d8; }
tbody tr:last-child td { border-bottom: none; }
.pos { color: var(--gain); font-weight: 700; }
.neg { color: var(--loss); font-weight: 700; }
.tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 7px;
  background: var(--white); color: var(--fg); border: 2px solid var(--fg);
}
.more {
  text-align: center; padding: 12px; color: var(--fg); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; cursor: pointer;
  background: var(--yellow); border-top: var(--bw-lg) solid var(--fg);
}
.more:active { filter: brightness(0.92); }

/* ---------- 今日訊號卡片 ---------- */
.sig {
  position: relative; background: var(--white); border: var(--bw) solid var(--fg);
  box-shadow: var(--sh-sm); padding: 13px 14px 13px 17px; margin-bottom: 10px;
}
.sig:has(.b-buy) { border-left: 8px solid var(--red); }
.sig:has(.b-watch) { border-left: 8px solid var(--yellow); }
.sig:has(.b-skip) { border-left: 8px solid var(--muted-ink); }
.sig-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sig-name { font-size: 16px; font-weight: 900; }
.sig-score { font-size: 12px; font-weight: 700; color: var(--muted-ink); }
.sig-row { font-size: 12.5px; color: var(--fg); margin-top: 6px; font-weight: 500; }
.badge {
  font-size: 10.5px; padding: 3px 9px; font-weight: 900; text-transform: uppercase;
  letter-spacing: 0.03em; border: 2px solid var(--fg);
}
.b-buy { background: var(--red); color: var(--white); }
.b-watch { background: var(--yellow); color: var(--fg); }
.b-skip { background: var(--muted); color: var(--muted-ink); }

/* ---------- 頁尾 ---------- */
footer {
  margin-top: 30px; padding: 18px 16px; background: var(--fg); color: var(--white);
  font-size: 11.5px; position: relative;
}
footer::before {
  content: ""; position: absolute; top: -6px; left: 16px; width: 12px; height: 12px;
  background: var(--red); border-radius: 50%;
}
footer::after {
  content: ""; position: absolute; top: -6px; left: 34px; width: 12px; height: 12px;
  background: var(--blue);
}
footer p { margin: 6px 0; }
footer b { color: var(--yellow); }

/* ---------- 狀態：載入中／錯誤 ---------- */
.loading {
  text-align: center; color: var(--muted-ink); padding: 50px 0; font-size: 13px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em;
}
.err {
  background: var(--red); border: var(--bw-lg) solid var(--fg); box-shadow: var(--sh-md);
  color: var(--white); padding: 15px 16px; font-size: 13px; font-weight: 600;
}

@media (min-width: 620px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  .logo-mark { width: 50px; height: 50px; }
}
