/* Dark theme matching the Streamlit dashboard (#0E1117 / #262730 / #00CED1) */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0E1117;
  --card: #1A1D26;
  --card-border: #262730;
  --text: #FAFAFA;
  --muted: #9AA0AC;
  --accent: #00CED1;
  --green: #26A69A;
  --red: #EF5350;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }

/* --- Hero --- */
.hero { position: relative; text-align: center; padding: 60px 8px 38px; overflow: hidden; }

.hero-glow {
  position: absolute;
  inset: 0; pointer-events: none;
  /* Centred inside the hero and fully transparent at every edge, so the
     glow never gets clipped into a hard line by overflow:hidden. */
  background: radial-gradient(ellipse 75% 62% at 50% 42%, rgba(0, 206, 209, .17), transparent 62%);
}

.tags {
  position: relative;
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 20px;
}

.tag, .live-badge {
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 1.5px;
  padding: 6px 11px;
  border-radius: 999px;
}

.tag {
  color: var(--muted);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, .02);
}

.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  color: #1ce27b; font-weight: 700;
  border: 1px solid rgba(28, 226, 123, .4);
  background: rgba(28, 226, 123, .08);
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #1ce27b; flex: none;
  animation: pulse 1.7s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(28, 226, 123, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(28, 226, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(28, 226, 123, 0); }
}

.hero h1 {
  position: relative;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.05;
  letter-spacing: -1.2px;
  margin: 8px 0 16px;
  background: linear-gradient(180deg, #ffffff 35%, #93dfe0);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}

.hero h1 .x { -webkit-text-fill-color: var(--accent); color: var(--accent); }

.tagline {
  position: relative;
  color: var(--muted);
  font-size: 16.5px;
  max-width: 640px;
  margin: 0 auto 28px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 22px;
  min-width: 150px;
}

.stat .value { font-size: 26px; font-weight: 700; }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }
.stat .value.accent { color: var(--accent); }
.stat .label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.updated-hero {
  position: relative;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .2px;
  margin-bottom: 12px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #13c636;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 3px 14px rgba(19, 198, 54, .2);
}

.cta:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(19, 198, 54, .35); }

/* --- Cards --- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  margin-bottom: 22px;
}

.card h2 { font-size: 20px; margin-bottom: 12px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card ul { padding-left: 22px; margin: 10px 0; }
.card li { margin-bottom: 8px; }
.card p { margin-bottom: 10px; }

.chart { width: 100%; height: 360px; }
.chart.tall { height: 400px; }
.chart.dd { height: 190px; margin-top: -4px; }

.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* --- Scale toggle --- */
.toggle {
  display: inline-flex;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
}

