/* ==========================================
   PORTFOLIO ANALYSIS & HOLDINGS BREAKDOWN
   ========================================== */

.portfolio-analysis-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 992px) {
  .portfolio-analysis-row {
    grid-template-columns: 4.5fr 7.5fr;
  }
}

.analysis-card {
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header-compact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 8px;
}

.card-label-strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.card-subtitle-compact {
  font-size: 11px;
  color: var(--text-muted);
}

/* Allocation Visuals */
.allocation-visual-wrapper {
  display: grid;
  grid-template-columns: minmax(150px, 0.85fr) minmax(0, 1.15fr);
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
  flex-grow: 1;
}

.allocation-donut {
  --stock-pct: 0%;
  --cash-end-pct: 0%;
  position: relative;
  width: 168px;
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent) 0 var(--stock-pct),
    var(--success) var(--stock-pct) var(--cash-end-pct),
    var(--warning) var(--cash-end-pct) 100%
  );
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.1);
  align-self: center;
  justify-self: center;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.allocation-donut.is-empty {
  background: rgba(148, 163, 184, 0.14);
  box-shadow: none;
}

.allocation-donut::before {
  content: '';
  position: absolute;
  inset: 21px;
  border-radius: 50%;
  background: #101a2d;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.allocation-donut-center {
  position: absolute;
  inset: 30px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.allocation-donut-center span {
  color: var(--text-muted);
  font-size: 10px;
}

.allocation-donut-center strong {
  margin-top: 3px;
  color: var(--text-primary);
  font-size: 13px;
}

.allocation-legend-grid {
  display: contents;
}

.alloc-legend-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-input);
}

.alloc-legend-item:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.alloc-legend-item:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

@media (max-width: 680px) {
  .allocation-visual-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .allocation-legend-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .alloc-legend-item:nth-child(1),
  .alloc-legend-item:nth-child(2) {
    grid-column: auto;
    grid-row: auto;
    align-items: flex-start;
  }
}

.alloc-legend-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.dot-stock { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.dot-cash { background: var(--success); box-shadow: 0 0 6px var(--success-glow); }
.dot-other { background: var(--warning); box-shadow: 0 0 6px var(--warning-glow); }

.alloc-legend-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.alloc-legend-title {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.alloc-legend-val {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.alloc-legend-pct {
  font-size: 11px;
  color: var(--text-muted);
}

/* Holdings Detail List */
.holdings-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar styling */
.holdings-list-container::-webkit-scrollbar {
  width: 4px;
}
.holdings-list-container::-webkit-scrollbar-track {
  background: transparent;
}
.holdings-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.holding-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-input);
  transition: transform 0.2s, border-color 0.2s;
}

.holding-list-item:hover {
  transform: translateX(2px);
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.holding-item-ticker-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.holding-ticker-badge {
  width: 42px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-badge);
  text-transform: uppercase;
}

/* Custom ticker colors */
.badge-rsp { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.35); }
.badge-spmo { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-boxx { background: rgba(20, 184, 166, 0.15); color: #2dd4bf; border: 1px solid rgba(20, 184, 166, 0.3); }
.badge-sgov { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.35); }
.badge-cash { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-other { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

.holding-ticker-name-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.holding-ticker-symbol {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.holding-ticker-fullname {
  font-size: 9px;
  color: var(--text-secondary);
}

.holding-item-metrics {
  display: flex;
  gap: 18px;
}

.holding-metric-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 70px;
}

.holding-metric-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.holding-metric-label {
  font-size: 9px;
  color: var(--text-secondary);
}

.pnl-up { color: var(--success) !important; }
.pnl-down { color: var(--danger) !important; }
.pnl-neutral { color: var(--text-secondary) !important; }

.holdings-loading {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

.portfolio-insight-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 992px) {
  .portfolio-insight-row {
    grid-template-columns: 1fr 1fr;
  }
}

.pnl-breakdown-container,
.cashflow-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
}

.pnl-metric-grid,
.cashflow-metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pnl-metric-grid div,
.cashflow-metric-list div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-input);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.025);
}

