/* ── Fund Detail Page Styles ── */

/* NAV chart period stats (High / Low / Return) */
.nav-stats {
  display: flex;
  gap: var(--sp-8);
  padding: var(--sp-4) var(--sp-2) var(--sp-2);
  flex-wrap: wrap;
}
.nav-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-stat .ns-label {
  font-size: var(--fs-11);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-stat .ns-val {
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
}
/* Return value: green when positive, red when negative (override brand color) */
.nav-stat .ns-val.text-up { color: var(--color-up); }
.nav-stat .ns-val.text-down { color: var(--color-down); }

/* Back button */
.fd-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-3);
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.fd-back:hover {
  color: var(--text-brand);
  border-color: var(--border-default);
  background: var(--bg-hover-light);
}
.fd-back svg { width: 16px; height: 16px; }

.fund-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--bg-white);
  padding: var(--sp-6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-flat);
  margin-bottom: var(--sp-5);
}

.fund-title {
  font-size: var(--fs-24);
  margin-bottom: var(--sp-2);
}

.fund-amc-detail {
  font-size: var(--fs-14);
  color: var(--text-tertiary);
}

.fund-header-right {
  text-align: right;
  flex-shrink: 0;
}

.nav-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.nav-label {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-value {
  font-size: var(--fs-28);
  font-weight: var(--fw-bold);
  color: var(--text-brand);
}

.nav-change {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  margin-top: var(--sp-1);
}

/* Metrics Strip */
.metrics-strip {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-flat);
  overflow-x: auto;
  margin-bottom: var(--sp-6);
}

.metric-item {
  flex: 1;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 120px;
  border-right: 1px solid var(--border-light);
}

.metric-item:last-child {
  border-right: none;
}

.metric-label {
  font-size: var(--fs-11);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--fw-medium);
}

.metric-value {
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
}

/* Chart Container */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

.chart-container canvas {
  width: 100% !important;
}

/* Risk meter */
.risk-meter-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-5);
}

.risk-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.risk-metric {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  background: var(--bg-light-grey);
  border-radius: var(--radius-sm);
}

.risk-metric-label {
  font-size: var(--fs-11);
  color: var(--text-tertiary);
}

.risk-metric-value {
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
}

/* Cap chart */
.cap-chart-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-label {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
}

.info-value {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

/* Peer table */
.current-fund-row {
  background: var(--bg-selected-light) !important;
}

.current-fund-row td {
  font-weight: var(--fw-semibold) !important;
}

/* Returns table */
.returns-table td, .returns-table th { padding: var(--sp-3) var(--sp-4); }

@media (max-width: 768px) {
  .fund-header {
    flex-direction: column;
    gap: var(--sp-5);
  }
  .fund-header-right { text-align: left; }
  .nav-display { align-items: flex-start; }
  .risk-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Fund Detail — enhanced sections
   ============================================ */

/* Clickable category badge */
.badge-clickable {
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}
.badge-clickable:hover { filter: brightness(0.95); transform: translateY(-1px); }
.badge-clickable:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }

/* Health Scorecard */
.health-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--sp-7);
  align-items: center;
}
.health-score { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.health-ring {
  width: 140px; height: 140px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.health-ring-inner {
  width: 108px; height: 108px; border-radius: 50%;
  background: var(--bg-white);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.health-num { font-size: var(--fs-28); font-weight: var(--fw-bold); color: var(--text-brand); font-variant-numeric: tabular-nums; }
.health-den { font-size: var(--fs-16); color: var(--text-tertiary); font-weight: var(--fw-medium); }
.health-pct { font-size: var(--fs-12); color: var(--text-tertiary); }
.health-verdict { font-size: var(--fs-15); font-weight: var(--fw-bold); }
.health-checks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3) var(--sp-5); }
.health-check { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-2) 0; }
.hc-icon {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.hc-icon svg { width: 13px; height: 13px; }
.health-check.pass .hc-icon { background: rgba(25,175,85,0.13); color: #19af55; }
.health-check.fail .hc-icon { background: rgba(216,47,68,0.12); color: #d82f44; }
.hc-text { display: flex; flex-direction: column; gap: 1px; }
.hc-label { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--text-brand); }
.hc-detail { font-size: var(--fs-12); color: var(--text-tertiary); }

/* Key Metrics grid */
.keymetric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.keymetric { display: flex; flex-direction: column; gap: 3px; padding: var(--sp-4); background: var(--bg-light-grey); border-radius: var(--radius-md); }
.keymetric.km-wide { grid-column: span 2; }
.km-label { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: var(--fw-medium); }
.km-value { font-size: var(--fs-18); font-weight: var(--fw-bold); color: var(--text-brand); }
.km-value.km-small { font-size: var(--fs-13); font-weight: var(--fw-semibold); line-height: 1.35; }
.km-value.km-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: help; }
.km-sub { font-size: var(--fs-11); color: var(--text-tertiary); }

/* Asset Breakdown stacked bar */
.asset-stack { display: flex; height: 28px; border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--sp-5); }
.asset-seg { height: 100%; transition: width var(--transition-base); }
.asset-legend { display: flex; flex-direction: column; gap: var(--sp-3); }