.toggle button.active { background: var(--accent); color: #06282a; font-weight: 700; }

/* --- Chart controls --- */
.chart-controls { display: inline-flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.cmp {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
  white-space: nowrap;
}
.cmp input { accent-color: #7C9CFF; width: 15px; height: 15px; cursor: pointer; }

.period-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 6px; }
.period-bar button {
  background: transparent; color: var(--muted);
  border: 1px solid var(--card-border); border-radius: 7px;
  padding: 5px 13px; font-size: 12.5px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.period-bar button:hover { color: var(--text); border-color: #3a3e4a; }
.period-bar button.active {
  background: var(--accent); color: #06282a; font-weight: 700; border-color: var(--accent);
}

.range-inputs { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.range-inputs label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
}
.range-inputs input[type="date"] {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 6px;
  padding: 5px 9px; font-size: 12.5px; color-scheme: dark;
}

/* --- Monthly returns heatmap --- */
.heatmap-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 480px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.heatmap {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.heatmap th, .heatmap td {
  padding: 4px 7px;
  text-align: right;
  border: 1px solid #14161d;
}

.heatmap thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  color: var(--muted);
  z-index: 1;
}

.heatmap tbody th {
  position: sticky;
  left: 0;
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
}

.heatmap .total-col { font-weight: 700; border-left: 2px solid var(--card-border); }

.heatmap tr.live-row td { border-top: 1.5px solid rgba(28,226,123,.55); border-bottom: 1.5px solid rgba(28,226,123,.55); }
.heatmap tr.live-row th { color: #1ce27b; }

.live-tag {
  display: inline-flex; align-items: center; gap: 4px;
  color: #1ce27b;
  background: rgba(28, 226, 123, .12);
  border: 1px solid rgba(28, 226, 123, .4);
  font-size: 10px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: 1px;
}
.live-tag .live-dot { width: 5px; height: 5px; }

/* --- Risk gauge (strategy hero, under the stats band) --- */
.risk-gauge { max-width: 360px; margin: 22px auto 4px; text-align: left; }
.rg-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.rg-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rg-score { font-family: "Space Grotesk", "Inter", sans-serif; font-variant-numeric: tabular-nums; line-height: 1; }
.rg-score b { font-size: 22px; font-weight: 700; }
.rg-score span { color: var(--muted); font-size: 13px; margin-left: 1px; }
.rg-track { display: flex; gap: 4px; }
.rg-seg {
  flex: 1; height: 10px; border-radius: 3px;
  background: var(--spectrum, linear-gradient(100deg, #22D3EE, #6366F1, #EC4899));
  background-size: 1000% 100%;
  background-position: calc(var(--i) / 9 * 100%) 0;
  opacity: .15; transition: opacity .3s ease;
}
.rg-seg.on { opacity: 1; }
.rg-scale { display: flex; justify-content: space-between; margin-top: 7px; font-size: 11px; letter-spacing: .04em; color: var(--muted); }
.rg-note { color: var(--muted); font-size: 11.5px; margin-top: 8px; line-height: 1.45; }

/* --- Current portfolio (Quality tab) --- */
.countdown {
  color: var(--muted);
  font-size: 13.5px;
}
.countdown strong { color: var(--accent); font-size: 16px; }
.countdown .cd-date { opacity: .8; }

.holdings-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.holdings {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.holdings th, .holdings td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}
.holdings thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.holdings tbody tr:last-child td { border-bottom: none; }
.holdings tbody tr:hover td { background: rgba(255, 255, 255, .02); }

.holdings .tk { font-weight: 700; color: var(--text); }
.holdings .sec { color: var(--muted); }
.holdings .num { text-align: right; font-variant-numeric: tabular-nums; }
.holdings .num.pos { color: var(--green); font-weight: 600; }
.holdings .num.neg { color: var(--red); font-weight: 600; }

/* --- FAQ accordion (native <details>, exclusive via shared name="faq") --- */
.faq details {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .015);
}
.faq details:last-child { margin-bottom: 0; }
.faq details[open] { border-color: #3a3e4a; }

.faq summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  padding: 14px 46px 14px 16px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent); }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 20px; line-height: 1;
}
.faq details[open] summary::after { content: "\2212"; }

.faq .answer {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 14.5px;
}
.faq .answer a { color: var(--accent); text-decoration: none; }

/* --- Disclaimers / footer --- */
.disclaimer p { color: var(--muted); font-size: 14px; }
.disclaimer strong { color: var(--text); }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding-top: 10px;
}

footer a { color: var(--accent); text-decoration: none; }

/* --- Responsive --- */
@media (max-width: 760px) {
  main { padding: 16px 12px 40px; }

  .card { padding: 16px 14px 14px; border-radius: 12px; }

  .hero { padding: 44px 4px 28px; }
  .hero h1 { font-size: clamp(28px, 8vw, 44px); }
  .tagline { font-size: 15px; }

  /* Stats: tidy 2-per-row grid that fills the width */
  .stats { gap: 10px; }
  .stat { flex: 1 1 calc(50% - 10px); min-width: 0; padding: 12px 14px; }
  .stat .value { font-size: 22px; }

  /* Chart card head stacks: title on top, controls full-width below */
  .card-head { align-items: flex-start; }
  .chart-controls { width: 100%; justify-content: space-between; gap: 10px; }

  .chart { height: 300px; }
  .chart.tall { height: 320px; }
  .chart.dd { height: 150px; }

  .period-bar { gap: 5px; }
  .period-bar button { padding: 5px 10px; font-size: 12px; }
  .range-inputs { gap: 12px; }

  /* Monthly grid stays a horizontal-scroll table (sticky year + header) */
  .heatmap-wrap { max-height: 62vh; }
  .heatmap { font-size: 11px; }
  .heatmap th, .heatmap td { padding: 4px 6px; }

  .holdings { font-size: 12.5px; }
  .holdings th, .holdings td { padding: 8px 9px; }
  .holdings .sec { display: none; }
  .card-head .countdown { width: 100%; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 25px; }
  .cta { font-size: 13.5px; padding: 10px 16px; }
  .tag, .live-badge { font-size: 10px; padding: 5px 9px; }
  .stat .value { font-size: 20px; }
}
