/* Portfolio Summary — AI coaching dashboard. Dark theme, global vars. */
.ps-wrap { max-width: 1600px; margin: 0 auto; padding: 28px 32px 64px; }

.ps-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.ps-greeting { margin: 0 0 3px; color: var(--text-muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.ps-title { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.5px; margin: 0; color: var(--ink); }
.ps-sub { margin: 6px 0 0; color: var(--ink-a55); font-size: 14px; }

.ps-cur-toggle { display: flex; border: 1px solid rgba(var(--wash-rgb),0.12); border-radius: 9px; overflow: hidden; }
.ps-cur-btn {
  background: none; border: 0; color: var(--ink-a60);
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.ps-cur-btn.active { background: var(--forest, #00d4aa); color: var(--on-accent); }

.ps-hero {
  margin-top: 22px; padding: 28px 30px;
  background: var(--hero-networth); border: 1px solid var(--border); border-radius: 20px;
}
.ps-hero-label { margin: 0; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sage, #7fb8a8); font-weight: 700; }
.ps-hero-value { margin: 8px 0 4px; font-size: 54px; font-weight: 600; letter-spacing: -1.5px; color: var(--ink); font-family: var(--font-display); }
html[data-theme="ivory"] .ps-hero-value { font-size: 56px; }
.ps-hero-formula { margin: 0; font-size: 12.5px; color: var(--ink-a45); }
.ps-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 20px 0 12px; background: rgba(var(--wash-rgb),0.05); }
.ps-bar span { display: block; height: 100%; }
.ps-seg-india { background: var(--forest); }
.ps-seg-us    { background: #4f9cff; }
.ps-seg-re    { background: #b97cff; } /* Real Estate     — soft violet */
.ps-seg-gold  { background: var(--warn); } /* Gold & metals   — amber */
.ps-seg-fd    { background: #6ec27a; } /* FDs & bonds     — moss */
.ps-seg-biz   { background: #d96bff; } /* Business stakes — magenta */
.ps-seg-other { background: #ffb020; } /* Other           — original yellow */
.ps-seg-liab  { background: var(--amber); }
.ps-bar-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink-a70); }
.ps-bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

.ps-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 22px; }

.ps-hero-rate { margin: 10px 0 0; font-size: 12px; color: var(--ink-a45); }
.ps-hero-fx {
  margin: 6px 0 0; font-size: 12px; color: var(--ink-a60);
  font-family: var(--mono, 'JetBrains Mono', monospace);
  /* Currency-mix one-liner wraps awkwardly on narrow viewports — letting
     the anonymous text runs flow with explicit flex-wrap keeps the segments
     readable when they spill onto two lines. */
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 2px;
  line-height: 1.45;
}
.ps-hero-fx b { color: var(--ink, #e8ecf0); font-weight: 600; }

.ps-xirr {
  margin-top: 18px; padding: 22px;
  background: var(--white, #1c2028); border: 1px solid rgba(var(--wash-rgb),0.07); border-radius: 14px;
}
.ps-xirr .ps-card-head { margin-bottom: 14px; }
.ps-xirr-group-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--sage, #7fb8a8); font-weight: 700; margin: 16px 0 8px;
}
.ps-xirr-group-label:first-child { margin-top: 0; }
.ps-xirr-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 9px 0; border-bottom: 1px solid rgba(var(--wash-rgb),0.05); font-size: 13.5px;
}
.ps-xirr-row:last-child { border-bottom: 0; }
.ps-xirr-name { color: var(--ink-a85); }
.ps-xirr-val { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.ps-xirr-val.pos { color: var(--forest); }
.ps-xirr-val.neg { color: var(--amber); }
.ps-xirr-val.muted { color: var(--ink-a45); font-weight: 500; }
.ps-xirr-cagr { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--ink-a70); }
.ps-xirr-cagr b { color: var(--ink, #e8ecf0); }
.ps-xirr-combined {
  margin-top: 16px; padding: 14px 16px; border-radius: 10px;
  background: rgba(var(--forest-rgb),0.08); border: 1px solid rgba(var(--forest-rgb),0.22);
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
}
.ps-xirr-combined .lbl { font-size: 13px; color: var(--ink-a80); }
.ps-xirr-combined .v { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 18px; }
.ps-xirr-note { margin: 10px 0 0; font-size: 11.5px; color: var(--ink-a40); }

/* Portfolio Performance — overall block + breakdown table.
   Read-only section fed from /api/xirr/results. */
.ps-xirr-overall {
  margin: 4px 0 18px; padding: 18px 20px; border-radius: 12px;
  background: rgba(var(--forest-rgb),0.06); border: 1px solid rgba(var(--forest-rgb),0.22);
}
.ps-xirr-overall-label {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-a55); font-weight: 700; margin-bottom: 6px;
}
.ps-xirr-overall-value {
  font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 30px;
  line-height: 1.1; color: var(--ink, #e8ecf0);
}
.ps-xirr-overall-value.pos { color: var(--forest); }
.ps-xirr-overall-value.neg { color: var(--amber); }
.ps-xirr-overall-value.muted { color: var(--ink-a45); }
.ps-xirr-overall-sub { margin-top: 6px; font-size: 11.5px; color: var(--ink-a55); }

.ps-xirr-table-wrap { overflow-x: auto; }
.ps-xirr-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  color: var(--ink, #e8ecf0);
}
.ps-xirr-table thead th {
  text-align: left; padding: 10px 12px; font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
  color: var(--ink-a55);
  border-bottom: 1px solid rgba(var(--forest-rgb),0.35);
}
.ps-xirr-table thead th.num { text-align: right; }
.ps-xirr-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid rgba(var(--wash-rgb),0.05);
}
.ps-xirr-table tbody tr:last-child td { border-bottom: 0; }
.ps-xirr-table tbody td.num {
  text-align: right; font-family: 'JetBrains Mono', monospace; font-weight: 600;
}
.ps-xirr-table .pos { color: var(--forest); }
.ps-xirr-table .neg { color: var(--amber); }
.ps-xirr-table .muted { color: var(--ink-a45); }
.ps-card {
  background: var(--white, #1c2028); border: 1px solid rgba(var(--wash-rgb),0.07);
  border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 12px;
}
.ps-card-head { display: flex; align-items: center; gap: 10px; }
.ps-card-icon { font-size: 20px; }
.ps-card-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink, #e8ecf0); }
.ps-card-body { flex: 1; font-size: 13.5px; color: var(--ink-a80); }
.ps-card-body[data-state="loading"] { color: var(--ink-a40); }
.ps-metric { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(var(--wash-rgb),0.05); }
.ps-metric:last-child { border-bottom: 0; }
.ps-metric b { color: var(--ink, #e8ecf0); font-weight: 700; }
.ps-metric .pos { color: var(--forest); }
.ps-metric .neg { color: var(--amber); }
.ps-notconnected { color: var(--ink-a50); font-size: 13px; }
.ps-card-link { color: var(--forest, #00d4aa); font-weight: 600; font-size: 13px; text-decoration: none; }
.ps-card-link:hover { text-decoration: underline; }

.ps-coach { margin-top: 30px; }
.ps-coach-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.ps-coach-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ps-coach-head h2 { margin: 0; font-size: 19px; font-weight: 800; color: var(--ink, #e8ecf0); }
.ps-ai-badge {
  font-size: 10px; letter-spacing: 0.1em; background: rgba(var(--forest-rgb),0.15);
  color: var(--forest, #00d4aa); padding: 3px 8px; border-radius: 20px; font-weight: 700; vertical-align: middle;
}
.ps-refresh {
  background: rgba(var(--wash-rgb),0.05); color: var(--ink-a80);
  border: 1px solid rgba(var(--wash-rgb),0.12); border-radius: 9px;
  padding: 9px 15px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.ps-refresh:hover { background: rgba(var(--wash-rgb),0.09); }
.ps-refresh:disabled { opacity: 0.55; cursor: default; }

.ps-insights { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.ps-insights-loading, .ps-insights-error { grid-column: 1 / -1; color: var(--ink-a50); font-size: 14px; padding: 18px 0; }
.ps-insight {
  background: var(--white, #1c2028); border: 1px solid rgba(var(--wash-rgb),0.07);
  border-left-width: 4px; border-radius: 12px; padding: 18px 20px;
}
.ps-insight.positive { border-left-color: var(--forest); }
.ps-insight.tip { border-left-color: #ffb020; }
.ps-insight.milestone { border-left-color: #4f9cff; }
.ps-insight-title { margin: 0 0 6px; font-size: 14.5px; font-weight: 700; color: var(--ink, #e8ecf0); }
.ps-insight-title .ps-i-emoji { margin-right: 7px; }
.ps-insight-body { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-a78); }

.ps-disclaimer {
  margin-top: 28px; padding: 14px 18px; font-size: 12px; line-height: 1.6;
  color: var(--ink-a50);
  background: rgba(var(--amber-rgb),0.05); border: 1px solid rgba(var(--amber-rgb),0.3); border-radius: 10px;
}

@media (max-width: 920px) {
  .ps-cards, .ps-insights { grid-template-columns: 1fr; }
  .ps-wrap { padding: 22px 18px 48px; }
}

/* ═══════════ Detailed AI Analysis (per-market, below the coach) ═══════════ */
.ps-deep { margin-top: 34px; }
.ps-deep-lede {
  margin: 8px 0 18px; max-width: 70ch;
  font-size: 14px; line-height: 1.6; color: var(--text-muted);
}
.ps-deep-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
.ps-deep-card {
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.ps-deep-title {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--parchment);
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--sage-pale);
}
.ps-deep-body { font-size: 13.5px; line-height: 1.65; color: var(--text-body); }
/* The model returns "**Heading:**" lines and "- bullet" lists; mdToHtml maps
   those onto these three classes. */
.ps-deep-h {
  margin: 14px 0 5px; font-size: 11px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--forest);
}
.ps-deep-h:first-child { margin-top: 0; }
.ps-deep-p { margin: 0 0 8px; }
.ps-deep-list { margin: 0 0 10px; padding-left: 18px; }
.ps-deep-list li { margin-bottom: 5px; }
.ps-deep-body strong { color: var(--sage-pale); font-weight: 600; }

@media (max-width: 900px) {
  .ps-deep-grid { grid-template-columns: 1fr; }
}
