/* ============================================================
   主動 ETF 每日概覽 — 暗色調、清晰優先、桌機/手機自適應
   ============================================================ */
:root {
  --bg: #0e1116;
  --bg2: #12161d;
  --card: #161b23;
  --card2: #1a212b;
  --line: #263040;
  --txt: #dfe5ee;
  --muted: #8a94a6;
  --dim: #5f6b7e;
  --up: #e07a7a;        /* 偏多：柔和紅 */
  --up-strong: #f0937f;
  --up-bg: rgba(224, 122, 122, .10);
  --up-line: rgba(224, 122, 122, .32);
  --dn: #57b98a;        /* 偏空：柔和綠 */
  --dn-strong: #6ecf9c;
  --dn-bg: rgba(87, 185, 138, .09);
  --dn-line: rgba(87, 185, 138, .30);
  --accent: #6ea8fe;
  --gold: #d9b45b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 15px/1.65 "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  letter-spacing: .01em;
}
.wrap { max-width: 1020px; margin: 0 auto; padding: 0 16px; }

/* ---------- header（不凍結） ---------- */
.hd { background: var(--bg); border-bottom: 1px solid var(--line); }
.hd-in { max-width: 1020px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hd-title h1 { margin: 0; font-size: 19px; font-weight: 700; }
.hd-sub { color: var(--muted); font-size: 12.5px; margin-left: 10px; }
.hd-ctrl { display: flex; align-items: center; gap: 8px; }
.hd-label { color: var(--muted); font-size: 13px; }
.sel {
  background: var(--card2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 14px; outline: none; min-width: 130px;
}
.sel:focus { border-color: var(--accent); }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: var(--card); white-space: nowrap; }
.badge.ok { color: var(--dn-strong); border-color: var(--dn-line); }

/* ---------- 卡片區塊 ---------- */
main.wrap { padding: 18px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.sec-h { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.sec-h .ico { font-size: 16px; }
.sec-h h2 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: .02em; }
.sec-h .hint { color: var(--muted); font-size: 12px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- 個股標籤（圓角方框） ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 8px; padding: 2px 9px; margin: 1px 2px;
  font-size: 13px; font-weight: 600; line-height: 1.5;
  background: var(--card2); color: var(--txt); border: 1px solid var(--line);
  white-space: nowrap;
}
.tag .code { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.tag.up { background: var(--up-bg); color: var(--up-strong); border-color: var(--up-line); }
.tag.up .code { color: color-mix(in srgb, var(--up-strong) 62%, transparent); }
.tag.dn { background: var(--dn-bg); color: var(--dn-strong); border-color: var(--dn-line); }
.tag.dn .code { color: color-mix(in srgb, var(--dn-strong) 62%, transparent); }
.tag.flat { color: var(--muted); }

/* ---------- 表格（手機優先：自動換行、不需橫滑） ---------- */
.tbl-wrap { overflow-x: visible; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(38, 48, 64, .55); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(110, 168, 254, .04); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-r { text-align: right !important; }
.up-t { color: var(--up-strong); font-weight: 700; }
.dn-t { color: var(--dn-strong); font-weight: 700; }
.mut { color: var(--muted); }
.etf-codes { color: var(--muted); font-size: 12px; white-space: normal; word-break: keep-all; line-height: 1.7; }
.etf-pri { color: #79b0ff; font-weight: 700; }   /* 重點 ETF：亮藍色，與灰色一般 ETF 區隔 */

/* ---------- 清單（共識等） ---------- */
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 7px 2px; border-bottom: 1px solid rgba(38, 48, 64, .55); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
ul.plain li:last-child { border-bottom: none; }
.li-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.li-etfs { color: var(--muted); font-size: 12.5px; }
.dot-up::before { content: "▲"; color: var(--up); font-size: 10px; margin-right: 4px; }
.dot-dn::before { content: "▼"; color: var(--dn); font-size: 10px; margin-right: 4px; }

/* ---------- 族群 ---------- */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-cell { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.theme-cell .t-name { font-weight: 700; font-size: 13.5px; }
.theme-cell .t-m { float: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.theme-cell .t-stocks { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- 摘要橫幅 ---------- */
.hero { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.hero .h-cell { flex: 1 1 150px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.hero .h-k { color: var(--muted); font-size: 12px; }
.hero .h-v { font-size: 17px; font-weight: 800; margin-top: 2px; }
.hero .h-s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ---------- 深度解讀 ---------- */
.interp h3 { font-size: 14.5px; margin: 14px 0 6px; }
.interp p { margin: 6px 0; color: #c8d0dc; }
.interp .tag { font-size: 12px; padding: 1px 7px; }
.interp b { color: var(--gold); font-weight: 700; }   /* 重點數字：金色標註 */
.etf-plain { font-weight: 600; color: var(--txt); }
.sec-no { color: var(--dim); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; background: var(--card2); }

/* ---------- 解讀缺漏提示 ---------- */
.pending { color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }

/* ---------- footer ---------- */
.ft { border-top: 1px solid var(--line); background: var(--bg2); }
.ft-in { padding: 18px 16px 30px; color: var(--dim); font-size: 12px; }
.ft-in p { margin: 4px 0; }

/* ---------- 手機 ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .hd-in { padding: 10px 14px; }
  .hd-title h1 { font-size: 17px; }
  .hd-sub { display: block; margin: 2px 0 0; }
  .card { padding: 13px 11px; border-radius: 12px; }
  .theme-grid { grid-template-columns: 1fr; }

  /* 手機表格改卡片式：一格一行自動換行，不需橫向捲動 */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr { display: flex; flex-wrap: wrap; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(38, 48, 64, .55); }
  .tbl tr:last-child { border-bottom: none; }
  .tbl td { display: inline-block; border-bottom: none; padding: 2px 12px 2px 0; }
  .tbl td.num { text-align: left; }
  .tbl td:last-child { flex: 1 1 100%; padding: 4px 0 0; line-height: 1.7; }

  .tag { font-size: 12px; padding: 2px 6px; }
  .tag .code { font-size: 10.5px; }
  .hero .h-cell { flex: 1 1 44%; }
}