/* Sector Allocation bars */
.sector-bars { display: flex; flex-direction: column; gap: var(--sp-4); }
.sector-row { display: grid; grid-template-columns: 130px 1fr 48px; align-items: center; gap: var(--sp-3); }
.sector-name { font-size: var(--fs-12); color: var(--text-brand); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-track { height: 8px; background: var(--bg-light-grey); border-radius: var(--radius-full); overflow: hidden; }
.sector-fill { height: 100%; background: linear-gradient(90deg, #61a1e7, #3f7fd0); border-radius: var(--radius-full); }
.sector-pct { font-size: var(--fs-12); color: var(--text-secondary); text-align: right; }

/* Fund Management */
.manager-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.manager-chip {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); background: var(--bg-light-grey);
  border-radius: var(--radius-md); border: 1px solid transparent;
  transition: all var(--transition-fast); text-decoration: none;
}
.manager-chip:hover { border-color: var(--border-default); background: var(--bg-white); box-shadow: var(--shadow-flat); }
.manager-initials {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--chart-1, #61a1e7), var(--chart-7, #3f7fd0));
  color: #fff; font-size: var(--fs-12); font-weight: var(--fw-bold);
  display: flex; align-items: center; justify-content: center;
}
.manager-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.manager-name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--text-brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manager-sub { font-size: var(--fs-11); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manager-ext { width: 14px; height: 14px; color: var(--text-tertiary); flex-shrink: 0; }

/* Tax card */
.tax-rows { display: flex; flex-direction: column; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.tax-row { display: flex; gap: var(--sp-3); align-items: flex-start; }
.tax-badge { flex-shrink: 0; font-size: var(--fs-11); font-weight: var(--fw-bold); padding: 3px 8px; border-radius: var(--radius-sm); letter-spacing: 0.03em; }
.tax-st { background: rgba(232,161,58,0.15); color: #c47f14; }
.tax-lt { background: rgba(97,161,231,0.16); color: #2f6fbf; }
.tax-text { font-size: var(--fs-13); color: var(--text-secondary); line-height: 1.5; }
.tax-note { font-size: var(--fs-12); color: var(--text-brand); background: var(--bg-light-grey); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); line-height: 1.5; }
.tax-disclaimer { font-size: var(--fs-11); color: var(--text-tertiary); margin-top: var(--sp-3); font-style: italic; }

/* YouTube research card */
.yt-thumb { position: relative; display: block; height: 150px; border-radius: var(--radius-md); overflow: hidden; background: linear-gradient(135deg, #1a1f28, #2a3340); text-decoration: none; margin-bottom: var(--sp-4); }
.yt-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(255,0,0,0.92); display: flex; align-items: center; justify-content: center; transition: transform var(--transition-fast), background var(--transition-fast); }
.yt-thumb:hover .yt-play { transform: translate(-50%, -50%) scale(1.08); background: #ff0000; }
.yt-play svg { width: 26px; height: 26px; color: #fff; margin-left: 2px; }
.yt-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--sp-4); background: linear-gradient(transparent, rgba(0,0,0,0.65)); display: flex; flex-direction: column; gap: 2px; }
.yt-title { color: #fff; font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.yt-sub { color: rgba(255,255,255,0.75); font-size: var(--fs-12); }
.yt-links { display: flex; flex-direction: column; gap: var(--sp-2); }
.yt-links a { font-size: var(--fs-13); color: var(--text-brand); text-decoration: none; font-weight: var(--fw-medium); }
.yt-links a:hover { color: var(--color-up); }

/* FAQ accordion */
.faq-list { display: flex; flex-direction: column; }
.faq-item { border-bottom: 1px solid var(--border-light, #eceef1); }
.faq-item:last-child { border-bottom: none; }
.faq-q { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) 0; background: none; border: none; cursor: pointer; text-align: left; font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--text-brand); }
.faq-chev { width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0; transition: transform var(--transition-fast); }
.faq-item.open .faq-chev { transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height var(--transition-base); }
.faq-item.open .faq-a { max-height: 320px; }
.faq-a p { font-size: var(--fs-13); color: var(--text-secondary); line-height: 1.6; padding: 0 0 var(--sp-5); margin: 0; }

@media (max-width: 768px) {
  .health-layout { grid-template-columns: 1fr; justify-items: center; }
  .health-checks { grid-template-columns: 1fr; width: 100%; }
  .keymetric-grid { grid-template-columns: repeat(2, 1fr); }
  .keymetric.km-wide { grid-column: span 2; }
  .sector-row { grid-template-columns: 100px 1fr 44px; }
}

/* ── NAV chart: benchmark toggle + legend ── */
.nav-card-header { flex-wrap: wrap; gap: var(--sp-3); }
.nav-head-controls { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.bench-toggle {
  display: inline-flex; align-items: center;
  padding: 5px var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: var(--fs-12); font-weight: var(--fw-semibold);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition-fast);
}
.bench-toggle:hover { border-color: var(--text-brand); color: var(--text-brand); }
.bench-toggle.active { background: var(--bg-dark); border-color: var(--bg-dark); color: var(--text-white); }
.nav-bench-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-3) 0 0;
  font-size: var(--fs-12); color: var(--text-secondary);
}
.nav-bench-legend .nbl-item { display: inline-flex; align-items: center; gap: 6px; }
.nav-bench-legend .nbl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.nav-bench-legend b { font-weight: var(--fw-bold); }
.nav-bench-legend .nbl-verdict { font-weight: var(--fw-bold); font-size: var(--fs-12); }

@media (max-width: 600px) {
  .nav-head-controls { width: 100%; justify-content: space-between; }
  .bench-toggle { order: 2; }
}
