@import url("https://fonts.googleapis.com/css2?family=Internal:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  /* --- NEW: Professional Dark Theme (From Screenshot) --- */
  --background-dark: #1c202b;
  --background-light-glass: #2a2e3e;
  --border-color-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #e0e1ec;
  --text-secondary: #8e92b1;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --header-bg: rgba(28, 32, 43, 0.5);

  /* Chart Colors */
  --chart-grid-color: rgba(255, 255, 255, 0.05);
  --chart-tick-color: #8e92b1;

  /* --- UNIVERSAL COLORS --- */
  --accent-blue: #00a3ff;
  --accent-red: #ff3b30; /* Changed from pink to Red */
  --accent-orange: #ff8f00;
  --signal-green: #00e676;
  --signal-red: #ff3b30; /* Changed from pinkish-red to Red */
  --signal-gray: #6c7499;
  --signal-yellow: #ffb700;
  --signal-purple: #9d4edd;
  --stop-loss-color: #ffb700; /* Yellow for stop-loss line annotation */

  --font-primary: "Inter", sans-serif;
  --font-mono: "Roboto Mono", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background-color: var(--background-dark);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  padding: 1rem;
  min-height: 100vh;
  transition:
    background-color 0.4s ease,
    color 0.4s ease;
}

#app-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hidden {
  display: none !important;
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--background-dark);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    visibility 0.3s;
  pointer-events: none;
  visibility: hidden;
}
#loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

#loading-overlay.has-error .loading-icon {
  display: none;
}
#loading-overlay.has-error .error-icon {
  display: block;
}

.loading-icon-container {
  width: 50px;
  height: 50px;
  margin-bottom: 1rem;
  position: relative;
}

#loading-overlay .loading-icon,
#loading-overlay .error-icon {
  width: 100%;
  height: 100%;
}
#loading-overlay .loading-icon {
  animation: spin 1s linear infinite;
}
#loading-overlay .loading-icon svg {
  stroke: var(--accent-blue);
}
#loading-overlay .error-icon svg {
  stroke: var(--accent-red);
}

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

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.cursor-blink {
  animation: blink 1s step-end infinite;
  display: inline-block;
  width: 8px;
  height: 1em;
  background-color: currentColor;
  vertical-align: text-bottom;
  margin-left: 2px;
}

main#main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out 0.2s;
}

main#main-content.loaded {
  opacity: 1;
  visibility: visible;
}

.metrics-grid {
  display: grid;
  gap: 1.5rem;
}

/* --- Price Header Section --- */
.price-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.price-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}

.agi-lock-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 auto;
}

.agi-lock-status.hidden {
  display: none;
}

.agi-lock-status .lock-title {
  color: var(--color-danger);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: pulse-danger 2s infinite;
}

.agi-lock-status .lock-desc {
  color: var(--text-secondary);
  font-size: 0.65rem;
  opacity: 0.7;
  margin-top: 2px;
}

.live-status-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-price-display {
  text-align: center;
}

/* --- UPGRADED AGI Status Icon --- */
.brain-status-indicator {
  position: relative;
  width: 48px;
  height: 48px;
  cursor: help;
  transition:
    transform 0.3s ease,
    filter 0.3s ease;
}

.brain-status-indicator svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.5;
  transition: stroke 0.5s ease;
}

/* Base colors */
.brain-status-indicator.status-monitoring svg {
  stroke: var(--text-secondary);
}
.brain-status-indicator.status-consulting svg {
  stroke: var(--accent-blue);
}
.brain-status-indicator.status-profit svg {
  stroke: var(--signal-green);
}
.brain-status-indicator.status-loss svg {
  stroke: var(--signal-red);
}
.brain-status-indicator.status-cooldown svg {
  stroke: var(--signal-yellow);
}

/* Blinking animations */
.brain-status-indicator.is-blinking.status-consulting {
  animation: pulse-blue 2s infinite ease-in-out;
}
.brain-status-indicator.is-blinking.status-profit {
  animation: pulse-green 1.5s infinite ease-in-out;
}
.brain-status-indicator.is-blinking.status-loss {
  animation: pulse-red 1.5s infinite ease-in-out;
}
.brain-status-indicator.is-blinking.status-cooldown {
  animation: pulse-yellow 2.5s infinite ease-in-out;
}

