/* 投資看板（templates/admin_investment*.html）共用的樣式 */
.viz-root {
  color-scheme: light;
  --surface-0: #f4f3f0; --surface-1: #fcfcfb; --border: #e2e1dc;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #7a7974;
  --grid: #ebeae6; --series-1: #2a78d6;
  --series-2: #c96a12; --series-3: #23875a; --series-4: #c43b4f; --series-5: #7b55c7; --series-6: #8a6a1f;
  --chip-profit: #e0a43a; --chip-trapped: #b9b8b2;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-0: #111110; --surface-1: #1a1a19; --border: #2e2e2c;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --grid: #2a2a28; --series-1: #3987e5;
    --series-2: #e8913f; --series-3: #3fb27f; --series-4: #e8687a; --series-5: #a487e8; --series-6: #d4b25a;
    --chip-profit: #d9a03c; --chip-trapped: #5c5b57;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-0: #111110; --surface-1: #1a1a19; --border: #2e2e2c;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --grid: #2a2a28; --series-1: #3987e5;
  --series-2: #e8913f; --series-3: #3fb27f; --series-4: #e8687a; --series-5: #a487e8; --series-6: #d4b25a;
    --chip-profit: #d9a03c; --chip-trapped: #5c5b57;
}
* { box-sizing: border-box; }
body { margin: 0; }
.viz-root { background: var(--surface-0); color: var(--text-primary); min-height: 100vh;
  font: 14px/1.5 system-ui, -apple-system, "Noto Sans TC", sans-serif; padding: 20px; }
main { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 12px; }
h2 .heading-meta { font-weight: 400; color: var(--text-secondary); font-size: 14px; margin-left: 8px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; }
.meta { color: var(--text-muted); font-size: 12px; }
.groups { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas: "ratio ratio price" "long long price" "short short price"; }
/* 日股的基本面（static/js/investment-jp.js 的 renderFundamentals）：業績、估值與財務兩張卡並排，窄的時候疊起來 */
.fundamentals { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "results value"; }
@media (max-width: 960px) { .fundamentals { grid-template-columns: minmax(0, 1fr); grid-template-areas: "results" "value"; } }
@media (max-width: 960px) { .groups { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ratio" "long" "short" "price"; } }
.group h3 { display: flex; justify-content: space-between; gap: 8px; }
.group .tally { font-weight: 400; white-space: nowrap; }
.group th { font-weight: 400; color: var(--text-secondary); }
.group td.val { font-weight: 600; white-space: nowrap; }
.group .why { color: var(--text-muted); font-size: 12px; }
/* min-width: 0：grid 的子項目預設不會窄於內容，圖的 SVG 是依當下寬度畫的固定寬度，不設的話視窗縮小時卡片縮不回去 */
.card { min-width: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.tip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; }
td.num, th.num { text-align: right; }
.empty { color: var(--text-muted); }
.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
/* 名詞說明：虛線底線，滑鼠移上去或點一下（focus）才顯示 */
.term { border-bottom: 1px dashed currentColor; cursor: help; position: relative; outline: none; }
.term:hover::after, .term:focus::after { content: attr(data-tip); position: absolute; left: 0; top: 100%; margin-top: 4px; z-index: 10;
  width: max-content; max-width: min(320px, 80vw); white-space: pre-line; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.src { color: var(--text-muted); font-size: 11px; margin-top: 8px; }
.markets { display: flex; gap: 16px; margin: 8px 0 12px; border-bottom: 1px solid var(--border); }
.markets a { padding: 4px 2px 6px; color: var(--text-secondary); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.markets a[aria-current="page"] { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--text-primary); }
.tickers { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 4px; }
.tickers button { font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--text-secondary); cursor: pointer; }
.tickers button .code { font-variant-numeric: tabular-nums; color: var(--text-muted); margin-right: 4px; }
.tickers button[aria-selected="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.tickers button[aria-selected="true"] .code { color: inherit; }
.ranges { display: flex; gap: 4px; margin-bottom: 6px; align-items: center; }
.ranges .sep { width: 12px; }
.ranges button { font: inherit; font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-1); color: var(--text-secondary); cursor: pointer; }
.ranges button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px dashed; vertical-align: middle; margin-right: 4px; }
.legend i.solid { border-top-style: solid; }
/* 總覽（static/js/investment-overview.js）：一檔一列，標題後面不放日期時間，燈號不換行；手機上每檔排成一張小卡（見下面的 @media） */
.overview { margin-top: 20px; }
.overview h2 { font-size: 16px; margin: 0 0 6px; }
.overview h2 a, .overview td a { color: inherit; text-decoration: none; }
.overview td a:hover { text-decoration: underline; }
.overview table { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; }
.overview th, .overview td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; font-size: 13px; }
.overview th { color: var(--text-muted); font-weight: 500; }
.overview .heading-meta { display: none; }
.overview .tally { white-space: nowrap; }
.overview .na { color: var(--text-muted); }
/* Rule of 40（investment-overview.js 的 rule40Cell）：進度條中間的直線是 40% 門檻，達標的填色換成 --series-3 */
.overview .rule40 { white-space: nowrap; }
.overview .rule40 .head { display: flex; align-items: center; gap: 6px; }
.overview .rule40 .track { position: relative; display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.overview .rule40 .fill { display: block; height: 100%; background: var(--text-muted); }
.overview .rule40 .fill.pass { background: var(--series-3); }
.overview .rule40 .mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--text-primary); }
.overview .rule40 .verdict, .overview .rule40 .past { color: var(--text-secondary); font-size: 12px; }
/* 價格與成本（investment-overview.js 的 costCell）：獲利盤的進度條，顏色同股價圖的籌碼分布（獲利盤、套牢盤） */
.overview .cost-cell { white-space: nowrap; }
.overview .cost-cell .profit { display: flex; align-items: center; gap: 6px; }
.overview .cost-cell .track { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--chip-trapped); overflow: hidden; }
.overview .cost-cell .fill { display: block; height: 100%; background: var(--chip-profit); }
.overview .cost-cell .levels { color: var(--text-secondary); font-size: 12px; white-space: normal; }
/* 拖拉排序的把手（investment-overview.js 的 sortable）：touch-action 關掉，觸控拖的時候頁面才不會跟著捲 */
.overview td.drag { width: 1%; padding-right: 0; }
.overview .handle { border: 0; background: none; color: var(--text-muted); cursor: grab; touch-action: none; user-select: none; font-size: 16px; padding: 0 2px; }
.overview tr.dragging { opacity: 0.6; }
.overview tr.dragging .handle { cursor: grabbing; }
.overview .remove { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 13px; }
/* 手機：四欄放不下，每檔第一行是把手、股票與 ✕，下面一行一欄、可以換行，欄名（data-label）寫在前面 */
@media (max-width: 640px) {
  .overview table, .overview tbody { display: block; }
  .overview thead { display: none; }
  .overview tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; border-bottom: 1px solid var(--grid); padding: 6px 0; }
  .overview tr:last-child { border-bottom: 0; }
  .overview td { border-bottom: 0; padding: 2px 10px; }
  .overview td.drag { grid-row: 1; grid-column: 1; width: auto; }
  .overview td.name { grid-row: 1; grid-column: 2; }
  .overview td:last-child { grid-row: 1; grid-column: 3; }
  .overview td.tally { grid-column: 1 / -1; white-space: normal; color: var(--text-secondary); }
  .overview td.tally::before { content: attr(data-label) "："; color: var(--text-muted); }
}
/* 標題的漲跌：台股、日股的慣例是紅漲綠跌 */
.price-up { color: var(--series-4); }
.price-down { color: var(--series-3); }