.pnl-metric-grid span,
.cashflow-metric-list span,
.cashflow-node span,
.cashflow-node small {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.pnl-metric-grid strong,
.cashflow-metric-list strong {
  color: var(--text-primary);
  font-size: 13px;
}

.pnl-metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pnl-contributor-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 2px;
}

.pnl-contributor-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pnl-contributor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.pnl-contributor-head span {
  color: var(--text-secondary);
  font-weight: 700;
}

.pnl-contributor-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.pnl-contributor-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.pnl-contributor-fill.positive {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.45), rgba(45, 212, 191, 0.9));
}

.pnl-contributor-fill.negative {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.45), rgba(248, 113, 113, 0.9));
}

.cashflow-river {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cashflow-node {
  padding: 14px 16px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.045);
  background: rgba(255, 255, 255, 0.018);
}

.cashflow-node strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1.15;
}

.cashflow-node.outflow {
  border-color: rgba(59, 130, 246, 0.16);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.10), rgba(15, 23, 42, 0.24));
}

.cashflow-node.inflow {
  border-color: rgba(59, 130, 246, 0.16);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.10), rgba(15, 23, 42, 0.24));
}

@media (max-width: 680px) {
  .portfolio-tab-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .daily-change-panel,
  .portfolio-pnl-overview,
  .portfolio-pnl-detail-grid,
  .pnl-metric-grid,
  .cashflow-metric-list,
  .cashflow-river {
    grid-template-columns: 1fr;
  }

  .daily-change-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portfolio-pnl-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .portfolio-pnl-range-controls {
    max-width: 100%;
    overflow-x: auto;
  }

  .portfolio-pnl-kpi-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-pnl-custom-range {
    align-items: stretch;
    flex-direction: column;
  }

  .portfolio-pnl-custom-range input {
    width: 100%;
  }
}

/* ==========================================
   PRICE ACTION JOURNAL
   ========================================== */
.price-action-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-subtitle {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}

.journal-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.journal-stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.025);
}

.journal-stat-card span,
.journal-stat-card small {
  display: block;
  color: var(--text-secondary);
  font-size: 11px;
}

.journal-stat-card strong {
  display: block;
  margin: 5px 0 3px;
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1.1;
}

.journal-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.045);
  background: rgba(255, 255, 255, 0.018);
}

.journal-filter-tabs-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.journal-filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.journal-filter-controls select,
.journal-filter-controls input {
  min-height: 36px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 12px;
}

.journal-filter-controls input {
  width: min(280px, 28vw);
}

.quality-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: var(--radius-badge);
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.quality-badge.quality-planned {
  border-color: rgba(59, 130, 246, 0.22);
  background: rgba(59, 130, 246, 0.1);
  color: var(--success);
}

.quality-badge.quality-minor {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.quality-badge.quality-major,
.quality-badge.quality-emotional {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.journal-mode-tabs {
  min-height: 38px;
  flex-shrink: 0;
}

.journal-mode-tabs .filter-btn,
.pa-form-mode-tabs .filter-btn {
  white-space: nowrap;
}

.pa-form-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 42px;
}

.label-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 18px;
  margin-bottom: 3px;
}

.label-action-row label {
  margin-bottom: 0 !important;
}

.field-link-btn {
  padding: 0;
  background: transparent;
  color: var(--accent-hover);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
}

.field-link-btn:hover {
  color: var(--text-primary);
}

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

.journal-setup-actions input {
  flex: 1;
  min-height: 36px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 12px;
}

.journal-setup-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.journal-setup-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 7px 4px 10px;
  border-radius: var(--radius-badge);
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
  font-size: 12px;
}

.journal-setup-chip button {
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
}

.journal-setup-chip button:hover {
  background: rgba(255, 255, 255, 0.11);
  color: var(--text-primary);
}

.modal-content-pa-setup {
  width: min(620px, calc(100vw - 32px)) !important;
  max-width: 620px !important;
}

.modal-content-pa-setup .modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.journal-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px;
}

.journal-charts-grid .journal-chart-card:nth-child(1) {
  grid-row: 1;
  grid-column: 1;
}

