/* ============================================================
   GPT Portfolio — "warm editorial fintech"
   Mobile-first. Paper-toned light theme, emerald growth accent.
   Fonts: Fraunces (display) · Hanken Grotesk (UI) · Spline Sans Mono (figures)
   ============================================================ */

:root {
  --paper:      #F3EDE2;
  --paper-deep: #EDE4D5;
  --surface:    #FCF9F3;
  --surface-2:  #F8F2E8;
  --ink:        #211D16;
  --ink-2:      #4E4739;
  --muted:      #877D6B;
  --line:       #E7DCC9;
  --line-strong:#D9C8AC;

  --primary:      #1E6E4F;
  --primary-deep: #14503A;
  --primary-tint: rgba(30,110,79,.10);

  --sell:  #B23A24;   --sell-tint:  rgba(178,58,36,.10);
  --keep:  #A6781C;   --keep-tint:  rgba(166,120,28,.12);
  --buy:   #1E6E4F;   --buy-tint:   var(--primary-tint);
  --etf:   #2C5A83;   --etf-tint:   rgba(44,90,131,.12);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(33,29,22,.05), 0 14px 32px -18px rgba(33,29,22,.28);
  --shadow-sm: 0 1px 2px rgba(33,29,22,.06), 0 6px 16px -12px rgba(33,29,22,.22);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
}
/* atmosphere: warm glow + fine grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(120% 80% at 85% -10%, rgba(30,110,79,.13), transparent 55%),
    radial-gradient(90% 60% at -10% 110%, rgba(166,120,28,.10), transparent 50%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

a { color: var(--primary-deep); text-decoration: none; }
a:hover { color: var(--primary); }
::selection { background: var(--primary-tint); }

code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 6px; word-break: break-word;
}

/* ---------- Top bar (desktop) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: none; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: rgba(243,237,226,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand span { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -.01em; }
.logo-mark { display: block; border-radius: 8px; box-shadow: 0 4px 12px -4px rgba(30,110,79,.5); }
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav a { color: var(--ink-2); padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: .93rem; transition: background .15s, color .15s; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.active { background: var(--ink); color: var(--paper); }
.who { color: var(--muted); font-size: .82rem; margin-left: 8px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-out { border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 14px !important; color: var(--ink-2) !important; }
.chip-out:hover { background: var(--surface-2); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 880px; margin: 0 auto; padding: 22px 18px 24px; }
.container.has-tabbar { padding-bottom: 96px; }
.footer { text-align: center; color: var(--muted); font-size: .76rem; padding: 34px 8px 6px; }

/* ---------- Typography ---------- */
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.7rem, 6vw, 2.3rem); line-height: 1.08; letter-spacing: -.02em; margin: 4px 0 18px; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.28rem; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-weight: 700; font-size: .92rem; margin: 0 0 10px; letter-spacing: .01em; }
.eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--primary); margin: 0 0 6px; }
.lead { color: var(--ink-2); font-size: 1.02rem; margin: 0 0 18px; }

.page-head { margin-bottom: 18px; animation: rise .5s ease both; }
.page-head h1 { margin: 2px 0 0; }
.cache-note { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 10px 12px; margin: 4px 0 16px; }