@keyframes pulse-blue {
  0%,
  100% {
    filter: drop-shadow(0 0 3px var(--accent-blue));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--accent-blue));
    transform: scale(1.1);
  }
}
@keyframes pulse-green {
  0%,
  100% {
    filter: drop-shadow(0 0 3px var(--signal-green));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--signal-green));
    transform: scale(1.1);
  }
}
@keyframes pulse-red {
  0%,
  100% {
    filter: drop-shadow(0 0 3px var(--signal-red));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--signal-red));
    transform: scale(1.1);
  }
}
@keyframes pulse-yellow {
  0%,
  100% {
    filter: drop-shadow(0 0 3px var(--signal-yellow));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--signal-yellow));
    transform: scale(1.1);
  }
}

#price-card-content #current-price {
  font-size: 4rem;
  line-height: 1;
  font-family: var(--font-mono);
}
.price-change-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  color: var(--text-secondary);
}
.price-change-value {
  font-family: var(--font-mono);
  font-weight: 600;
}
.price-change-value.pnl-positive {
  color: var(--signal-green);
}
.price-change-value.pnl-negative {
  color: var(--signal-red);
}

/* --- UPDATED: Top Row Layout --- */
.top-metrics-grid {
  grid-template-columns: 1.75fr 1.25fr;
  gap: 1.5rem;
}
.main-metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric-card,
.chart-container,
.details-container {
  background: var(--background-light-glass);
  border: 1px solid var(--border-color-glass);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px 0 var(--shadow-color);
  min-width: 0; /* Prevents grid blowout from oversized content */
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    opacity 0.3s ease,
    background-color 0.4s ease,
    border-color 0.4s ease,
    padding 0.5s ease;
}

/* Apply hover effects only on devices that support hover properly */
@media (hover: hover) and (pointer: fine) {
  .metric-card:hover,
  .chart-container:hover,
  .details-container:hover {
    /* transform: translateY(-8px); REMOVED to prevent "sticky" feel on touch devices */
    box-shadow: 0 16px 32px 0 rgba(0, 0, 0, 0.25);
  }
}

.full-width {
  grid-column: 1 / -1;
}

/* --- Operational Mode Glow Effects --- */
.glow-reflex {
  box-shadow:
    0 0 25px 0px rgba(255, 137, 0, 0.4),
    inset 0 0 0 1px rgba(255, 137, 0, 0.3);
}
.glow-trend {
  box-shadow:
    0 0 25px 0px rgba(0, 163, 255, 0.4),
    inset 0 0 0 1px rgba(0, 163, 255, 0.3);
}
.glow-long {
  box-shadow:
    0 0 25px 0px rgba(0, 230, 118, 0.5),
    inset 0 0 0 1px rgba(0, 230, 118, 0.4) !important;
}
.glow-short {
  box-shadow:
    0 0 25px 0px rgba(255, 59, 48, 0.5),
    inset 0 0 0 1px rgba(255, 59, 48, 0.4) !important;
}

/* --- NEW: System Bias Glow Effects --- */
.bias-glow-aggressive {
  box-shadow:
    0 0 25px 0px rgba(255, 61, 113, 0.4),
    inset 0 0 0 1px rgba(255, 61, 113, 0.3);
}
.bias-glow-balanced {
  box-shadow:
    0 0 25px 0px rgba(0, 230, 118, 0.3),
    inset 0 0 0 1px rgba(0, 230, 118, 0.2);
}
.bias-glow-defensive {
  box-shadow:
    0 0 25px 0px rgba(0, 163, 255, 0.4),
    inset 0 0 0 1px rgba(0, 163, 255, 0.3);
}
.bias-glow-intelligent {
  box-shadow:
    0 0 25px 0px rgba(255, 183, 0, 0.4),
    inset 0 0 0 1px rgba(255, 183, 0, 0.3);
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-subtitle {
  font-family: var(--font-primary);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.card-value {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
}

.card-value.small-value {
  font-size: 1.5rem;
  line-height: 1.2;
}

/* --- Price Card Styles --- */
#price-card-content .price-value {
  font-weight: 700;
  line-height: 1;
  color: var(--accent-red);
  text-shadow: 0 0 20px rgba(255, 59, 48, 0.5);
  transition:
    color 0.5s ease,
    text-shadow 0.5s ease;
}

/* FIX: Increase specificity to override base magenta color */
#price-card-content .price-value.price-up {
  color: var(--signal-green);
  text-shadow: 0 0 20px rgba(0, 230, 118, 0.5);
}

#price-card-content .price-value.price-down {
  color: var(--signal-red);
  text-shadow: 0 0 20px rgba(255, 61, 113, 0.5);
}

.value-red {
  color: var(--signal-red) !important;
}
.value-green {
  color: var(--signal-green) !important;
}
.value-yellow {
  color: var(--signal-yellow) !important;
}
.value-neutral {
  color: var(--text-primary) !important;
}