.journal-charts-grid .journal-chart-card:nth-child(2) {
  grid-row: 2;
  grid-column: 1 / -1;
}

.journal-charts-grid .journal-chart-card:nth-child(3) {
  grid-row: 1;
  grid-column: 2;
}

.journal-chart-card {
  min-height: 310px;
  padding: 16px !important;
}

.journal-chart-wrapper {
  height: 240px;
  min-height: 0;
  margin-top: 12px;
  position: relative;
}

.journal-screenshot-wall-card {
  padding: 16px !important;
}

.journal-screenshot-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: 330px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
  padding-right: 4px;
}

.journal-screenshot-wall::-webkit-scrollbar {
  width: 5px;
}

.journal-screenshot-wall::-webkit-scrollbar-track {
  background: transparent;
}

.journal-screenshot-wall::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.journal-screenshot-wall::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.journal-screenshot-card {
  contain: content;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-primary);
  text-align: left;
  transition: border-color 0.1s ease;
}

.journal-screenshot-card:hover {
  border-color: rgba(96, 165, 250, 0.36);
  background: rgba(30, 41, 59, 0.58);
}

.journal-screenshot-preview-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.journal-screenshot-preview-btn img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: rgba(2, 6, 23, 0.72);
}

.journal-screenshot-meta,
.journal-screenshot-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px 0;
  min-width: 0;
}

.journal-screenshot-tags {
  justify-content: space-between;
  padding-bottom: 9px;
}

.journal-screenshot-quality-select {
  min-width: 88px;
  max-width: 96px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-badge);
  border: 1px solid rgba(148, 163, 184, 0.14);
  background-color: rgba(15, 23, 42, 0.76);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.journal-screenshot-quality-select:disabled {
  cursor: wait;
  opacity: 0.7;
}

.journal-screenshot-quality-select.quality-planned {
  border-color: rgba(59, 130, 246, 0.22);
  color: var(--success);
}

.journal-screenshot-quality-select.quality-minor {
  border-color: rgba(245, 158, 11, 0.24);
  color: var(--warning);
}

.journal-screenshot-quality-select.quality-major,
.journal-screenshot-quality-select.quality-emotional {
  border-color: rgba(239, 68, 68, 0.24);
  color: var(--danger);
}

.journal-screenshot-quality-select option.quality-option-planned {
  color: var(--success);
}

.journal-screenshot-quality-select option.quality-option-minor {
  color: var(--warning);
}

.journal-screenshot-quality-select option.quality-option-major,
.journal-screenshot-quality-select option.quality-option-emotional {
  color: var(--danger);
}

.journal-screenshot-symbol {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-screenshot-meta .font-mono {
  color: var(--text-muted);
  font-size: 10.5px;
  margin-left: auto;
  white-space: nowrap;
}

.journal-screenshot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  border-radius: var(--radius-input);
  border: 1px dashed rgba(148, 163, 184, 0.18);
  color: var(--text-secondary);
  font-size: 12px;
  background: rgba(15, 23, 42, 0.28);
}

.journal-table-wrapper {
  max-height: 520px;
}

#price-action-table th,
#price-action-table td {
  white-space: nowrap;
}

#price-action-table .journal-notes-cell {
  max-width: 220px;
}

#price-action-table .journal-price-cell {
  color: var(--text-secondary);
  font-size: 11px;
}

#price-action-table .journal-price-cell.text-success {
  color: var(--success) !important;
}

#price-action-table .journal-price-cell.text-danger {
  color: var(--danger) !important;
}

.journal-image-link {
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.journal-image-link:hover {
  color: var(--text-primary);
}

.journal-day-summary-row {
  background: rgba(15, 23, 42, 0.32);
}

.journal-day-summary-row.is-expanded {
  background: rgba(37, 99, 235, 0.08);
}

.journal-day-detail-row > td {
  padding: 0 !important;
  background: rgba(2, 6, 23, 0.22);
}

.journal-detail-table-wrap {
  padding: 10px 14px 14px;
  overflow-x: auto;
}

.journal-detail-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  overflow: hidden;
}

.journal-detail-table th,
.journal-detail-table td {
  padding: 10px 12px !important;
  font-size: 12px;
}

