/* ============================================
   Components — Cards, Tree, Buttons, Forms, Lightbox
   ============================================ */

/* ---- Chart Tabs (index switcher) ---- */
.chart-tabs {
  display: flex;
  gap: 2px;
}

.chart-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.chart-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chart-tab.active {
  background: var(--accent-blue);
  color: var(--text-on-accent);
}

.chart-tab-name {
  font-family: var(--font-sans);
  font-weight: var(--weight-normal);
  font-size: var(--text-xs);
  opacity: 0.8;
}

@media (max-width: 480px) {
  .chart-tab-name {
    display: none;
  }
}

/* ---- Example Cards ---- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-thumbnail {
  height: 140px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-thumbnail .placeholder-icon {
  color: var(--text-tertiary);
  font-size: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.card-thumbnail .placeholder-icon span {
  font-size: var(--text-sm);
}

.card-body {
  padding: var(--space-4);
}

.card-symbol {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.card-title {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.card-date {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.badge-group {
  color: var(--text-on-accent);
}

.badge-tag {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

/* ---- Tree Navigation ---- */
.tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-item {
  user-select: none;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 2px solid transparent;
}

.tree-node:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tree-node.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-left-color: var(--accent-blue);
}

.tree-node .chevron {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.tree-node .chevron.expanded {
  transform: rotate(90deg);
}

.tree-node .chevron.hidden {
  visibility: hidden;
}

.tree-node .icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.tree-node .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node .count-badge {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-surface);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Nested tree levels */
.tree-children {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

.tree-children .tree-node {
  padding-left: var(--space-8);
}

.tree-children .tree-children .tree-node {
  padding-left: var(--space-12);
}

.tree-children.collapsed {
  max-height: 0 !important;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

.btn-primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: #4d9bff;
  border-color: #4d9bff;
}

.btn-danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: var(--text-on-accent);
}

.btn-danger:hover {
  background: #ff6961;
  border-color: #ff6961;
}

.btn-sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-surface);
  border-color: var(--border-primary);
}

/* ---- Select / Dropdown ---- */
.select {
  appearance: none;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select:hover {
  border-color: var(--text-tertiary);
}

.select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ---- Input ---- */
.input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: border-color var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.input::placeholder {
  color: var(--text-tertiary);
}

/* ---- Textarea ---- */
.textarea {
  padding: var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition-fast);
}

.textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ---- Form Groups ---- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-group .input,
.form-group .select,
.form-group .textarea {
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 600px) {
  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

.form-group .required {
  color: var(--accent-red);
}

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeIn 200ms ease;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-lg);
  transition: background var(--transition-fast);
}

.lightbox-close:hover {
  background: var(--bg-tertiary);
}

/* ---- Tags List ---- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-tertiary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
}

.empty-state h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

/* ---- Marker Legend ---- */
.marker-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

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

/* ---- Example Chart Section ---- */
.example-chart-section .chart-single .chart-wrapper {
  height: 500px;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideInLeft {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Auth Gate ---- */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  width: 320px;
  text-align: center;
}

.auth-box h2 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
}

.auth-box .input {
  width: 100%;
  text-align: center;
  font-size: var(--text-md);
}

/* ---- Admin-specific styles ---- */
.admin-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

.admin-header h1 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  padding: 0 var(--space-4);
}

.admin-tab {
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

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

.admin-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.admin-panel {
  display: none;
  max-width: 800px;
}

.admin-panel.active {
  display: block;
}

.admin-list {
  list-style: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-secondary);
  transition: background var(--transition-fast);
}

.admin-list-item:last-child {
  border-bottom: none;
}

.admin-list-item:hover {
  background: var(--bg-tertiary);
}

.admin-list-item .item-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-list-item .item-actions {
  display: flex;
  gap: var(--space-2);
}

.admin-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid var(--border-primary);
}

/* ---- Admin Form Card ---- */
.admin-form-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.admin-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
}

.admin-form-header h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.admin-form-section {
  padding: var(--space-4) var(--space-6);
  transition: max-height 250ms ease, padding 250ms ease, opacity 200ms ease;
  overflow: hidden;
}

