/* ============================================
   Portfolio — user-built (Library → Enter → Dashboard)
   White UI, matches the rest of the screener.
   ============================================ */

.pf-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.pf-sub { font-size: var(--fs-14); color: var(--text-tertiary); }
.pf-head-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* ── Search card ── */
.pf-search-card { padding: var(--sp-5) var(--sp-6); margin-bottom: var(--sp-5); }
.pf-search { position: relative; }
.pf-search .search-input {
  width: 100%;
  height: 50px;
  padding: 0 var(--sp-5) 0 46px;
  font-size: var(--fs-15);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--bg-light-grey);
  color: var(--text-brand);
  transition: all var(--transition-fast);
}
.pf-search .search-input:focus { background: var(--bg-white); border-color: var(--text-link); box-shadow: 0 0 0 3px var(--bg-selected-light); }
.pf-search .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-tertiary); }
.pf-search-meta { font-size: var(--fs-12); color: var(--text-tertiary); margin: var(--sp-3) 0 var(--sp-4); }

.pf-chips { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pf-chip-label { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: var(--fw-medium); margin-right: 2px; }
.pf-chip-sep { width: var(--sp-2); height: 1px; background: transparent; }
.pf-chip {
  padding: 6px 15px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-light-grey);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pf-chip:hover { background: var(--bg-dark-grey); color: var(--text-brand); }
.pf-chip.active { background: var(--text-link); color: #fff; box-shadow: 0 2px 6px -1px rgba(37, 99, 235, 0.4); }

/* ── Results ── */
.pf-results { display: flex; flex-direction: column; gap: var(--sp-3); }
.pf-empty-hint {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-6); text-align: center;
  color: var(--text-tertiary); font-size: var(--fs-14);
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: var(--radius-xl);
}
.pf-empty-ic { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-selected-light); color: var(--text-link); display: flex; align-items: center; justify-content: center; margin-bottom: var(--sp-2); }
.pf-empty-ic svg { width: 23px; height: 23px; }
.pf-empty-title { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--text-brand); }
.pf-empty-sub { font-size: var(--fs-13); color: var(--text-tertiary); }
.pf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.pf-row:hover { border-color: #c8d6f0; box-shadow: var(--shadow-flat); }
.pf-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-row-name { font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--text-brand); cursor: pointer; }
.pf-row-name:hover { color: var(--text-link); }
.pf-row-meta { font-size: var(--fs-12); color: var(--text-tertiary); }
.pf-row-actions { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.pf-icon-btn { width: 36px; height: 36px; border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--bg-white); cursor: pointer; font-size: var(--fs-16); line-height: 1; transition: all var(--transition-fast); }
.pf-star { color: var(--text-tertiary); }
.pf-star:hover { border-color: #f0b429; color: #f0b429; background: #fffaf0; }
.pf-star.on { color: #f0b429; border-color: #f0b429; background: #fff7e6; }
.pf-add-btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--text-link);
  background: var(--bg-white);
  color: var(--text-link);
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pf-add-btn:hover { background: var(--bg-selected-light); }
.pf-add-btn.added { background: var(--text-link); border-color: var(--text-link); color: #fff; }

/* ── Enter holdings ── */
.pf-enter-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.pf-enter-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--sp-5); box-shadow: var(--shadow-flat); }
.pf-enter-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.pf-enter-idx { font-size: var(--fs-13); font-weight: var(--fw-bold); color: var(--text-link); font-variant-numeric: tabular-nums; }
.pf-enter-name { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--text-brand); flex: 1; min-width: 0; }
.pf-enter-remove { margin-left: auto; width: 28px; height: 28px; border-radius: var(--radius-md); border: 1px solid var(--border-light); background: var(--bg-white); color: var(--text-tertiary); cursor: pointer; }
.pf-enter-remove:hover { border-color: var(--color-down); color: var(--color-down); }
.pf-enter-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.pf-field { display: flex; flex-direction: column; gap: var(--sp-2); }
.pf-field label { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: var(--fw-medium); }
.pf-field input {
  height: 42px; padding: 0 var(--sp-3);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-white); font-size: var(--fs-15); font-weight: var(--fw-semibold);
  color: var(--text-brand); font-variant-numeric: tabular-nums;
}
.pf-field input:focus { border-color: var(--text-link); box-shadow: 0 0 0 3px var(--bg-selected-light); }
.pf-field input.pf-locked { background: var(--bg-light-grey); color: var(--text-link); cursor: not-allowed; border-style: dashed; }
.pf-field-invested { justify-content: flex-end; }
.pf-invested-val { font-size: var(--fs-18); font-weight: var(--fw-bold); color: var(--text-brand); }
.pf-enter-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-5); }
.pf-addmore-btn { flex: 1; padding: var(--sp-4); border: 1px dashed var(--border-default); border-radius: var(--radius-lg); background: var(--bg-white); color: var(--text-secondary); font-weight: var(--fw-semibold); font-size: var(--fs-14); cursor: pointer; transition: all var(--transition-fast); }
.pf-addmore-btn:hover { border-color: var(--text-link); color: var(--text-link); background: var(--bg-selected-light); }