.journal-detail-table th {
  background: rgba(15, 23, 42, 0.72);
}

.modal-content-image-preview {
  width: min(1180px, calc(100vw - 40px)) !important;
  max-width: 1180px !important;
  height: min(860px, calc(100vh - 40px)) !important;
  max-height: calc(100vh - 40px) !important;
  display: flex !important;
  flex-direction: column !important;
}

.modal-content-image-preview .modal-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content-image-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.72);
}

.modal-content-price-action {
  width: min(980px, calc(100vw - 32px)) !important;
  max-width: 980px !important;
  max-height: calc(100vh - 32px) !important;
  display: flex !important;
  flex-direction: column !important;
}

.modal-content-price-action .form-group {
  margin-bottom: 12px;
  gap: 5px;
}

.modal-content-price-action .form-group label {
  margin-bottom: 3px;
}

.modal-content-price-action .form-group input,
.modal-content-price-action .form-group select {
  padding: 10px 12px;
}

.modal-content-price-action #pa-pnl-amount[readonly] {
  background: rgba(15, 23, 42, 0.72) !important;
  color: var(--text-primary) !important;
  border-color: rgba(96, 165, 250, 0.18) !important;
  cursor: default;
}

.modal-content-price-action .form-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-content-price-action .form-row-3col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modal-content-price-action .form-row-4col {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(160px, 1fr) minmax(140px, 0.85fr) minmax(190px, 1.1fr);
  gap: 12px;
}

.modal-content-price-action .modal-body {
  overflow-y: auto !important;
  padding-right: 4px;
  flex: 1;
}

.modal-content-price-action textarea {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
}

.modal-content-price-action textarea:focus,
.journal-filter-controls select:focus,
.journal-filter-controls input:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.journal-screenshot-dropzone {
  min-height: 58px;
  margin-bottom: 0;
}

.pa-prefill-panel {
  margin-bottom: 14px !important;
  padding: 10px 12px 12px;
  border: 1px solid rgba(96, 165, 250, 0.12);
  border-radius: var(--radius-input);
  background: rgba(59, 130, 246, 0.028);
}

.pa-prefill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 22px;
  margin-bottom: 8px;
}

.pa-prefill-header label {
  margin-bottom: 0 !important;
}

.journal-parse-dropzone {
  min-height: 46px;
  padding: 8px 12px;
  border-color: rgba(96, 165, 250, 0.26);
  background: rgba(15, 23, 42, 0.34);
}

.journal-parse-dropzone:hover,
.journal-parse-dropzone.dragover,
.journal-parse-dropzone:focus-visible {
  border-color: rgba(96, 165, 250, 0.58);
  background: rgba(59, 130, 246, 0.07);
}

.journal-image-preview {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  min-height: 72px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.42);
  overflow: hidden;
}

.journal-parse-preview {
  grid-template-columns: 88px minmax(0, 1fr);
  min-height: 58px;
  margin-top: 8px;
  padding: 6px 8px;
  border-color: rgba(96, 165, 250, 0.16);
  background: rgba(15, 23, 42, 0.48);
}

.journal-image-preview img {
  width: 100%;
  height: 56px;
  min-height: 0;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 6, 23, 0.55);
}

.journal-parse-preview img {
  height: 46px;
}

.journal-parse-preview .journal-image-preview-actions .action-btn,
.journal-parse-preview .journal-image-preview-actions .btn-delete-trade {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}

.journal-image-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.journal-image-preview-actions span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  min-width: 92px;
}

.journal-image-preview-actions > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.pa-ai-prefill-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.pa-ai-prefill-status[hidden] {
  display: none;
}

.pa-ai-prefill-status.is-loading {
  color: #bfdbfe;
}

.pa-ai-prefill-status.is-success {
  border-color: rgba(59, 130, 246, 0.22);
  background: rgba(59, 130, 246, 0.07);
  color: #a7f3d0;
}

.pa-ai-prefill-status.is-error {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.07);
  color: #fecaca;
}

.pa-ai-prefill-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.9;
}