/* --- System Brain Card Styles --- */
.signal-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  position: relative;
  background: #0b0e14 !important; /* Always dark and high contrast */
  border: 1px solid var(--border-color-glass);
  color: #ffffff !important;
}

body.theme-light .signal-card {
  background: #e8ecef !important; /* Specific light theme background for readability */
  color: #111827 !important;
}

/* --- Market Session Countdown --- */
.market-session-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color-glass);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.session-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--signal-gray);
  position: relative;
}
.session-status-dot.open {
  background-color: #00bfa5;
}
.session-status-dot.open::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  background-color: rgba(0, 191, 165, 0.2);
  border-radius: 50%;
}

.session-title {
  font-size: 1rem;
  font-weight: 600;
  color: #00bfa5;
}

.session-description {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.session-description strong {
  font-weight: 700;
}

.session-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.session-day-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  width: 30px;
}

.session-progress-bar {
  flex-grow: 1;
  height: 6px;
  background-color: var(--border-color-glass);
  border-radius: 3px;
  position: relative;
}

.session-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #00bfa5;
  border-radius: 3px;
  width: 0%;
  transition: width 1s linear;
}

.session-progress-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background-color: var(--text-primary);
  left: 0%;
  transition: left 1s linear;
}

.session-time-row {
  display: flex;
  justify-content: space-between;
  padding-left: calc(30px + 0.75rem); /* Align with progress bar */
}

.session-time-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.session-footer {
  text-align: center;
  margin-top: 0.25rem;
}

.session-timezone {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* NEW: Signal Header for rebalanced look */
.signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
}

.system-bias-container {
  text-align: right;
  z-index: 10;
}

/* --- NEW: Interactive Bias Selector --- */
.bias-selector {
  display: flex;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border-color-glass);
}
body.theme-light .bias-selector {
  background-color: rgba(0, 0, 0, 0.05);
}

.bias-button {
  padding: 0.5rem 0.9rem; /* Adjusted for single letters */
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.9rem; /* Slightly larger for clarity */
  border-radius: 6px;
  cursor: pointer;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

.bias-button.active {
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* --- NEW: Color coding for active bias buttons --- */
.bias-button.active[data-bias="Aggressive"] {
  background-color: var(--signal-red);
  color: white;
  box-shadow: 0 0 12px var(--signal-red);
}
.bias-button.active[data-bias="Balanced"] {
  background-color: var(--accent-blue);
  color: white;
  box-shadow: 0 0 12px var(--accent-blue);
}
.bias-button.active[data-bias="Defensive"] {
  background-color: var(--signal-green);
  color: #000; /* Black text for better contrast */
  box-shadow: 0 0 12px var(--signal-green);
}
.bias-button.active[data-bias="Intelligent"] {
  background-color: var(--signal-yellow);
  color: #000; /* Black text for better contrast */
  box-shadow: 0 0 12px var(--signal-yellow);
}

#brain-content-wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Allow wrapper to fill height */
  text-align: left;
  gap: 0; /* Let children define gaps */
}

.brain-state-display {
  text-align: left;
  margin-bottom: 0; /* Handled by signal-header */
}

.brain-state-label {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: 8px; /* More rectangular pill look */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

/* Specific Signal States */
.signal-long {
  background-color: var(--signal-green);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.4);
  text-shadow: none;
}
.signal-short {
  background-color: var(--signal-red);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 59, 48, 0.4);
}
.signal-wait {
  background-color: var(--signal-gray);
  color: #fff;
  box-shadow: 0 0 10px rgba(108, 116, 153, 0.3);
}
.signal-learning {
  background-color: var(--signal-yellow);
  color: #000;
  box-shadow: 0 0 20px rgba(255, 214, 10, 0.4);
}
.signal-monitoring {
  background-color: var(--accent-blue);
  color: #fff;
  box-shadow: 0 0 20px rgba(0, 163, 255, 0.4);
}
.signal-error,
.signal-rejected {
  background-color: var(--signal-red);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 59, 48, 0.4);
  animation: pulse-error-glow 1.5s infinite;
}
.signal-training {
  background-color: var(--accent-orange);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 143, 0, 0.4);
}

@keyframes pulse-error-glow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.4);
  }
  50% {
    box-shadow: 0 0 35px rgba(255, 59, 48, 0.6);
  }
}

@media (min-width: 900px) {
  .brain-state-label {
    font-size: 1.75rem; /* Restore for larger screens */
    padding: 0.5rem 1rem; /* Restore padding */
  }
}

