/* Trang chủ — Nhiệt kế thị trường */

/* ---------- Hero: đồng hồ điểm ---------- */
.card-hero { min-width: 0; }
.score-layout { display: grid; gap: var(--s4); margin-top: var(--s3); align-items: center; }
@media (min-width: 560px) { .score-layout { grid-template-columns: minmax(0, 1fr) auto; gap: var(--s6); } }

.gauge { position: relative; max-width: 320px; margin: 0 auto; width: 100%; }
.gauge-svg { width: 100%; height: auto; overflow: visible; }
.gauge-seg { fill: none; stroke-width: 20; stroke-linecap: butt; }
.gauge-seg.z1 { stroke: var(--down-bar); }
.gauge-seg.z2 { stroke: var(--down-on-dark); }
.gauge-seg.z3 { stroke: var(--gold); }
.gauge-seg.z4 { stroke: var(--up-on-dark); }
.gauge-seg.z5 { stroke: var(--up-bar); }
.gauge-tick { fill: var(--on-dark-2); font-family: var(--font-sans); font-size: 11px; text-anchor: middle; }
.gauge-needle { stroke: var(--on-dark); stroke-width: 4; stroke-linecap: round; }
.gauge-hub { fill: var(--on-dark); stroke: var(--ink); stroke-width: 3; }
.gauge-score { text-align: center; margin-top: var(--s2); color: var(--gold-light); }
.gauge-max { font-family: var(--font-serif); font-size: 20px; font-weight: 600; color: var(--on-dark-2); margin-left: 2px; }

/* Lịch sử điểm (kiểu CNN) */
.history { list-style: none; display: grid; gap: var(--s2); }
.history li { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 44px; padding: var(--s1) 0; border-bottom: 1px solid var(--navy-track); font-size: 14px; color: var(--on-dark-2); }
.history li:last-child { border-bottom: 0; }
.dot { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; border: 2px solid currentColor; font-family: var(--font-serif); font-weight: 700; font-size: 16px; flex-shrink: 0; }
.dot-z1 { color: var(--down-on-dark); }
.dot-z2 { color: var(--down-on-dark); }
.dot-z3 { color: var(--gold-light); }
.dot-z4, .dot-z5 { color: var(--up-on-dark); }

.hero-badges { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }

/* ---------- Hero: tỷ trọng ---------- */
.hero-alloc { display: flex; flex-direction: column; }
.alloc-big { color: var(--gold-light); margin-top: var(--s3); }
.alloc-bar { height: 14px; margin-top: var(--s4); border-radius: var(--r-full); background: var(--navy-track); overflow: hidden; }
.alloc-bar span { display: block; height: 100%; width: var(--w); background: var(--gold); border-radius: var(--r-full); }
.alloc-tiles { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s4); }
@media (min-width: 640px) { .alloc-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.alloc-tiles li { background: var(--navy-raised); border-radius: var(--r-sm); padding: var(--s3); display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.4; }
.alloc-num { font-family: var(--font-serif); font-size: 22px; font-weight: 700; color: var(--on-dark); line-height: 1.2; }
.hero-alloc .how-to-read { margin-top: auto; }
.hero-alloc .alloc-tiles + .how-to-read { margin-top: var(--s4); }

/* ---------- Thẻ chỉ số (dùng .stat-value / .stat-sub chung) ---------- */
.metrics .card { display: flex; flex-direction: column; }
.metrics .stat-value { margin-top: var(--s2); }
.metrics .stat-sub { margin-top: var(--s1); }
.metrics .how-to-read { margin-top: auto; }
.metrics .stat-sub + .how-to-read { margin-top: var(--s3); }

/* ---------- Nhóm yếu tố (dòng .disclosure, thêm thanh + điểm trong summary) ---------- */

.factor-grid { display: grid; gap: 0 var(--s8); margin-top: var(--s2); }
@media (min-width: 900px) { .factor-grid { grid-template-columns: 1fr 1fr; } }
.factor-col:last-child .factor:last-child { border-bottom: 0; }
@media (min-width: 900px) { .factor-col .factor:last-child { border-bottom: 0; } }
.factor { border-bottom: 1px solid var(--border); }
.factor-row {
  display: grid; align-items: center; gap: var(--s1) var(--s3); min-height: 48px; padding: var(--s2) 0;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name score" "bar bar";
}
@media (min-width: 480px) {
  .factor-row { grid-template-columns: minmax(0, 1fr) minmax(90px, 38%) 40px; grid-template-areas: "name bar score"; }
}
.f-name { grid-area: name; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.f-weight { font-size: 12px; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.f-bar { grid-area: bar; position: relative; height: 10px; border-radius: var(--r-full); background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--border); }
.f-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--v) * 1%); border-radius: var(--r-full); }
.f-bar::after { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--text-2); }
.f-bar.z-down i { background: var(--down-bar); }
.f-bar.z-mid i { background: var(--gold); }
.f-bar.z-up i { background: var(--up-bar); }
.f-score { grid-area: score; font-family: var(--font-serif); font-size: 20px; font-weight: 700; text-align: right; line-height: 1; }
.f-score.z-down { color: var(--down); }
.f-score.z-mid { color: var(--gold-strong); }
.f-score.z-up { color: var(--up); }