.pa-ai-prefill-status.is-loading .pa-ai-prefill-dot {
  animation: pulse-glow 1.4s infinite;
}

.modal-content-price-action .settings-actions {
  position: sticky;
  bottom: -1px;
  z-index: 2;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(10, 15, 30, 0), rgba(10, 15, 30, 0.96) 28%);
}

.modal-content-price-action .settings-actions .action-btn,
.journal-image-preview-actions .action-btn,
.journal-image-preview-actions .btn-delete-trade {
  white-space: nowrap;
}

@media (max-width: 980px) {
  .journal-stats-grid,
  .journal-charts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .journal-charts-grid .journal-chart-card:last-child {
    grid-column: 1 / -1;
  }

  #signals-view .summary-support-grid.summary-grid-4col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journal-filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .journal-filter-tabs-group {
    width: 100%;
  }

  .journal-filter-controls input {
    width: 100%;
  }

  .journal-screenshot-wall {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .journal-screenshot-card {
    flex: 0 0 172px;
    scroll-snap-align: start;
  }
}

@media (max-width: 680px) {
  .journal-stats-grid,
  .journal-charts-grid,
  .modal-content-price-action .form-row,
  .modal-content-price-action .form-row-3col,
  .modal-content-price-action .form-row-4col,
  .journal-filter-controls {
    grid-template-columns: 1fr;
  }

  .journal-charts-grid .journal-chart-card:nth-child(1),
  .journal-charts-grid .journal-chart-card:nth-child(2),
  .journal-charts-grid .journal-chart-card:nth-child(3) {
    grid-row: auto;
    grid-column: auto;
  }

  .journal-filter-controls {
    display: grid;
  }

  .journal-image-preview {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .pa-prefill-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .pa-ai-prefill-status {
    white-space: normal;
  }

  .journal-image-preview img {
    height: 48px;
  }

  .journal-image-preview-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .journal-image-preview-actions > div {
    width: 100%;
  }

  .journal-stat-card strong {
    font-size: 19px;
  }
}




/* Health Analytics Card Hover Effect */
#health-analytics-card {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
#health-analytics-card:hover {
  border-color: rgba(59, 130, 246, 0.35) !important;
  box-shadow: 0 8px 30px 0 rgba(0, 0, 0, 0.3), 0 0 12px rgba(59, 130, 246, 0.15) !important;
  transform: translateY(-2px);
}
#health-analytics-card:hover .view-details-hover-text {
  gap: 8px !important;
}

/* Website Analytics Modal Styles */
.modal-content-analytics {
  max-width: 1100px !important;
  width: calc(100% - 32px) !important;
  height: min(92vh, 920px) !important;
  max-height: calc(100vh - 32px) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px !important;
  overflow: hidden !important;
}
.modal-content-analytics .modal-header {
  flex: 0 0 auto;
}
.modal-content-analytics .modal-body {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  padding: 10px 4px 28px !important;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-height: 820px) {
  .modal-content-analytics {
    height: calc(100vh - 20px) !important;
    padding: 18px !important;
  }

  .modal-content-analytics .modal-body {
    gap: 18px;
    padding-bottom: 22px !important;
  }

  .modal-content-analytics .metric-card {
    min-height: 74px;
  }

  .modal-content-analytics .chart-container-card {
    min-height: 260px;
  }
}

/* ==========================================
   SCROLL PERFORMANCE PASS
   Keep the dark surface style while avoiding expensive repaint work on long pages.
   ========================================== */
body {
  background-attachment: scroll;
}

.dashboard-header,
.dashboard-tabs,
.dashboard-main .glass-card,
.backtest-layout .glass-card,
#signals-view .glass-card,
#price-action-view .glass-card,
#strategy-view .glass-card,
#health-view .glass-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.dashboard-main .glass-card:hover,
.backtest-layout .glass-card:hover,
#signals-view .glass-card:hover,
#price-action-view .glass-card:hover,
#strategy-view .glass-card:hover,
#health-view .glass-card:hover {
  box-shadow: var(--shadow-panel) !important;
  transform: none !important;
}

