:root {
  --ink: #1a2433;
  --muted: #5b6b7d;
  --border: #dde3ea;
  --accent: #2a6fdb;
  --green: #1a8a4a;
  --red: #c0392b;
  --bg-card: #ffffff;
  --bg-page: #eef1f5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-page);
  line-height: 1.55;
}

/* ── Sticky compact header ───────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.7rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 1.9rem;
  height: 1.9rem;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(42,111,219,0.3);
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.live-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--green);
  background: #eaf7ef;
  border: 1px solid #b6dfc5;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
}

.updated-at {
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.variant-tabs, .subtabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.variant-tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }

.variant-tabs { margin-bottom: 1.5rem; }
.subtabs { margin: 0 0 1.25rem; border-bottom-width: 1px; }

.variant-tab, .subtab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  padding: 0.6rem 1.1rem;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}

.subtab {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-bottom-width: 2px;
  margin-bottom: -1px;
}

.variant-tab.active  { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.subtab.active       { color: var(--accent); border-bottom-color: var(--accent); }
.variant-tab:hover:not(.active), .subtab:hover:not(.active) { color: var(--ink); background: rgba(0,0,0,0.03); }

/* ── Variant panel ───────────────────────────────────────────────────────── */

.variant-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}

.variant-description { color: var(--muted); margin: 0 0 1.25rem; font-size: 0.88rem; }

/* ── Metrics grid ────────────────────────────────────────────────────────── */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.side-buy  { color: var(--green); font-weight: 600; }
.side-sell { color: var(--red);   font-weight: 600; }

/* ── Benchmark compare ───────────────────────────────────────────────────── */

.benchmark-compare {
  max-width: 380px;
  margin: 0 auto 1.5rem;
  text-align: center;
}

.benchmark-compare h4 {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.benchmark-compare table { text-align: left; }

.compare-table { font-size: 0.85rem; }
.compare-table th, .compare-table td { padding: 0.35rem 0.6rem; }
.compare-table th:not(:first-child),
.compare-table td:not(:first-child) { text-align: right; }

/* ── Charts ──────────────────────────────────────────────────────────────── */

.curve-modes {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.curve-mode {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 1rem;
  transition: all 0.15s;
}

.curve-mode.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.curve-mode:hover:not(.active) { color: var(--ink); border-color: var(--accent); }

.equity-chart { max-height: 280px; margin-bottom: 1.5rem; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

h3 { font-size: 0.85rem; font-weight: 700; margin: 0 0 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table a { color: var(--accent); text-decoration: none; font-weight: 500; }
table a:hover { text-decoration: underline; }

/* Lets wide tables (holdings, trade journal) scroll horizontally on narrow
   screens instead of squeezing columns or breaking the page layout. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.wide table { min-width: 640px; }
.table-wrap.wide td { white-space: nowrap; }

th {
  text-align: left;
  padding: 0.45rem 0.7rem;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f5f8fd; }

/* Sortable column headers */
th[data-sort] {
  cursor: pointer;
  user-select: none;
}
th[data-sort]:hover { color: var(--ink); }
th.sort-active { color: var(--accent); }
.sort-rank { font-size: 0.65em; vertical-align: super; margin-left: 1px; }

.empty { color: var(--muted); font-size: 0.88rem; font-style: italic; }

/* ── Holdings toolbar (refresh button) ──────────────────────────────────── */

.holdings-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.holdings-toolbar h3 { margin: 0; }

.refresh-btn {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  padding: 0.35rem 0.85rem;
  transition: all 0.15s;
}

.refresh-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.refresh-btn:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.7; }

.refresh-status { color: var(--muted); font-size: 0.78rem; }

/* ── Insights grid ───────────────────────────────────────────────────────── */

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.75rem;
}

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.insight-wide { grid-column: 1 / -1; }

.insight-note { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.6rem; }

/* ── Contributors ────────────────────────────────────────────────────────── */

.contributors-col + .contributors-col { margin-top: 1rem; }
.contributors-col h4 { font-size: 0.8rem; margin: 0 0 0.4rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.contributor-list, .concentration-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.contributor-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.contributor-dates { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

/* ── Position concentration ──────────────────────────────────────────────── */

.concentration-list li {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3.5rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.concentration-bar {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-page);
  overflow: hidden;
}

.concentration-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  opacity: 0.75;
}

.concentration-pct { text-align: right; color: var(--muted); font-size: 0.8rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .header-inner { padding: 0.6rem 1.25rem; }
  .updated-at { display: none; }
  main { padding: 1.25rem 1.25rem 2.5rem; gap: 1.1rem; }
  .variant-panel { padding: 1.1rem 1.1rem; }
  .insights-grid { grid-template-columns: minmax(0, 1fr); }
  footer { padding: 0 1.25rem 2.5rem; }

  table { font-size: 0.8rem; }
  th, td { padding: 0.4rem 0.5rem; }

  .concentration-list li { grid-template-columns: 4.5rem 1fr 3rem; gap: 0.4rem; }

  .variant-tab { padding: 0.55rem 0.85rem; }
  .subtab { padding: 0.4rem 0.65rem; }
}

@media (max-width: 420px) {
  .brand-name { font-size: 0.95rem; }
  .live-badge { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .contributor-list li { flex-wrap: wrap; }
  .contributor-dates { flex-basis: 100%; text-align: right; }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

.footer-contact {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
}

.footer-contact a { color: var(--accent); }
.footer-contact a:hover { text-decoration: underline; }

.footer-disclaimer {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
  margin: 0;
}