/* ---------- Backtest ---------- */
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 13px; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.sw-up { background: var(--zone-up-fill); border-color: var(--up-bar); }
.sw-mid { background: var(--zone-mid-fill); border-color: var(--gold); }
.sw-down { background: var(--zone-down-fill); border-color: var(--down-bar); }
.sw-line { height: 3px; border: 0; border-radius: 2px; background: var(--gold); }

.chart-label { margin-top: var(--s4); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.chart { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); margin-top: var(--s2); }
.y-axis { position: relative; font-size: 11px; color: var(--text-muted); }
.y-axis span { position: absolute; right: 6px; top: var(--y); transform: translateY(-50%); line-height: 1; }
.plot { width: 100%; height: 200px; display: block; }
@media (min-width: 640px) { .plot-idx { height: 260px; } }
.plot-score { height: 90px; }
@media (min-width: 640px) { .plot-score { height: 110px; } }
.bands .band-up { fill: var(--zone-up-fill); }
.bands .band-down { fill: var(--zone-down-fill); }
.band-mid { fill: var(--zone-mid-fill); }
.gridlines line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.line-idx { fill: none; stroke: var(--ink); stroke-width: 2.25; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.line-score { fill: none; stroke: var(--gold); stroke-width: 2.25; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.x-axis { position: relative; height: 20px; margin: var(--s2) 0 0 40px; font-size: 11px; color: var(--text-muted); }
.x-axis span { position: absolute; left: var(--x); transform: translateX(-50%); }

/* Tầng tỷ trọng: vùng bậc thang + vạch cờ ở đáy; dòng tóm tắt dưới biểu đồ */
.sw-flag { background: var(--down-bar); }
.sw-ink { background: var(--ink); }
.sw-dash { background: repeating-linear-gradient(90deg, var(--up) 0 4px, transparent 4px 7px); }
.area-eq { fill: var(--ink); fill-opacity: .1; }
.line-eq { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.flag-marks rect { fill: var(--down-bar); }
.crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.nk-readout { margin-top: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--surface-soft); font-size: 13px; line-height: 1.55; color: var(--text-2); font-variant-numeric: tabular-nums; }
.nk-readout strong { color: var(--text); }

/* ---------- Kết quả theo trạng thái ---------- */
.section-head[hidden], .section-head .actions[hidden], .card[hidden], .nk-rg-compact[hidden] { display: none; }

.nk-rg-table tbody tr.is-current td, .nk-rg-table tbody tr.is-current:hover td { background: var(--gold-fill); }
.nk-rg-table td { vertical-align: top; }
.nk-rg-table td:first-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.nk-rg-table th { vertical-align: bottom; }
.nk-rg-table .nk-rg-group { text-align: center; }
.nk-hit { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--text-2); white-space: nowrap; }
.nk-hit i { font-style: normal; }
/* Màn hẹp hơn: hai số xuống hai dòng để bảng 4 kỳ không phải cuộn ngang */
@media (max-width: 1099px) {
  .nk-rg-matrix .nk-hit i { display: none; }
  .nk-rg-matrix .nk-hit span { display: block; }
}
@media (max-width: 479px) {
  .nk-rg-table th { white-space: normal; }
  .nk-rg-table th, .nk-rg-table td { padding-left: 6px; padding-right: 6px; }
}
@media (max-width: 899px) {
  .nk-rg-matrix th, .nk-rg-matrix td { padding-left: 6px; padding-right: 6px; }
}

/* Bảng đủ kỳ từ 640px; hẹp hơn thì một kỳ mỗi lần, chọn bằng .seg trên đầu khối */
@media (min-width: 640px) {
  .section-head .nk-hz-pick, .nk-rg-compact { display: none; }
}
@media (max-width: 639px) {
  #nk-rg-full.has-compact { display: none; }
}

.nk-tiles { --cols: 3; margin-top: var(--s4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 480px) { .nk-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Giả định phân bổ 1 tỷ ---------- */
#nk-sim-head .actions { align-items: center; }
#nk-sim-sub { white-space: nowrap; }
.nk-from { flex-direction: row; align-items: center; gap: var(--s2); }
.nk-from .field-label { white-space: nowrap; }
@media (min-width: 640px) { .nk-from .input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; } }
.nk-nowrap { white-space: nowrap; }

.chart-sim { grid-template-columns: 48px minmax(0, 1fr); margin-top: 0; }
.plot-wrap { position: relative; min-width: 0; }
.plot-sim { height: 280px; touch-action: pan-y; }
@media (min-width: 640px) { .plot-sim { height: 340px; } }
@media (min-width: 900px) { .plot-sim { height: 420px; } }
.plot-sim .line-idx { stroke-width: 1.5; }
.line-bond { fill: none; stroke: var(--up); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.sim-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); pointer-events: none; }
.nk-sim-x { margin-left: 48px; }
.nk-sim-legend { margin-top: var(--s2); }

/* Nhãn giá trị cuối kỳ ở mép phải; điện thoại không đủ chỗ thì bỏ, số đã có ở ô dưới biểu đồ */
.sim-ends { display: none; position: relative; font-size: 12px; font-weight: 600; color: var(--text); }
.sim-ends span { position: absolute; left: var(--s2); top: var(--y); transform: translateY(-50%); display: inline-flex; align-items: center; gap: 4px; line-height: 1; white-space: nowrap; }
.sim-ends .sw { flex-shrink: 0; width: 10px; }
@media (min-width: 640px) {
  .chart-sim { grid-template-columns: 48px minmax(0, 1fr) 76px; }
  .sim-ends { display: block; }
  .nk-sim-x { margin-right: 76px; }
}

/* ---------- FAQ ---------- */
.faq .disclosure:last-child { border-bottom: 0; }

/* ---------- Vùng nhận dữ liệu (scripts/index.js): trạng thái tải / lỗi ---------- */
.nk-alloc { display: flex; flex-direction: column; flex: 1; }
.metrics > .state, .factor-grid > .state { grid-column: 1 / -1; }
.card-hero .state { color: var(--on-dark-2); }
.card-hero .state-error p { color: var(--down-on-dark); }
.card-hero .skeleton { background: linear-gradient(90deg, var(--navy-raised) 0%, var(--navy-track) 50%, var(--navy-raised) 100%); background-size: 200% 100%; }
.factor-col:empty { display: none; }