.dashboard-main > section,
.backtest-layout > div,
#signals-view > section,
#price-action-view > section,
#strategy-view > section,
#health-view > section {
  min-height: 1px;
  content-visibility: auto;
  contain-intrinsic-size: 720px;
}

.chart-container-card,
.table-wrapper,
.journal-table-wrapper,
.transactions-section,
.journal-chart-card {
  min-height: 1px;
}

.journal-screenshot-wall-card,
.backtest-chart-card,
.backtest-attribution-card,
.backtest-heatmap-card,
.backtest-logs-card,
.analytics-charts-grid,
.portfolio-pnl-card {
  content-visibility: auto;
  contain-intrinsic-size: 520px;
}

.backtest-heatmap-card {
  content-visibility: visible;
  contain: layout style;
  overflow: visible;
}

.chart-container-card,
.journal-chart-card {
  min-height: 310px;
}

.table-wrapper,
.journal-table-wrapper {
  min-height: 96px;
}

.transactions-section {
  min-height: 180px;
}

.ai-drawer:not(.active) .ai-drawer-backdrop,
.ai-drawer:not(.active) .ai-drawer-content {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
}

.table-limit-row td {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  background: rgba(15, 23, 42, 0.42);
}

.chart-loading-overlay {
  background: rgba(10, 15, 30, 0.72);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ==========================================
   HOLDINGS PAGE SPACING RHYTHM
   ========================================== */
:root {
  --page-section-gap: 16px;
}

.app-container,
.dashboard-main {
  gap: var(--page-section-gap);
}

.dashboard-tabs {
  margin: 0;
}

#signals-view > .portfolio-tab-header,
#signals-view > .transactions-section {
  margin: 0;
}

#signals-view > .transactions-section {
  margin-top: 0;
}

.chart-loading-overlay .shimmer-placeholder {
  inset: 18px;
  width: auto;
  height: auto;
  opacity: 0.55;
}

/* ==========================================
   PORTFOLIO ANALYSIS & CALENDAR CUSTOM CONTROLS
   ========================================== */
.portfolio-pnl-chart-type-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 999px;
  margin-top: 12px;
  align-self: flex-start;
}

.portfolio-pnl-chart-type-toggle button {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portfolio-pnl-chart-type-toggle button.active {
  background: rgba(59, 130, 246, 0.18);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.22);
}

.portfolio-pnl-calendar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portfolio-pnl-calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(2, 6, 23, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.portfolio-pnl-calendar-nav .nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  font-weight: bold;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portfolio-pnl-calendar-nav .nav-btn:hover {
  color: var(--text-primary);
}

.portfolio-pnl-calendar-nav strong {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  min-width: 60px;
  text-align: center;
  font-weight: 800;
}

.portfolio-pnl-calendar-mode,
.portfolio-pnl-calendar-type {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.portfolio-pnl-calendar-mode button,
.portfolio-pnl-calendar-type button {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portfolio-pnl-calendar-mode button.active,
.portfolio-pnl-calendar-type button.active {
  background: rgba(59, 130, 246, 0.18);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.2);
}

.portfolio-pnl-calendar-cell.is-month-cell {
  height: 52px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

/* --- PRICE ACTION BATCH ENTRY STYLES --- */

/* Modal width expansion in batch mode */
.modal-content-price-action.modal-batch-mode {
  width: min(1200px, calc(100vw - 32px)) !important;
  max-width: 1200px !important;
}

/* Tabs */
.pa-modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 8px;
}

.pa-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.pa-tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.pa-tab-btn.active {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.2);
}

.pa-tab-btn:active {
  transform: scale(0.97);
}

/* Shared screenshot block layout adjustment */
.pa-screenshot-group-public {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Common configuration panel */
.pa-batch-common-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.pa-batch-common-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.pa-batch-common-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.pa-batch-common-grid .form-group {
  margin-bottom: 0 !important;
}

.pa-batch-common-grid label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.pa-batch-common-grid select,
.pa-batch-common-grid input {
  padding: 8px 10px !important;
  font-size: 12px !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}

/* High-density batch table */
.pa-batch-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.2);
  margin-bottom: 12px;
}

