:root {
    --primary: #0f766e;
    --primary-dark: #134e4a;
    --accent: #f59e0b;
    --bg: #f0fdfa;
    --card: #ffffff;
    --ink: #1a1f2c;
    --muted: #6b7280;
    --shadow: 0 4px 10px rgba(0,0,0,.08);
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --cheap: #059669;
    --fair: #6b7280;
    --expensive: #dc2626;
}
* { box-sizing: border-box; }
body.sim-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
}
.sim-header {
    background: linear-gradient(120deg, var(--primary-dark), var(--primary), var(--accent));
    color: #fff;
    padding: 22px 15px;
    text-align: center;
    box-shadow: var(--shadow);
}
.sim-header h1 { margin: 0; font-size: 1.7em; }
.sim-subtitle { margin: 6px 0 0; color: #ccfbf1; font-weight: 500; }

.sim-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 15px;
    display: grid;
    gap: 15px;
}
.panel {
    background: var(--card);
    border-radius: 12px;
    padding: 15px 18px;
    box-shadow: var(--shadow);
    border-left: 6px solid var(--primary);
}
.panel h2 {
    color: var(--primary-dark);
    margin: 0 0 12px;
    font-size: 1.15em;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 8px;
}

.ctrl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 14px;
}
.ctrl-grid label {
    display: flex;
    flex-direction: column;
    font-size: .85em;
    color: var(--muted);
    gap: 4px;
}
.ctrl-grid select, .ctrl-grid input, textarea {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1em;
    background: #f9fafb;
    color: var(--ink);
    font-family: inherit;
}
textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .9em;
    width: 100%;
}

