:root {
  --bg: #0a0a0a;
  --surface: #161618;
  --surface-2: #1f1f22;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text: #f5f5f4;
  --text-2: #a8a29e;
  --text-3: #57534e;
  --text-4: #44403c;

  --accent: #facc15;
  --accent-soft: rgba(250, 204, 21, 0.1);
  --accent-dim: #f59e0b;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.1);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.15);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.15);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.15);

  /* Heatmap ramp: cool (low concentration) → hot (high concentration) */
  --hm-0: #1a1a1a;        /* not held */
  --hm-1: #1e3a8a;        /* <2%   */
  --hm-2: #0e7490;        /* 2–5%  */
  --hm-3: #16a34a;        /* 5–10% */
  --hm-4: #ca8a04;        /* 10–15% */
  --hm-5: #ea580c;        /* 15–25% */
  --hm-6: #dc2626;        /* 25%+  */

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { padding: 28px 24px 40px; max-width: 1080px; margin: 0 auto; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-serif); }
a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.07);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-mark { color: var(--accent); }
.brand-tag {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.12em;
  margin-left: 6px;
}
.nav { display: flex; gap: 2px; font-size: 12px; }
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-2);
  letter-spacing: 0.02em;
  transition: color 120ms ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Guru tabs ---------- */
.guru-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 2px;
}
.guru-tab {
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 6px;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 120ms ease;
}
.guru-tab:hover { border-color: var(--border-strong); color: var(--text); }
.guru-tab.active {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 500;
}
.guru-tab-all {
  background: rgba(34, 211, 238, 0.08);
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.3);
}
.guru-tab-all:hover { color: var(--cyan); border-color: var(--cyan); }
.guru-tab-all.active {
  background: var(--cyan);
  color: #0a0a0a;
  border-color: var(--cyan);
}

/* ---------- Overview grid ---------- */
.guru-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.guru-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 0.5px solid var(--border);
  color: inherit;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, transform 120ms;
}
.guru-card:hover {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.05);
  transform: translateY(-1px);
}
.guru-card-photo {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guru-card-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.guru-card-photo .guru-photo-initials {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  color: #0a0a0a;
}
.guru-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.guru-card-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  margin: 0;
  line-height: 1.1;
}
.guru-card-fund {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  margin: 4px 0 6px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guru-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.guru-card-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 16px;
  color: var(--accent);
}
.guru-card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin: 6px 0 0;
  letter-spacing: 0.04em;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: 12px;
  border: 0.5px solid var(--border);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 12px;
  margin: 0 0 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.section-label::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

/* ---------- Guru info card ---------- */
.guru-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.guru-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guru-photo-initials {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 22px;
  color: #0a0a0a;
  letter-spacing: 0.02em;
}
.guru-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Legacy avatar (still used elsewhere if needed) */
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: #0a0a0a;
  flex-shrink: 0;
}
.guru-title { flex: 1; min-width: 0; }
.guru-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 26px;
  margin: 0;
  line-height: 1.05;
}
.guru-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  margin: 6px 0 0;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guru-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  border: 0.5px solid var(--border-strong);
  color: var(--text-2);
  text-transform: uppercase;
}
.tag-style { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag-year  { color: var(--text-3); }
.tag-quarter { color: var(--cyan); border-color: transparent; background: var(--cyan-soft); }
.guru-bio {
  font-size: 14px;
  line-height: 1.55;
  color: #d6d3d1;
  margin: 0 0 12px;
  max-width: 68ch;
}
.guru-notable {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  margin: 0 0 18px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
}
.guru-notable-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}
.photo-credit {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-4);
  letter-spacing: 0.04em;
  text-align: right;
}
.live-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--cyan-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.metric {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px 14px;
}
.metric.accent { border-left: 2px solid var(--accent); }
.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  margin: 0;
  letter-spacing: 0.1em;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  margin: 6px 0 0;
}
.metric-value .unit { color: var(--text-2); font-size: 14px; margin-left: 1px; }
.metric-value.cyan { color: var(--cyan); }