.pa-batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.pa-batch-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 8px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pa-batch-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.pa-batch-table tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.pa-batch-row-index {
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: monospace;
}

/* Minimal Table Inputs */
.pa-batch-table input,
.pa-batch-table select {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.pa-batch-table input:hover,
.pa-batch-table select:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

.pa-batch-table input:focus,
.pa-batch-table select:focus {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
  outline: none;
}

.pa-batch-table input[readonly] {
  background: rgba(0, 0, 0, 0.12) !important;
  color: #a1a1aa !important;
  border-color: transparent !important;
  cursor: not-allowed;
}

/* Actions Row */
.pa-batch-actions-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-sm {
  padding: 6px 12px !important;
  font-size: 11.5px !important;
  min-height: 28px !important;
}

.pa-batch-table .row-action-btn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pa-batch-table .row-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.pa-batch-table .row-action-btn.btn-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* CSV Paste Container */
.pa-csv-paste-panel {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  margin-bottom: 16px;
}

.pa-csv-paste-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pa-csv-paste-panel textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.06);
  font-family: monospace;
  font-size: 12px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 4px;
}

/* Drawdown Split Container */
.drawdown-split-container {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 12px;
  margin-top: 10px;
  flex: 1;
}

.drawdown-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

.drawdown-col .price-display {
  font-size: 20px;
}

.drawdown-col .price-change-percent {
  font-size: 12px;
}

.drawdown-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  align-self: stretch;
}

.asset-indicator {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

/* --- High Density Dashboard Card Optimizations --- */
/* Sparkline Container */
.price-value-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.price-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sparkline-container {
  width: 100px;
  height: 38px;
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sparkline-path {
  fill: none;
  stroke-width: 2.0;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-path.positive {
  stroke: var(--success);
  filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.35));
}

.sparkline-path.negative {
  stroke: var(--danger);
  filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.3));
}

/* Day Range Slider */
.day-range-slider-wrapper {
  margin: 10px 0 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.day-range-slider-wrapper .range-val {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.day-range-slider-wrapper .range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
  flex-grow: 1;
}

.day-range-slider-wrapper .range-thumb {
  width: 6px;
  height: 6px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: -1px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  transition: left 0.3s ease;
}

/* Drawdown Progress Bar */
.drawdown-progress-wrapper {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.drawdown-progress-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 1.5px;
  position: relative;
  width: 100%;
  overflow: hidden;
}

.drawdown-progress-bar {
  height: 100%;
  border-radius: 1.5px;
  width: 0%;
  transition: width 0.3s ease, background 0.3s ease;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
}

.drawdown-progress-bar.warning {
  background: linear-gradient(90deg, var(--warning) 0%, #fbbf24 100%);
}

.drawdown-progress-bar.danger {
  background: linear-gradient(90deg, var(--danger) 0%, #f87171 100%);
  box-shadow: 0 0 6px var(--danger-glow);
  animation: pulse-red-glow 2s infinite ease-in-out;
}

@keyframes pulse-red-glow {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; box-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
}

.drawdown-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: var(--text-muted);
  width: 100%;
}

.drawdown-progress-labels span {
  white-space: nowrap;
}

.range-label-sub {
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.4;
  color: var(--text-secondary);
  margin: 0 4px;
}

/* Strategy Signals Pipeline Flow */
.signals-pipeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  flex: 1;
  justify-content: center;
}

.pipeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 8px 12px;
  position: relative;
  transition: all 0.3s ease;
}

.pipeline-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}

.pipeline-icon {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.pipeline-icon svg {
  width: 14px;
  height: 14px;
}

.pipeline-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
  min-width: 0;
}

.pipeline-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.pipeline-desc {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.pipeline-status-indicator {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Base Buy active state */
.pipeline-item.active {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.03);
}

.pipeline-item.active .pipeline-icon {
  background: rgba(59, 130, 246, 0.1);
  color: var(--success);
  border-color: rgba(59, 130, 246, 0.2);
}

.pipeline-item.active .pipeline-status-indicator {
  background: var(--success-glow);
  color: var(--success);
  border-color: rgba(59, 130, 246, 0.2);
}

/* Bonus Buy active state (urgent) */
.pipeline-item.active-bonus {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.03);
}