.btn-row { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row button {
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.btn-row button:hover:not(:disabled) { background: var(--primary-dark); }
.btn-row button:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #6b7280 !important; }
.btn-secondary:hover:not(:disabled) { background: #4b5563 !important; }

.hint { color: var(--muted); font-size: .88em; margin: 8px 0 0; line-height: 1.55; }
.hint b { color: var(--ink); }
.hint a { color: var(--primary); }
.hint-mini { display: inline-block; font-size: .84em; color: #6b7280; background: #f9fafb; border-left: 3px solid #cbd5e1; padding: 4px 8px; margin-top: 6px; border-radius: 0 4px 4px 0; }
.hint-mini b { color: var(--primary-dark); }

.intro-panel { border-left-color: var(--accent); }
.warning-panel { border-left-color: var(--danger); background: #fef2f2; }
.warning-panel h2 { color: var(--danger); }
.warn-list { padding-left: 22px; margin: 6px 0; }
.warn-list li { margin: 6px 0; font-size: .9em; line-height: 1.6; }
.warn-list b { color: var(--danger); }

.query-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: .9em;
    font-family: ui-monospace, monospace;
}
.query-status.loading { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.query-status.error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.query-status.success { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }

/* Result */
.result-panel { border-left-color: var(--accent); }
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.result-cell {
    background: #f0fdfa;
    border: 1px solid #5eead4;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.result-label {
    font-size: .75em;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}
.result-val {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.4em;
    font-weight: 800;
    color: var(--primary-dark);
    margin-top: 2px;
}

.sample-warn {
    background: #fef3c7;
    border-left: 5px solid var(--warning);
    color: #78350f;
    padding: 12px 16px;
    margin: 14px 0 6px;
    border-radius: 0 8px 8px 0;
    font-size: .92em;
    line-height: 1.6;
}
.sample-warn b { color: #78350f; }

.verdict-box {
    padding: 16px 20px;
    border-radius: 10px;
    margin: 14px 0;
    border: 3px solid;
}
.verdict-box.cheap { background: #dcfce7; border-color: var(--cheap); }
.verdict-box.fair { background: #f3f4f6; border-color: var(--fair); }
.verdict-box.expensive { background: #fee2e2; border-color: var(--expensive); }
.verdict-box.warning { background: #fef3c7; border-color: var(--warning); }
.verdict-title {
    font-size: 1.4em;
    font-weight: 800;
    margin-bottom: 8px;
}
.verdict-box.cheap .verdict-title { color: var(--cheap); }
.verdict-box.fair .verdict-title { color: var(--fair); }
.verdict-box.expensive .verdict-title { color: var(--expensive); }
.verdict-box.warning .verdict-title { color: var(--warning); }
.verdict-body { font-size: .95em; line-height: 1.6; }

.chart-block {
    margin: 12px 0;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
}
.chart-title {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 8px;
    font-size: .95em;
}
.chart-block canvas {
    width: 100%;
    height: auto;
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.chart-legend {
    margin-top: 6px;
    font-size: .85em;
    color: var(--muted);
    font-family: ui-monospace, monospace;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.chart-legend .val { color: var(--primary-dark); font-weight: 700; }
.chart-legend .val.cheap { color: var(--cheap); }
.chart-legend .val.expensive { color: var(--expensive); }

.detail-box {
    background: #f9fafb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: .9em;
    line-height: 1.7;
}
.detail-box h3 {
    color: var(--primary-dark);
    margin: 4px 0 6px;
    font-size: 1em;
}
.detail-box table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-family: ui-monospace, monospace;
    font-size: .88em;
}
.detail-box th, .detail-box td {
    padding: 5px 8px;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}
.detail-box th { background: #f3f4f6; color: var(--primary-dark); font-weight: 700; text-align: center; }
.detail-box td:first-child { text-align: left; color: var(--muted); }

/* 財報成長性 4-cell 網格 */
.fund-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin: 10px 0;
}
.fund-cell {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
}
.fund-cell h4 {
    margin: 0 0 6px;
    font-size: .95em;
    color: var(--primary-dark);
    border-bottom: 1px dashed #e5e7eb;
    padding-bottom: 4px;
}
.fund-table {
    width: 100%;
    border-collapse: collapse;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .82em;
}
.fund-table th, .fund-table td {
    padding: 3px 5px;
    text-align: right;
    border-bottom: 1px solid #f3f4f6;
}
.fund-table th {
    background: #f9fafb;
    color: var(--primary-dark);
    font-weight: 700;
    text-align: center;
}
.fund-table td:first-child { text-align: left; color: var(--muted); font-size: .95em; }
.fund-table td.yoy-pos { color: var(--success); font-weight: 700; }
.fund-table td.yoy-neg { color: var(--danger); font-weight: 700; }

/* QoQ fallback tag（YoY 抓不到時用前一季比較，警示有季節性） */
.mode-tag {
    display: inline-block;
    font-size: .7em;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 3px;
    letter-spacing: .3px;
    cursor: help;
}
.mode-tag.mode-qoq {
    background: #dbeafe;
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

/* 會計基準 tag（GAAP / Non-GAAP）· 提醒使用者這是哪一種 PE / EPS */
.acct-tag {
    display: inline-block;
    font-size: .58em;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 4px;
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #fde68a;
    letter-spacing: .5px;
    cursor: help;
}

/* Peer 比較表 · 自己那行高亮 · peer 中位跟 SPY 底色不同 */
.peer-table td { text-align: right; }
.peer-table td:first-child { text-align: left; }
.peer-table tr.peer-self td {
    background: #fef3c7;
    font-weight: 700;
    color: #78350f;
    border-top: 2px solid var(--warning);
    border-bottom: 2px solid var(--warning);
}
.peer-table tr.peer-summary td {
    background: #f0fdfa;
    font-weight: 700;
    color: var(--primary-dark);
    border-top: 1px solid var(--primary);
}
.peer-table small { display: block; font-size: .8em; margin-top: 1px; }

/* ADR 折溢價計算表 */
.adr-calc {
    margin: 10px 0;
}
.adr-calc th:first-child { text-align: left; }
.adr-calc td:nth-child(2) {
    text-align: right;
    font-weight: 700;
    color: var(--primary-dark);
}
.adr-calc td:nth-child(3) {
    text-align: left;
    color: var(--muted);
    font-size: .9em;
}
.adr-calc tr:last-child td {
    background: #f0fdfa;
    border-top: 2px solid var(--primary);
}

/* 現金流背離 banner（層次 2） */
.divergence-banner {
    margin: 10px 0;
    padding: 12px 14px;
    border-radius: 8px;
    border-left: 5px solid;
    font-size: .92em;
    line-height: 1.6;
}
.divergence-banner.divergence-warn {
    background: #fef2f2;
    border-color: var(--danger);
    color: #7f1d1d;
}
.divergence-banner.divergence-good {
    background: #dcfce7;
    border-color: var(--success);
    color: #14532d;
}
.divergence-banner.divergence-ok {
    background: #f3f4f6;
    border-color: var(--muted);
    color: var(--ink);
}
.divergence-banner b { color: inherit; }

/* 法人買賣超 summary（層次 5） */
.inst-summary {
    background: #f0fdfa;
    border: 1px solid #5eead4;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .92em;
    line-height: 1.7;
    margin-top: 8px;
    font-family: ui-monospace, SFMono-Regular, monospace;
}
.inst-summary b { color: var(--primary-dark); font-family: inherit; }

/* 5 層框架 tag（intro-panel） */
.layer-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .82em;
    font-weight: 700;
    margin-right: 4px;
    color: #fff;
}
.layer-tag.layer-1 { background: #0891b2; }   /* cyan  · 估值 */
.layer-tag.layer-2 { background: #059669; }   /* green · 品質 */
.layer-tag.layer-3 { background: #7c3aed; }   /* purple · 護城河 */
.layer-tag.layer-4 { background: #d97706; }   /* orange · 總體 */
.layer-tag.layer-5 { background: #db2777; }   /* pink  · 情緒 */

/* 🔍 診斷 panel（FinMind 原始欄位） */
.debug-panel { border-left-color: #6366f1; background: #eef2ff; }
.debug-panel h2 { color: #4338ca; }
.debug-block {
    background: #fff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
}
.debug-block h3 {
    color: #4338ca;
    margin: 0 0 6px;
    font-size: 1em;
    font-family: ui-monospace, SFMono-Regular, monospace;
}
.debug-note {
    color: var(--muted);
    font-size: .82em;
    margin: 4px 0 8px;
    line-height: 1.5;
}
.debug-empty, .debug-error {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: .88em;
    margin: 6px 0;
}
.debug-empty { background: #fef3c7; color: #92400e; }
.debug-error { background: #fee2e2; color: #7f1d1d; }
.debug-table {
    width: 100%;
    border-collapse: collapse;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .82em;
    margin: 8px 0;
}
.debug-table th, .debug-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}
.debug-table th {
    background: #e0e7ff;
    color: #3730a3;
    font-weight: 700;
}
.debug-table code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    color: #4338ca;
}
.debug-details {
    margin-top: 8px;
    padding: 6px 10px;
    background: #f9fafb;
    border-radius: 6px;
}
.debug-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    font-size: .88em;
}
.debug-details pre {
    margin: 8px 0 0;
    padding: 10px;
    background: #1f2937;
    color: #e5e7eb;
    border-radius: 6px;
    font-size: .78em;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
}

/* 🌐 總體環境 panel（層次 4） */
.macro-panel { border-left-color: #d97706; background: #fffbeb; }
.macro-panel h2 { color: #b45309; }
.macro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.macro-cell {
    background: #fff;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 12px;
}
.macro-label {
    font-size: .82em;
    color: var(--muted);
    font-weight: 600;
}
.macro-val {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.4em;
    font-weight: 800;
    color: #b45309;
    margin: 4px 0;
}
.macro-spark {
    width: 100%;
    height: 42px;
    display: block;
    background: #fef3c7;
    border-radius: 4px;
    margin: 4px 0;
}
.macro-note-slot { margin-top: 4px; }
.macro-note {
    display: block;
    font-size: .82em;
    line-height: 1.55;
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 3px solid;
}
.macro-note-warn { background: #fef2f2; color: #7f1d1d; border-color: var(--danger); }
.macro-note-good { background: #dcfce7; color: #14532d; border-color: var(--success); }
.macro-note-ok   { background: #f3f4f6; color: var(--ink); border-color: var(--muted); }
.macro-note b { color: inherit; }
.macro-note a { color: var(--primary); }
.macro-val-empty { color: #d1d5db !important; font-size: 1em !important; font-weight: 400 !important; }
.macro-status-line {
    background: #fff;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .85em;
    font-family: ui-monospace, SFMono-Regular, monospace;
    margin: 6px 0;
    line-height: 1.7;
}
.macro-status-line .src-ok   { color: var(--success); font-weight: 700; }
.macro-status-line .src-warn { color: #b45309; font-weight: 700; }
.macro-status-line .src-err  { color: var(--danger); font-weight: 700; }

/* 融資餘額 · 股本結構警訊 */
.margin-caveat {
    display: block;
    background: #fef3c7;
    border-left: 3px solid var(--warning);
    color: #78350f;
    padding: 6px 10px;
    margin-top: 8px;
    border-radius: 0 4px 4px 0;
    font-size: .9em;
    line-height: 1.55;
}
.margin-caveat b { color: #78350f; }
.macro-links {
    background: #fff;
    border: 1px dashed #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .88em;
    line-height: 1.65;
    color: var(--ink);
    margin-top: 8px;
}
.macro-links ul { padding-left: 22px; margin: 6px 0 0; }
.macro-links li { margin: 4px 0; color: var(--muted); }
.macro-links a { color: var(--primary); font-weight: 600; }

/* 🎯 決策框架 panel */
.decision-panel { border-left-color: #7c3aed; background: #faf5ff; }
.decision-panel h2 { color: #6b21a8; }
.decision-panel h3 { color: #6b21a8; margin: 14px 0 6px; font-size: 1em; border-bottom: 1px dashed #ddd6fe; padding-bottom: 4px; }
.decision-timestamp {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: .9em;
    margin: 4px 0 12px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    line-height: 1.6;
}
.decision-timestamp.ts-fresh { background: #f0fdf4; border-left: 4px solid var(--success); color: #14532d; }
.decision-timestamp.ts-stale { background: #fef3c7; border-left: 4px solid var(--warning); color: #78350f; }
.decision-timestamp b { color: inherit; }
.decision-section {
    background: #fff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
}

/* 情境樹 */
.scenario-row {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 6px 0;
}
.scenario-header { margin-bottom: 6px; }
.scenario-name {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: .95em;
    font-weight: 600;
    color: var(--ink);
    background: #fff;
    font-family: inherit;
}
.scenario-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    align-items: center;
}
.scenario-prob-label, .scenario-verdict-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: .8em;
    color: var(--muted);
}
.scenario-prob {
    width: 100%;
    accent-color: #7c3aed;
}
.scenario-prob-val {
    font-family: ui-monospace, monospace;
    font-weight: 700;
    color: #6b21a8;
    text-align: right;
    font-size: .95em;
    display: block;
}
.scenario-verdict {
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    font-size: .9em;
    font-family: inherit;
}
.prob-sum {
    padding: 6px 10px;
    border-radius: 4px;
    text-align: center;
    font-family: ui-monospace, monospace;
    font-weight: 700;
    margin-top: 8px;
}
.prob-sum.prob-sum-ok { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.prob-sum.prob-sum-warn { background: #fee2e2; color: #7f1d1d; border: 2px solid var(--danger); animation: subtle-pulse 1.5s ease-in-out infinite; }
@keyframes subtle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .7; }
}

/* 部位試算 */
.calc-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 8px 0;
}
.calc-inputs label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: .85em;
    color: var(--muted);
}
.calc-inputs input {
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f9fafb;
    font-family: inherit;
    font-size: .95em;
}
.calc-result {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 8px;
    font-size: .95em;
    line-height: 1.6;
}
.calc-primary { font-size: 1.15em; color: #6b21a8; margin-bottom: 4px; }
.calc-primary b { color: #4c1d95; }
.calc-detail { color: var(--muted); font-size: .85em; margin-bottom: 6px; }
.calc-detail code { background: #ede9fe; padding: 1px 5px; border-radius: 3px; color: #5b21b6; }
.calc-warn { color: #78350f; background: #fef3c7; padding: 6px 8px; border-radius: 4px; font-size: .82em; line-height: 1.5; }
.calc-warn b { color: inherit; }

/* 證偽清單 */
.falsify-row {
    display: grid;
    grid-template-columns: auto 1fr 130px auto;
    gap: 8px;
    align-items: center;
    padding: 5px 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin: 4px 0;
}
.falsify-check {
    accent-color: #7c3aed;
    width: 18px;
    height: 18px;
}
.falsify-row:has(.falsify-check:checked) {
    background: #fef3c7;
    border-color: var(--warning);
}
.falsify-row:has(.falsify-check:checked) .falsify-text {
    text-decoration: line-through;
    color: #78350f;
}
.falsify-text {
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f9fafb;
    font-size: .88em;
    font-family: inherit;
    color: var(--ink);
}
.falsify-date {
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: .82em;
    font-family: inherit;
    background: #f9fafb;
}
.falsify-del {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: .95em;
    padding: 4px 6px;
    border-radius: 4px;
}
.falsify-del:hover { background: #fee2e2; }

.dec-save-status {
    margin-left: 10px;
    font-size: .88em;
    color: var(--muted);
}
.dec-save-status.saved { color: var(--success); font-weight: 700; }
.dec-save-status.err { color: var(--danger); font-weight: 700; }

/* 「還沒回答的問題」panel */
.unknowns-panel { border-left-color: #d97706; background: #fffbeb; }
.unknowns-panel h2 { color: #b45309; }
.unknowns-list {
    padding-left: 22px;
    margin: 10px 0;
}
.unknowns-list li {
    margin: 8px 0;
    font-size: .92em;
    line-height: 1.65;
    color: var(--ink);
}
.unknowns-list li b { color: #b45309; }

/* 🎮 模擬器（sim.html）· 頁面特有元素 */
.snapshot-panel { border-left-color: #4c1d95; background: #f5f3ff; }
.snapshot-panel h2 { color: #4c1d95; }
.sim-price-panel { margin: 10px 0; }
.sim-price-tile {
    background: #fff;
    border: 2px solid #7c3aed;
    border-radius: 10px;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.15);
}
.sim-price-label { font-size: .85em; color: var(--muted); font-weight: 600; }
.sim-price-val {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.8em;
    font-weight: 800;
    color: #4c1d95;
    margin: 4px 0;
}
.sim-price-note { font-size: .8em; color: var(--muted); }
.sim-loading { text-align: center; padding: 20px; color: var(--muted); font-family: ui-monospace, monospace; }
.sim-error { background: #fef2f2; color: #7f1d1d; padding: 12px; border-radius: 6px; text-align: center; }

.sim-snapshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.snap-cell {
    background: #fff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 10px 12px;
}
.snap-label { font-size: .82em; color: var(--muted); font-weight: 600; }
.snap-val {
    font-size: 1.05em;
    font-weight: 700;
    color: #4c1d95;
    margin: 4px 0;
}
.snap-note { font-size: .82em; color: var(--muted); line-height: 1.5; }

.snap-known-hint {
    background: #ede9fe;
    border-left: 4px solid #7c3aed;
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    font-size: .88em;
    line-height: 1.65;
    color: #4c1d95;
    margin-top: 12px;
}
.snap-known-hint b { color: #6b21a8; }

/* 決策模擬 · sim panel */
.decision-sim-panel { border-left-color: var(--primary); background: var(--card); }
.sim-pos-row {
    display: flex;
    gap: 12px;
    align-items: center;
}
.sim-pos-row input[type="range"] {
    flex: 1;
    accent-color: #7c3aed;
}
.sim-pos-val {
    font-family: ui-monospace, monospace;
    font-weight: 800;
    color: #4c1d95;
    font-size: 1.3em;
    min-width: 60px;
    text-align: right;
}
.sim-falsify-row {
    display: block;
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin: 4px 0;
    cursor: pointer;
    font-size: .92em;
}
.sim-falsify-row:has(input:checked) {
    background: #ede9fe;
    border-color: #7c3aed;
}
.sim-falsify-row input { margin-right: 8px; accent-color: #7c3aed; }

/* Reveal · checkpoints */
.reveal-panel { border-left-color: var(--accent); background: #fffbeb; }
.reveal-panel h2 { color: #b45309; }
.reveal-checkpoints {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.cp-card {
    background: #fff;
    border: 2px solid;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.cp-card.cp-pos { border-color: var(--success); }
.cp-card.cp-neg { border-color: var(--danger); }
.cp-label { font-size: .85em; color: var(--muted); font-weight: 600; }
.cp-date { font-size: .78em; color: var(--muted); font-family: ui-monospace, monospace; }
.cp-price {
    font-size: 1.3em;
    font-weight: 800;
    color: var(--ink);
    font-family: ui-monospace, monospace;
    margin: 4px 0;
}
.cp-return { font-size: 1.15em; font-weight: 700; }
.cp-card.cp-pos .cp-return { color: var(--success); }
.cp-card.cp-neg .cp-return { color: var(--danger); }
.cp-note { font-size: .8em; color: var(--muted); margin-top: 6px; }

.reveal-chart canvas { width: 100%; height: auto; background: #fff; border-radius: 6px; border: 1px solid #e5e7eb; }
.ev-item {
    padding: 6px 10px;
    background: #fff;
    border-left: 3px solid;
    margin: 4px 0;
    font-size: .85em;
    line-height: 1.5;
    border-radius: 0 4px 4px 0;
}
.ev-item small { color: var(--muted); }
.ev-item.ev-pos { border-color: var(--success); background: #f0fdf4; }
.ev-item.ev-neg { border-color: var(--danger); background: #fef2f2; }
.ev-item.ev-ambig { border-color: var(--warning); background: #fef3c7; }

/* Postmortem */
.postmortem-panel { border-left-color: #059669; background: #f0fdf4; }
.postmortem-panel h2 { color: #14532d; }
.postmortem-panel h3 { color: #14532d; margin: 12px 0 6px; font-size: 1em; }
.pm-section {
    background: #fff;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
}
.pm-table {
    width: 100%;
    border-collapse: collapse;
    font-family: ui-monospace, monospace;
    margin: 6px 0;
}
.pm-table th, .pm-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.pm-table th { background: #f9fafb; color: var(--muted); font-weight: 600; width: 40%; }
.pm-table td.pm-pos { color: var(--success); font-weight: 700; }
.pm-table td.pm-neg { color: var(--danger); font-weight: 700; }
.pm-table small { color: var(--muted); font-weight: 400; }

.pm-events, .pm-lessons { padding-left: 22px; margin: 6px 0; }
.pm-events li, .pm-lessons li { margin: 8px 0; font-size: .9em; line-height: 1.6; }
.pm-thesis-quote {
    background: #f0fdf4;
    border-left: 4px solid var(--success);
    padding: 10px 14px;
    font-style: italic;
    color: #14532d;
    border-radius: 0 4px 4px 0;
}

.sim-footer {
    text-align: center;
    color: var(--muted);
    padding: 10px 5px 30px;
    font-size: .85em;
}
.sim-footer a { color: var(--primary); }

@media (min-width: 700px) {
    .sim-main { padding: 20px; gap: 18px; }
}

/* ====================== SCENARIO SELECTOR ====================== */
.scenario-selector-panel {
    border-left-color: #059669;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}
.scenario-selector-panel h2 { color: #14532d; }

.scenario-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 10px;
}
@media (min-width: 700px) {
    .scenario-grid { grid-template-columns: repeat(3, 1fr); }
}

.scenario-card {
    background: #fff;
    border: 2px solid #d1fae5;
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.scenario-card:hover {
    transform: translateY(-2px);
    border-color: #059669;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.15);
}
.scenario-emoji { font-size: 2.5em; text-align: center; }
.scenario-title {
    font-size: 1.15em;
    font-weight: 700;
    color: #14532d;
    text-align: center;
}
.scenario-subtitle {
    font-size: .85em;
    color: #4b5563;
    line-height: 1.5;
    flex: 1;
}
.scenario-outcome {
    font-size: .82em;
    font-weight: 600;
    padding: 6px 8px;
    background: #f9fafb;
    border-radius: 4px;
    color: #374151;
    border-left: 3px solid #9ca3af;
}
.btn-scenario-select {
    background: #059669;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: .9em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
.btn-scenario-select:hover { background: #047857; }

.btn-secondary {
    background: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
}
.btn-secondary:hover:not(:disabled) { background: #e5e7eb !important; }

/* ====================== GAME PANEL (event-by-event) ====================== */
.game-panel {
    border-left-color: #7c3aed;
    background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
}
.game-panel h2 { color: #4c1d95; }
.game-panel h3 { color: #4c1d95; margin: 14px 0 6px; font-size: 1em; }

.game-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.game-header h2 { margin: 0; flex-shrink: 0; }
.game-progress {
    flex: 1;
    height: 10px;
    background: #ede9fe;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #ddd6fe;
}
.game-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #a855f7);
    width: 0;
    transition: width 0.4s ease;
    border-radius: 5px;
}

/* ---- Event card ---- */
.event-card {
    background: #fff;
    border: 2px solid #ddd6fe;
    border-radius: 10px;
    padding: 14px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.08);
}
.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-weight: 700;
}
.event-header.ev-pos { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.event-header.ev-neg { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }
.event-header.ev-ambig { background: #fef3c7; color: #78350f; border: 1px solid #fde68a; }
.event-date { font-family: ui-monospace, monospace; font-size: .95em; }
.event-kind { font-size: .88em; }

.event-title {
    font-size: 1.15em;
    font-weight: 700;
    color: #1f2937;
    margin: 6px 0;
}
.event-desc {
    color: #4b5563;
    line-height: 1.6;
    margin: 8px 0;
    font-size: .95em;
}
.event-price-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: center;
    background: #f9fafb;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 10px;
}
.event-price-cell {
    text-align: left;
    border-right: 1px solid #e5e7eb;
    padding-right: 14px;
}
.event-price-label { font-size: .78em; color: #6b7280; font-weight: 600; }
.event-price-val {
    font-size: 1.5em;
    font-weight: 700;
    color: #7c3aed;
    font-family: ui-monospace, monospace;
    margin-top: 2px;
}
.event-price-delta { font-size: .85em; font-weight: 600; margin-top: 2px; }
.delta-pos { color: #059669; }
.delta-neg { color: #dc2626; }
.event-hint {
    font-size: .9em;
    color: #4b5563;
    line-height: 1.5;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
}

/* ---- Portfolio panel ---- */
.portfolio-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin: 12px 0;
}
.pf-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.pf-cell {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
}
.pf-cell.pf-total {
    background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
    border-color: #ddd6fe;
}
.pf-label { font-size: .8em; color: #6b7280; font-weight: 600; }
.pf-val {
    font-size: 1.4em;
    font-weight: 700;
    color: #1f2937;
    font-family: ui-monospace, monospace;
    margin: 2px 0;
}
.pf-cell.pf-total .pf-val { color: #6b21a8; }
.pf-sub { font-size: .78em; color: #6b7280; }
.pf-sub.delta-pos, .pf-sub.delta-neg { font-weight: 600; }

/* 部位漂移說明 · 讓玩家理解「目前 % vs 上次目標 %」的差異 */
.pf-drift {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f9fafb;
    border-left: 4px solid #9ca3af;
    border-radius: 0 6px 6px 0;
    font-size: .88em;
    color: #4b5563;
    line-height: 1.6;
}
.pf-drift b { color: #1f2937; font-family: ui-monospace, monospace; }
.pf-drift small { display: block; font-size: .82em; color: #9ca3af; margin-top: 2px; }
.pf-drift.drift-up { border-left-color: #059669; background: #ecfdf5; }
.pf-drift.drift-up b { color: #065f46; }
.pf-drift.drift-down { border-left-color: #dc2626; background: #fef2f2; }
.pf-drift.drift-down b { color: #7f1d1d; }

/* ---- Live decision panel ---- */
.decision-panel-live {
    background: #fff;
    border: 2px solid #a855f7;
    border-radius: 10px;
    padding: 14px;
    margin: 12px 0;
}
.pos-adjust-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 8px 0;
}

/* Share-delta slider · 中間 = 0 = 維持、左賣右買 */
.share-delta-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: #faf5ff;
    border-radius: 8px;
    border: 1px solid #ddd6fe;
    margin: 8px 0;
}
.share-delta-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .9em;
}
.share-delta-label b {
    font-family: ui-monospace, monospace;
    font-size: 1.3em;
    color: #7c3aed;
    font-weight: 700;
}
.share-delta-label .delta-arrow {
    color: #6b7280;
    font-size: .82em;
    font-weight: 600;
}
.share-delta-row input[type="range"] {
    width: 100%;
    accent-color: #7c3aed;
}
.share-delta-range {
    display: flex;
    justify-content: space-between;
    font-size: .78em;
    color: #6b7280;
    font-family: ui-monospace, monospace;
}
#btn-confirm-decision.btn-warn { background: #d97706; }
#btn-confirm-decision.btn-warn:hover:not(:disabled) { background: #b45309; }
.pos-current {
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: .95em;
    color: #4b5563;
}
.pos-current b { color: #7c3aed; font-size: 1.15em; font-family: ui-monospace, monospace; }
.pos-target {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #faf5ff;
    border-radius: 6px;
}
.pos-target input[type="range"] {
    flex: 1;
    accent-color: #7c3aed;
}
.pos-target b {
    font-size: 1.2em;
    color: #7c3aed;
    font-family: ui-monospace, monospace;
    min-width: 55px;
    text-align: right;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 6px;
    margin: 10px 0;
}
.preset-btn {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: .88em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.preset-btn.preset-sell-all { border-color: #fca5a5; color: #7f1d1d; background: #fef2f2; }
.preset-btn.preset-sell { border-color: #fca5a5; color: #991b1b; background: #fef2f2; }
.preset-btn.preset-hold { border-color: #d1d5db; color: #374151; background: #f9fafb; }
.preset-btn.preset-buy { border-color: #86efac; color: #065f46; background: #ecfdf5; }
.preset-btn.preset-all-in { border-color: #86efac; color: #14532d; background: #d1fae5; }

.pos-delta-preview {
    margin: 10px 0;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: .92em;
    font-weight: 600;
    border-left: 4px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
}
.pos-delta-preview.preview-hold { border-color: #6b7280; background: #f9fafb; color: #374151; }
.pos-delta-preview.preview-buy { border-color: #059669; background: #ecfdf5; color: #065f46; }
.pos-delta-preview.preview-sell { border-color: #dc2626; background: #fef2f2; color: #7f1d1d; }
.pos-delta-preview.preview-warn { border-color: #f59e0b; background: #fef3c7; color: #78350f; }

/* ---- Decision log ---- */
.decision-log {
    margin-top: 14px;
}
.decision-log-table {
    width: 100%;
    font-size: .85em;
}
.decision-log-table th {
    background: #ede9fe;
    color: #4c1d95;
    font-weight: 700;
}
.decision-log-table td { vertical-align: top; }
.decision-log-table td small { color: var(--muted); }

/* ---- Postmortem: decision table + colored rows ---- */
.pm-decision-table {
    width: 100%;
    font-size: .85em;
}
.pm-decision-table th {
    background: #f0fdf4;
    color: #14532d;
    font-weight: 700;
}
.pm-decision-table td { vertical-align: top; }
.pm-decision-table small { color: var(--muted); }
.pm-decision-table tr.pm-buy { background: #f0fdf4; }
.pm-decision-table tr.pm-sell { background: #fef2f2; }
.pm-decision-table tr.pm-hold { background: #ffffff; }

.btn-link {
    display: inline-block;
    padding: 8px 14px;
    background: #fff;
    color: var(--primary);
    text-decoration: none;
    border: 1px solid var(--primary);
    border-radius: 6px;
    font-size: .9em;
    font-weight: 600;
}
.btn-link:hover { background: var(--primary); color: #fff; }

/* 動態按鈕：hold=灰、buy=綠、sell=紅 · 讓玩家一眼看出這關會不會動 */
#btn-confirm-decision.btn-hold { background: #6b7280; }
#btn-confirm-decision.btn-hold:hover:not(:disabled) { background: #4b5563; }
#btn-confirm-decision.btn-buy { background: #059669; }
#btn-confirm-decision.btn-buy:hover:not(:disabled) { background: #047857; }
#btn-confirm-decision.btn-sell { background: #dc2626; }
#btn-confirm-decision.btn-sell:hover:not(:disabled) { background: #b91c1c; }

@media (min-width: 700px) {
    .pf-grid { grid-template-columns: repeat(4, 1fr); }
    .event-price-row { grid-template-columns: 220px 1fr; }
    .pos-adjust-row { grid-template-columns: auto 1fr; align-items: center; }
    .preset-buttons { grid-template-columns: repeat(5, 1fr); }
}

/* ============================================================
 * Phase 7 · 6 軸估值雷達
 * ============================================================ */
.radar-panel {
    margin-top: 20px;
    background: linear-gradient(180deg, #fffaf0 0%, #fff 100%);
    border-left: 4px solid #f59e0b;
}
.radar-panel h2 {
    color: #78350f;
    margin: 0 0 8px;
}
.radar-wrapper {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}
.radar-summary {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}
.radar-avg {
    text-align: center;
    padding: 14px 24px;
    background: #fef3c7;
    border: 2px solid #fbbf24;
    border-radius: 12px;
    max-width: 400px;
}
.radar-avg-label {
    font-size: .85em;
    color: #78350f;
    font-weight: 700;
    margin-bottom: 4px;
}
.radar-avg-value {
    font-size: 2.4em;
    font-weight: 700;
    color: #92400e;
    line-height: 1;
}
.radar-avg-suffix {
    font-size: .5em;
    color: #a68a3d;
    font-weight: 500;
}
.radar-avg-verdict {
    margin-top: 6px;
    font-size: .9em;
    color: #78350f;
    font-weight: 600;
}
.radar-details {
    margin-top: 12px;
    padding: 0 4px;
}
.radar-details summary {
    cursor: pointer;
    color: #78350f;
    font-weight: 700;
    padding: 6px 0;
}
.radar-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: .9em;
}
.radar-table th {
    background: #fef3c7;
    color: #78350f;
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid #fbbf24;
}
.radar-table td {
    padding: 6px 8px;
    border-bottom: 1px dashed #fde68a;
}
.radar-table .axis-good { color: #059669; font-weight: 700; }
.radar-table .axis-mid  { color: #d97706; font-weight: 700; }
.radar-table .axis-poor { color: #dc2626; font-weight: 700; }

/* 跨頁跳轉按鈕（valuation → rotation） */
.cross-nav-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #0ea5e9;
    color: #fff;
    border-radius: 999px;
    font-size: .85em;
    text-decoration: none;
    margin-left: 8px;
    font-weight: 600;
}
.cross-nav-btn:hover { background: #0284c7; }

/* Phase 7.1 · 雷達 lens tag + disclaimer */
.radar-lens-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 10px;
    background: #fbbf24;
    color: #78350f;
    border-radius: 999px;
    font-size: .65em;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: 0.5px;
}
.radar-warning {
    margin: 12px 0;
    padding: 12px 14px;
    background: #fef2f2;
    border: 2px solid #fca5a5;
    border-radius: 10px;
}
.radar-warning-title {
    font-weight: 700;
    color: #991b1b;
    margin-bottom: 6px;
    font-size: .95em;
}
.radar-warning-body {
    color: #7f1d1d;
    font-size: .88em;
    line-height: 1.65;
}
.radar-warning-body ul {
    margin: 6px 0 0 4px;
    padding-left: 20px;
}
.radar-warning-body li {
    margin: 3px 0;
}

/* Phase 7 · 成長股雷達（紫色系 · 跟價值派橘色系區隔） */
.radar-panel-growth {
    background: linear-gradient(180deg, #faf5ff 0%, #fff 100%);
    border-left: 4px solid #8b5cf6;
    margin-top: 24px;
}
.radar-panel-growth h2 {
    color: #5b21b6;
}
.radar-panel-growth .radar-avg {
    background: #ede9fe;
    border-color: #a78bfa;
}
.radar-panel-growth .radar-avg-label { color: #5b21b6; }
.radar-panel-growth .radar-avg-value { color: #4c1d95; }
.radar-panel-growth .radar-avg-verdict { color: #5b21b6; }
.radar-panel-growth .radar-details summary { color: #5b21b6; }
.radar-panel-growth .radar-table th {
    background: #ede9fe;
    color: #5b21b6;
    border-bottom-color: #a78bfa;
}
.radar-panel-growth .radar-table td { border-bottom-color: #ddd6fe; }
.radar-warning-growth {
    background: #eef2ff;
    border-color: #a5b4fc;
}
.radar-warning-growth .radar-warning-title { color: #4338ca; }
.radar-warning-growth .radar-warning-body { color: #3730a3; }
.radar-lens-tag.lens-growth {
    background: #8b5cf6;
    color: #fff;
}

/* Phase 7.2 · 分數落差偵測 alert（兩雷達之間 · gap ≥ 30 時顯示） */
.radar-mismatch {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 12px;
    border: 2px solid;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}
.radar-mismatch.mismatch-growth {
    background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
    border-color: #8b5cf6;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15);
}
.radar-mismatch.mismatch-value {
    background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
    border-color: #f59e0b;
}
.radar-mismatch.mismatch-elite {
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
    border-color: #10b981;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.25);
}
.radar-mismatch.mismatch-elite .radar-mismatch-title {
    color: #065f46;
}
.radar-mismatch.mismatch-elite .radar-mismatch-body {
    color: #064e3b;
}
.radar-mismatch-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.radar-mismatch-icon {
    font-size: 22px;
}
.radar-mismatch-title {
    font-size: 16px;
    font-weight: 700;
    color: #78350f;
}
.radar-mismatch.mismatch-growth .radar-mismatch-title {
    color: #5b21b6;
}
.radar-mismatch-body {
    font-size: 13.5px;
    line-height: 1.7;
    color: #451a03;
}
.radar-mismatch.mismatch-growth .radar-mismatch-body {
    color: #3b0764;
}
.radar-mismatch-body p {
    margin: 0;
}
.radar-mismatch-scores {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.score-chip {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}
.score-chip.score-value {
    background: #f59e0b;
}
.score-chip.score-growth {
    background: #8b5cf6;
}
.mismatch-arrow {
    font-size: 18px;
    color: #64748b;
    font-weight: 700;
}

/* 應收 / 存貨 / CapEx 季度 drill-down（QoQ） */
.drilldown-panel {
    margin-top: 16px;
    border-left-color: #f59e0b;
}
.drilldown-panel h3 {
    color: #78350f;
    margin-top: 0;
}
.drilldown-table {
    width: 100%;
    font-size: .88em;
    margin-top: 8px;
}
.drilldown-table th, .drilldown-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}
.drilldown-table th {
    background: #fef3c7;
    color: #78350f;
    text-align: center;
    font-weight: 700;
}
.drilldown-table td:first-child {
    text-align: left;
    color: #6b7280;
    font-family: ui-monospace, monospace;
}

/* Step 2 · 12 月營收 / 季度毛利+營益 panel */
.monthly-metrics-panel {
    margin-top: 16px;
    border-left-color: #10b981;
}
.monthly-metrics-panel h3 {
    color: #065f46;
    margin-top: 0;
}
.monthly-metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Step 3 · 外資訊號警報 */
.foreign-signal-panel {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 5px solid #94a3b8;
}
.foreign-signal-panel.severity-0 {
    background: #f0fdf4;
    border-left-color: #22c55e;
}
.foreign-signal-panel.severity-1 {
    background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
    border-left-color: #f59e0b;
}
.foreign-signal-panel.severity-2 {
    background: linear-gradient(135deg, #fed7aa 0%, #fef3c7 100%);
    border-left-color: #ea580c;
}
.foreign-signal-panel.severity-3 {
    background: linear-gradient(135deg, #fecaca 0%, #fee2e2 100%);
    border-left-color: #dc2626;
    box-shadow: 0 3px 12px rgba(220, 38, 38, 0.2);
}
.signal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.signal-severity { font-size: 18px; }
.signal-title { font-weight: 700; font-size: 15px; color: #7c2d12; }
.severity-0 .signal-title { color: #14532d; }
.signal-list { margin-bottom: 10px; }
.signal-item {
    padding: 4px 0;
    font-size: 13.5px;
    font-weight: 600;
    color: #7f1d1d;
}
.signal-table { width: 100%; margin: 8px 0; }
.signal-table th, .signal-table td {
    padding: 6px 10px;
    text-align: center;
    font-size: 13px;
}
.signal-table td:first-child { text-align: left; width: 60px; }
.signal-60d {
    margin: 6px 0;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    font-size: 13px;
    color: #78350f;
}
.signal-rules {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    font-size: 11.5px;
    color: #78350f;
    line-height: 1.7;
}

/* 軌跡圖 · 營收 × 毛利 */
.trajectory-panel {
    margin-top: 16px;
    background: linear-gradient(180deg, #faf5ff 0%, #fff 100%);
    border-left-color: #7c3aed;
}
.trajectory-panel h3 {
    color: #5b21b6;
    margin-top: 0;
}
.trajectory-verdict {
    margin: 12px 0;
    padding: 10px 14px;
    border-left: 4px solid;
    background: #fff;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
}

/* 季節性柱狀圖 */
.seasonality-panel {
    margin-top: 16px;
    background: linear-gradient(180deg, #fefce8 0%, #fff 100%);
    border-left-color: #f59e0b;
}
.seasonality-panel h3 {
    color: #92400e;
    margin-top: 0;
}
.seasonality-verdict {
    margin: 12px 0;
    padding: 10px 14px;
    border-left: 4px solid #f59e0b;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 13.5px;
    color: #78350f;
}
.seasonality-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 10px;
}
@media (min-width: 900px) {
    .seasonality-grid { grid-template-columns: 1fr 1fr; }
}
.seasonality-chart h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: #334155;
    font-weight: 700;
}
.seasonality-chart svg { display: block; width: 100%; }

/* 月度熱區（TW 專用） */
.heatmap-panel {
    margin-top: 16px;
    border-left-color: #f97316;
}
.heatmap-panel h3 {
    color: #7c2d12;
    margin-top: 0;
}
.heatmap-insight {
    margin: 10px 0;
    padding: 10px 12px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    font-size: 13px;
    color: #78350f;
}
.heatmap-scroll {
    overflow-x: auto;
    margin-top: 8px;
}
.monthly-heatmap {
    border-collapse: collapse;
    font-size: 12.5px;
    margin: 0 auto;
    min-width: 640px;
}
.monthly-heatmap th, .monthly-heatmap td {
    padding: 6px 8px;
    text-align: center;
    border: 1px solid #e2e8f0;
    min-width: 42px;
}
.monthly-heatmap thead th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
}
.heatmap-year {
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
}
.heatmap-cell {
    font-weight: 600;
    font-size: 11.5px;
    transition: transform 0.1s;
    cursor: help;
}
.heatmap-cell:hover {
    transform: scale(1.05);
    z-index: 1;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.heatmap-empty {
    background: #f8fafc;
    color: #94a3b8;
}
.heatmap-avg {
    font-weight: 700;
    border-top: 2px solid #94a3b8;
}

/* Feature 1 · DSO/DIO drilldown verdict */
.drilldown-verdict {
    margin: 10px 0;
    padding: 10px 14px;
    background: #f0f9ff;
    border-left: 4px solid #0284c7;
    border-radius: 6px;
    font-size: 13px;
    color: #0c4a6e;
    line-height: 1.7;
}

/* Feature 2 · PEG 低基期扭曲警訊 */
.peg-distortion-banner {
    margin: 10px 0;
    padding: 12px 14px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    font-size: 13px;
    color: #78350f;
    line-height: 1.7;
}

/* Feature B · 資產負債結構 panel */
.balance-sheet-panel {
    margin-top: 16px;
    border-left-color: #3b82f6;
}
.balance-sheet-panel h3 {
    color: #1e3a8a;
    margin-top: 0;
}
.balance-sheet-panel h4 {
    margin: 8px 0 6px;
    color: #1e40af;
    font-size: 14px;
}
.balance-sheet-panel svg {
    display: block;
    width: 100%;
    max-width: 800px;
    margin: 4px 0;
    border-radius: 4px;
    overflow: hidden;
}
.bs-note {
    margin: 8px 0;
    padding: 8px 12px;
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    border-radius: 6px;
    font-size: 13px;
    color: #1e3a8a;
    line-height: 1.7;
}
.bs-metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 14px;
}
.bs-metric {
    padding: 10px 12px;
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: 8px;
    text-align: center;
    cursor: help;
}
.bs-metric-label {
    font-size: 11px;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}
.bs-metric-val {
    font-family: ui-monospace, monospace;
    font-size: 1.3em;
    font-weight: 800;
    color: #1e3a8a;
    margin-top: 2px;
}
.bs-table {
    font-size: 0.85em;
    width: 100%;
}
.bs-table td:first-child { display: flex; align-items: center; gap: 6px; }
.bs-table td:nth-child(2), .bs-table td:nth-child(3) { text-align: right; font-family: ui-monospace, monospace; }
.bs-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Feature B · 「其他流動負債」拆解 sub-section */
.bs-cl-details {
    margin-top: 14px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}
.bs-cl-details summary {
    cursor: pointer;
    color: #1e40af;
    font-weight: 600;
    padding: 4px 0;
}
.bs-cl-details summary:hover {
    color: #1e3a8a;
}
.bs-cl-details table {
    margin-top: 8px;
}

/* Feature · 內部人持股變化 panel */
.insider-panel {
    margin-top: 16px;
    border-left-color: #8b5cf6;
}
.insider-panel h3 {
    color: #5b21b6;
    margin-top: 0;
}
.insider-verdict {
    margin: 10px 0;
    padding: 10px 14px;
    background: #f5f3ff;
    border-left: 4px solid #8b5cf6;
    border-radius: 6px;
    font-size: 13px;
    color: #4c1d95;
    line-height: 1.7;
}
.insider-table {
    width: 100%;
    font-size: 0.85em;
    margin-top: 8px;
}
.insider-table td, .insider-table th {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}
.insider-table th {
    background: #f5f3ff;
    color: #5b21b6;
    text-align: center;
    font-weight: 700;
}
.insider-table td:first-child, .insider-table td:nth-child(2) {
    text-align: left;
    font-family: ui-monospace, monospace;
}

/* Feature · 配息 + 庫藏股 panel */
.dividend-panel {
    margin-top: 16px;
    border-left-color: #10b981;
}
.dividend-panel h3 {
    color: #065f46;
    margin-top: 0;
}
.dividend-panel h4 {
    margin: 8px 0 4px;
    color: #047857;
    font-size: 14px;
}
.dividend-panel svg {
    display: block;
    margin: 4px 0;
    background: #f0fdf4;
    border-radius: 6px;
}

/* Feature · 機構持股集中度 13F panel */
.io-panel {
    margin-top: 16px;
    border-left-color: #6366f1;
}
.io-panel h3 {
    color: #4338ca;
    margin-top: 0;
}
.io-changes {
    margin: 8px 0;
    padding: 10px 12px;
    background: #eef2ff;
    border-left: 4px solid #6366f1;
    border-radius: 6px;
    font-size: 13px;
    color: #3730a3;
    line-height: 1.8;
}
.io-details {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}
.io-details summary {
    cursor: pointer;
    color: #4338ca;
    font-weight: 600;
    padding: 4px 0;
}
.io-table {
    width: 100%;
    font-size: 0.85em;
    margin-top: 8px;
}
.io-table th, .io-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}
.io-table th {
    background: #eef2ff;
    color: #4338ca;
    text-align: center;
    font-weight: 700;
}
.io-table td:nth-child(2) {
    text-align: left;
    font-family: ui-monospace, monospace;
}

/* 診斷 · FMP endpoint 狀態 panel */
.fmp-status-panel {
    margin-top: 12px;
    padding: 12px 14px;
    background: #fef3c7;
    border-left-color: #f59e0b;
    border-radius: 8px;
    font-size: 13px;
}
.fmp-status-panel summary {
    cursor: pointer;
    color: #78350f;
    font-weight: 600;
}
.fmp-status-list {
    margin: 8px 0 0;
    padding-left: 20px;
    color: #78350f;
    font-size: 12.5px;
    line-height: 1.8;
}
.fmp-status-list code {
    background: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
    color: #92400e;
}

/* ============================================================ */
/* ETF 專屬 panel · header + dividend + institutional + chip + external */
/* ============================================================ */
.etf-panel { margin-top: 20px; }
.etf-panel h3 {
    margin-top: 28px;
    margin-bottom: 12px;
    color: #0f766e;
    font-size: 1.05em;
    border-bottom: 2px solid #a7f3d0;
    padding-bottom: 6px;
}
.etf-panel h3:first-child { margin-top: 0; }

/* Header 卡：ETF 標籤 + KPI grid */
.etf-header-card {
    position: relative;
    background: linear-gradient(135deg, #ecfeff 0%, #f0fdfa 100%);
    border: 2px solid #99f6e4;
    border-radius: 12px;
    padding: 20px 20px 14px;
    margin-bottom: 16px;
}
.etf-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #0891b2;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 800;
    letter-spacing: 1px;
}
.etf-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.etf-kpi-label {
    font-size: 0.78em;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.etf-kpi-val {
    font-size: 1.4em;
    font-weight: 800;
    color: #0f766e;
    margin-top: 2px;
}
.etf-kpi-val.chg-up { color: #16a34a; }
.etf-kpi-val.chg-down { color: #dc2626; }
.chg-up { color: #16a34a; font-weight: 700; }
.chg-down { color: #dc2626; font-weight: 700; }

/* Dividend table */
.etf-div-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    background: #f0fdfa;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.92em;
    color: #134e4a;
}
.etf-div-summary b { color: #0f766e; font-size: 1.05em; }
.etf-div-table th { background: #f0fdfa; color: #134e4a; }
.table-scroll {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* Institutional 3-column grid */
.etf-inst-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 700px) {
    .etf-inst-grid { grid-template-columns: 1fr; }
}
.etf-inst-cell {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
}
.etf-inst-label {
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
}
.etf-inst-vals { line-height: 1.9; font-size: 0.92em; }
.etf-inst-window {
    display: inline-block;
    width: 28px;
    color: #94a3b8;
    font-size: 0.85em;
    font-family: ui-monospace, monospace;
}
.etf-inst-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9em;
    font-family: ui-monospace, monospace;
}
.etf-inst-badge.inst-buy { background: #dcfce7; color: #14532d; }
.etf-inst-badge.inst-sell { background: #fee2e2; color: #7f1d1d; }

#etf-inst-chart, #etf-whale-chart {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

/* Chip 大戶散戶 · 5 條水平 bar */
.etf-chip-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}
.chip-bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 60px;
    align-items: center;
    gap: 12px;
}
.chip-bar-label {
    font-size: 0.92em;
    color: #334155;
    font-weight: 600;
}
.chip-bar-track {
    height: 18px;
    background: #f1f5f9;
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.chip-bar-fill {
    height: 100%;
    transition: width 0.4s ease;
    border-radius: 9px;
}
.chip-bar-fill.chip-retail { background: #93c5fd; }
.chip-bar-fill.chip-small { background: #60a5fa; }
.chip-bar-fill.chip-mid { background: #f59e0b; }
.chip-bar-fill.chip-big { background: #ef4444; }
.chip-bar-fill.chip-whale { background: linear-gradient(90deg, #7c3aed, #4c1d95); }
.chip-bar-pct {
    text-align: right;
    font-family: ui-monospace, monospace;
    font-weight: 700;
    color: #0f172a;
}
@media (max-width: 600px) {
    .chip-bar-row { grid-template-columns: 90px 1fr 50px; }
    .chip-bar-label { font-size: 0.82em; }
}

/* External guide cards */
.etf-external-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
@media (max-width: 700px) {
    .etf-external-grid { grid-template-columns: 1fr; }
}
.etf-ext-card {
    background: #fff;
    border: 1px solid #e0e7ff;
    border-left: 4px solid #6366f1;
    border-radius: 6px;
    padding: 10px 14px;
}
.etf-ext-title {
    font-weight: 700;
    color: #3730a3;
    margin-bottom: 6px;
    font-size: 0.95em;
}
.etf-ext-body {
    font-size: 0.88em;
    color: #475569;
    line-height: 1.6;
}
.etf-ext-body a {
    color: #4338ca;
    text-decoration: underline;
    font-weight: 600;
}

/* Tier 1 · 技術訊號 panel */
.etf-tech-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
    margin: 10px 0;
}
@media (max-width: 800px) {
    .etf-tech-grid { grid-template-columns: 1fr; }
}
.etf-tech-cell {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px 14px;
}
.etf-tech-label {
    font-size: 0.78em;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.etf-tech-val {
    font-size: 1.05em;
    color: #0f172a;
    font-weight: 700;
}
.etf-ma-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ma-cell {
    font-family: ui-monospace, monospace;
    font-size: 0.92em;
    color: #334155;
}
.ma-cell b { color: #64748b; font-weight: 700; margin-right: 4px; }

/* Tier 1 · 風險指標 panel */
.etf-risk-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 10px 0;
}
@media (max-width: 700px) {
    .etf-risk-grid { grid-template-columns: 1fr 1fr; }
}
.etf-risk-cell {
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
}
.etf-risk-label {
    font-size: 0.78em;
    color: #713f12;
    font-weight: 700;
    margin-bottom: 6px;
}
.etf-risk-val {
    font-size: 1.2em;
    font-weight: 800;
    color: #713f12;
}

/* Tier 1 · 融資融券 panel */
.etf-margin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 10px 0;
}
@media (max-width: 700px) {
    .etf-margin-grid { grid-template-columns: 1fr 1fr; }
}
.etf-margin-cell {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
}
.etf-margin-label {
    font-size: 0.78em;
    color: #7c2d12;
    font-weight: 700;
    margin-bottom: 6px;
}
.etf-margin-val {
    font-size: 1.15em;
    font-weight: 800;
    color: #7c2d12;
}
#etf-margin-chart {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

/* ============================================================ */
/* 主動 ETF 持股 panel（CI 每日抓經理人 PCF · 見 scripts/etf_holdings_monitor.py）  */
/* ============================================================ */
.holdings-freshness {
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    color: #64748b;
    font-weight: 500;
}
.holdings-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    background: #eff6ff;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.92em;
    color: #1e3a8a;
}
.holdings-summary b { color: #1e40af; font-size: 1.05em; }
.holdings-generated { margin-left: auto; color: #64748b; font-size: 0.85em; }

.holdings-table th { background: #eff6ff; color: #1e3a8a; }
.holdings-table td.rank { color: #94a3b8; font-family: ui-monospace, monospace; text-align: right; }
.holdings-table a { color: #4338ca; text-decoration: none; font-size: 1.1em; }
.holdings-table a:hover { text-decoration: underline; }

.holdings-actions {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.holdings-actions-label {
    font-size: 0.85em;
    color: #6b7280;
    font-weight: 700;
    margin-bottom: 6px;
}
.holdings-actions-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.holding-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.82em;
    font-weight: 600;
    line-height: 1.4;
}
.holding-chip.chip-new { background: #dcfce7; color: #14532d; }
.holding-chip.chip-add { background: #dbeafe; color: #1e3a8a; }
.holding-chip.chip-reduce { background: #fef3c7; color: #78350f; }
.holding-chip.chip-drop { background: #fee2e2; color: #7f1d1d; }

/* 跨基金共識 · consensus */
.consensus-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.consensus-item {
    display: grid;
    grid-template-columns: 60px 1.5fr 2fr;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #f8fafc;
    border-left: 4px solid #cbd5e1;
    font-size: 0.92em;
}
.consensus-item.consensus-buy { border-left-color: #16a34a; background: #f0fdf4; }
.consensus-item.consensus-sell { border-left-color: #dc2626; background: #fef2f2; }
.consensus-item.consensus-div { border-left-color: #f59e0b; background: #fffbeb; }
.consensus-badge {
    font-weight: 700;
    font-size: 0.9em;
    text-align: center;
}
.consensus-item a {
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
}
.consensus-item a:hover { color: #4338ca; text-decoration: underline; }
.consensus-funds {
    color: #64748b;
    font-size: 0.88em;
}
@media (max-width: 700px) {
    .consensus-item { grid-template-columns: 50px 1fr; }
    .consensus-funds { grid-column: 1 / -1; }
}

.holdings-stale {
    font-size: 0.72em;
    color: #92400e;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
}

/* Tier A · 個股新聞 timeline */
.news-panel h3 { border-bottom: 2px solid #a5f3fc; }
.news-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}
.news-group {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
}
.news-group:last-child { border-bottom: 0; }
.news-date {
    font-family: ui-monospace, monospace;
    font-weight: 700;
    color: #0891b2;
    font-size: 0.9em;
}
.news-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.news-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    line-height: 1.5;
}
.news-item a {
    color: #0f172a;
    text-decoration: none;
    flex: 1;
}
.news-item a:hover {
    color: #0891b2;
    text-decoration: underline;
}
.news-source {
    color: #94a3b8;
    font-size: 0.85em;
    white-space: nowrap;
}
@media (max-width: 700px) {
    .news-group { grid-template-columns: 1fr; }
    .news-date { margin-bottom: 4px; }
    .news-item { flex-direction: column; align-items: flex-start; gap: 2px; }
}

/* Tier A · 除息填息 · 減資 panels */
.dividend-result-panel h3 { border-bottom: 2px solid #fbbf24; }
.capital-reduction-panel h3 { border-bottom: 2px solid #ef4444; }

/* ========== 穿透鏈 · 10 關逐關檢查 ========== */
.chain-panel {
    border-left-color: #7c3aed;
    background: #faf5ff;
}
.chain-panel h2 { color: #6d28d9; }

.chain-legend-icon {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin: 0 3px;
}

.chain-summary {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid #7c3aed;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.6;
}
.chain-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 3px 0;
}

.chain-progress {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    background: #e5e7eb;
}
.chain-progress-seg { height: 100%; transition: width 0.3s; }
.chain-progress-green { background: #16a34a; }
.chain-progress-amber { background: linear-gradient(90deg, #d97706, #dc2626); }
.chain-progress-gray  { background: #d1d5db; }

.chain-merged-ok {
    color: #166534;
    font-weight: 700;
}
.chain-merged-pending {
    color: #b45309;
    font-weight: 600;
}

.chain-gate {
    background: white;
    border-radius: 6px;
    margin-bottom: 4px;
    overflow: hidden;
    border-left: 3px solid #ccc;
}
.chain-gate.gate-pass    { border-left-color: #16a34a; }
.chain-gate.gate-warn    { border-left-color: #d97706; }
.chain-gate.gate-fail    { border-left-color: #dc2626; }
.chain-gate.gate-manual  { border-left-color: #6b7280; }

.chain-gate-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    user-select: none;
}
.chain-gate-summary::-webkit-details-marker { display: none; }
.chain-gate[open] .chain-gate-summary { border-bottom: 1px solid #eee; }

.chain-gate-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 50%;
    font-size: 12px;
    flex-shrink: 0;
}
.gate-pass    .chain-gate-icon { background: #dcfce7; color: #166534; }
.gate-warn    .chain-gate-icon { background: #fef3c7; color: #92400e; }
.gate-fail    .chain-gate-icon { background: #fee2e2; color: #991b1b; }
.gate-manual  .chain-gate-icon { background: #e5e7eb; color: #374151; }

.chain-gate-title {
    font-weight: 700;
    min-width: 100px;
    flex-shrink: 0;
}
.chain-gate-headline {
    flex: 1;
    color: #4b5563;
    font-size: 12px;
}
.chain-gate-expand {
    color: #9ca3af;
    font-size: 11px;
    background: #f3f4f6;
    padding: 1px 8px;
    border-radius: 10px;
}
.chain-gate[open] .chain-gate-expand::after { content: ' ▲'; }
.chain-gate:not([open]) .chain-gate-expand::after { content: ' ▼'; }

.chain-gate-body {
    padding: 10px 14px;
    font-size: 12px;
    background: #fafafa;
}
.chain-kv {
    padding: 3px 0;
    line-height: 1.5;
}
.chain-desc {
    background: #fff;
    border-left: 2px solid #ccc;
    padding: 6px 10px;
    margin: 6px 0;
    font-size: 11.5px;
    color: #4b5563;
    line-height: 1.5;
    border-radius: 3px;
}
.chain-hint {
    color: #6b7280;
    font-size: 11px;
    font-style: italic;
}
.chain-input-label {
    display: block;
    margin-top: 8px;
    font-size: 11.5px;
    color: #374151;
}
.chain-input {
    display: block;
    width: 100%;
    max-width: 400px;
    padding: 4px 8px;
    margin-top: 3px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
}
.chain-gate-source {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #e5e7eb;
    color: #9ca3af;
    font-size: 10.5px;
}

.chain-cp {
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 6px;
}
.chain-cp-label {
    font-size: 12px;
    margin-bottom: 4px;
}
.chain-cp-radios {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11.5px;
}
.chain-cp-radios label {
    cursor: pointer;
    color: #4b5563;
}
.chain-cp-score {
    margin-top: 8px;
    padding: 6px 10px;
    background: #ede9fe;
    color: #6d28d9;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

.chain-debug {
    margin-top: 8px;
    padding: 6px 10px;
    background: #f3f4f6;
    border: 1px dashed #9ca3af;
    border-radius: 4px;
    font-size: 10.5px;
    color: #4b5563;
    font-family: monospace;
    line-height: 1.5;
}

.chain-gate.gate-na {
    border-left-color: #6366f1;
}
.gate-na .chain-gate-icon { background: #e0e7ff; color: #4338ca; }
.chain-na-note {
    color: #4f46e5;
    font-weight: 600;
    font-size: 11.5px;
}