/* ---------- Performance chart ---------- */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}
.legend-key {
  display: inline-block;
  width: 12px;
  height: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Holdings donut + legend ---------- */
.holdings-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}
.donut-box {
  flex: 0 0 220px;
  display: flex;
  justify-content: center;
}
.donut {
  width: 220px;
  height: 220px;
  display: block;
}
.donut-center-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  fill: var(--text-3);
}
.donut-center-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  fill: var(--text);
}
.holdings-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 0;
}
.hold-row {
  display: grid;
  grid-template-columns: 14px 56px 1fr auto auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 13px;
}
.hold-row:last-child { border-bottom: none; }
.hold-row.other { color: var(--text-3); }
.hold-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  align-self: center;
}
.hold-ticker {
  color: var(--accent);
  font-weight: 500;
}
.hold-row.other .hold-ticker { color: var(--text-3); }
.hold-issuer {
  font-family: var(--font-sans);
  color: #d6d3d1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.hold-row.other .hold-issuer { color: var(--text-3); }
.hold-val {
  text-align: right;
  color: var(--text-2);
  min-width: 60px;
}
.hold-pct {
  text-align: right;
  color: var(--text);
  font-weight: 500;
  min-width: 56px;
}
.hold-pct .unit { color: var(--text-3); font-size: 11px; margin-left: 1px; }

/* ---------- Heatmap ---------- */
.heatmap-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -4px;
  padding: 0 4px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--surface-2);
  /* Right-edge fade hints that more content scrolls off-screen.
     `local` scroll attachment makes it disappear once user scrolls fully right. */
  background:
    linear-gradient(to right, var(--surface) 0%, transparent 12px) 0 0 / 100% 100% no-repeat local,
    linear-gradient(to left,  var(--surface) 0%, transparent 24px) 100% 0 / 100% 100% no-repeat local;
}
.heatmap-scroll::-webkit-scrollbar { height: 10px; }
.heatmap-scroll::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 5px;
}
.heatmap-scroll::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 5px;
}
.heatmap-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.heatmap-grid {
  display: grid;
  /* width:max-content keeps columns from being squeezed when card is narrower
     than the natural grid width — together with overflow-x on the parent it
     guarantees a working horizontal scroll. */
  width: max-content;
  font-family: var(--font-mono);
  font-size: 10px;
  gap: 2px;
}
.heatmap-grid .col-label,
.heatmap-grid .row-label {
  text-align: center;
  padding: 5px 0;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}
.heatmap-grid .row-label {
  text-align: left;
  padding: 8px 4px 8px 0;
  color: var(--accent);
  font-weight: 500;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}
.heatmap-cell {
  text-align: center;
  padding: 8px 0;
  border-radius: 3px;
  color: #fff;
  font-size: 10px;
}
.heatmap-cell.empty { background: var(--hm-0); color: var(--text-4); }
.heatmap-cell.h1 { background: var(--hm-1); color: #93c5fd; }
.heatmap-cell.h2 { background: var(--hm-2); }
.heatmap-cell.h3 { background: var(--hm-3); }
.heatmap-cell.h4 { background: var(--hm-4); font-weight: 500; }
.heatmap-cell.h5 { background: var(--hm-5); font-weight: 500; }
.heatmap-cell.h6 { background: var(--hm-6); font-weight: 500; }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.06em;
}
.heatmap-scale {
  display: flex;
  gap: 2px;
  flex: 1;
  max-width: 300px;
}
.heatmap-scale > div { flex: 1; height: 8px; border-radius: 2px; }

/* ---------- Trades ---------- */
.trade {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 6px;
  border-left: 2px solid var(--border-strong);
}
.trade:last-child { margin-bottom: 0; }
.trade.NEW    { border-left-color: var(--green); }
.trade.ADD    { border-left-color: var(--orange); }
.trade.REDUCE { border-left-color: var(--red); }
.trade.EXIT   { border-left-color: var(--hm-6); }