.pipeline-item.active-bonus .pipeline-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
  animation: pulse-danger-border 2s infinite ease-in-out;
}

.pipeline-item.active-bonus .pipeline-status-indicator {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Pending monitoring state */
.pipeline-status-indicator.monitoring {
  background: rgba(59, 130, 246, 0.05);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.15);
  position: relative;
  padding-left: 18px;
}

.pipeline-status-indicator.monitoring::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #3b82f6;
  border-radius: 50%;
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 6px #3b82f6;
  animation: pulse-dot 1.8s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.5; transform: translateY(-50%) scale(0.8); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.2); }
}

@keyframes pulse-danger-border {
  0%, 100% { box-shadow: 0 0 0 0px rgba(239, 68, 68, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Performance guard: keep fast scroll/tab switching from repainting expensive hover effects. */
.tab-btn {
  position: relative;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.tab-btn.is-loading::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: dashboard-tab-loading 0.7s linear infinite;
  pointer-events: none;
}

@keyframes dashboard-tab-loading {
  to { transform: rotate(360deg); }
}

.metric-card,
.glass-card {
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

body.is-interaction-quiet .tab-btn,
body.is-interaction-quiet .action-btn,
body.is-interaction-quiet .icon-btn,
body.is-interaction-quiet .filter-btn,
body.is-interaction-quiet .row-actions button,
body.is-interaction-quiet .link-btn,
body.is-interaction-quiet .btn-edit-trade,
body.is-interaction-quiet .btn-delete-trade,
body.is-interaction-quiet .metric-card,
body.is-interaction-quiet .glass-card,
body.is-interaction-quiet .rule-box,
body.is-interaction-quiet .summary-item,
body.is-interaction-quiet .stats-box {
  transition: none !important;
}

body.is-interaction-quiet .metric-card:hover,
body.is-interaction-quiet .glass-card:hover,
body.is-interaction-quiet .rule-box:hover,
body.is-interaction-quiet .summary-item:hover,
body.is-interaction-quiet .stats-box:hover,
body.is-interaction-quiet .tab-btn:hover,
body.is-interaction-quiet .action-btn:hover,
body.is-interaction-quiet .icon-btn:hover,
body.is-interaction-quiet .filter-btn:hover,
body.is-interaction-quiet .row-actions button:hover,
body.is-interaction-quiet .link-btn:hover,
body.is-interaction-quiet .btn-edit-trade:hover,
body.is-interaction-quiet .btn-delete-trade:hover {
  transform: none !important;
  box-shadow: none !important;
}

body.is-interaction-quiet .heatmap-tooltip,
body.is-interaction-quiet .chartjs-tooltip,
body.is-interaction-quiet [role="tooltip"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

body.is-window-resizing *,
body.is-window-resizing *::before,
body.is-window-resizing *::after {
  animation-play-state: paused !important;
  transition: none !important;
}

@media (max-width: 768px) {
  body {
    background-color: #020617;
    background-image: linear-gradient(180deg, #07101f 0%, #030712 44%, #020617 100%);
  }

  .ai-float-trigger {
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    contain: paint;
  }

  .ai-float-trigger:hover {
    transform: translate3d(0, 0, 0);
  }

}

/* IBKR Sync Mode Selector Segmented Control */
.ibkr-sync-mode-selector {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sync-mode-btn {
  flex: 1;
  padding: 7px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s ease;
  background: transparent;
  color: #94a3b8;
  outline: none;
}

.sync-mode-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.02);
}

.sync-mode-btn.active {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
}

/* Limit trades-table height to show approx 5 rows of data */
#trades-table-wrapper {
  max-height: 310px !important;
  overflow-y: auto !important;
}

#trades-table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a !important; /* solid color matching background theme */
}

/* Calendar Tooltip styling */
.calendar-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 10px;
  background: rgba(8, 13, 27, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #dbeafe;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 11px;
  line-height: 1.5;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.calendar-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

body.is-interaction-quiet .calendar-tooltip {
  display: none !important;
}