.brain-state-reason {
  font-family: var(--font-primary);
  font-size: 1.3rem; /* Increased for better visibility */
  color: inherit; /* Use parent color */
  font-weight: 500;
  min-height: 1.5em; /* Reduced min-height */
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.5;
  margin-top: 0.5rem; /* Slightly more spacing */
}

.brain-context-grid {
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Push to bottom */
  flex-grow: 1; /* Take remaining space */
  padding-top: 1rem;
  border-top: 1px solid var(--border-color-glass);
  margin-top: 1rem;
}

.context-item {
  text-align: left;
}

/* FIX: Add specific rule to ensure AGI Core value is centered */
#agi-core-container {
  text-align: center;
}

.context-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.context-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
}

.context-value.bias-defensive {
  color: var(--accent-blue);
}
.context-value.bias-balanced {
  color: var(--text-primary);
}
.context-value.bias-aggressive {
  color: var(--signal-yellow);
}

/* Specific Signal States moved up for cleaner organization */

#training-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.training-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.training-metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  display: block;
}

.training-metric-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
}

/* --- DAY'S RANGE AND MARKET TENSION REFACTOR --- */
.range-indicator-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.range-bar-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.range-title {
  font-family: var(--font-primary);
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.range-bar {
  width: 100%;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}

.range-track {
  width: 100%;
  height: 4px;
  background-color: var(--border-color-glass);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  transition: background-color 0.5s ease;
}

body.theme-light .range-track {
  background-color: #e0e1ec;
}

.range-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 2px;
  transition:
    width 0.5s ease,
    left 0.5s ease,
    right 0.5s ease,
    background-color 0.5s ease;
}

.zscore-indicator {
  padding: 0;
}

#zscore-container .range-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#zscore-track {
  height: 4px;
  background-color: var(--text-secondary);
  opacity: 0.3;
}
#zscore-fill {
  height: 8px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 4px;
}

.range-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

#zscore-fill.tension-green {
  background-color: var(--signal-green);
}
#zscore-fill.tension-yellow {
  background-color: var(--signal-yellow);
}
#zscore-fill.tension-red {
  background-color: var(--signal-red);
}

#zscore-marker {
  position: absolute;
  top: 50%;
  left: 50%; /* JS will update this */
  width: 14px;
  height: 14px;
  background-color: #000;
  border: 2px solid var(--text-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.5s ease;
  box-shadow: none;
}

/* New Day's Range Marker */
#days-range-marker {
  position: absolute;
  top: 50%; /* Vertically center in parent */
  left: 50%; /* JS will update this */
  width: 0;
  height: 0;
  transform: translate(
    -50%,
    4px
  ); /* Center horizontally, push below the 4px bar */
  transition:
    left 0.5s ease,
    border-bottom-color 0.4s ease;
  /* Create upward-pointing triangle */
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  /* THEME-AWARE ARROW COLOR: Overrides JS inline style. Default is white for dark theme. */
  border-bottom: 8px solid #ffffff !important;
}

/* On light theme, make the arrow dark. */
body.theme-light #days-range-marker {
  border-bottom-color: var(--text-primary) !important;
}

/* Tactical Target Card */
#tactical-target-card {
  display: flex;
  flex-direction: column;
}
.tactical-target-value {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  transition: color 0.4s ease;
  text-shadow: 0 0 15px currentColor;
}

/* NEW: Key Levels Grid in Tactical Target Card */
.key-levels-grid {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color-glass);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.key-level-item {
  text-align: left;
}
.key-level-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.key-level-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  overflow: hidden;
}
.chart-wrapper {
  height: 400px;
  position: relative;
}
#shortTermPriceChart-container .chart-wrapper {
  height: 450px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.chart-header h2 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

/* NEW: Charts Grid Layout */
.charts-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Details Table */
.details-container h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 0.8rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color-glass);
  font-size: 0.9rem;
  line-height: 1.6;
}
th {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}
th:nth-child(n + 2),
td:nth-child(n + 2) {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
}
tbody tr:hover {
  background-color: rgba(42, 45, 73, 0.5);
}

.table-wrapper td.value-red {
  background-color: rgba(255, 61, 113, 0.1);
}
.table-wrapper td.value-green {
  background-color: rgba(0, 230, 118, 0.1);
}
.table-wrapper td.value-yellow {
  background-color: rgba(255, 183, 0, 0.1);
}

/* --- Integrated Order Flow Section --- */
.order-flow-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color-glass);
}

.order-flow-section .card-title {
  margin-bottom: 0.75rem;
}