/* ---- Wallet / allocation chart ---- */
.chart-wrap { display: flex; flex-direction: column; gap: 18px; align-items: center; margin: 6px 0 18px; }
.donut-box { position: relative; width: 220px; height: 220px; flex: none; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-total { font-family: var(--font-mono); font-weight: 600; font-size: 1.4rem; letter-spacing: -.02em; }
.donut-sub { color: var(--muted); font-size: .78rem; }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.legend li { display: flex; align-items: center; gap: 7px; font-size: .84rem; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .mono { font-weight: 600; }
.legend .leg-amt { margin-left: auto; font-family: var(--font-mono); color: var(--ink-2); font-size: .8rem; }

/* ---- Onboarding ---- */
.intro { background: linear-gradient(160deg, var(--primary-tint), var(--surface)); border-color: rgba(30,110,79,.2); }
.intro p { margin: 0; font-size: 1rem; }
.steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.step { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); animation: rise .5s ease both; }
.step.locked { opacity: .55; }
.step.active { border-color: rgba(30,110,79,.45); box-shadow: 0 0 0 3px var(--primary-tint), var(--shadow-sm); }
.step-num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-family: var(--font-mono); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.step.active .step-num { background: var(--primary); color: #F4EEE3; border-color: transparent; }
.step.done .step-num { background: var(--primary-tint); color: var(--primary-deep); border-color: transparent; }
.step-body { flex: 1; min-width: 0; }
.step-body h3 { margin: 4px 0 6px; font-size: 1.02rem; }

.budget-form { margin-top: 12px; }
.budget-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.budget-input { position: relative; flex: 1; min-width: 160px; }
.budget-input .dollar { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; font-family: var(--font-mono); }
.budget-input input { margin-top: 0; padding-left: 28px; font-family: var(--font-mono); font-size: 1.1rem; }
.budget-row .btn { flex: none; }

.news-list { margin: 8px 0 0; padding-left: 18px; }
.news-list li { margin-bottom: 8px; font-size: .88rem; color: var(--ink-2); line-height: 1.45; }

.howto { margin-top: 4px; }
.howto-list { margin: 12px 0 6px; padding-left: 20px; }
.howto-list li { margin-bottom: 8px; font-size: .9rem; color: var(--ink-2); }

.strategy { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 4px 0 16px; }
.strategy-title { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); }
.strategy .flow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.strategy .flow span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: .82rem; font-weight: 600; }
.strategy .flow i { color: var(--muted); font-style: normal; }