/* ── Dashboard stat cards ── */
.pf-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); margin-bottom: var(--sp-6); }
.pf-stat {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-flat);
}
.pf-stat-accent { border-top-color: var(--chart-1, #61a1e7); }
.pf-stat-up { border-top-color: var(--color-up); }
.pf-stat-down { border-top-color: var(--color-down); }
.pf-stat-label { font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: var(--fw-medium); }
.pf-stat-value { font-size: var(--fs-24); font-weight: var(--fw-bold); color: var(--text-brand); letter-spacing: var(--ls-tight); }
.pf-stat-sub { font-size: var(--fs-12); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

/* ── Tabs ── */
.pf-tabs { display: inline-flex; gap: var(--sp-2); background: var(--bg-light-grey); padding: var(--sp-2); border-radius: var(--radius-lg); margin-bottom: var(--sp-5); }
.pf-tab { padding: var(--sp-3) var(--sp-6); border: none; background: none; border-radius: var(--radius-md); font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--text-secondary); cursor: pointer; transition: all var(--transition-fast); }
.pf-tab.active { background: var(--bg-white); color: var(--text-brand); box-shadow: var(--shadow-flat); }

/* ── Best / Worst performer ── */
.pf-perf-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.pf-perf { padding: var(--sp-5) var(--sp-6); border-radius: var(--radius-lg); border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 4px; }
.pf-perf-best { background: linear-gradient(135deg, #effaf3, #e3f7ea); border-color: #cdeed8; }
.pf-perf-worst { background: linear-gradient(135deg, #fdf0f1, #fbe6e8); border-color: #f3d4d8; }
.pf-perf-tag { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.pf-perf-name { font-size: var(--fs-15); font-weight: var(--fw-bold); color: var(--text-brand); }
.pf-perf-ret { font-size: var(--fs-14); font-weight: var(--fw-semibold); }

/* ── Holdings table ── */
.pf-table-card { padding: 0; overflow: hidden; }
/* compact columns so all 11 fit on screen — no horizontal scroll */
.pf-table th, .pf-table td { padding: var(--sp-3) var(--sp-3); font-size: var(--fs-13); }
.pf-table th:first-child, .pf-table td:first-child { padding-left: var(--sp-5); }
.pf-table th:last-child, .pf-table td:last-child { padding-right: var(--sp-5); }
.pf-table .fund-name-cell .name { font-size: var(--fs-13); }
.pf-table .fund-name-cell .sub { font-size: var(--fs-11); }
.pf-table td.numeric { white-space: nowrap; }
.pf-table .name.pf-link { cursor: pointer; }
.pf-table .name.pf-link:hover { color: var(--text-link); }
.pf-row-tools { display: flex; gap: var(--sp-2); }
.pf-tool { width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); background: var(--bg-white); cursor: pointer; font-size: var(--fs-13); line-height: 1; transition: all var(--transition-fast); }
.pf-tool:hover { border-color: var(--text-tertiary); background: var(--bg-light-grey); }
.pf-tool-del:hover { border-color: var(--color-down); }
.pf-tool-save { border-color: var(--text-link); color: var(--text-link); }
.pf-tool-save:hover { background: var(--text-link); color: #fff; }
.pf-inline-input { width: 84px; height: 32px; text-align: right; padding: 0 var(--sp-2); border: 1px solid var(--text-link); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); color: var(--text-brand); }

.btn-xs { padding: 4px 10px; font-size: var(--fs-12); border-radius: var(--radius-sm); }

/* ── Allocation tab ── */
.pf-alloc .mb-6 { margin-bottom: var(--sp-6); }
.pf-donut-row { display: flex; align-items: center; gap: var(--sp-6); flex-wrap: wrap; }
.pf-donut-wrap { flex-shrink: 0; }
.pf-donut-row .allocation-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: var(--sp-3); }
.pf-bars { display: flex; flex-direction: column; gap: var(--sp-4); }
.pf-bar-row { display: grid; grid-template-columns: 110px 1fr 52px 84px; align-items: center; gap: var(--sp-3); }
.pf-bar-label { font-size: var(--fs-13); color: var(--text-brand); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-bar-track { height: 10px; background: var(--bg-light-grey); border-radius: var(--radius-full); overflow: hidden; }
.pf-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--transition-base); }
.pf-bar-pct { font-size: var(--fs-13); color: var(--text-secondary); text-align: right; }
.pf-bar-val { font-size: var(--fs-13); color: var(--text-brand); font-weight: var(--fw-semibold); text-align: right; }

@media (max-width: 768px) {
  .pf-bar-row { grid-template-columns: 84px 1fr 44px 70px; }
  .pf-donut-row { justify-content: center; }
}

/* ── Build-your-portfolio landing (two choices) ── */
.pw-hero { max-width: 620px; margin: var(--sp-8) auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.pw-hero-title { font-size: 34px; font-weight: var(--fw-bold); color: var(--text-brand); letter-spacing: var(--ls-tight); }
.pw-hero-sub { font-size: var(--fs-15); color: var(--text-tertiary); line-height: 1.6; margin-top: var(--sp-3); }
.pw-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); width: 100%; margin: var(--sp-7) 0 var(--sp-5); }
.pw-choice {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
  padding: var(--sp-7) var(--sp-5); background: var(--bg-white);
  border: 1px solid var(--border-light); border-radius: var(--radius-xl, 16px);
  box-shadow: var(--shadow-flat); cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.pw-choice:hover { transform: translateY(-3px); box-shadow: var(--shadow-raised); border-color: var(--border-default); }
.pw-choice-ic { width: 76px; height: 76px; border-radius: 20px; display: flex; align-items: center; justify-content: center; }
.pw-choice-ic svg { width: 76px; height: 76px; display: block; }
.pw-ic-create { box-shadow: 0 12px 26px rgba(60, 40, 160, 0.30); }
.pw-ic-upload { box-shadow: 0 12px 26px rgba(80, 130, 220, 0.26); }
.pw-choice-t { font-size: var(--fs-18); font-weight: var(--fw-bold); color: var(--text-brand); line-height: 1.3; }
.pw-demo {
  margin-top: var(--sp-3); padding: var(--sp-4) var(--sp-6);
  border-radius: var(--radius-full); border: 1.5px solid transparent;
  background: linear-gradient(var(--bg-white), var(--bg-white)) padding-box,
              linear-gradient(90deg, #4aa3ff, #21c08b) border-box;
  color: var(--text-brand); font-size: var(--fs-14); font-weight: var(--fw-semibold); cursor: pointer;
  transition: background var(--transition-fast);
}
.pw-demo:hover { filter: brightness(0.98); }
.pw-upload-hint { font-size: var(--fs-12); color: var(--text-tertiary); margin-top: var(--sp-5); line-height: 1.5; }

.pw-importing { display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); padding: var(--sp-9) 0; color: var(--text-secondary); font-size: var(--fs-15); }
.pw-importing .boot-spinner { width: 36px; height: 36px; }

@media (max-width: 560px) { .pw-choices { grid-template-columns: 1fr; } }

/* ── Welcome / onboarding (no holdings) ── */
.pf-welcome { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-7); align-items: center; padding: var(--sp-7); margin-bottom: var(--sp-6); }
.pw-left { display: flex; flex-direction: column; align-items: flex-start; }
.pw-eyebrow { font-size: var(--fs-15); color: var(--text-secondary); font-weight: var(--fw-medium); }
.pw-headline { font-size: 26px; font-weight: var(--fw-bold); color: #624bff; letter-spacing: var(--ls-tight); line-height: 1.2; margin-top: var(--sp-2); min-height: 64px; }
.pw-dots { display: flex; gap: 6px; margin: var(--sp-3) 0 var(--sp-5); }
.pw-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-default); cursor: pointer; transition: all var(--transition-base); }
.pw-dot.active { background: var(--text-brand); width: 20px; border-radius: 4px; }
.pw-cta { background: var(--bg-dark); color: #fff; height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-15); font-weight: var(--fw-semibold); border-radius: var(--radius-md); border: none; cursor: pointer; transition: background var(--transition-fast); }
.pw-cta:hover { background: #0f1620; }

.pw-right { display: flex; flex-direction: column; gap: var(--sp-4); }
.pw-gauge { position: relative; height: 60px; }
.pw-gauge-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 12px; border-radius: var(--radius-full); background: linear-gradient(90deg, #f0508c, #f7b733 52%, #19af55); }
.pw-marker { position: absolute; bottom: 0; transform: translateX(-50%); height: 60px; display: flex; flex-direction: column; align-items: center; }
.pw-marker::after { content: ''; width: 2px; flex: 1; background: var(--border-default); }
.pw-marker-you::after { background: #624bff; }
.pw-marker-pill { background: var(--bg-white); border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 3px 10px; font-size: var(--fs-12); color: var(--text-secondary); white-space: nowrap; box-shadow: var(--shadow-flat); }
.pw-marker-pill b { font-weight: var(--fw-bold); color: var(--text-brand); }
.pw-marker-pill.pw-you { color: #624bff; border-color: #c9c1ff; background: #f3f1ff; font-weight: var(--fw-semibold); }
.pw-gauge-labels { display: flex; justify-content: space-between; font-size: var(--fs-12); color: var(--text-tertiary); }

.pw-benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.pw-benefit { display: flex; gap: var(--sp-3); align-items: flex-start; background: var(--bg-white); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--sp-5); }
.pw-benefit-ic { font-size: 22px; line-height: 1; }
.pw-benefit-tx { display: flex; flex-direction: column; gap: 2px; }
.pw-benefit-t { font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--text-brand); }
.pw-benefit-d { font-size: var(--fs-12); color: var(--text-tertiary); line-height: 1.45; }

@media (max-width: 860px) {
  .pf-welcome { grid-template-columns: 1fr; }
  .pw-benefits { grid-template-columns: 1fr; }
}

/* ── Toast ── */
.pf-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-dark); color: #fff; padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md); font-size: var(--fs-13); font-weight: var(--fw-medium);
  box-shadow: var(--shadow-popup); opacity: 0; pointer-events: none;
  transition: opacity var(--transition-base), transform var(--transition-base); z-index: var(--z-toast, 900);
}
.pf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1024px) {
  .pf-stats { grid-template-columns: repeat(2, 1fr); }
  .pf-enter-fields { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .pf-stats { grid-template-columns: 1fr; }
  .pf-perf-row { grid-template-columns: 1fr; }
  .pf-top { flex-direction: column; }
}