.order-flow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: center;
  text-align: center;
}

#tactical-target-card .order-flow-grid .card-value {
  font-size: 1.2rem;
}

/* --- NEW: AGI Playbook Card --- */
.playbook-card {
  border-color: var(--accent-blue);
}

#playbook-state {
  text-transform: uppercase;
  /* letter-spacing: 0.05em; */
  line-height: 1.3;
  font-size: 1.3rem;
  word-break: break-word;
}

#playbook-state.playbook-trap {
  color: var(--accent-orange) !important;
}

#playbook-state.playbook-flip {
  color: var(--accent-red) !important;
}

#playbook-state.playbook-breakout {
  color: var(--signal-green) !important;
}

#playbook-state.playbook-reload {
  color: var(--accent-blue) !important;
}

#narrative-sentiment {
  font-size: 1.4rem;
  word-break: break-word;
}

/* --- NEW: AI Grounding Sources --- */
.ai-grounding-sources-wrapper {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color-glass);
}
.ai-grounding-sources-wrapper h5 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-grounding-sources-wrapper ul {
  list-style-type: none;
  padding-left: 0;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ai-grounding-sources-wrapper li {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Collapsible Sections */
.collapsible-container .details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.collapsible-container .details-header h2,
.collapsible-container .details-header h3 {
  margin-bottom: 0;
}

.jetson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.jetson-header h2 {
  margin: 0;
  flex-shrink: 0;
}

.jetson-kpis-container {
  margin: 0;
  flex-grow: 1;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.jetson-header .collapse-toggle {
  flex-shrink: 0;
}
.collapsible-container .collapse-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* FIX: Change arrow direction logic */
.collapsible-container .chevron {
  width: 24px;
  height: 24px;
  fill: var(--text-secondary);
  transition: transform 0.3s ease;
  transform: rotate(-90deg); /* Start pointing right */
}
.collapsible-container.expanded .chevron {
  transform: rotate(0deg); /* Point down when expanded */
}
.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.5s ease-out,
    padding-top 0.5s ease-out,
    margin-top 0.5s ease-out;
}
.collapsible-container.expanded .collapsible-content {
  max-height: 2000px;
  margin-top: 1.5rem;
  transition:
    max-height 0.7s ease-in,
    margin-top 0.7s ease-in;
}

#ai-detailed-analysis-text {
  white-space: pre-wrap;
}

/* Special handling for chart content to avoid margin jump */
.collapsible-container.chart-container.expanded .collapsible-content {
  margin-top: 0;
}

/* NEW: Portfolio & Logs Grid */
.portfolio-and-logs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Performance Log */
#trade-log-card .details-header .card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.icon-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}
.icon-button:hover {
  color: var(--text-primary);
}
.webhook-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--signal-gray);
  cursor: help;
}
.webhook-status.configured {
  background-color: var(--accent-blue);
}
.log-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.log-metric {
  text-align: center;
}
.log-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.log-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
}
.log-value.pnl-positive,
.pnl-positive {
  color: var(--signal-green);
}
.log-value.pnl-negative,
.pnl-negative {
  color: var(--signal-red);
}
.recent-trades-list {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color-glass);
  border-radius: 8px;
  padding: 0 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.trade-log-item {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 2fr;
  gap: 1.5rem;
  padding: 0.75rem 0;
  font-family: var(--font-mono);
  align-items: center;
  word-break: break-word;
}
.trade-log-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color-glass);
}
.trade-log-item.active-trade {
  background-color: rgba(0, 163, 255, 0.1);
  border: 1px solid var(--accent-blue);
  margin: 0 -0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0, 163, 255, 0.3);
}
.trade-col .primary {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}
.trade-col .secondary {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.trade-col .primary.long {
  color: var(--signal-green);
}
.trade-col .primary.short {
  color: var(--signal-red);
}

/* --- Operational Mode Badge in Log --- */
.op-mode-label {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #fff;
  font-weight: bold;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.op-mode-reflex {
  background-color: var(--accent-orange);
}
.op-mode-trend {
  background-color: var(--accent-blue);
}

.no-trades {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
  font-style: italic;
}

/* NEW: Styles for Portfolio Card */
.live-position-container {
  margin-top: 1rem;
}

.live-position-details {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color-glass);
  border-radius: 8px;
  padding: 1rem;
}

.position-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color-glass);
}

.position-direction-label {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
}

.position-direction-label.long {
  color: var(--signal-green);
}
.position-direction-label.short {
  color: var(--signal-red);
}

.position-size-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--text-primary);
}

.position-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.pos-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.pos-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
}