.run-live { text-align: center; border-color: rgba(30,110,79,.3); }
.btn-cancel { background: none; border: 1.5px solid var(--line-strong); color: var(--sell); font-family: var(--font-body); font-weight: 600; font-size: .88rem; padding: 9px 18px; border-radius: 999px; cursor: pointer; }
.btn-cancel:hover { border-color: var(--sell); background: var(--sell-tint); }
.run-live .spinner { margin: 12px auto; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin: 0 auto 10px; box-shadow: 0 0 0 0 var(--primary-tint); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30,110,79,.5); } 70% { box-shadow: 0 0 0 12px rgba(30,110,79,0); } 100% { box-shadow: 0 0 0 0 rgba(30,110,79,0); } }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--font-mono); font-weight: 500; }
.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.prewrap { white-space: pre-wrap; }
.strong { font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.card:nth-of-type(1) { animation-delay: .02s; }
.card:nth-of-type(2) { animation-delay: .08s; }
.card:nth-of-type(3) { animation-delay: .14s; }
.card:nth-of-type(4) { animation-delay: .2s; }
.card:nth-of-type(5) { animation-delay: .26s; }
.empty { text-align: center; color: var(--muted); padding: 30px 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px; box-shadow: var(--shadow-sm);
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.cards .stat:nth-child(2){animation-delay:.05s} .cards .stat:nth-child(3){animation-delay:.1s} .cards .stat:nth-child(4){animation-delay:.15s}
.stat-label { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-family: var(--font-mono); font-weight: 600; font-size: 1.5rem; letter-spacing: -.02em; margin-top: 5px; }
.stat-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.stat-link { font-size: .8rem; font-weight: 600; display: inline-block; margin-top: 4px; }
.stat.accent { background: linear-gradient(160deg, var(--primary) 0%, var(--primary-deep) 100%); border-color: transparent; color: #F4EEE3; box-shadow: 0 14px 30px -16px rgba(30,110,79,.7); }
.stat.accent .stat-label, .stat.accent .stat-sub { color: rgba(244,238,227,.82); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--primary); color: #F6F1E8; border: none; border-radius: 12px;
  padding: 15px 22px; font-family: var(--font-body); font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 10px 22px -12px rgba(30,110,79,.8); transition: transform .12s, box-shadow .18s, background .18s;
}
.btn:hover { background: var(--primary-deep); box-shadow: 0 14px 26px -12px rgba(30,110,79,.85); }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { background: var(--line-strong); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn-link { color: var(--primary-deep); font-size: .9rem; font-weight: 600; }
.btn-link:hover { color: var(--primary); }
.btn-link.danger { color: var(--sell); background: none; border: none; cursor: pointer; padding: 4px 0; font: inherit; font-weight: 600; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 15px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
input, select {
  display: block; width: 100%; margin-top: 7px; padding: 13px 14px;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); font-family: var(--font-body); font-size: 16px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-tint); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none'%3E%3Cpath d='M3 5l4 4 4-4' stroke='%23877D6B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

label.check { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 14px; color: var(--ink); font-weight: 600; }
label.check input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); flex: none; }

/* ---------- Grids ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.col.sell h3 { color: var(--sell); } .col.keep h3 { color: var(--keep); } .col.buy h3 { color: var(--buy); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; margin: 3px 4px 3px 0;
  font-size: .84rem; font-family: var(--font-mono); font-weight: 500;
}
.pill .muted { font-size: .78rem; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.holdings { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 460px; }
table.holdings th, table.holdings td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.holdings thead th { color: var(--muted); font-weight: 700; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1.5px solid var(--line-strong); }
table.holdings tbody tr { transition: background .12s; }
table.holdings tbody tr:hover { background: var(--surface-2); }
table.holdings td.num, table.holdings th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.holdings td.mono { font-family: var(--font-mono); font-weight: 600; }
td.strong { font-weight: 700; color: var(--ink); }
table.holdings tfoot td { border-top: 1.5px solid var(--line-strong); border-bottom: none; padding-top: 12px; }

.gain { color: var(--primary); }
.loss { color: var(--sell); }
.stat-value.gain, .stat-value.loss { color: inherit; }
.stat .stat-value.gain { color: var(--primary); }
.stat .stat-value.loss { color: var(--sell); }

.toggle-btn {
  font-family: var(--font-body); font-size: .8rem; font-weight: 700; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1.5px solid var(--line-strong);
  transition: background .15s, color .15s, border-color .15s;
}
.toggle-btn:hover { border-color: var(--primary); color: var(--primary-deep); }
.toggle-btn.on { background: var(--primary); color: #F4EEE3; border-color: transparent; }

/* ---------- Tags ---------- */
.tag { font-size: .68rem; font-weight: 700; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; text-transform: uppercase; border: 1px solid var(--line); }
.tag.current { background: var(--primary-tint); color: var(--primary-deep); border-color: transparent; }
.tag.etf { background: var(--etf-tint); color: var(--etf); border-color: transparent; }
.tag.stock { background: var(--primary-tint); color: var(--primary-deep); border-color: transparent; }

/* ---------- Flash ---------- */
.flashes { margin-bottom: 16px; display: grid; gap: 10px; }
.flash { padding: 13px 16px; border-radius: 12px; font-size: .9rem; font-weight: 500; border: 1px solid; animation: rise .4s ease both; }
.flash-error { background: var(--sell-tint); color: #7c2716; border-color: rgba(178,58,36,.25); }
.flash-info { background: var(--primary-tint); color: var(--primary-deep); border-color: rgba(30,110,79,.22); }

/* ---------- Progress ---------- */
.progress { font-family: var(--font-mono); color: var(--primary-deep); word-break: break-word; font-size: .9rem; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 12px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- "Why these picks" ---------- */
details.why { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 15px; margin-bottom: 10px; background: var(--surface-2); transition: border-color .15s; }
details.why[open] { border-color: var(--line-strong); background: var(--surface); }
details.why summary { cursor: pointer; font-size: .92rem; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
details.why summary::-webkit-details-marker { display: none; }
details.why summary::before { content: "+"; font-family: var(--font-mono); color: var(--primary); font-weight: 600; }
details.why[open] summary::before { content: "\2212"; }
details.why[open] summary { margin-bottom: 12px; }
.report { font-size: .88rem; color: var(--ink-2); max-height: 340px; overflow-y: auto; padding-right: 4px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 74vh; display: grid; place-items: center; padding: 24px 4px; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-mark { display: inline-flex; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 18px; }
.auth-card h1 { margin: 6px 0 4px; }
.auth-card form { text-align: left; margin-top: 20px; }
.auth-card .btn { margin-top: 6px; }

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(252,249,243,.9); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: .66rem; font-weight: 600; padding: 4px 12px; border-radius: 12px; transition: color .15s; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.active { color: var(--primary-deep); }
.tabbar a:active { transform: scale(.94); }

/* ---------- Responsive ---------- */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .cards { grid-template-columns: repeat(4, 1fr); }
  .btn { width: auto; }
}
@media (min-width: 560px) {
  .chart-wrap { flex-direction: row; align-items: center; gap: 28px; }
  .donut-box { width: 240px; height: 240px; }
  .legend { flex: 1; }
}
@media (min-width: 820px) {
  .topbar { display: flex; }
  .tabbar { display: none; }
  .container.has-tabbar { padding-bottom: 24px; }
  .container { padding: 32px 22px; }
  .card { padding: 24px; }
}
