/* Portfolio Overview Page */

.portfolio-main {
  padding: 28px 40px 80px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.portfolio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.portfolio-balance-label {
  font-size: 13px;
  color: var(--app-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.portfolio-balance-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.portfolio-balance-amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--app-text-white);
  letter-spacing: -0.5px;
}

.portfolio-balance-change {
  font-size: 14px;
  font-weight: 600;
}

.portfolio-balance-change.positive { color: #22c55e; }
.portfolio-balance-change.negative { color: #ef4444; }

.change-period {
  color: var(--app-text-muted);
  font-weight: 400;
  font-size: 12px;
}

.portfolio-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* btn-primary / btn-outline: now inherited from style.css .app-body scope */

/* Overview Grid */
.portfolio-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Card shared */
.card {
  background: var(--app-surface-2);
  border: 1px solid rgba(var(--app-content-overlay-rgb),0.06);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(var(--app-content-overlay-rgb),0.06);
}

.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--app-text-strong);
}

.card-body {
  padding: 20px;
}

/* Donut Chart - CSS only */
.donut-chart-container {
  display: flex;
  align-items: center;
  gap: 32px;
}

.donut-chart {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: conic-gradient(#2a2d35 0deg 360deg);
  position: relative;
  flex-shrink: 0;
}

.donut-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--app-surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-total-label {
  font-size: 11px;
  color: var(--app-text-muted);
}

.donut-total-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--app-text-white);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  /* theme-aware: dark (#1a1a1a) on the Ultimo light card, light (#e0e0e8) on the Vestex
     dark card. The old hardcoded #cbd5e1 was near-invisible on the light theme. */
  color: var(--app-text-1, #cbd5e1);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-pct {
  color: var(--app-text-muted);
  margin-left: auto;
  min-width: 40px;
  text-align: right;
}

/* Stats card */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(var(--app-content-overlay-rgb),0.04);
}

.stat-row:last-child { border-bottom: none; }

.stat-label {
  font-size: 13px;
  color: var(--app-text-muted);
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text-strong);
}