/* Settings Sidebar */
.settings-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: 100%;
  background: #1c202b;
  border-left: 1px solid var(--border-color-glass);
  z-index: 1001;
  transform: translateX(100%);
  transition:
    transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    background-color 0.4s ease;
  display: flex;
  flex-direction: column;
}
.settings-sidebar.sidebar-open {
  transform: translateX(0);
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color-glass);
}
.sidebar-content {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.spx-live-data {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border-color-glass);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.metric-label {
  color: var(--text-secondary);
}
.metric-value {
  font-family: var(--font-mono);
  font-weight: 600;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.form-group input {
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color-glass);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 8px;
  font-family: var(--font-primary);
}
.form-group small {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}
.sidebar-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.button-primary,
.button-secondary,
.button-danger {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}
.button-primary {
  background-color: var(--accent-blue);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 163, 255, 0.2);
}
.button-secondary {
  background-color: var(--border-color-glass);
  color: var(--text-primary);
}
.button-danger {
  background-color: var(--signal-red);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 61, 113, 0.2);
}
.button-success {
  background-color: var(--signal-green) !important;
  color: #000 !important;
  box-shadow: 0 4px 15px rgba(0, 230, 118, 0.2) !important;
}
.button-primary:hover,
.button-secondary:hover,
.button-danger:hover,
.button-success:hover {
  transform: translateY(-2px);
}

/* NEW: Password Visibility Toggle Styles */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrapper input {
  padding-right: 2.75rem; /* Make space for the icon button */
  width: 100%;
}
.password-toggle-button {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}
.password-toggle-button:hover {
  color: var(--text-primary);
}

/* FIX: New styles for AGI Training UI */
.sidebar-section h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1rem;
  margin-bottom: -0.5rem; /* pull actions closer */
  border-bottom: 1px solid var(--border-color-glass);
  padding-bottom: 0.5rem;
}

.skepticism-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--signal-yellow);
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color-glass);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  text-align: center;
}

#calibrate-skepticism-button {
  background-color: var(--signal-yellow);
  color: var(--background-dark);
  box-shadow: 0 4px 15px rgba(255, 183, 0, 0.2);
}

/* --- REDESIGNED: System Log & Webhook Styling --- */
.sidebar-log-container,
#webhook-queue-list {
  max-height: 450px; /* Limit height */
  overflow-y: auto; /* Enable scrolling */
  overscroll-behavior: contain; /* Prevent scroll chaining */
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color-glass);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  user-select: text; /* Ensure text is selectable for copying */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

@media (max-width: 768px) {
  .sidebar-log-container,
  #webhook-queue-list {
    max-height: 300px; /* Smaller max height on mobile to prevent taking up the whole screen */
  }
}

.sidebar-log-container::-webkit-scrollbar,
#webhook-queue-list::-webkit-scrollbar {
  width: 16px; /* Much wider scrollbar for easier grabbing on all devices */
}
.sidebar-log-container::-webkit-scrollbar-track,
#webhook-queue-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05); /* Visible track */
  border-radius: 8px;
  border: 4px solid transparent;
  background-clip: padding-box;
}
.sidebar-log-container::-webkit-scrollbar-thumb,
#webhook-queue-list::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.4); /* Highly visible thumb */
  border-radius: 8px;
  border: 3px solid transparent; /* Creates padding around the thumb */
  background-clip: padding-box; /* Makes the border act as padding */
}
.sidebar-log-container::-webkit-scrollbar-thumb:hover,
#webhook-queue-list::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.6); /* Brighter on hover */
}

.log-entry,
.webhook-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border-radius: 6px;
  border-bottom: 1px solid var(--border-color-glass);
  transition: background-color 0.2s ease;
}
.log-entry:last-child,
.webhook-item:last-child {
  border-bottom: none;
}
.log-entry:hover,
.webhook-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
.log-entry-header,
.webhook-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.log-time,
.webhook-time {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.log-type,
.webhook-directive {
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  display: inline-block;
}
.log-message {
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.6;
  font-size: 0.9rem;
  margin: 0;
}

.log-type-error {
  background-color: var(--signal-red);
  color: white;
}
.log-type-trade {
  background-color: var(--accent-blue);
  color: white;
}
.log-type-plan {
  background-color: var(--signal-yellow);
  color: var(--background-dark);
}
.log-type-system {
  background-color: var(--signal-gray);
  color: white;
}
.log-type-omnibook {
  background-color: var(--signal-purple);
  color: white;
}
.log-type-learning {
  background-color: var(--signal-yellow);
  color: var(--background-dark);
}
.webhook-directive {
  background-color: var(--accent-blue);
  color: white;
}

.log-empty,
.webhook-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
  font-style: italic;
}