.trade-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.trade-badge.NEW    { background: var(--green-soft);  color: var(--green);  }
.trade-badge.ADD    { background: var(--orange-soft); color: var(--orange); }
.trade-badge.REDUCE { background: var(--red-soft);    color: var(--red);    }
.trade-badge.EXIT   { background: rgba(220,38,38,0.2); color: #fca5a5;       }

.trade-ticker {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  min-width: 56px;
  color: var(--accent);
}
.trade-meta {
  font-size: 13px;
  color: var(--text-2);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trade-extra { color: var(--text-3); font-family: var(--font-mono); }
.trade-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.trade-value.pos { color: var(--green); }
.trade-value.neg { color: var(--red); }

/* ---------- Footer ---------- */
.footer {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.06em;
}

/* ---------- States ---------- */
.loading, .error {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 14px 4px;
}
.loading { color: var(--text-3); }
.error { color: var(--red); }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { padding: 18px 14px 28px; }
  .brand { font-size: 20px; }
  .brand-tag { display: none; }
  .nav { font-size: 11px; }
  .nav-link { padding: 4px 8px; }
  .card { padding: 14px 14px; margin-bottom: 10px; }

  /* Tabs — tighter spacing so 22 chips don't blow up to 5+ rows */
  .guru-tab { padding: 5px 10px; font-size: 11px; }
  .guru-tab-all { padding: 5px 12px; }

  /* Overview grid — 1 wide card per row on phones */
  .guru-grid { grid-template-columns: 1fr; gap: 8px; }
  .guru-card { padding: 10px; gap: 10px; }
  .guru-card-photo { width: 48px; height: 48px; }
  .guru-card-photo .guru-photo-initials { font-size: 15px; }
  .guru-card-name { font-size: 16px; }
  .guru-card-value { font-size: 15px; }

  /* Detail vizitka */
  .guru-name { font-size: 21px; }
  .guru-photo { width: 60px; height: 60px; }
  .guru-photo-initials { font-size: 18px; }
  .guru-bio { font-size: 13px; }
  .guru-notable { font-size: 11px; padding: 8px 10px; }
  .live-badge { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric-value { font-size: 16px; }
  .photo-credit { text-align: left; }

  /* Holdings donut */
  .holdings-wrap { flex-direction: column; gap: 14px; }
  .donut-box { flex: 0 0 auto; }
  .donut { width: 180px; height: 180px; }
  .hold-row { grid-template-columns: 12px 46px 1fr auto auto; gap: 8px; font-size: 12px; }
  .hold-issuer { font-size: 11px; }

  /* Heatmap labels smaller so a few more cols fit before scroll kicks in */
  .heatmap-grid .col-label { font-size: 8px; }
  .heatmap-grid .row-label { font-size: 10px; padding: 6px 4px 6px 0; }
  .heatmap-cell { padding: 6px 0; font-size: 9px; }

  /* Trades + footer */
  .trade { padding: 8px 10px; gap: 8px; }
  .footer { flex-direction: column; gap: 4px; align-items: flex-start; }
}

@media (max-width: 480px) {
  body { padding: 14px 10px 24px; }
  .header { margin-bottom: 14px; padding-bottom: 10px; }
  .card { padding: 12px 12px; border-radius: 10px; }

  /* Detail vizitka tightens further */
  .guru-header { gap: 12px; }
  .guru-photo { width: 52px; height: 52px; }
  .guru-name { font-size: 18px; }
  .guru-meta { font-size: 9px; }
  .guru-tags { gap: 4px; margin-top: 6px; }
  .tag { font-size: 9px; padding: 2px 6px; }

  /* Overview card — even tighter */
  .guru-card-fund { font-size: 9px; }
  .guru-card-meta { font-size: 9px; }

  /* Hide issuer column in holdings legend to keep $ + % visible on tiny screens */
  .hold-issuer { display: none; }
  .hold-row { grid-template-columns: 12px 1fr auto auto; }

  .donut { width: 150px; height: 150px; }

  .trade-ticker { min-width: 44px; font-size: 12px; }
  .trade-meta { font-size: 12px; }
  .trade-value { font-size: 12px; }
}
