:root {
  --accent-from: #8a5bff;
  --accent-to:   #4ad6ff;
  --positive:    #7affaa;
  --negative:    #ffb84a;

  --bg-0: #04030e;
  --bg-1: #0b0720;
  --bg-card: rgba(255, 255, 255, 0.02);
  --border:  rgba(255, 255, 255, 0.05);
  --text-primary:   #e9e4ff;
  --text-secondary: #a79dc9;
  --text-muted:     #6e6792;
}

:root[data-theme="light"] {
  --bg-0: #fbfaff;
  --bg-1: #ffffff;
  --bg-card: rgba(10, 7, 24, 0.03);
  --border: rgba(10, 7, 24, 0.08);
  --text-primary:   #0b0720;
  --text-secondary: #4b446b;
  --text-muted:     #8a84a8;
  /* Semantics designed for legibility on white. */
  --positive: #16803c;
  --negative: #b45309;
}

[data-theme="light"] .pg-bignum {
  /* Dark-mode gradient ends in pale green which vanishes on white. */
  background: linear-gradient(90deg, var(--text-primary), #5b34d6 60%, var(--positive));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
[data-theme="light"] .m-add   { color: #1d6fb0; border-color: rgba(29,111,176,.25); background: rgba(29,111,176,.10); }
[data-theme="light"] .m-close { color: #b3267a; border-color: rgba(179,38,122,.25); background: rgba(179,38,122,.10); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(60% 80% at 0% 0%, rgba(138,91,255,.18), transparent 60%),
    radial-gradient(50% 70% at 100% 0%, rgba(74,214,255,.12), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 60%);
  color: var(--text-primary);
  font-family: ui-sans-serif, -apple-system, "Inter", system-ui, sans-serif;
  line-height: 1.5;
}

.container { max-width: 1100px; margin: 0 auto; padding: 22px 22px 60px; container-type: inline-size; }

/* ----- Header ----- */
.pg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 8px; }
.pg-brand  { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.pg-header-right { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-secondary); }
.pg-chip   { font-size: 9px; padding: 4px 9px; border-radius: 999px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; border: 1px solid; }
.pg-chip--ok     { background: rgba(122,255,170,.12); color: var(--positive); border-color: rgba(122,255,170,.22); }
.pg-chip--warn   { background: rgba(255,184,74,.12); color: var(--negative); border-color: rgba(255,184,74,.22); }
.pg-chip--muted  { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }
.pg-toggle { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); display: grid; place-items: center; cursor: pointer; font-size: 13px; color: var(--text-primary); }

/* ----- Hero ----- */
.pg-hero { margin-bottom: 32px; }
.pg-hero-top { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.pg-eyebrow { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; }
.pg-bignum {
  font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1;
  background: linear-gradient(90deg, var(--text-primary), #b9a5ff 60%, var(--positive));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pg-bignum-sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.pg-delta { color: var(--positive); font-weight: 600; }
.pg-ranges { display: flex; gap: 4px; background: var(--bg-card); padding: 4px; border-radius: 10px; border: 1px solid var(--border); align-self: flex-start; }
.pg-range  { font-size: 10px; padding: 6px 10px; border-radius: 7px; color: var(--text-secondary); cursor: pointer; background: transparent; border: 0; font-family: inherit; }
.pg-range.is-active { background: linear-gradient(135deg, rgba(138,91,255,.35), rgba(74,214,255,.25)); color: #fff; }

.pg-chart { width: 100%; height: 200px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; position: relative; }
.pg-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 11px; color: var(--text-secondary); flex-wrap: wrap; }
.pg-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.pg-chart-tip { position: absolute; pointer-events: none; display: none; transform: translate(-50%, calc(-100% - 10px)); background: rgba(11, 7, 32, 0.92); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 11px; line-height: 1.5; color: var(--text-primary); white-space: nowrap; z-index: 5; backdrop-filter: blur(6px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
[data-theme="light"] .pg-chart-tip { background: rgba(255, 255, 255, 0.96); }
.pg-chart-tip-date { color: var(--text-secondary); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 4px; }
.pg-chart-tip-row  { display: flex; align-items: center; gap: 8px; }
.pg-chart-tip-row .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.pg-chart-tip-row strong { margin-left: auto; padding-left: 16px; font-weight: 600; color: var(--text-primary); }

/* ----- Section heads ----- */
.pg-section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 28px 0 10px; gap: 10px; flex-wrap: wrap; }
.pg-section-title h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pg-section-title .hint { font-size: 10px; color: var(--text-muted); }

/* ----- Holdings ----- */
.pg-holdings { display: grid; grid-template-columns: 1fr; gap: 16px; }
.pg-donut-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; align-items: center; }
.pg-donut { width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center; position: relative; box-shadow: 0 0 50px rgba(138,91,255,.35); }
.pg-donut::after { content: ""; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, var(--bg-0) 60%, var(--bg-1) 100%); position: absolute; }
.pg-donut-center { position: relative; z-index: 1; text-align: center; }
.pg-donut-count  { font-size: 24px; font-weight: 700; }
.pg-donut-label  { font-size: 9px; letter-spacing: .22em; color: var(--text-secondary); text-transform: uppercase; }
.pg-rows { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 0; }
.pg-row  { display: grid; grid-template-columns: 10px 54px 1fr 54px; align-items: center; gap: 10px; padding: 11px 16px; font-size: 12px; border-bottom: 1px solid var(--border); }
.pg-row:last-child { border-bottom: none; }
.pg-row .sym { font-weight: 600; }
.pg-row .bar { height: 5px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; position: relative; }
.pg-row .bar > span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent-from), var(--accent-to)); border-radius: 999px; }
.pg-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-primary); }
.pg-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ----- Recent Activity ----- */
.pg-moves { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 0; }
.pg-move  { display: grid; grid-template-columns: 30px 1fr; align-items: start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pg-move:last-child { border-bottom: none; }
.pg-move-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.pg-move-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pg-move-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.pg-move-action { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }
.pg-move-time   { font-size: 10px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.pg-move-text   { font-size: 12px; color: var(--text-primary); line-height: 1.45; }
.pg-move-text .sym { font-weight: 600; }
.m-open  { background: rgba(122,255,170,.12); color: var(--positive); border: 1px solid rgba(122,255,170,.22); }
.m-add   { background: rgba(74,214,255,.12); color: #4ad6ff; border: 1px solid rgba(74,214,255,.22); }
.m-trim  { background: rgba(255,184,74,.12); color: var(--negative); border: 1px solid rgba(255,184,74,.22); }
.m-close { background: rgba(255,107,214,.12); color: #ff6bd6; border: 1px solid rgba(255,107,214,.22); }
.chg-pos { color: var(--positive); }
.chg-neg { color: var(--negative); }

.pg-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 12px; }

.pg-footer { margin-top: 28px; font-size: 10px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }

/* ----- Narrow viewport: header chips wrap to a second row ----- */
@media (max-width: 600px) {
  .pg-header        { flex-wrap: wrap; row-gap: 10px; }
  .pg-header-right  { flex-wrap: wrap; row-gap: 6px; }
}

/* ----- Responsive (≥720px) ----- */
@container (min-width: 720px) {
  .container   { padding: 28px 36px 80px; }
  .pg-header   { margin-bottom: 32px; }
  .pg-header-right { font-size: 12px; }
  .pg-chip     { font-size: 10px; }
  .pg-hero-top { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .pg-ranges   { align-self: auto; }
  .pg-bignum   { font-size: 44px; }
  .pg-bignum-sub { font-size: 13px; }
  .pg-chart    { height: 260px; padding: 18px; }
  .pg-holdings { grid-template-columns: 280px 1fr; gap: 24px; }
  .pg-donut    { width: 210px; height: 210px; }
  .pg-donut::after { width: 140px; height: 140px; }
  .pg-donut-count  { font-size: 28px; }
  .pg-row      { grid-template-columns: 14px 70px 1fr 60px; padding: 12px 22px; font-size: 13px; }
  .pg-move     { grid-template-columns: 32px 1fr; padding: 14px 22px; }
  .pg-move-icon { width: 30px; height: 30px; }
  .pg-move-text { font-size: 13px; }
  .pg-footer   { flex-direction: row; justify-content: space-between; font-size: 11px; }
}