/* Theme switcher & Notification Toggle */
.form-group.theme-switcher,
.form-group.notification-toggle-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 24px;
}
.toggle-switch-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch-label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color-glass);
  transition: 0.4s;
  border-radius: 24px;
}
.toggle-switch-switch {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
.toggle-switch-checkbox:checked + .toggle-switch-label {
  background-color: var(--accent-blue);
}
.toggle-switch-checkbox.toggle-switch-danger:checked + .toggle-switch-label {
  background-color: var(--signal-red);
}
.toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-switch {
  transform: translateX(36px);
}

/* NEW: ON/OFF text for toggle switch */
.toggle-switch-inner {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
}
.toggle-switch-inner::after,
.toggle-switch-inner::before {
  content: "OFF";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: bold;
  color: white;
}
.toggle-switch-inner::before {
  content: "ON";
  left: -30px;
}
.toggle-switch-inner::after {
  right: 8px;
}
.toggle-switch-checkbox:checked
  + .toggle-switch-label
  .toggle-switch-inner::before {
  left: 8px;
  transition: left 0.4s ease;
}
.toggle-switch-checkbox:checked
  + .toggle-switch-label
  .toggle-switch-inner::after {
  right: -30px;
  transition: right 0.4s ease;
}

/* --- iOS Install Prompt --- */
.ios-install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--background-light-glass);
  border-top: 1px solid var(--border-color-glass);
  padding: 1.5rem 2rem;
  z-index: 2000;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
}
.ios-install-prompt.visible {
  transform: translateY(0);
}
.ios-install-prompt .close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 1024px) {
  /* Widen breakpoint for tablets */
  .top-metrics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .chart-wrapper {
    height: 40vh;
    min-height: 350px;
  }
  .log-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .trade-log-item {
    grid-template-columns: 1fr 1fr 0.8fr;
    grid-template-rows: auto auto;
    row-gap: 0.5rem;
  }
  .trade-log-item .trade-reason {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
  }
  #current-price,
  .tactical-target-value {
    font-size: 4rem;
  }
  /* Make table and roadmap fit without scrolling */
  .details-container .table-wrapper {
    overflow-x: hidden;
  }
  table th,
  table td {
    font-size: 0.75rem;
    padding: 0.4rem 0.2rem;
  }
  th:nth-child(n + 2),
  td:nth-child(n + 2) {
    font-size: 0.75rem;
  }
  .hide-mobile {
    display: none;
  }

  /* Make jetson KPIs wrap nicely */
  .jetson-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .jetson-header h2 {
    align-self: flex-start;
    margin-bottom: 0;
  }

  .jetson-header .collapse-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
  }

  #jetson-kpis.log-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
  }
}

.log-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  width: auto;
}

.log-metric .log-label {
  font-size: 0.75rem;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.log-metric .log-value {
  font-size: 1.5rem;
  font-weight: 600;
}

.trend-indicator {
  font-size: 0.7em;
  margin-left: 2px;
}

.kpi-subtext {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

@media (max-width: 600px) {
  body {
    padding: 0.5rem;
  }
  #app-container,
  main#main-content,
  .metrics-grid {
    gap: 1rem;
  }
  header {
    display: none;
  }
  .metric-card,
  .chart-container,
  .details-container {
    padding: 1rem;
  }
  .card-value {
    font-size: 1.75rem;
  }
  #current-price,
  .tactical-target-value {
    font-size: 3.5rem;
  }
}

/* --- NEW: Flashing Bias Text --- */
@keyframes flash-green {
  0%,
  100% {
    color: var(--signal-green);
  }
  50% {
    color: var(--text-primary);
  }
}

@keyframes flash-red {
  0%,
  100% {
    color: var(--signal-red);
  }
  50% {
    color: var(--text-primary);
  }
}

.flash-green {
  animation: flash-green 1.5s infinite;
}

.flash-red {
  animation: flash-red 1.5s infinite;
}

/* --- Live Dot Status Styles --- */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-secondary);
  display: inline-block;
  margin-right: 6px;
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.live-dot.active {
  background-color: var(--signal-green);
  box-shadow: 0 0 8px var(--signal-green);
  animation: pulse-live 1.5s infinite;
}

.live-dot.error {
  background-color: var(--signal-red);
  box-shadow: 0 0 8px var(--signal-red);
}

@keyframes pulse-live {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- NEW: Custom Slider Styles (for RR Slider) --- */
.rr-slider-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#rr-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-color-glass);
  border-radius: 3px;
  outline: none;
  opacity: 0.7;
  transition: opacity 0.2s;
  cursor: pointer;
}

#rr-slider:hover {
  opacity: 1;
}