.admin-form-section.collapsed {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.admin-form-actions {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
}

/* ---- Section Toggle ---- */
.admin-section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-6);
  border: none;
  border-top: 1px solid var(--border-secondary);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.admin-section-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-section-chevron {
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.admin-section-toggle.open .admin-section-chevron {
  transform: rotate(90deg);
}

/* ---- P&L Badge ---- */
.admin-pnl-badge {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
}

.pnl-positive {
  background: rgba(46, 160, 67, 0.15);
  color: var(--accent-green);
}

.pnl-negative {
  background: rgba(248, 81, 73, 0.15);
  color: var(--accent-red);
}

/* ---- Trade Stats Chips ---- */
.admin-trade-stats {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.admin-stat-chip {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-secondary);
}

.admin-stat-chip.chip-positive {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.admin-stat-chip.chip-negative {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* ---- Admin Modal ---- */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 150ms ease;
}

.admin-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-primary);
}

.admin-modal-header h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.admin-modal-body {
  padding: var(--space-4);
}

.admin-connect-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.admin-connect-option strong {
  font-size: var(--text-sm);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-tooltip);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideInLeft 200ms ease;
}

.toast-success {
  border-color: var(--accent-green);
}

.toast-error {
  border-color: var(--accent-red);
}

/* ---- Sidebar View Toggle ---- */
.sidebar-view-toggle {
  display: flex;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.sidebar-view-toggle button {
  flex: 1;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-primary);
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.sidebar-view-toggle button:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.sidebar-view-toggle button.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: var(--text-on-accent);
}

/* ---- Trade Stats Panel ---- */
.trade-stats-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}

.trade-stats-panel h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

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

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
}

.stat-value {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.stat-positive {
  color: var(--accent-green);
}

.stat-negative {
  color: var(--accent-red);
}

.stat-mono {
  font-family: var(--font-mono);
}

/* ---- Stats Dashboard (Group Page) ---- */
.stats-dashboard {
  margin-bottom: var(--space-6);
}

.stats-dashboard h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-4);
}

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

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-card .stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.stat-card .stat-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* ---- Stats Table ---- */
.stats-table-wrapper {
  overflow-x: auto;
  margin-top: var(--space-4);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.stats-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid var(--border-primary);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.stats-table th:hover {
  color: var(--text-primary);
}

.stats-table th.sort-asc::after {
  content: ' \u25B2';
  font-size: 9px;
}

.stats-table th.sort-desc::after {
  content: ' \u25BC';
  font-size: 9px;
}

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

.stats-table tr:hover td {
  background: var(--bg-tertiary);
}

.stats-table td a {
  color: var(--text-link);
  text-decoration: none;
  font-weight: var(--weight-semibold);
}

.stats-table td a:hover {
  text-decoration: underline;
}

/* ---- Histogram ---- */
.histogram-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.histogram-container h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.histogram-container canvas {
  width: 100%;
  height: 180px;
  display: block;
}

/* ---- Badge Gain/Loss ---- */
.badge-gain {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
  background: rgba(46, 160, 67, 0.15);
  color: var(--accent-green);
}

.badge-loss {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
  background: rgba(248, 81, 73, 0.15);
  color: var(--accent-red);
}

.badge-setup {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-secondary);
}

/* ---- Global Stats Bar ---- */
.global-stats-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  font-size: var(--text-sm);
}

.global-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.global-stat .stat-label {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.global-stat .stat-value {
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
}

.global-stat-divider {
  width: 1px;
  height: 16px;
  background: var(--border-primary);
}

/* ---- Market Condition Colors ---- */
.market-uptrend { color: var(--accent-green); }
.market-uptrend-pressure { color: var(--accent-orange); }
.market-correction { color: var(--accent-red); }

/* ---- Returns by Period Table ---- */
.returns-period-table {
  margin-top: var(--space-4);
}

.returns-period-table h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

/* ---- Responsive: Stats ---- */
@media (max-width: 768px) {
  .trade-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .global-stats-bar {
    gap: var(--space-2);
  }
  .global-stat-divider {
    display: none;
  }
}

@media (max-width: 480px) {
  .trade-stats-grid {
    grid-template-columns: 1fr;
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
}
