/* ═══════════════════════════════════════════════════════════
   INVEST — Multi-Asset Investing Cockpit
   ═══════════════════════════════════════════════════════════ */

.invest-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.invest-search { width: 100%; }

.invest-classes {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.invest-class-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.invest-class-btn:hover { color: var(--text-secondary); border-color: var(--border-strong); }

.invest-class-btn.active {
  color: var(--accent-primary);
  border-color: var(--border-accent);
  background: rgba(0, 212, 255, 0.07);
}

.invest-class-btn__icon { font-size: 12px; opacity: 0.8; }
.invest-class-btn__n { font-size: 9px; opacity: 0.55; }

/* ── Layout ── */
.invest-layout {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}

.invest-list {
  width: 400px;
  flex-shrink: 0;
  max-height: 72vh;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.invest-detail {
  flex: 1;
  min-width: 0;
}

/* ── Rows ── */
.invest-row {
  display: grid;
  grid-template-columns: 68px 1fr auto auto auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.invest-row:hover { background: var(--bg-secondary); }

.invest-row.is-active {
  background: rgba(0, 212, 255, 0.07);
  border-left: 2px solid var(--accent-primary);
}

.invest-row__sym {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.invest-row__name {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invest-row__price {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-primary);
}

.invest-row__chg {
  font-family: var(--font-mono);
  font-size: 10px;
  min-width: 54px;
  text-align: right;
}

.invest-row__chg.up { color: var(--semantic-green); }
.invest-row__chg.dn { color: var(--semantic-red); }
.invest-row__dim { color: var(--text-muted); }

.invest-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
}

.invest-tag--stocks      { color: #6ea8fe; border-color: rgba(110,168,254,0.3); }
.invest-tag--indices     { color: var(--accent-primary); border-color: rgba(0,212,255,0.3); }
.invest-tag--crypto      { color: #f7931a; border-color: rgba(247,147,26,0.3); }
.invest-tag--forex       { color: #22c55e; border-color: rgba(34,197,94,0.3); }
.invest-tag--commodities { color: var(--accent-gold); border-color: rgba(212,168,83,0.3); }
.invest-tag--bonds       { color: #b48ef0; border-color: rgba(180,142,240,0.3); }

/* ── Detail head ── */
.invest-detail__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.invest-detail__empty-icon { font-size: 40px; color: var(--accent-primary); opacity: 0.5; margin-bottom: var(--space-4); }
.invest-detail__empty h3 { color: var(--text-primary); font-size: var(--text-lg); margin-bottom: var(--space-2); }
.invest-detail__empty p { max-width: 420px; font-size: var(--text-sm); line-height: 1.7; }

.invest-detail__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.invest-detail__sym {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
}

.invest-detail__name { font-size: var(--text-md); color: var(--text-secondary); margin-top: 2px; }
.invest-detail__meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.invest-detail__sector { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

.invest-detail__price-block { text-align: right; }

.invest-detail__price {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
}

.invest-detail__chg { font-family: var(--font-mono); font-size: var(--text-md); font-weight: var(--weight-bold); }
.invest-detail__chg--up { color: var(--semantic-green); }
.invest-detail__chg--dn { color: var(--semantic-red); }
.invest-detail__src,
.invest-detail__extra { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
/* A failure message is a sentence — it must wrap inside the panel, not run
   off the right edge as one clipped red line. */
.invest-detail__fail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--semantic-red);
  max-width: 320px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: right;
}

.invest-drivers {
  padding: var(--space-3) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.invest-drivers__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Felicity Bot advisor ── */
.invest-advisor {
  background: var(--surface-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.invest-advisor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: rgba(0, 212, 255, 0.05);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.invest-advisor__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--accent-primary);
}

.invest-advisor__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.invest-advisor__btn {
  padding: var(--space-3) var(--space-5);
  min-height: 40px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg-primary);
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  transition: opacity var(--duration-fast) var(--ease-out);
}

.invest-advisor__btn:hover:not(:disabled) { opacity: 0.85; }
.invest-advisor__btn:disabled { opacity: 0.5; cursor: default; }

.invest-advisor__body:empty { display: none; }
.invest-advisor__body { padding: var(--space-5); }

.invest-advisor__loading,
.invest-advisor__fail { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }
.invest-advisor__fail { color: var(--semantic-red); }

.invest-call {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.invest-call__badge {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
}

.invest-call__badge--bullish { color: var(--semantic-green); background: var(--semantic-green-glow); border: 1px solid rgba(34,197,94,0.3); }
.invest-call__badge--bearish { color: var(--semantic-red);   background: var(--semantic-red-glow);   border: 1px solid rgba(239,68,68,0.3); }
.invest-call__badge--neutral { color: var(--accent-gold);    background: var(--semantic-amber-glow); border: 1px solid rgba(245,158,11,0.3); }

.invest-call__conv,
.invest-call__horizon { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.invest-call__conv strong { color: var(--text-primary); }

.invest-thesis {
  font-size: var(--text-md);
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.invest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.invest-grid__cell {
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.invest-grid__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.invest-grid__value { font-size: var(--text-sm); line-height: 1.6; color: var(--text-primary); }
.invest-grid__value--risk { color: var(--semantic-red); }
.invest-grid__value--target { color: var(--semantic-green); }

.invest-block {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-left: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.invest-block--bear { border-left-color: var(--semantic-red); }

.invest-block__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.invest-cats { margin: 0; padding-left: 18px; }
.invest-cats li { margin-bottom: 4px; }

.invest-advisor__foot {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.7;
  color: var(--text-muted);
}

.invest-advisor__foot strong { color: var(--accent-gold); }

/* ── News ── */
.invest-news {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.invest-news__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.invest-news__title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.invest-news__sub { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); }

.invest-news__item {
  display: block;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out);
}

.invest-news__item:hover { background: var(--bg-secondary); }

.invest-news__item-head { display: flex; gap: var(--space-2); margin-bottom: 4px; }

.invest-news__item-src,
.invest-news__item-date {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.invest-news__item-src { color: var(--accent-primary); }
.invest-news__item-title { font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary); }
.invest-news__item-sum { font-size: var(--text-xs); line-height: 1.6; color: var(--text-muted); margin-top: 4px; }
.invest-news__empty { padding: var(--space-5); font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 1023px) {
  .invest-list { width: 320px; }
  .invest-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .invest-layout { flex-direction: column; }
  .invest-list { width: 100%; max-height: 40vh; }
  .invest-row { grid-template-columns: 60px 1fr auto auto; }
  .invest-row__class { display: none; }
  .invest-detail__head { flex-direction: column; }
  .invest-detail__price-block { text-align: left; }
  .invest-advisor__btn { width: 100%; }
  .invest-classes {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-1);
    scrollbar-width: none;
  }
  .invest-classes::-webkit-scrollbar { display: none; }
  .invest-class-btn { flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════════════
   WATCHLIST · SWEEP · INVESTOR PROFILE
   ═══════════════════════════════════════════════════════════ */

.invest-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.invest-watch-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 38px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.invest-watch-toggle:hover { border-color: var(--border-strong); }

.invest-watch-toggle.active {
  color: var(--accent-gold);
  border-color: rgba(212, 168, 83, 0.45);
  background: rgba(212, 168, 83, 0.09);
}

.invest-star { color: var(--accent-gold); font-size: 13px; }

.invest-profile-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: var(--space-2) var(--space-4);
  min-height: 38px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.invest-profile-chip:hover { border-color: var(--border-accent); }

.invest-profile-chip__label {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.invest-profile-chip__value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-primary);
}

/* ── Star toggles ── */
.invest-row__star,
.invest-detail__star {
  background: none;
  color: var(--border-strong);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  transition: color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.invest-row__star:hover,
.invest-detail__star:hover { color: var(--accent-gold); transform: scale(1.15); }
.invest-row__star.is-on,
.invest-detail__star.is-on { color: var(--accent-gold); }

.invest-detail__star { font-size: 18px; margin-left: var(--space-2); vertical-align: middle; }

.invest-row { grid-template-columns: 24px 68px 1fr auto auto auto; }

/* ── Sweep bar ── */
.invest-sweepbar {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(212, 168, 83, 0.05);
  position: sticky;
  top: 0;
  z-index: 2;
}

.invest-sweepbar__run {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg-primary);
  background: var(--accent-gold);
  border-radius: var(--radius-sm);
}

.invest-sweepbar__clear {
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

/* ── Sweep results ── */
.sweep {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sweep__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(212, 168, 83, 0.05);
}

.sweep__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--accent-gold);
}

.sweep__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.sweep__progress {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
}

.sweep__item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.sweep__item-sym {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.sweep__item-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.sweep__item-head .invest-call__badge { font-size: var(--text-xs); padding: 3px 10px; }
.sweep__item-conv,
.sweep__item-price { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.sweep__item-price .up { color: var(--semantic-green); }
.sweep__item-price .dn { color: var(--semantic-red); }
.sweep__item-thesis { font-size: var(--text-sm); line-height: 1.65; color: var(--text-secondary); }
.sweep__item-size { font-family: var(--font-mono); font-size: 10px; color: var(--text-primary); margin-top: var(--space-2); }
.sweep__item-size strong { color: var(--accent-primary); }
.sweep__pending { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.sweep__fail { font-family: var(--font-mono); font-size: 11px; color: var(--semantic-red); }

/* ── Profile modal ── */
.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 900);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(6, 8, 12, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}

.profile-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.profile-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.profile-modal__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.profile-modal__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; line-height: 1.6; }

.profile-modal__close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-size: 22px;
  color: var(--text-muted);
  background: none;
}

.profile-modal__close:hover { color: var(--text-primary); }

.profile-form { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.profile-form__row { display: flex; gap: var(--space-3); }
.profile-form__field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.profile-form__field--narrow { max-width: 110px; }

.profile-form__label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.profile-form__input,
.profile-form__select,
.profile-form__textarea {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  outline: none;
}

.profile-form__input:focus,
.profile-form__select:focus,
.profile-form__textarea:focus { border-color: var(--border-accent); }
.profile-form__textarea { resize: vertical; }
.profile-form__select option { background: var(--bg-secondary); }

.profile-form__privacy {
  padding: var(--space-3);
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.18);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--text-secondary);
}

.profile-form__privacy strong { color: var(--accent-primary); }

.profile-form__actions { display: flex; gap: var(--space-3); }

.profile-form__save {
  flex: 1;
  padding: var(--space-3) var(--space-5);
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg-primary);
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
}

.profile-form__clear {
  padding: var(--space-3) var(--space-5);
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

@media (max-width: 767px) {
  .invest-topbar { flex-direction: column; align-items: stretch; }
  .invest-row { grid-template-columns: 22px 58px 1fr auto auto; }
  .sweep__item { grid-template-columns: 1fr; }
  .profile-form__row { flex-direction: column; }
  .profile-form__field--narrow { max-width: none; }
  .profile-form__actions { flex-direction: column; }
}

/* ── Watchlist daily news digest ── */
.invest-sweepbar__news {
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.invest-sweepbar__news:hover { background: rgba(0, 212, 255, 0.15); }

.wnews__group { border-bottom: 1px solid var(--border-subtle); }
.wnews__group--empty { padding: var(--space-3) var(--space-5); display: flex; gap: var(--space-3); align-items: baseline; }

.wnews__group-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-2);
  background: var(--bg-secondary);
}

.wnews__sym {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--accent-primary);
}

.wnews__name {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.wnews__count {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
}

.wnews__none { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

.wnews__item {
  display: block;
  padding: var(--space-2) var(--space-5);
  text-decoration: none;
  border-top: 1px solid var(--border-subtle);
  transition: background var(--duration-fast) var(--ease-out);
}

.wnews__item:hover { background: var(--bg-secondary); }
.wnews__item-meta { display: flex; gap: var(--space-2); margin-bottom: 2px; }

.wnews__item-src,
.wnews__item-date {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.wnews__item-src { color: var(--accent-primary); }
.wnews__item-title { font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary); }

/* Headlines the model actually read, shown inside a sweep result */
.sweep__item-news {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.sweep__item-news-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sweep__item-news-item {
  display: block;
  font-size: var(--text-xs);
  line-height: 1.55;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 0;
}

.sweep__item-news-item:hover { color: var(--text-primary); }

.sweep__item-news-src {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  margin-right: 4px;
}

@media (max-width: 767px) {
  .invest-sweepbar { flex-wrap: wrap; }
  .invest-sweepbar__run { flex: 1 1 100%; }
}

/* ═══════════════════════════════════════════════════════════
   TRADINGVIEW WIDGETS — tape, heatmaps, calendar
   ═══════════════════════════════════════════════════════════ */

.tv-tape {
  height: 78px;
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-card);
}

.tv-tape .tradingview-widget-container__widget { height: 100%; width: 100%; }

.tv-fail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 60px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-4);
}

/* ── Market view launcher ── */
.invest-views {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.invest-view-btn {
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.invest-view-btn:hover { color: var(--text-secondary); border-color: var(--border-strong); }

/* Secondary label inside a view button ("Heatmaps · 60+ markets") so the
   row itself says the heatmap is not just the S&P 500. */
.invest-view-btn__sub {
  margin-left: var(--space-1);
  padding-left: var(--space-1);
  border-left: 1px solid var(--border-default);
  font-weight: var(--weight-medium);
  letter-spacing: 0.04em;
  text-transform: none;
  opacity: 0.7;
}
.invest-view-btn.active .invest-view-btn__sub { opacity: 0.9; border-left-color: var(--border-accent); }

.invest-view-btn.active {
  color: var(--accent-primary);
  border-color: var(--border-accent);
  background: rgba(0, 212, 255, 0.08);
}

/* ── Instrument price chart ──
   Salvaged from the retired css/sp500.css, renamed off the legacy prefix.
   #invest-tv previously had NO desktop height — only mobile.css set one — so
   the autosizing TradingView iframe had nothing to fill and collapsed. */
.invest-chart {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-5);
}

.invest-chart__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.invest-chart__label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.invest-chart__src {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.invest-chart__fail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

#invest-tv { height: 420px; width: 100%; }
#invest-tv .tradingview-widget-container__widget { height: 100%; width: 100%; }

/* ── Full-width view panel ── */
.tv-view {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tv-view__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.tv-view__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.tv-view__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; line-height: 1.6; }

.tv-view__src {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.tv-view__body { height: 620px; width: 100%; }
.tv-view__body .tradingview-widget-container__widget { height: 100%; width: 100%; }
/* mountWidget's inner container on the panel body: takes TradingView's inline
   height:100% so the body keeps its own (see js/tv-widgets.js) */
.tv-fill { height: 100%; width: 100%; }

/* ── Market views take the full panel ──
   A 500-constituent treemap rendered in the detail column next to a 400px
   instrument list collapses into unreadable slivers. While a market view is
   open the list steps aside, and Fullscreen gives the widget the viewport. */
.tv-view__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.tv-view__expand,
.tv-view__back {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px var(--space-3);
  min-height: 32px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.tv-view__expand:hover,
.tv-view__back:hover { color: var(--accent-primary); border-color: var(--border-accent); }

.invest-layout.is-market-view .invest-list { display: none; }
.invest-layout.is-market-view .invest-detail { width: 100%; flex: 1 1 100%; }
.invest-layout.is-market-view .tv-view__body { height: min(78vh, 900px); }

/* Fullscreen: a fixed overlay, because the widget cannot escape the panel's
   own scroll container any other way. */
.tv-view.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 900);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.tv-view.is-fullscreen .tv-view__body { flex: 1; height: auto; min-height: 0; }
body.tv-fullscreen-open { overflow: hidden; }

/* ── Fundamentals (moved here from the retired S&P 500 tab) ── */
.fund {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.fund__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.fund__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.fund__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; line-height: 1.6; }

.fund__print {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px var(--space-3);
  min-height: 34px;
  cursor: pointer;
  white-space: nowrap;
}

.fund__print:hover { color: var(--accent-primary); border-color: var(--border-accent); }

.fund__metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.fund__metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.fund__metric span {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.fund__metric strong { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-primary); }

.fund__body { min-height: 40px; }
.fund__ratings { margin-bottom: var(--space-2); }

.fund__block { margin-bottom: var(--space-5); }
.fund__block:last-child { margin-bottom: 0; }

.fund__block-title {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.fund__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.fund__table { width: 100%; border-collapse: collapse; min-width: 420px; }

.fund__table th {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.fund__table td {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.fund--beat { color: var(--semantic-green); }
.fund--miss { color: var(--semantic-red); }
.fund--meet { color: var(--semantic-amber); }
.fund--unknown { color: var(--text-muted); }

.fund__bar { display: flex; height: 26px; border-radius: var(--radius-sm); overflow: hidden; }

.fund__bar-seg {
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: #04121c;
  min-width: 0;
}

.fund__bar-seg--strong-buy { background: #16a34a; }
.fund__bar-seg--buy        { background: #4ade80; }
.fund__bar-seg--hold       { background: #f59e0b; }
.fund__bar-seg--sell       { background: #f87171; }
.fund__bar-seg--strong-sell{ background: #dc2626; color: #fff; }

.fund__bar-key { display: flex; gap: var(--space-4); margin-top: var(--space-2); }

.fund__key { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.fund__key--buy  { color: var(--semantic-green); }
.fund__key--hold { color: var(--semantic-amber); }
.fund__key--sell { color: var(--semantic-red); }

.fund__targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-4); }

.fund__target {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.fund__target--avg { border-color: var(--border-accent); }

.fund__target span {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.fund__target strong { font-family: var(--font-mono); font-size: var(--text-md); color: var(--text-primary); }
.fund__target--avg strong { color: var(--accent-primary); }

.fund__empty { font-size: var(--text-sm); line-height: 1.7; color: var(--text-muted); }

@media (max-width: 767px) {
  .tv-tape { height: 68px; }
  .tv-view__body { height: 460px; }
  .invest-layout.is-market-view .tv-view__body { height: 70vh; }
  .tv-view__head { flex-direction: column; gap: var(--space-3); }
  .tv-view__actions { width: 100%; }
  .tv-view__expand, .tv-view__back { flex: 1; min-height: 38px; }
  .fund { padding: var(--space-4); }
  .fund__head { flex-direction: column; gap: var(--space-2); }
  .fund__print { width: 100%; }
  .fund__metrics { grid-template-columns: 1fr 1fr; }
  .invest-views {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-1);
    scrollbar-width: none;
  }
  .invest-views::-webkit-scrollbar { display: none; }
  .invest-view-btn { flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════════════
   TOOLS — Screener and Backtest
   ═══════════════════════════════════════════════════════════
   Shared chrome for the two analytical panels. Both render into
   #invest-detail in place of an instrument.
   ═══════════════════════════════════════════════════════════ */

.tool {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.tool__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.tool__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.tool__sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 3px; line-height: 1.65; max-width: 60ch; }
.tool__sub em { color: var(--text-secondary); font-style: normal; font-weight: var(--weight-bold); }

.tool__src {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.tool__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.tool__label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  min-width: 62px;
}

.tool__chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.tool-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px var(--space-3);
  min-height: 30px;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.tool-chip:hover { color: var(--text-secondary); border-color: var(--border-strong); }

.tool-chip.is-on {
  color: var(--accent-primary);
  border-color: var(--border-accent);
  background: rgba(0, 212, 255, 0.08);
}

.tool__criteria {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.7;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-left: 2px solid var(--accent-primary);
  border-radius: var(--radius-xs);
  margin: var(--space-4) 0;
}

/* ── Form ── */
.tool__form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.tool__field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tool__field .tool__label { min-width: 0; }

.tool__input,
.tool__select {
  width: 100%;
  min-height: 38px;
  padding: 8px var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.tool__input:focus,
.tool__select:focus { outline: none; border-color: var(--border-accent); }

.tool__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.tool__run {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg-primary);
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-5);
  min-height: 40px;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.tool__run:hover:not(:disabled) { opacity: 0.85; }
.tool__run:disabled { opacity: 0.4; cursor: not-allowed; }

.tool__note { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); }

.tool__out { margin-top: var(--space-5); }

.tool__loading,
.tool__empty {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.7;
  padding: var(--space-5);
  text-align: center;
}

.tool__fail {
  font-size: var(--text-sm);
  color: var(--semantic-red);
  padding: var(--space-4);
  background: rgba(239, 68, 68, 0.06);
  border-radius: var(--radius-sm);
}

.tool__method {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  line-height: 1.75;
  color: var(--text-muted);
}

.tool .up, .bt .up { color: var(--semantic-green); }
.tool .dn, .bt .dn { color: var(--semantic-red); }

/* ── Screener results ── */
.screen-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  line-height: 1.7;
}

.screen-summary strong { color: var(--accent-primary); font-size: var(--text-md); }
.screen-summary__crit { display: block; font-size: var(--text-xs); color: var(--text-muted); }
.screen-summary__fail { display: block; font-family: var(--font-mono); font-size: 9px; color: var(--semantic-amber); margin-top: 4px; }

.screen-table { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); overflow: hidden; }

.screen-table__head,
.screen-table__row {
  display: grid;
  grid-template-columns: 2.2fr 1fr 0.7fr 1fr 1fr 1.3fr;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
}

.screen-table__head {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.screen-table__row {
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.screen-table__row:hover { background: var(--bg-secondary); }

.screen-table__sym {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.screen-table__sym em {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: var(--weight-normal);
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-table__trend { display: flex; gap: 4px; flex-wrap: wrap; }

.screen-table__trend em {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 9px;
  color: var(--semantic-green);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  white-space: nowrap;
}

.screen-table__trend em.is-off { color: var(--text-muted); border-color: var(--border-subtle); }

/* ── Backtest result ── */
.bt__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.bt__sym {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.bt__name { font-family: var(--font-display); font-weight: var(--weight-normal); font-size: var(--text-sm); color: var(--text-muted); }
.bt__strat { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 3px; line-height: 1.6; }

.bt__period {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.7;
  white-space: nowrap;
}

.bt__headline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.bt__big {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bt__big--edge { border-color: var(--border-accent); }

.bt__big-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.bt__big-value { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: var(--weight-bold); }

.bt__chart {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.bt__chart svg { width: 100%; height: 150px; display: block; }

.bt__line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.bt__line--strat { stroke: var(--accent-primary); }
.bt__line--hold { stroke: var(--text-muted); stroke-dasharray: 4 3; opacity: 0.8; }

.bt__legend { display: flex; gap: var(--space-4); margin-top: var(--space-3); }

.bt__key { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.bt__key::before { content: ''; width: 14px; height: 2px; background: currentColor; }
.bt__key--strat { color: var(--accent-primary); }
.bt__key--hold::before { background: repeating-linear-gradient(to right, currentColor 0 4px, transparent 4px 7px); }

.bt__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.bt__stats > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.bt__stats span {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.bt__stats strong { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-primary); }

.bt__verdict {
  font-size: var(--text-sm);
  line-height: 1.75;
  color: var(--text-secondary);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--text-muted);
  background: var(--bg-secondary);
  margin-bottom: var(--space-4);
}

.bt__verdict.is-good { border-left-color: var(--semantic-green); }
.bt__verdict.is-bad { border-left-color: var(--semantic-amber); }
.bt__verdict strong { color: var(--text-primary); }

.bt__trades { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); overflow: hidden; }

.bt__trades-head,
.bt__trade {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 0.6fr 0.8fr;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  align-items: center;
}

.bt__trades-head {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.bt__trade { border-top: 1px solid var(--border-subtle); color: var(--text-secondary); }
.bt__trade span { display: flex; flex-direction: column; min-width: 0; }
.bt__trade em { font-family: var(--font-mono); font-style: normal; font-size: 9px; color: var(--text-muted); }
.bt__trade > span:last-child { font-family: var(--font-mono); font-weight: var(--weight-bold); }

.bt__more { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); margin-top: var(--space-2); }

/* ── Mobile ── */
@media (max-width: 767px) {
  .tool { padding: var(--space-4); }
  .tool__head { flex-direction: column; gap: var(--space-2); }
  .tool__row { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
  /* Symbol and strategy get the full width; the numeric fields pair up. */
  .tool__form { grid-template-columns: 1fr 1fr; }
  .tool__field { grid-column: span 2; }
  .tool__field--sm { grid-column: span 1; }
  .tool__run { width: 100%; }
  .tool__actions { flex-direction: column; align-items: stretch; text-align: center; }

  /* Six columns will not fit a phone. Scroll the table rather than hide
     columns — which metric matters depends on which screen was run, so
     dropping any of them would blind half the screens. */
  .screen-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .screen-table__head,
  .screen-table__row { min-width: 560px; }

  .bt__head { flex-direction: column; gap: var(--space-2); }
  .bt__period { text-align: left; white-space: normal; }
  .bt__headline { grid-template-columns: 1fr; }
  .bt__big { flex-direction: row; align-items: baseline; justify-content: space-between; }
  .bt__chart svg { height: 120px; }
  .bt__trades-head,
  .bt__trade { grid-template-columns: 1.2fr 1.2fr 0.5fr 0.8fr; padding: var(--space-2) var(--space-3); }
}

/* ═══════════════════════════════════════════════════════════
   PORTFOLIO — holdings marked to the live market
   ═══════════════════════════════════════════════════════════ */

.pf-add {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr auto;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.pf-add__num { min-width: 0; }
.pf-add__btn { min-height: 38px; padding: 0 var(--space-4); }

.pf-error {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--semantic-red);
}

.pf-table { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); overflow: hidden; }

.pf-table__head,
.pf-table__row,
.pf-table__total {
  display: grid;
  grid-template-columns: 1.7fr 0.8fr 1fr 1fr 1.1fr 1.2fr 1fr 30px;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.pf-table__head {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.pf-table__row {
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.pf-table__row:hover { background: var(--bg-secondary); }

.pf-table__sym { display: flex; flex-direction: column; min-width: 0; font-weight: var(--weight-bold); color: var(--text-primary); }
.pf-table__sym em {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: var(--weight-normal);
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-table__row span em,
.pf-table__total span em {
  display: block;
  font-style: normal;
  font-size: 9px;
  opacity: 0.8;
}

.pf-na { font-style: normal; color: var(--semantic-amber); font-size: 10px; }

.pf-table .up { color: var(--semantic-green); }
.pf-table .dn { color: var(--semantic-red); }

.pf-table__del {
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.pf-table__del:hover { color: var(--semantic-red); }

.pf-table__total {
  border-top: 2px solid var(--border-strong);
  color: var(--text-primary);
  font-weight: var(--weight-bold);
  background: var(--bg-secondary);
}

@media (max-width: 767px) {
  .pf-add { grid-template-columns: 1fr 1fr; }
  .pf-add__sym { grid-column: span 2; }
  .pf-add__btn { grid-column: span 2; width: 100%; }

  /* Eight columns cannot fit a phone — scroll the table, hide nothing. */
  .pf-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pf-table__head, .pf-table__row, .pf-table__total { min-width: 640px; }
}

/* ═══════════════════════════════════════════════════════════
   BOND DESK — US curve from our feed, Asia via TradingView
   ═══════════════════════════════════════════════════════════ */

.bonddesk { display: flex; flex-direction: column; height: 100%; }

.bonddesk__us { flex-shrink: 0; }

.bonddesk__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.bonddesk__title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.bonddesk__src {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.bonddesk__cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-4);
}

.bonddesk__card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.bonddesk__tenor {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.bonddesk__val {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.bonddesk__chg { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.bonddesk__chg.up { color: var(--semantic-green); }
.bonddesk__chg.dn { color: var(--semantic-red); }

.bonddesk__tv { flex: 1; min-height: 0; }
.bonddesk__tv .tradingview-widget-container__widget { height: 100%; width: 100%; }

/* Range buttons on self-drawn charts */
.ychart__ranges { display: flex; gap: var(--space-1); }

.ychart__range {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  cursor: pointer;
}

.ychart__range:hover { color: var(--text-secondary); }
.ychart__range.is-on { color: var(--accent-primary); border-color: var(--border-accent); }

/* ── Yield history chart (drawn by us — TradingView cannot embed US yields) ── */
.ychart { padding: var(--space-4); }

.ychart__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.ychart__meta .up { color: var(--semantic-green); }
.ychart__meta .dn { color: var(--semantic-red); }

.ychart svg { width: 100%; height: 160px; display: block; }

.ychart__line { fill: none; stroke: var(--accent-primary); stroke-width: 1.6; vector-effect: non-scaling-stroke; }

.ychart__src {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

@media (max-width: 767px) {
  .bonddesk__cards { grid-template-columns: 1fr 1fr; }
  .ychart svg { height: 130px; }
}

/* ── Heatmap market picker (chips over the TradingView treemap) ── */
/* .tv-view--picker / --own are set by mountHeatmapPicker (js/tv-widgets.js),
   not :has(): a browser without :has() collapsed the Nikkei map to 0px */
.tv-view--picker .tv-view__body { display: flex; flex-direction: column; gap: var(--space-2); }
.hm-picker { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding: var(--space-2) 0; }
.hm-picker__group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.hm-picker__region {
  font-family: var(--font-mono); font-size: 8px; font-weight: var(--weight-bold);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-right: 4px;
}
.hm-picker__chip {
  font-family: var(--font-mono); font-size: 9px; font-weight: var(--weight-bold); letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--bg-secondary); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs); padding: 4px 8px; min-height: 26px; cursor: pointer; white-space: nowrap;
}
.hm-picker__chip:hover { color: var(--text-secondary); }
.hm-picker__chip.is-on { color: var(--accent-primary); border-color: var(--border-accent); background: var(--accent-glow); }
.hm-picker__note { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); line-height: 1.5; }
.hm-picker__widget { flex: 1 1 auto; min-height: 380px; position: relative; }
.hm-picker__widget .tradingview-widget-container__widget { height: 100%; width: 100%; }
.hm-picker__group--menu { flex-basis: 100%; align-items: flex-start; }
.hm-picker__hint { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.6; max-width: 90ch; }
.hm-picker__hint strong { color: var(--accent-primary); }
.hm-picker__hint a { color: var(--accent-primary); text-decoration: underline; text-underline-offset: 2px; }

/* ── Nikkei 225 heatmap: drawn by us (js/nikkei-heatmap.js) ──
   Styled to sit beside TradingView's heatmaps: a black frame, a toolbar,
   1px gaps between tiles, a floating card on hover/tap/focus and the
   legend underneath. The map's height is its own (never a percentage of a
   parent whose height may not be definite — that rendered it 0px tall). */
.nkhm { display: flex; flex-direction: column; background: #000; border-radius: var(--radius-xs); overflow: hidden; color: #d1d4dc; font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif; }
.nkhm__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 14px; border-bottom: 1px solid #1f2229; }
.nkhm__idx { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 15px; }
.nkhm__name { font-weight: 600; color: #fff; }
.nkhm__level { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.nkhm__idxchg { font-weight: 600; font-variant-numeric: tabular-nums; }
.nkhm__idxchg.is-up, .nkhm__tip-move.is-up { color: #22ab94; }
.nkhm__idxchg.is-down, .nkhm__tip-move.is-down { color: #f7525f; }
.nkhm__badge { align-self: center; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 4px; background: #2a2e39; color: #b2b5be; }
.nkhm__asof { font-size: 13px; color: #787b86; }
.nkhm__basis { display: flex; gap: 18px; font-size: 14px; color: #d1d4dc; }
.nkhm__basis b { font-weight: 400; color: #787b86; margin-right: 6px; }
.nkhm__refresh { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #2a2e39; background: transparent; color: #d1d4dc; cursor: pointer; }
.nkhm__refresh svg { width: 16px; height: 16px; }
.nkhm__refresh:hover:not(:disabled) { background: #1e222d; }
.nkhm__refresh.is-busy svg { animation: nkhm-spin 0.9s linear infinite; }
.nkhm__refresh:disabled { cursor: progress; }
@keyframes nkhm-spin { to { transform: rotate(360deg); } }

.nkhm__stage { position: relative; }
.nkhm__map { position: relative; height: clamp(420px, 64vh, 820px); overflow: hidden; background: #000; }
.nkhm__sector { position: absolute; box-sizing: border-box; border: 2px solid #000; pointer-events: none; }
.nkhm__sector-label { position: absolute; left: 4px; top: 0; height: 16px; line-height: 16px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: #b2b5be; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 8px); }
.nkhm__tile {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; color: #fff; text-align: center; line-height: 1.2;
  border: 0; padding: 0; margin: 0; font-family: inherit; cursor: pointer; background: rgb(42, 46, 57);
}
.nkhm__tile:hover, .nkhm__tile:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.9); outline-offset: -2px; z-index: 1; }
/* No quote, or no trade this session: a pattern no move colour can produce */
.nkhm__tile.is-missing, .nkhm__legend i.is-missing {
  background: repeating-linear-gradient(45deg, #2a2e39 0 4px, #14171f 4px 8px);
  color: #b2b5be;
}
.nkhm__code { font-weight: 600; max-width: 94%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nkhm__chg { font-size: 0.86em; opacity: 0.95; font-variant-numeric: tabular-nums; }

.nkhm__tip { position: absolute; z-index: 5; min-width: 180px; max-width: 280px; padding: 10px 12px; border-radius: 6px; background: #1e222d; border: 1px solid #2a2e39; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); pointer-events: none; }
.nkhm__tip[hidden] { display: none; }
.nkhm__tip-name { font-size: 14px; font-weight: 600; color: #fff; }
.nkhm__tip-name span { font-weight: 400; color: #787b86; margin-left: 4px; }
.nkhm__tip-move { font-size: 18px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.nkhm__tip-meta { font-size: 12px; color: #b2b5be; line-height: 1.5; }

.nkhm__credit { position: absolute; right: 6px; bottom: 6px; z-index: 4; font-size: 11px; color: #d1d4dc; background: rgba(0, 0, 0, 0.62); padding: 2px 7px; border-radius: 4px; pointer-events: none; }

.nkhm__bottom { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; padding: 10px 14px 8px; }
.nkhm__legend { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.nkhm__legend span { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; }
.nkhm__legend em { font-style: normal; font-size: 12px; color: #d1d4dc; }
.nkhm__legend i { display: block; width: 100%; height: 8px; }
.nkhm__status { font-size: 12px; color: #787b86; }
.nkhm__about { padding: 0 14px 10px; font-size: 12px; color: #787b86; }
.nkhm__about > summary { cursor: pointer; color: #b2b5be; list-style: none; }
.nkhm__about > summary::-webkit-details-marker { display: none; }
.nkhm__about > summary::before { content: '\25B8 '; }
.nkhm__about[open] > summary::before { content: '\25BE '; }
.nkhm__about p { margin: 6px 0 0; line-height: 1.6; }
.nkhm__about a { color: var(--accent-primary); }
.nkhm__about strong { color: #f7525f; }
.nkhm__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The Nikkei view: the panel grows around the map instead of clipping it */
.invest-layout .tv-view.tv-view--own .tv-view__body { height: auto; flex: 0 0 auto; }
.tv-view.tv-view--own .hm-picker__widget { height: auto; min-height: 0; flex: 0 0 auto; }
.tv-view.is-fullscreen.tv-view--own { overflow-y: auto; }

/* Why some markets have no chip — open on desktop, folded on phones */
.hm-picker__why > summary { cursor: pointer; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); list-style: none; }
.hm-picker__why > summary::-webkit-details-marker { display: none; }
.hm-picker__why > summary::before { content: '\25B8 '; }
.hm-picker__why[open] > summary::before { content: '\25BE '; }

@media (max-width: 767px) {
  /* Chips scroll sideways, one row per region, so the map starts near the top */
  .hm-picker { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
  .hm-picker__group:not(.hm-picker__group--menu) { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .hm-picker__group:not(.hm-picker__group--menu)::-webkit-scrollbar { display: none; }
  .hm-picker__chip { min-height: 36px; flex: 0 0 auto; }
  .hm-picker__region, .hm-picker__note, .hm-picker__why > summary { font-size: 11px !important; }
  .invest-layout .tv-view.tv-view--picker .tv-view__body { height: auto; }
  /* An explicit height, not a minimum: the TradingView iframe is 100% of it */
  .tv-view.tv-view--picker .hm-picker__widget { height: 70vh; min-height: 0; flex: 0 0 auto; }
  .tv-view.tv-view--own .hm-picker__widget { height: auto; min-height: 0; }
  .tv-view.is-fullscreen.tv-view--picker { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .nkhm__map { height: 62vh; }
  /* Nothing under 11px on a phone: the chips and the view header too */
  .hm-picker__chip, .hm-picker__hint, .tv-view__expand, .tv-view__back, .tv-view__src { font-size: 11px !important; }
  .nkhm__bar { padding: 8px 10px; gap: 6px 12px; }
  .nkhm__basis { font-size: 12px; gap: 12px; }
  .nkhm__asof, .nkhm__badge, .nkhm__sector-label, .nkhm__legend em, .nkhm__status, .nkhm__about, .nkhm__credit, .nkhm__tip-meta { font-size: 11px !important; }
  /* The legend spans the width; the credit moves left, clear of the floating buttons */
  .nkhm__bottom { flex-direction: column; align-items: stretch; }
  .nkhm__legend { display: flex; width: 100%; }
  .nkhm__legend em { white-space: nowrap; }
  .nkhm__legend span { width: auto; flex: 1 1 0; }
  .nkhm__legend span:last-child { flex: 1.6 1 0; }
  .nkhm__credit { right: auto; left: 6px; }
  .nkhm__chg { font-size: 1em; }
  .nkhm__refresh { width: 40px; height: 40px; }
}