#rr-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent-blue);
  border-radius: 50%;
  border: 3px solid var(--background-dark);
  box-shadow: 0 0 5px var(--accent-blue);
}

#rr-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent-blue);
  border-radius: 50%;
  border: 3px solid var(--background-dark);
  box-shadow: 0 0 5px var(--accent-blue);
  cursor: pointer;
}

#rr-slider-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  width: 60px;
  text-align: right;
}

/* --- NEW: Light Theme --- */
body.theme-light {
  --background-dark: #f4f6f9;
  --background-light-glass: #ffffff;
  --border-color-glass: rgba(0, 0, 0, 0.1);
  --text-primary: #1c202b;
  --text-secondary: #6c7499;
  --shadow-color: rgba(99, 99, 99, 0.2);
  --header-bg: rgba(255, 255, 255, 0.7);
  --chart-grid-color: rgba(0, 0, 0, 0.07);
  --chart-tick-color: #6c7499;
}

body.theme-light .settings-sidebar {
  background: #f4f6f9;
}

body.theme-light .trade-log-item:hover,
body.theme-light tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

body.theme-light .recent-trades-list,
body.theme-light .form-group input,
body.theme-light #system-log-content-main,
body.theme-light .skepticism-display,
body.theme-light .live-position-details {
  background-color: rgba(0, 0, 0, 0.05);
}

body.theme-light #rr-slider {
  background: #e0e1ec;
}

body.theme-light #rr-slider::-webkit-slider-thumb {
  border-color: var(--background-light-glass);
}

body.theme-light #rr-slider::-moz-range-thumb {
  border-color: var(--background-light-glass);
}

/* --- NEW: Glowing border for training mode --- */
.trade-log-card.in-training-session {
  border: 2px solid var(--signal-yellow);
  animation: glow-yellow-border 2s infinite ease-in-out;
}

@keyframes glow-yellow-border {
  0%,
  100% {
    box-shadow:
      0 0 20px -5px var(--signal-yellow),
      inset 0 0 10px rgba(255, 183, 0, 0.2);
  }
  50% {
    box-shadow:
      0 0 35px 0px var(--signal-yellow),
      inset 0 0 15px rgba(255, 183, 0, 0.3);
  }
}

/* --- NEW: Trend indicators for KPI dashboards --- */
.trend-indicator {
  font-size: 0.9em;
  margin-left: 0.25rem;
  vertical-align: text-top;
  display: inline-block;
  font-weight: bold;
}

/* --- Mobile Overrides (Moved to end to ensure precedence) --- */
@media (max-width: 480px) {
  .signal-header {
    margin-bottom: 0.75rem;
  }
  .metric-card,
  .chart-container,
  .details-container {
    padding: 0.75rem;
  }
  .bias-selector {
    padding: 2px;
    border-radius: 4px;
  }
  .bias-button {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    border-radius: 3px;
  }
  .brain-state-label {
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
  }
  .brain-state-reason {
    font-size: 1rem;
    color: var(--text-primary);
    margin-top: 0.25rem;
    line-height: 1.4;
  }
  .brain-context-grid {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }
}

/* --- Terminal Text Bias Colors --- */
.terminal-text-aggressive {
  color: var(--signal-red);
  text-shadow: 0 0 4px rgba(255, 59, 48, 0.3);
  font-weight: 500;
}
.terminal-text-balanced {
  color: var(--accent-blue);
  text-shadow: 0 0 4px rgba(0, 163, 255, 0.3);
  font-weight: 500;
}
.terminal-text-defensive {
  color: var(--signal-green);
  text-shadow: 0 0 4px rgba(0, 230, 118, 0.3);
  font-weight: 500;
}
.terminal-text-intelligent {
  color: var(--signal-yellow);
  text-shadow: 0 0 4px rgba(255, 183, 0, 0.4);
  font-weight: 500;
}

body.theme-light .terminal-text-aggressive {
  color: #d32f2f;
  text-shadow: none;
  font-weight: 600;
}
body.theme-light .terminal-text-balanced {
  color: #0077cc;
  text-shadow: none;
  font-weight: 600;
}
body.theme-light .terminal-text-defensive {
  color: #00a651;
  text-shadow: none;
  font-weight: 600;
}
body.theme-light .terminal-text-intelligent {
  color: #d48c00;
  text-shadow: none;
  font-weight: 600;
}
