/* ─── Base ──────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }

/* ─── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #161b22; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }

/* ─── Top Nav ───────────────────────────────── */
.top-nav {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 20px;
  font-weight: 900;
  color: #c9a84c;
  letter-spacing: 1.5px;
}
.nav-brand span {
  font-size: 11px;
  color: #4b5563;
  letter-spacing: 3px;
  text-transform: uppercase;
  display: block;
  margin-top: -2px;
}
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a {
  color: #8b949e;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: #21262d; color: #e6edf3; }
.nav-links a.active { background: #21262d; color: #c9a84c; }
.nav-logout {
  color: #4b5563 !important;
  font-size: 12px !important;
}

/* ─── Panel ─────────────────────────────────── */
.panel {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
}

/* ─── Stat Cards ─────────────────────────────── */
.stat-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 20px 22px;
}
.stat-label {
  font-size: 10px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: #e6edf3;
  line-height: 1;
}
.stat-value.gold { color: #c9a84c; }
.stat-sub {
  font-size: 12px;
  color: #4b5563;
  margin-top: 4px;
}

/* ─── Colour utilities ──────────────────────── */
.pos  { color: #10b981; }
.neg  { color: #ef4444; }
.neu  { color: #8b949e; }
.gold { color: #c9a84c; }

/* ─── Tables (dark — dashboard) ─────────────── */
.tbl-dark { width: 100%; border-collapse: collapse; }
.tbl-dark thead tr { background: #1c2128; }
.tbl-dark th {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: right;
  border-bottom: 1px solid #30363d;
  white-space: nowrap;
}
.tbl-dark th.left, .tbl-dark td.left { text-align: left; }
.tbl-dark td {
  padding: 11px 14px;
  font-size: 12px;
  color: #c9d1d9;
  border-bottom: 1px solid #21262d;
  text-align: right;
  vertical-align: middle;
}
.tbl-dark tr:last-child td { border-bottom: none; }
.tbl-dark tbody tr:hover td { background: #1c2128; cursor: pointer; }
.tbl-dark .fund-name { font-weight: 700; color: #e6edf3; font-size: 13px; }
.tbl-dark tr.subtotal td {
  background: #1c2128; font-weight: 700; font-size: 12px;
  border-top: 2px solid #30363d; color: #8b949e;
}

/* ─── Category pills ─────────────────────────── */
.cat-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.cat-hf  { background: #1d2d50; color: #60a5fa; border-left: 3px solid #3b82f6; }
.cat-pe  { background: #2d1d4d; color: #a78bfa; border-left: 3px solid #7c3aed; }
.cat-pc  { background: #3d1d35; color: #f472b6; border-left: 3px solid #be185d; }
.cat-re  { background: #1d3d2d; color: #34d399; border-left: 3px solid #059669; }
.cat-vc  { background: #3d2d1d; color: #fb923c; border-left: 3px solid #ea580c; }

/* ─── Account tags ───────────────────────────── */
.acct-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.acct-private { background: rgba(22,101,52,0.3); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.acct-ira     { background: rgba(30,58,138,0.3); color: #60a5fa; border: 1px solid rgba(96,165,250,0.3); }
.acct-company { background: rgba(131,24,67,0.3); color: #f472b6; border: 1px solid rgba(244,114,182,0.3); }
.acct-trust   { background: rgba(154,52,18,0.3); color: #fb923c; border: 1px solid rgba(251,146,60,0.3); }

/* ─── Return cells ───────────────────────────── */
.ret-pos { color: #10b981; font-weight: 700; }
.ret-neg { color: #ef4444; font-weight: 700; }
.ret-na  { color: #4b5563; font-size: 11px; }
.alpha-pos { color: #10b981; font-size: 10px; font-weight: 700; }
.alpha-neg { color: #ef4444; font-size: 10px; font-weight: 700; }

/* ─── Progress bars ──────────────────────────── */
.bar-bg { background: #21262d; border-radius: 3px; height: 7px; flex: 1; }
.bar-fill { height: 7px; border-radius: 3px; }
.bar-call { background: #3b82f6; }
.bar-dist { background: #10b981; }

/* ─── Horizontal alloc bars ──────────────────── */
.alloc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.alloc-label { font-size: 12px; color: #8b949e; width: 80px; flex-shrink: 0; }
.alloc-bar-bg { flex: 1; background: #21262d; border-radius: 3px; height: 10px; }
.alloc-bar-fill { height: 10px; border-radius: 3px; transition: width 0.5s; }
.alloc-pct { font-size: 12px; font-weight: 700; color: #e6edf3; width: 44px; text-align: right; }

/* ─── Loading ────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: #4b5563;
  font-size: 13px;
}
.loading-state { text-align: center; padding: 48px; color: #4b5563; font-size: 14px; }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #30363d;
  border-top-color: #c9a84c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error ──────────────────────────────────── */
.error-box {
  background: #2d1b1b;
  border: 1px solid #5c1f1f;
  color: #f87171;
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
}

/* ─── Rank badge ─────────────────────────────── */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: #21262d;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #4b5563;
  flex-shrink: 0;
}

/* ─── Search ─────────────────────────────────── */
.search-box {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #e6edf3;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box:focus { border-color: #c9a84c; }
.search-box::placeholder { color: #4b5563; }


/* ═══════════════════════════════════════════════
   DASHBOARD PAGE
   ═══════════════════════════════════════════════ */

.page-content { padding: 24px; max-width: 1600px; margin: 0 auto; }

.headline-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.mid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #4b5563;
  margin-bottom: 16px;
  padding: 16px 16px 0;
}

/* Fund drilldown modal */
.fund-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  align-items: center; justify-content: center;
}
.fund-modal-overlay.open { display: flex; }
.fund-modal {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 14px; width: 600px; max-width: 92vw;
  max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.fund-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #30363d;
}
.fund-modal-title { font-size: 15px; font-weight: 800; color: #e6edf3; }
.fund-modal-close {
  background: none; border: none; color: #8b949e;
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.fund-modal-close:hover { color: #e6edf3; }
.fund-modal-body { overflow-y: auto; padding: 16px 22px; }
.fund-modal-stats { display: flex; gap: 16px; margin-bottom: 16px; }
.fund-modal-stat { background: #0d1117; border-radius: 8px; padding: 10px 16px; flex: 1; }
.fund-modal-stat .lbl { font-size: 10px; color: #4b5563; text-transform: uppercase; letter-spacing: 1px; }
.fund-modal-stat .val { font-size: 18px; font-weight: 800; color: #c9a84c; margin-top: 2px; }

.investor-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid #21262d; cursor: pointer;
}
.investor-row:last-child { border-bottom: none; }
.investor-row:hover { opacity: 0.85; }
.investor-name { font-size: 13px; font-weight: 700; color: #e6edf3; flex: 1; }
.investor-nav { font-size: 13px; font-weight: 700; color: #c9a84c; }
.investor-pct { font-size: 11px; color: #4b5563; width: 38px; text-align: right; }

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.tbl-wrap-dark { overflow-x: auto; border-radius: 10px; }
.panel .tbl-dark { border-radius: 0; }
.panel .tbl-dark td, .panel .tbl-dark th { padding: 10px 16px; }

.client-list-wrap { overflow-y: auto; max-height: 360px; }
.search-panel-inner { padding: 16px; }

/* Sortable table headers */
.tbl-dark th.sortable { cursor: pointer; user-select: none; }
.tbl-dark th.sortable:hover { color: #c9a84c; }
.sort-arrow { font-size: 9px; opacity: 0.5; margin-left: 2px; }
.sort-arrow.active { opacity: 1; color: #c9a84c; }

/* Category filter pills */
.cat-filter-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 12px;
  cursor: pointer; transition: all 0.15s;
  border: 1px solid #30363d;
  background: #0d1117; color: #8b949e;
  user-select: none; text-transform: uppercase; letter-spacing: 0.5px;
}
.cat-filter-pill:hover { border-color: #4b5563; color: #c9d1d9; }
.cat-filter-pill.active { border-color: var(--cat-color, #c9a84c); color: var(--cat-color, #c9a84c); background: rgba(201,168,76,0.08); }

/* Benchmark toggle pills */
.bench-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 14px;
  cursor: pointer; transition: all 0.15s;
  border: 1px solid #30363d;
  background: #0d1117; color: #8b949e;
  user-select: none;
}
.bench-pill:hover { border-color: #4b5563; color: #c9d1d9; }
.bench-pill.active { border-color: var(--bench-color, #c9a84c); color: var(--bench-color, #c9a84c); background: rgba(201,168,76,0.1); }
.bench-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bench-color, #4b5563);
}


/* ═══════════════════════════════════════════════
   CLIENT PAGE
   ═══════════════════════════════════════════════ */

.page-header {
  background: linear-gradient(135deg, #0d1b2a 0%, #1b2838 100%);
  padding: 28px 40px; color: white;
  display: flex; justify-content: space-between; align-items: flex-end;
  border-bottom: 3px solid #c9a84c;
}
.client-info h1 { font-size: 26px; font-weight: 800; color: #e6edf3; }
.client-info .meta { font-size: 13px; color: #8b949e; margin-top: 5px; }
.client-info .meta span { color: #c9a84c; font-weight: 600; }
.logo-block { text-align: right; }
.logo-block .brand { font-size: 20px; font-weight: 900; color: #c9a84c; letter-spacing: 1px; }
.logo-block .sub { font-size: 11px; color: #4b5563; letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }
.logo-block .date { font-size: 12px; color: #4b5563; margin-top: 4px; }

.stats-bar {
  background: #161b22; border-bottom: 1px solid #30363d;
  display: grid; grid-template-columns: repeat(6, 1fr);
}
.stat { padding: 16px 18px; border-right: 1px solid #30363d; }
.stat:last-child { border-right: none; }

.section { margin: 20px 24px; }
.section-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.section-title {
  font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.5px; color: #e6edf3;
}
.section-badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.badge-hf  { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-pe  { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.badge-pc  { background: rgba(190,24,93,0.15);  color: #f472b6; border: 1px solid rgba(190,24,93,0.3); }
.badge-re  { background: rgba(5,150,105,0.15);  color: #34d399; border: 1px solid rgba(5,150,105,0.3); }
.badge-vc  { background: rgba(234,88,12,0.15);  color: #fb923c; border: 1px solid rgba(234,88,12,0.3); }
.section-totals { font-size: 12px; color: #4b5563; margin-left: auto; }
.section-totals strong { color: #8b949e; }

/* Client page tables (tbl-wrap) */
.tbl-wrap { background: #161b22; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,0.3); }
.tbl-wrap table { width: 100%; border-collapse: collapse; }
.tbl-wrap thead tr { background: #0d1117; }
.tbl-wrap th {
  padding: 10px 14px; font-size: 10px; font-weight: 700; color: #4b5563;
  text-transform: uppercase; letter-spacing: 0.8px; text-align: right;
  border-bottom: 2px solid #30363d; white-space: nowrap;
}
.tbl-wrap th.left, .tbl-wrap td.left { text-align: left; }
.tbl-wrap th.center { text-align: center; }
.tbl-wrap td {
  padding: 12px 14px; font-size: 12px; color: #c9d1d9;
  border-bottom: 1px solid #21262d; text-align: right; vertical-align: middle;
}
.tbl-wrap tr:last-child td { border-bottom: none; }
.tbl-wrap tr.subtotal td {
  background: #1c2128; font-weight: 700; font-size: 12px; color: #8b949e;
  border-top: 2px solid #30363d; border-bottom: 2px solid #30363d;
}
.tbl-wrap tr:not(.subtotal):hover td { background: #1c2128; }

.fund-name { font-weight: 700; color: #e6edf3; font-size: 13px; }
.fund-sub  { font-size: 11px; color: #4b5563; margin-top: 2px; }

/* Benchmark / return block cells */
.ret-block { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.ret-block .main { font-size: 13px; font-weight: 700; }
.ret-block .bench-line { font-size: 10px; color: #4b5563; }
.ret-block .alpha { font-size: 10px; font-weight: 700; }

/* Progress bar stacks */
.bar-stack { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.bar-row { display: flex; align-items: center; gap: 5px; }
.bar-lbl { font-size: 10px; color: #4b5563; width: 36px; text-align: right; flex-shrink: 0; }
.bar-pct { font-size: 10px; font-weight: 700; color: #8b949e; width: 32px; text-align: right; }

/* PE metrics */
.pe-metric { display: flex; flex-direction: column; align-items: flex-end; }
.pe-metric .tvpi { font-size: 14px; font-weight: 800; }
.pe-metric .dpi  { font-size: 10px; color: #4b5563; margin-top: 1px; }

/* IRR cell */
.irr-cell { font-size: 13px; font-weight: 700; }
.irr-na   { font-size: 11px; color: #4b5563; font-style: italic; }

/* Client bottom panels */
.mini-panel { background: #161b22; border-radius: 12px; padding: 20px; box-shadow: 0 1px 6px rgba(0,0,0,0.3); border: 1px solid #21262d; }
.mini-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #4b5563; margin-bottom: 16px; }
.liq-row    { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #21262d; gap: 10px; }
.liq-row:last-child { border-bottom: none; }
.liq-lbl    { font-size: 12px; color: #8b949e; flex-shrink: 0; }
.liq-bg     { flex: 1; background: #21262d; border-radius: 3px; height: 7px; }
.liq-fill   { height: 7px; border-radius: 3px; }
.liq-pct    { font-size: 12px; font-weight: 700; width: 38px; text-align: right; color: #e6edf3; }

/* Back nav */
.back-nav {
  background: #161b22; border-bottom: 1px solid #30363d;
  padding: 8px 24px; display: flex; align-items: center; justify-content: space-between;
}

/* Toggle button */
.btn-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: #0d1117; color: #8b949e;
  border: 1px solid #30363d; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  padding: 6px 14px; cursor: pointer;
  transition: all 0.15s; letter-spacing: 0.3px;
}
.btn-toggle:hover { border-color: #4b5563; color: #c9d1d9; }
.btn-toggle.active { border-color: #c9a84c; color: #c9a84c; background: rgba(201,168,76,0.08); }
.back-nav a {
  font-size: 12px; color: #8b949e; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.back-nav a:hover { color: #c9a84c; }

/* Footer */
.footer-note {
  background: #161b22; color: #4b5563; padding: 10px 24px;
  font-size: 11px; border-top: 1px solid #30363d;
}
.footer-note strong { color: #c9a84c; }

/* Risk metrics grid */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}
.risk-cell {
  padding: 14px 16px;
  border-right: 1px solid #21262d;
  border-bottom: 1px solid #21262d;
}
.risk-cell:nth-child(5n) { border-right: none; }
.risk-cell:nth-last-child(-n+5) { border-bottom: none; }
.risk-label {
  font-size: 10px; color: #4b5563;
  text-transform: uppercase; letter-spacing: 0.8px;
  font-weight: 600; margin-bottom: 6px;
}
.risk-value {
  font-size: 20px; font-weight: 800; color: #e6edf3;
  line-height: 1;
}
.risk-value.good { color: #10b981; }
.risk-value.warn { color: #f59e0b; }
.risk-value.bad  { color: #ef4444; }
.risk-value.neu  { color: #8b949e; }


/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE (Task 4)
   ═══════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .mid-grid { grid-template-columns: 1fr 1fr; }
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .risk-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .top-nav { padding: 0 12px; height: 48px; }
  .nav-brand { font-size: 16px; }
  .nav-brand span { font-size: 9px; letter-spacing: 2px; }
  .nav-links a { font-size: 12px; padding: 4px 10px; }

  .page-content { padding: 12px; }
  .headline-stats { grid-template-columns: 1fr; }
  .mid-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }

  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 20px; }

  /* Client page */
  .page-header { padding: 16px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .logo-block { display: none; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .risk-grid { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 12px 14px; }
  .stat .stat-value { font-size: 17px; }
  .section { margin: 12px; }

  /* Tables — horizontal scroll */
  .tbl-wrap, .tbl-wrap-dark { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap table, .tbl-dark { min-width: 600px; }

  .back-nav { padding: 8px 12px; }
  .bottom-grid { margin: 12px; }
  .mini-panel { padding: 14px; }

  /* Modals */
  .fund-modal { width: 95vw; max-height: 90vh; }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid #30363d; }
  .stat:last-child { border-bottom: none; }
  .client-info h1 { font-size: 20px; }
  .headline-stats { gap: 10px; }
  .stat-card { padding: 12px; }
}

/* Clickable client name — activity popup trigger */
#client-name {
  cursor: pointer;
  transition: color 0.15s;
}
#client-name:hover {
  color: #58a6ff;
}