.stat-value.positive { color: #22c55e; }
.stat-value.negative { color: #ef4444; }

/* Table shared */
.table-responsive {
  overflow-x: auto;
  padding: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(var(--app-content-overlay-rgb),0.06);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--app-text-strong);
  border-bottom: 1px solid rgba(var(--app-content-overlay-rgb),0.04);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: rgba(var(--app-content-overlay-rgb),0.02);
}

.positive { color: #22c55e; }
.negative { color: #ef4444; }
.neutral { color: var(--app-text-muted); }

/* Asset cell */
.asset-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.asset-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--app-text-white);
  flex-shrink: 0;
}

.asset-info {
  display: flex;
  flex-direction: column;
}

.asset-name {
  font-weight: 600;
  color: var(--app-text-strong);
  font-size: 14px;
}

.asset-ticker {
  font-size: 12px;
  color: var(--app-text-muted);
}

/* Allocation bar */
.alloc-bar-wrap {
  width: 60px;
  height: 4px;
  background: rgba(var(--app-content-overlay-rgb),0.06);
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

.alloc-bar {
  height: 100%;
  border-radius: 2px;
}

/* Action buttons in table */
.action-cell {
  display: flex;
  gap: 8px;
}

.table-action-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  background: var(--app-primary);
  color: #0a0e17;
  transition: background 0.15s;
}

.table-action-btn:hover {
  background: var(--app-primary-hover);
}

.table-action-btn.outline {
  background: transparent;
  color: var(--app-primary);
  border: 1px solid rgba(92,184,230,0.3);
}

.table-action-btn.outline:hover {
  border-color: var(--app-primary);
}

/* Transaction types */
.tx-type {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.tx-type.buy { background: rgba(34,197,94,0.15); color: #22c55e; }
.tx-type.sell { background: rgba(239,68,68,0.15); color: #ef4444; }
.tx-type.deposit { background: rgba(92,184,230,0.15); color: var(--app-primary); }
.tx-type.withdraw { background: rgba(251,191,36,0.15); color: #fbbf24; }
.tx-type.send { background: rgba(168,85,247,0.15); color: #a855f7; }
.tx-type.receive { background: rgba(34,197,94,0.15); color: #22c55e; }

.tx-status {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.tx-status.completed { background: rgba(34,197,94,0.15); color: #22c55e; }
.tx-status.pending { background: rgba(251,191,36,0.15); color: #fbbf24; }

/* Responsive */
@media (max-width: 900px) {
  .portfolio-overview-grid {
    grid-template-columns: 1fr;
  }
  .donut-chart-container {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 1024px) {
  .portfolio-main { padding: 24px 20px 60px; }
}
@media (max-width: 640px) {
  .portfolio-main { padding: 20px 16px 60px; }
  .portfolio-balance-amount { font-size: 28px; }
  .portfolio-header { flex-direction: column; }
}

/* Ultimo: Holdings action pills — KEEP each button's own dominant color but
   re-style for the light theme. The original (VESTEX) style is colored text on a
   transparent pill, designed for the dark box → faint on the white Ultimo box.
   Each becomes a readable COLORED CHIP: pale tinted bg + darker same-hue text +
   matching border. !important beats the inline accent colors (Buy/Sell/Margin)
   without touching shared markup → vestex keeps its original pills. Scoped →
   vestex zero-diff. audit 2026-06-25 */
html[data-brand="ultimo"] .act-btn { font-weight: 700 !important; }
html[data-brand="ultimo"] .act-buy,
html[data-brand="ultimo"] .act-deposit {
  background: rgba(38,166,154,0.12) !important; border-color: rgba(38,166,154,0.45) !important; color: #1a8f84 !important;
}
html[data-brand="ultimo"] .act-buy:hover,
html[data-brand="ultimo"] .act-deposit:hover { background: rgba(38,166,154,0.2) !important; }
html[data-brand="ultimo"] .act-convert {
  background: rgba(224,160,80,0.16) !important; border-color: rgba(224,160,80,0.5) !important; color: #a76a14 !important;
}
html[data-brand="ultimo"] .act-convert:hover { background: rgba(224,160,80,0.26) !important; }
html[data-brand="ultimo"] .act-trade {
  background: rgba(245,181,10,0.16) !important; border-color: rgba(245,181,10,0.55) !important; color: #8a6500 !important;
}
html[data-brand="ultimo"] .act-trade:hover { background: rgba(245,181,10,0.26) !important; }
html[data-brand="ultimo"] .act-margin {
  background: rgba(124,58,237,0.12) !important; border-color: rgba(124,58,237,0.45) !important; color: #6d28d9 !important;
}
html[data-brand="ultimo"] .act-margin:hover { background: rgba(124,58,237,0.2) !important; }
html[data-brand="ultimo"] .act-withdraw {
  background: rgba(239,154,58,0.15) !important; border-color: rgba(239,154,58,0.5) !important; color: #bf6f15 !important;
}
html[data-brand="ultimo"] .act-withdraw:hover { background: rgba(239,154,58,0.25) !important; }

/* ---- Total Assets Over Time (Stage 3 item #16) ---- */
.portfolio-history-range-buttons {
  display: flex;
  gap: 6px;
}
.portfolio-history-range-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  background: transparent;
  color: var(--app-text-muted-2);
  cursor: pointer;
}
.portfolio-history-range-btn[aria-pressed="true"] {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: var(--app-primary-fg);
}
/* NO height/padding on the chart mount div itself — same convention as
   ai-trading.css's .ai-slot/.ai-yp-chart: the chart module (lightweight-
   charts) sizes its own container. */
.portfolio-history-chart { min-height: 220px; }
.portfolio-history-empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--app-text-muted-2);
}
.portfolio-history-asof {
  margin-top: 8px;
  font-size: 12px;
  color: var(--app-text-muted-2);
}
.portfolio-history-disclosure {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--app-text-muted-2);
  opacity: 0.85;
}
