/* Simplified v3 portfolio page */

.v3-portfolio {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--container-padding);
  color: var(--text-primary);
}

.v3-portfolio__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}

.v3-portfolio__header-main {
  min-width: min(720px, 100%);
}

.v3-portfolio__title {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--text-3xl);
  letter-spacing: -0.01em;
}

.v3-portfolio__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.v3-portfolio__meta--secondary {
  margin-top: var(--space-sm);
}

.v3-portfolio__header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.v3-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin: 0 0 var(--space-lg) 0;
}

.v3-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.14);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
}

.v3-tab:hover {
  border-color: var(--border-primary);
  color: var(--text-primary);
}

.v3-tab.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.v3-tab i {
  opacity: 0.9;
}

.v3-segment {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
}

.v3-seg-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.v3-seg-btn:hover {
  color: var(--text-primary);
}

.v3-seg-btn.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.v3-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-primary);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.v3-badge.is-demo {
  border-color: rgba(147, 197, 253, 0.35);
}

.v3-badge.is-live {
  border-color: rgba(255, 255, 255, 0.18);
}

.v3-meta-item,
.v3-meta-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.v3-meta-link {
  color: inherit;
  text-decoration: none;
}

.v3-meta-link:hover {
  color: var(--text-primary);
}

.v3-card {
  background: var(--surface-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.v3-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.v3-card__title {
  margin: 0;
  font-size: var(--text-xl);
}

.v3-metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-md);
}

.v3-metrics-grid--risk {
  margin-top: var(--space-sm);
}

@media (max-width: 1100px) {
  .v3-metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .v3-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.v3-metric {
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-height: 74px;
}

.v3-metric__label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
}

.v3-metric__value {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
}

.v3-hint {
  margin-top: var(--space-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.v3-pill-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.v3-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.v3-table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.v3-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.v3-table th,
.v3-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.v3-table th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
  z-index: 1;
}

.v3-table th.v3-right {
  text-align: right;
}

.v3-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.v3-right {
  text-align: right;
}

.v3-muted {
  color: var(--text-muted);
}

.v3-num {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.v3-positive {
  color: #86efac;
}

.v3-negative {
  color: #fca5a5;
}

.v3-side {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.v3-side.buy {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
  background: rgba(134, 239, 172, 0.06);
}

.v3-side.sell {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.35);
  background: rgba(252, 165, 165, 0.06);
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: var(--text-sm);
}

.v3-symbol {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.v3-symbol-link {
  color: inherit;
  text-decoration: none;
}

.v3-symbol-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.v3-symbol-count {
  font-size: var(--text-xs);
}

.v3-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.14);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.v3-row-toggle:hover {
  border-color: var(--border-primary);
  color: var(--text-primary);
}

.v3-row-toggle__icon {
  display: inline-block;
  transition: transform var(--transition-fast);
}

.v3-row-toggle.is-open .v3-row-toggle__icon {
  transform: rotate(90deg);
}

.v3-side.mix {
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.v3-child-row {
  background: rgba(0, 0, 0, 0.1);
}

.v3-child-row td:nth-child(2) {
  padding-left: 1.25rem;
}

.v3-child-indent {
  color: var(--text-muted);
}

#positionsTable th.v3-toggle-col,
#positionsTable td.v3-toggle-col {
  width: 2.6rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  text-align: center;
}

.v3-earnings-chart {
  position: relative;
  height: 160px;
  margin: var(--space-md) 0;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: stretch;
  gap: 0.2rem;
  overflow: hidden;
}

.v3-earnings-chart.is-empty {
  display: none;
}

.v3-earnings-chart__baseline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-subtle);
  opacity: 0.8;
  pointer-events: none;
}

.v3-earnings-bar {
  flex: 1;
  position: relative;
  min-width: 2px;
}

.v3-earnings-bar__fill {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 3px;
  opacity: 0.85;
  transition: opacity var(--transition-fast), filter var(--transition-fast);
}

.v3-earnings-bar__fill[data-sign="pos"] {
  bottom: 50%;
  background: rgba(134, 239, 172, 0.9);
}

.v3-earnings-bar__fill[data-sign="neg"] {
  top: 50%;
  background: rgba(252, 165, 165, 0.9);
}

.v3-earnings-bar__fill:hover {
  opacity: 1;
  filter: brightness(1.08);
}

.v3-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: var(--space-sm);
}

.v3-pagination[hidden] {
  display: none;
}
