/* ==========================================
   DESIGN SYSTEM - TASTE SPECIFICATION
   Dark Tech Glassmorphic Theme
   Variance: 4 | Motion: 3 | Density: 8
   ========================================== */

:root {
  color-scheme: dark;
  /* Color Palette */
  --bg-app: #030712;
  --bg-gradient-start: #0a0f1d;
  --bg-gradient-end: #02040a;
  
  --card-bg: rgba(15, 23, 42, 0.45);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-glow: rgba(59, 130, 246, 0.08);

  --accent-rgb: 59, 130, 246;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.35);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.15);
  --danger: #f43f5e;
  --danger-glow: rgba(244, 63, 94, 0.15);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radii */
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-badge: 6px;
}

/* 2026 reliability and decision hierarchy pass */
#live-monitor-view > * {
  order: 4;
}

#live-monitor-view > .live-decision-strip {
  order: 1;
}

#live-monitor-view > .metrics-grid {
  order: 2;
}

#live-monitor-view > .macro-radar-row {
  order: 3;
}

.live-decision-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 20px 24px;
  border-color: rgba(59, 130, 246, 0.25);
  background: linear-gradient(110deg, rgba(37, 99, 235, 0.12), rgba(15, 23, 42, 0.82) 56%);
}

.live-decision-copy {
  min-width: 0;
}

.live-decision-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.live-decision-copy h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.25;
}

.live-decision-copy p {
  margin: 7px 0 0;
  color: #a8b6ca;
  font-size: 13px;
  line-height: 1.55;
}

.live-confidence-block {
  display: grid;
  flex: 0 0 220px;
  gap: 4px;
  padding-left: 22px;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
}

.live-confidence-block > span,
.live-confidence-block small {
  color: #94a3b8;
  font-size: 12px;
}

.live-confidence-block strong {
  color: #f8fafc;
  font-size: 17px;
}

.live-confidence-block strong[data-quality="live"] { color: #34d399; }
.live-confidence-block strong[data-quality="delayed"],
.live-confidence-block strong[data-quality="last_close"] { color: #fbbf24; }
.live-confidence-block strong[data-quality="stale"],
.live-confidence-block strong[data-quality="unavailable"] { color: #f87171; }

.journal-empty-state {
  padding: 30px 24px;
  text-align: center;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.34);
}

.journal-empty-state p {
  margin: 7px 0 16px;
  color: #94a3b8;
  font-size: 13px;
}

.journal-empty-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.strategy-form-feedback {
  margin-top: 14px;
  padding: 10px 12px;
  color: #94a3b8;
  font-size: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.35);
}

.strategy-form-feedback[data-state="changed"] {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.strategy-form-feedback[data-state="invalid"] {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.28);
}

.strategy-form-feedback ul {
  margin: 7px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

#strategy-config-form input[aria-invalid="true"] {
  border-color: rgba(239, 68, 68, 0.75);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.ai-float-trigger.ai-toolbar-trigger {
  position: static;
  z-index: auto;
  width: auto;
  height: 30px;
  padding: 0 10px;
  gap: 5px;
  border-radius: 6px;
  box-shadow: none;
  animation: none;
}

.ai-toolbar-trigger .sparkle-icon {
  font-size: 13px;
}

.ai-toolbar-trigger .trigger-text {
  display: inline;
  font-size: 12px;
}

.health-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.health-incident-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
}

.health-incident-panel strong,
.health-incident-panel p {
  overflow-wrap: anywhere;
}

.health-incident-panel p {
  margin: 7px 0 0;
  color: #9aa9bc;
  font-size: 12px;
  line-height: 1.55;
  white-space: normal;
}

.health-incident-metrics {
  display: flex;
  flex: 0 0 auto;
  gap: 18px;
  color: #94a3b8;
  font-size: 12px;
}

.table-wrapper:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-view-status[data-state="degraded"] {
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(120, 53, 15, 0.16);
}

.dashboard-view-status[data-state="degraded"] .dashboard-view-status-indicator {
  background: #fbbf24;
}

@media (max-width: 1080px) {
  .health-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .live-decision-strip,
  .health-incident-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-confidence-block {
    width: 100%;
    padding: 12px 0 0;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    border-left: 0;
  }

  .health-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* Reset & Global Elements */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  background-image: radial-gradient(at top, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html {
  background: var(--bg-app);
}

body.scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

body:has(#auth-modal.show) {
  overflow: hidden;
}

html[data-initial-dashboard-view]:not(.dashboard-view-ready) #live-monitor-view,
html[data-initial-dashboard-view]:not(.dashboard-view-ready) #signals-view,
html[data-initial-dashboard-view]:not(.dashboard-view-ready) #price-action-view,
html[data-initial-dashboard-view]:not(.dashboard-view-ready) #strategy-view,
html[data-initial-dashboard-view]:not(.dashboard-view-ready) #backtest-view,
html[data-initial-dashboard-view]:not(.dashboard-view-ready) #health-view {
  display: none !important;
}

html[data-initial-dashboard-view="live-monitor-view"]:not(.dashboard-view-ready) #live-monitor-view,
html[data-initial-dashboard-view="signals-view"]:not(.dashboard-view-ready) #signals-view,
html[data-initial-dashboard-view="price-action-view"]:not(.dashboard-view-ready) #price-action-view,
html[data-initial-dashboard-view="strategy-view"]:not(.dashboard-view-ready) #strategy-view,
html[data-initial-dashboard-view="backtest-view"]:not(.dashboard-view-ready) #backtest-view,
html[data-initial-dashboard-view="health-view"]:not(.dashboard-view-ready) #health-view {
  display: flex !important;
}

html[data-initial-dashboard-view]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn.active {
  color: var(--text-secondary);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

html[data-initial-dashboard-view="live-monitor-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="live-monitor-view"],
html[data-initial-dashboard-view="signals-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="signals-view"],
html[data-initial-dashboard-view="price-action-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="price-action-view"],
html[data-initial-dashboard-view="strategy-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="strategy-view"],
html[data-initial-dashboard-view="backtest-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="backtest-view"],
html[data-initial-dashboard-view="health-view"]:not(.dashboard-view-ready) .dashboard-tabs .tab-btn[data-view="health-view"] {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

/* Main Layout */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header UI */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
  border-radius: 8px;
  position: relative;
  box-shadow: 0 0 15px var(--accent-glow);
}

/* Logo-icon before pseudo element removed to display SVG icons cleanly */

.title-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-text .subtitle {
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-weight: 500;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Connection Status Badge */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-badge);
  border: 1px solid var(--card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-glow 2s infinite;
}

.status-dot.offline {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* Button & Actions UI */
button {
  cursor: pointer;
  border: none;
  outline: none;
}

.action-btn, .icon-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-secondary);
}

.action-btn {
  padding: 12px 24px;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 15px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: var(--text-primary);
  box-shadow: 0 0 15px var(--danger-glow);
  transform: translateY(-1px);
}

.btn-danger:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* Glass Card Definition */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
  position: relative;
  overflow: hidden;
  contain: paint;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

/* Visual Warnings */
.glass-card.card-alert {
  border-color: var(--danger);
  box-shadow: 0 8px 32px var(--danger-glow);
}

/* Layout Main Content */
.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Grid Top metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}

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

@media (min-width: 1024px) {
  .metrics-grid {
    grid-template-columns: 1.1fr 1.1fr 1.8fr 1.6fr;
  }
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 90px;
  padding: 12px 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Badges */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-badge);
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #fde047;
  border-color: rgba(245, 158, 11, 0.2);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.2);
}

.badge-danger {
  background: rgba(244, 63, 94, 0.1);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.2);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.14);
}

/* Metric Display Values */
.price-value-container {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0;
}

.price-display {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.price-change-percent {
  font-size: 13px;
  font-weight: 600;
}

.price-change-percent.positive {
  color: var(--success);
}

.price-change-percent.negative {
  color: var(--danger);
}

.card-footer-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 6px;
  margin-top: 8px;
}

/* Flags Layout */
.flags-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.flag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.flag-label {
  color: var(--text-secondary);
}

.flag-status {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.flag-status.executed {
  background: var(--success-glow);
  color: var(--success);
  border-color: rgba(59, 130, 246, 0.2);
}

.flag-status.pending {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  border-color: var(--card-border);
}

/* Row Layout: Chart + Rules */
.layout-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 1024px) {
  .layout-row {
    flex-direction: row;
  }
}

.flex-grow {
  flex: 1;
}

.chart-container {
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 8px;
}

.chart-wrapper {
  position: relative;
  flex-grow: 1;
  height: 320px;
  width: 100%;
}

/* Rules Section Layout */
.strategy-panel {
  width: 100%;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .strategy-panel {
    width: 380px;
  }
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.rule-box {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px 16px;
  transition: all 0.3s ease;
}

.rule-box:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.1);
}

.rule-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rule-title-row h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.rule-box.active .indicator-dot {
  background-color: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.rule-box.triggered .indicator-dot {
  background-color: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.rule-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.console-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.console-actions button {
  width: 100%;
}

/* History logs table */
.logs-section {
  display: flex;
  flex-direction: column;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.1);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 0;
  font-style: italic;
}

/* Modal UI Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay:not(.show) {
  display: none;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#custom-dialog-modal {
  z-index: 3000;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  margin: 16px;
  background: rgba(15, 23, 42, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 16px !important;
  padding: 28px !important;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
  animation: slide-up 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.close-btn:hover {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.form-group input {
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-sans);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-group input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.form-group input:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.8);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), inset 0 2px 4px rgba(0, 0, 0, 0.2);
  outline: none;
  background: rgba(15, 23, 42, 0.9);
}

.form-group input[readonly] {
  background: rgba(255, 255, 255, 0.02) !important;
  color: var(--text-muted) !important;
  border-color: rgba(255, 255, 255, 0.04) !important;
  cursor: not-allowed;
  box-shadow: none;
}

.settings-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.settings-actions button {
  width: 100%;
}

/* Animations */
@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

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

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Transactions & Forms Custom Styles */
/* Transactions & Forms Custom Styles */
.modal-body select {
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  font-family: var(--font-sans);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.modal-body select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: rgba(15, 23, 42, 0.8);
}

.modal-body select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), inset 0 2px 4px rgba(0, 0, 0, 0.2);
  background-color: rgba(15, 23, 42, 0.9);
}

.modal-body select option {
  background-color: #0f172a;
  color: var(--text-primary);
  padding: 12px;
}

/* Modal Primary Button Special Styling */
#btn-save-trade {
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%) !important;
  color: var(--text-primary);
  border: none;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 14px;
  border-radius: var(--radius-input);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#btn-save-trade:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #2563eb 100%) !important;
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

#btn-save-trade:active {
  transform: translateY(1px);
}

.summary-item {
  background: rgba(255, 255, 255, 0.015) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
  border-radius: var(--radius-card);
  padding: 14px 18px !important;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.summary-item:hover {
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-accent {
  color: var(--accent-hover) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

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

/* ==========================================
   UI REFINEMENT PASS
   Dense product-dashboard polish: lower glow, steadier rhythm.
   ========================================== */
/* Global letter-spacing wipe removed to support Outfit typography tracking */

:root {
  --surface-1: rgba(15, 23, 42, 0.42);
  --surface-2: rgba(8, 13, 26, 0.64);
  --surface-3: rgba(255, 255, 255, 0.025);
  --line-soft: rgba(148, 163, 184, 0.12);
  --line-subtle: rgba(148, 163, 184, 0.08);
  --shadow-panel: 0 14px 34px rgba(0, 0, 0, 0.24);
  --shadow-raised: 0 16px 36px rgba(0, 0, 0, 0.3);
  --radius-badge: 999px;
}

.hidden {
  display: none;
}

.app-container {
  gap: 18px;
}

.dashboard-header,
.dashboard-tabs,
.glass-card,
.modal-content,
.auth-card {
  background: var(--surface-1);
  border-color: var(--line-soft);
  box-shadow: var(--shadow-panel);
}

.dashboard-header {
  min-height: 72px;
  padding: 14px 20px;
}

.logo-icon,
.auth-card .logo-icon {
  box-shadow: none;
}

/* Subtitle, labels, and table header overrides removed to restore tracked uppercase styles */

.header-actions {
  gap: 10px;
}

.btn-logout {
  display: none;
  margin-left: 0;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.26);
}

.btn-icon,
.tab-icon {
  margin-right: 8px;
  flex: 0 0 auto;
}

.btn-icon-sm {
  margin-right: 4px;
  flex: 0 0 auto;
}

.action-btn,
.icon-btn,
.filter-btn,
.row-actions button,
.link-btn,
.btn-edit-trade,
.btn-delete-trade {
  box-shadow: none !important;
}

.action-btn:hover,
.icon-btn:hover,
.filter-btn:hover,
.row-actions button:hover,
.link-btn:hover,
.btn-edit-trade:hover,
.btn-delete-trade:hover {
  transform: none;
  box-shadow: none !important;
}

.btn-primary,
#btn-run-backtest,
#btn-save-trade {
  background: #2563eb !important;
  border: 1px solid rgba(147, 197, 253, 0.28);
}

.btn-primary:hover,
#btn-run-backtest:hover,
#btn-save-trade:hover {
  background: #3b82f6 !important;
}

.glass-card {
  padding: 18px;
  overflow: hidden;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.glass-card::before {
  opacity: 0.45;
}

.metric-card:hover,
.glass-card:hover,
#backtest-view .glass-card:hover {
  border-color: rgba(148, 163, 184, 0.2) !important;
  box-shadow: var(--shadow-panel) !important;
}

.dashboard-main {
  gap: 14px;
}

.metrics-grid,
.layout-row,
.holding-summary-grid {
  gap: 12px;
}

.metric-card {
  min-height: 112px;
}

.card-label,
.summary-label,
.stats-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.price-display {
  font-size: 25px;
}

.section-toolbar,
.app-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-subtle);
}

.compact-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.chart-controls-wrapper,
.timeframe-selector,
.ticker-selector,
.inline-stat-row,
.dialog-actions {
  display: flex;
  align-items: center;
}

.chart-controls-wrapper {
  gap: 12px;
}

.timeframe-selector {
  gap: 6px;
}

.ticker-selector,
.filter-tabs,
.auth-tabs {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-input);
  background: rgba(2, 6, 23, 0.34);
}

.dashboard-tabs {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  padding: 5px;
  gap: 4px;
  scrollbar-width: none;
}

.dashboard-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  min-height: 42px;
  min-width: 118px;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-input);
  white-space: nowrap;
}

.tab-btn.active,
.filter-btn.active {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(96, 165, 250, 0.34);
  box-shadow: none;
}

.summary-item {
  min-height: 76px;
  padding: 12px 14px !important;
  border-radius: var(--radius-input);
  background: var(--surface-3) !important;
  box-shadow: none !important;
}

.summary-label {
  margin-bottom: 5px;
}

.summary-value {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
}

.summary-value-sm {
  font-size: 13px;
}

.accent-value {
  color: var(--accent);
}

.fx-summary-item {
  position: relative;
  overflow: hidden;
}

.fx-summary-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.08));
  pointer-events: none;
}

.fx-summary-item > * {
  position: relative;
}

.fx-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fx-edit-btn {
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius-badge);
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.fx-edit-btn:hover {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.38);
}

.fx-edit-btn:active {
  transform: translateY(1px);
}

.fx-summary-lines {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.fx-summary-lines div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.fx-summary-lines span {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.fx-summary-lines strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 11px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-cost-modal-content {
  max-width: 460px !important;
}

.fx-cost-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fx-cost-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-input);
  background: rgba(255, 255, 255, 0.018);
}

.fx-cost-preview span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.fx-cost-preview strong {
  color: var(--text-primary);
  font-size: 15px;
}

.transactions-section {
  margin-top: 6px;
}

.portfolio-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px !important;
  margin-bottom: 16px;
}

.portfolio-tab-header p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

#signals-view > .portfolio-tab-header {
  content-visibility: visible;
  contain-intrinsic-size: auto;
  min-height: 0;
  padding: 14px 18px !important;
  margin-bottom: 12px;
}

#signals-view > .portfolio-tab-header p {
  margin-top: 4px;
}

#signals-view .holding-summary-grid {
  align-items: stretch;
}

#signals-view .holding-summary-grid .summary-item {
  display: flex;
  flex-direction: column;
  min-height: 128px;
  height: 100%;
}

#signals-view .holding-summary-grid .summary-item:not(.fx-summary-item) {
  padding: 16px 18px !important;
}

#signals-view .holding-summary-grid .summary-item:not(.fx-summary-item) .summary-label {
  margin-bottom: 8px;
}

.portfolio-section-nav {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(7, 13, 26, 0.96);
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.28);
  scrollbar-width: none;
}

.portfolio-section-nav::-webkit-scrollbar {
  display: none;
}

.portfolio-section-nav a {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.portfolio-section-nav a:hover {
  color: var(--text-primary);
}

.portfolio-section-nav a.active {
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.16);
}

.portfolio-decision-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.1), rgba(15, 23, 42, 0.34) 58%);
}

.portfolio-decision-kicker {
  color: #93c5fd;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.portfolio-decision-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.portfolio-decision-content strong {
  color: var(--text-primary);
  font-size: 14px;
}

.portfolio-decision-content span {
  color: var(--text-muted);
  font-size: 12px;
}

.portfolio-decision-status {
  padding: 5px 9px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.portfolio-decision-status.balanced {
  border-color: rgba(16, 185, 129, 0.24);
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.08);
}

.portfolio-decision-status.attention {
  border-color: rgba(245, 158, 11, 0.24);
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.08);
}

.portfolio-decision-status.alert {
  border-color: rgba(239, 68, 68, 0.24);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

#portfolio-section-overview,
#portfolio-pnl-analysis-card,
#portfolio-section-holdings,
#portfolio-section-rebalance,
#trades-table-wrapper {
  scroll-margin-top: 76px;
}

@media (max-width: 680px) {
  .portfolio-decision-summary {
    grid-template-columns: 1fr auto;
  }

  .portfolio-decision-kicker {
    grid-column: 1 / -1;
  }
}

#signals-view .summary-support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.045);
}

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

#signals-view .summary-support-grid div {
  min-width: 0;
}

#signals-view .summary-support-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

#signals-view .summary-support-grid strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-change-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 2.6fr);
  gap: 14px;
  align-items: stretch;
  margin: 14px 0 18px;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.36);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-input);
}

.daily-change-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}

.daily-change-head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.daily-change-kicker {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.daily-change-head strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.daily-change-head > span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.daily-change-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.daily-change-item {
  min-width: 0;
  padding: 10px 12px;
  background: rgba(2, 6, 23, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: var(--radius-input);
}

.daily-change-item span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.daily-change-item strong {
  display: block;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-pnl-analysis-card {
  margin: 14px 0 18px;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-card);
}

.portfolio-pnl-header,
.portfolio-pnl-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.portfolio-pnl-header h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 800;
}

.portfolio-pnl-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.portfolio-pnl-range-controls,
.portfolio-pnl-rank-tabs {
  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;
}

.portfolio-pnl-range-controls button,
.portfolio-pnl-rank-tabs button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.portfolio-pnl-range-controls button.active,
.portfolio-pnl-rank-tabs 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-custom-range {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.portfolio-pnl-custom-range label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.portfolio-pnl-custom-range input {
  width: 148px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: var(--radius-input);
  background: rgba(2, 6, 23, 0.32);
  color: var(--text-primary);
  font: 600 12px var(--font-mono);
}

.portfolio-pnl-status {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(96, 165, 250, 0.16);
  border-radius: var(--radius-input);
  background: rgba(59, 130, 246, 0.08);
  color: #bfdbfe;
  font-size: 12px;
}

.portfolio-pnl-status.is-error {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.06);
  color: #fecaca;
}

.portfolio-pnl-overview {
  display: grid;
  grid-template-columns: minmax(210px, 0.68fr) minmax(0, 2.2fr);
  gap: 16px;
  margin-top: 16px;
}

.portfolio-pnl-hero,
.portfolio-pnl-calendar-card,
.portfolio-pnl-ranking-card,
.portfolio-pnl-kpi-grid > div {
  background: rgba(2, 6, 23, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-input);
}

.portfolio-pnl-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 224px;
  padding: 20px;
}

.portfolio-pnl-hero span,
.portfolio-pnl-kpi-grid span,
.portfolio-pnl-subhead span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.portfolio-pnl-hero strong {
  margin-top: 12px;
  color: var(--success);
  font-size: 36px;
  line-height: 1;
  letter-spacing: 0;
}

.portfolio-pnl-hero small {
  margin-top: 8px;
  color: var(--success);
  font-size: 15px;
  font-weight: 800;
}

.portfolio-pnl-hero em {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
}

.portfolio-pnl-hero.is-negative strong,
.portfolio-pnl-hero.is-negative small {
  color: var(--danger);
}

.portfolio-pnl-chart-wrap {
  position: relative;
  min-height: 260px;
  padding: 10px 4px 0;
}

.portfolio-pnl-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.portfolio-pnl-kpi-grid > div {
  min-width: 0;
  padding: 13px 14px;
}

.portfolio-pnl-kpi-grid strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-pnl-detail-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(0, 1.08fr);
  gap: 14px;
  margin-top: 14px;
}

.portfolio-pnl-calendar-card,
.portfolio-pnl-ranking-card {
  padding: 14px;
}

.portfolio-pnl-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.portfolio-pnl-calendar-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 52px;
  min-height: 52px;
  padding: 7px 6px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--text-secondary);
  font-size: 11px;
}

.portfolio-pnl-calendar-cell.is-head {
  display: block;
  height: auto;
  min-height: auto;
  padding: 0 6px 4px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 800;
}

.portfolio-pnl-calendar-cell.is-empty {
  background: transparent;
}

.portfolio-pnl-calendar-cell.is-positive {
  background: rgba(59, 130, 246, 0.14);
  color: #a7f3d0;
}

.portfolio-pnl-calendar-cell.is-negative {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.portfolio-pnl-calendar-cell.is-flat {
  background: rgba(148, 163, 184, 0.08);
  color: #cbd5e1;
}

.portfolio-pnl-calendar-cell.is-market-closed {
  background: rgba(180, 133, 72, 0.07);
  color: rgba(203, 174, 128, 0.68);
  box-shadow: inset 0 0 0 1px rgba(180, 133, 72, 0.08);
}

.portfolio-pnl-calendar-cell.is-today,
.portfolio-pnl-calendar-cell.is-latest {
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.52);
}

.portfolio-pnl-calendar-cell strong,
.portfolio-pnl-calendar-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-pnl-calendar-cell small {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
}

.portfolio-pnl-calendar-status,
.portfolio-pnl-calendar-closed {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  line-height: 1;
}

.portfolio-pnl-calendar-status {
  color: #93c5fd;
  font-size: 11px;
}

.portfolio-pnl-calendar-status.is-latest-marker {
  color: #94a3b8;
}

.portfolio-pnl-calendar-closed {
  width: 18px;
  height: 16px;
  border: 1px solid rgba(214, 177, 116, 0.2);
  border-radius: 4px;
  background: rgba(180, 133, 72, 0.12);
  color: rgba(232, 198, 143, 0.92);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
}

.portfolio-pnl-rank-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
}

.portfolio-pnl-rank-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(92px, 0.55fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-input);
}

.portfolio-pnl-rank-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 900;
}

.portfolio-pnl-rank-main {
  min-width: 0;
}

.portfolio-pnl-rank-main strong,
.portfolio-pnl-rank-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-pnl-rank-main strong {
  color: var(--text-primary);
  font-size: 13px;
}

.portfolio-pnl-rank-main span {
  color: var(--text-secondary);
  font-size: 10px;
}

.portfolio-pnl-rank-value {
  text-align: right;
  font-size: 13px;
  font-weight: 900;
}

.portfolio-pnl-empty {
  padding: 22px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

#signals-view .fx-summary-item {
  justify-content: flex-start;
  padding: 14px 16px !important;
}

#signals-view .fx-summary-head {
  margin-bottom: 6px;
}

@media (min-width: 1100px) {
  #signals-view .holding-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(340px, 0.92fr);
  }

  #signals-view .fx-summary-lines {
    grid-template-columns: minmax(132px, 1fr) minmax(176px, 1.35fr);
    gap: 6px 10px;
  }

  #signals-view .fx-summary-lines div {
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  #signals-view .fx-summary-lines strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 10.5px;
    text-overflow: ellipsis;
  }
}

.signal-center-modal-content {
  width: min(1180px, calc(100vw - 32px)) !important;
  max-width: 1180px !important;
  height: min(82vh, 760px);
  max-height: calc(100vh - 32px);
  padding: 22px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.signal-center-modal-header {
  flex: 0 0 auto;
}

.signal-center-modal-header h3 {
  margin: 0;
}

.signal-center-modal-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.signal-center-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.signal-center-panel {
  min-height: 100%;
}

.signal-center-panel .app-section-header {
  margin-bottom: 14px;
}

.signal-center-panel .app-section-header .section-title {
  display: none;
}

.compact-action {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.table-wrapper {
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-input);
  background: rgba(2, 6, 23, 0.18);
}

table {
  min-width: 760px;
  font-size: 13px;
}

th,
td {
  padding: 11px 14px;
  vertical-align: middle;
}

th {
  background: rgba(2, 6, 23, 0.28);
  color: #9ca9bd;
  font-size: 12px;
}

td.font-mono,
th:nth-child(n+3) {
  white-space: nowrap;
}

#signals-table,
#trades-table,
#monitor-runs-table,
#backtest-table,
#strategy-comparison-table,
#rebalance-table {
  min-width: max-content;
}

#signals-table th:nth-child(3),
#signals-table th:nth-child(4),
#signals-table th:nth-child(5),
#signals-table th:nth-child(6),
#signals-table td:nth-child(3),
#signals-table td:nth-child(4),
#signals-table td:nth-child(5),
#signals-table td:nth-child(6),
#rebalance-table th:nth-child(n+2),
#rebalance-table td:nth-child(n+2),
#trades-table th:nth-child(4),
#trades-table th:nth-child(5),
#trades-table th:nth-child(6),
#trades-table td:nth-child(4),
#trades-table td:nth-child(5),
#trades-table td:nth-child(6) {
  text-align: right;
}

#signals-table th:nth-last-child(-n+3),
#signals-table td:nth-last-child(-n+3),
#trades-table th:last-child,
#trades-table td:last-child,
#monitor-runs-table th:nth-child(3),
#monitor-runs-table td:nth-child(3),
#monitor-runs-table th:nth-child(6),
#monitor-runs-table td:nth-child(6) {
  text-align: center;
}

.monitor-runs-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.monitor-runs-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.monitor-runs-heading .section-title {
  margin: 0;
}

.monitor-runs-wrapper {
  overflow: auto;
}

#monitor-runs-table {
  width: 100%;
  min-width: 940px;
  table-layout: fixed;
}

#monitor-runs-table th:nth-child(1),
#monitor-runs-table td:nth-child(1) {
  width: 160px;
}

#monitor-runs-table th:nth-child(2),
#monitor-runs-table td:nth-child(2) {
  width: 120px;
}

#monitor-runs-table th:nth-child(3),
#monitor-runs-table td:nth-child(3) {
  width: 92px;
}

#monitor-runs-table th:nth-child(4),
#monitor-runs-table td:nth-child(4) {
  width: 150px;
}

#monitor-runs-table th:nth-child(5),
#monitor-runs-table td:nth-child(5) {
  width: 110px;
}

#monitor-runs-table th:nth-child(6),
#monitor-runs-table td:nth-child(6) {
  width: 96px;
}

#monitor-runs-table th:nth-child(7),
#monitor-runs-table td:nth-child(7) {
  width: auto;
}

@media (max-width: 760px) {
  .monitor-runs-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

.table-time {
  font-size: 12px;
}

.cell-strong {
  font-weight: 700;
}

.cell-medium {
  font-weight: 500;
}

.cell-pnl {
  font-size: 11px;
  font-weight: 700;
}

.cell-truncate {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  justify-content: center;
  flex-wrap: nowrap;
}

.row-actions button {
  min-width: 54px;
  white-space: nowrap;
}

.badge,
.badge-compact,
.flag-status,
.rebalance-status {
  border-radius: var(--radius-badge);
}

.badge-compact {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
}

.running-badge {
  animation: pulse 1.5s infinite;
}

.flag-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 9px;
  font-size: 11px;
  white-space: nowrap;
}

.flag-status.failed {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.26);
}

.flag-status.muted {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.16);
}

.rebalance-panel {
  padding: 14px;
  border-radius: var(--radius-input);
  background: rgba(2, 6, 23, 0.2);
}

.rebalance-panel-header {
  margin-bottom: 12px;
}

.rebalance-panel-header p {
  max-width: 54ch;
}

.rebalance-meter-track {
  height: 8px;
}

.rebalance-summary-grid {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 8px;
}

.rebalance-summary-grid div {
  border-radius: var(--radius-input);
  background: rgba(255, 255, 255, 0.014);
}

.modal-content {
  border-radius: var(--radius-card) !important;
  padding: 24px !important;
  box-shadow: var(--shadow-raised) !important;
}

.modal-content-trade {
  max-width: 520px;
}

.modal-content-ibkr {
  max-width: 960px;
}

.modal-content-dialog {
  max-width: 420px;
}

.modal-section-title,
#auth-form-register h4 {
  margin: 15px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.modal-section-title-spaced {
  margin-top: 24px;
}

.form-group-spaced {
  margin-bottom: 24px;
}

.full-width {
  width: 100%;
}

.auth-submit {
  margin-bottom: 10px;
}

.dialog-message {
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 12px;
}

.form-row-custom-date {
  display: none;
  margin-top: -8px;
  margin-bottom: 8px;
}

#backtest-view {
  gap: 14px;
}

#backtest-view .glass-card {
  background: var(--surface-1);
  border-color: var(--line-soft);
  box-shadow: var(--shadow-panel);
}

#backtest-view .backtest-config-card,
#backtest-view .backtest-results-card,
#backtest-view .backtest-chart-card,
#backtest-view .backtest-logs-card {
  border-radius: var(--radius-card);
}

#backtest-view .stats-box {
  min-height: 184px;
  border-radius: var(--radius-input);
  background: rgba(2, 6, 23, 0.28);
  grid-template-rows: 76px 72px auto;
}

#backtest-view .stats-value,
#backtest-view .stats-value[style] {
  letter-spacing: 0 !important;
}

.strong-value {
  font-weight: 700;
}

.danger-value {
  color: var(--danger) !important;
}

.inline-stat-row {
  gap: 8px;
  flex-wrap: wrap;
}

.comparison-panel {
  border-top-color: var(--line-subtle);
}

.pinned-row td {
  background: rgba(59, 130, 246, 0.075) !important;
  border-top: 1px solid rgba(96, 165, 250, 0.2);
  border-bottom: 1px solid rgba(96, 165, 250, 0.16);
}

.pinned-row td:first-child {
  border-left: 3px solid rgba(59, 130, 246, 0.58);
}

.pinned-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.pinned-date {
  color: var(--accent);
  font-size: 12px;
}

.pinned-note {
  padding-left: 8px;
  color: var(--text-muted);
  font-size: 11px;
}

@media (max-width: 760px) {
  .dashboard-tabs {
    align-self: stretch;
  }

  .section-toolbar,
  .app-section-header {
    align-items: stretch;
  }

  .chart-controls-wrapper {
    width: 100%;
    justify-content: space-between;
  }

  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .rebalance-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .title-text h1 {
    font-size: 22px;
  }

  .header-actions {
    overflow-x: auto;
  }

  .dashboard-tabs {
    padding: 4px;
  }

  .tab-btn {
    flex: 0 0 auto;
    min-width: 112px;
  }

  .chart-controls-wrapper {
    align-items: stretch;
    flex-direction: column;
  }

  .timeframe-selector,
  .ticker-selector {
    width: 100%;
  }

  .timeframe-btn,
  .ticker-btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

.backtest-easy-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 10px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 8px;
  background: rgba(4, 11, 23, 0.42);
  overflow: hidden;
}

.backtest-easy-metrics > div,
.backtest-benchmark-metric {
  min-width: 0;
  padding: 9px 12px;
  border-right: 1px solid rgba(148, 163, 184, 0.1);
}

.backtest-easy-metrics > div:not(.backtest-benchmark-metric) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.backtest-benchmark-metric {
  grid-column: span 2;
  border-right: 0;
  background: rgba(23, 49, 80, 0.16);
}

.backtest-easy-metrics span,
.backtest-trust-grid span {
  display: block;
  margin-bottom: 4px;
  color: #718096;
  font-size: 10px;
}

.backtest-easy-metrics strong {
  display: block;
  color: #dbe5f4;
  font-size: 13px;
  white-space: nowrap;
}

.backtest-benchmark-title {
  margin-bottom: 6px !important;
}

.backtest-benchmark-values {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.backtest-benchmark-values > div {
  min-width: 0;
}

.backtest-benchmark-values > .is-beat {
  text-align: right;
}

.backtest-benchmark-values span {
  margin-bottom: 2px;
  font-size: 9px;
}

.backtest-benchmark-values strong {
  font-size: 12px;
}

.backtest-benchmark-values .is-trail strong {
  color: #f29a9a;
}

.backtest-benchmark-values .is-beat strong {
  color: #52d6a3;
}

.backtest-benchmark-bar {
  display: flex;
  width: 100%;
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(113, 128, 150, 0.2);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.backtest-benchmark-bar i {
  display: block;
  width: 0;
  height: 100%;
  transition: width 220ms ease;
}

.backtest-benchmark-bar i.is-trail {
  background: #d86f78;
}

.backtest-benchmark-bar i.is-tie {
  background: #718096;
}

.backtest-benchmark-bar i.is-beat {
  background: #32b986;
}

.backtest-easy-metric-note {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #718096;
  font-size: 9px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backtest-benchmark-breakdowns {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
}

.backtest-beat-breakdown {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.backtest-beat-breakdown:last-child {
  align-items: flex-end;
}

.backtest-breakdown-title {
  margin: 0 !important;
  color: #718096 !important;
  font-size: 8px !important;
  line-height: 1.2;
}

.backtest-beat-breakdown > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.backtest-beat-breakdown small {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  color: #718096;
  font-size: 9px;
  line-height: 1.3;
}

.backtest-beat-breakdown small + small {
  padding-left: 8px;
  border-left: 1px solid rgba(148, 163, 184, 0.1);
}

.backtest-beat-breakdown small span {
  display: block;
  margin: 0;
  color: #718096;
  font-size: inherit;
  white-space: nowrap;
}

.backtest-beat-breakdown small b {
  display: inline;
  color: #91a8c4;
  font-weight: 600;
  white-space: nowrap;
}

.backtest-trust-panel {
  margin-top: 14px;
  padding: 11px 14px;
  border: 1px solid rgba(96, 165, 250, 0.15);
  border-radius: 10px;
  background: rgba(8, 20, 38, 0.52);
}

.backtest-trust-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.backtest-trust-kicker {
  display: block;
  margin-bottom: 2px;
  color: #60a5fa;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.backtest-trust-head h4 {
  margin: 0;
  color: #dce7f7;
  font-size: 13px;
}

.backtest-trust-overall {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.backtest-trust-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin-top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.09);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.24);
  overflow: hidden;
}

.backtest-trust-grid > div {
  min-width: 0;
  padding: 7px 10px;
  border-right: 1px solid rgba(148, 163, 184, 0.08);
}

.backtest-trust-grid > div:last-child {
  border-right: 0;
}

.backtest-trust-grid strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backtest-trust-panel .is-good {
  color: #34d399;
}

.backtest-trust-panel .is-warning {
  color: #fbbf24;
}

.backtest-trust-panel .is-bad {
  color: #fb7185;
}

.backtest-trust-summary {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  color: #91a2ba;
  font-size: 11px;
  line-height: 1.6;
}

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

  .backtest-easy-metrics > div:nth-child(3) {
    border-right: 0;
  }

  .backtest-benchmark-metric {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
  }

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

  .backtest-trust-grid > div {
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  }

  .backtest-trust-grid > div:nth-child(3n) {
    border-right: 0;
  }

  .backtest-trust-grid > div:nth-last-child(-n + 3) {
    border-bottom: 0;
  }
}

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

  .backtest-easy-metrics > div {
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  }

  .backtest-easy-metrics > div:nth-child(even) {
    border-right: 0;
  }

  .backtest-easy-metrics > div:nth-child(3) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .backtest-easy-metrics > div:nth-child(4) {
    border-bottom: 0;
  }

  .backtest-benchmark-metric {
    grid-column: 1 / -1;
    border-top: 0;
    border-bottom: 0 !important;
  }

  .backtest-benchmark-breakdowns {
    gap: 6px;
  }

  .backtest-beat-breakdown {
    gap: 3px;
  }

  .backtest-beat-breakdown > div {
    gap: 6px;
  }

  .backtest-beat-breakdown small + small {
    padding-left: 6px;
  }

  .backtest-trust-grid > div {
    border-right: 1px solid rgba(148, 163, 184, 0.08);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  }

  .backtest-trust-grid > div:nth-child(even) {
    border-right: 0;
  }

  .backtest-trust-grid > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .backtest-trust-head {
    align-items: flex-start;
  }
}

.text-warning {
  color: var(--warning) !important;
}

.btn-edit-trade {
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.btn-edit-trade:hover {
  background: var(--accent);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.btn-delete-trade {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.btn-delete-trade:hover {
  background: var(--danger);
  color: var(--text-primary);
  border-color: var(--danger);
  box-shadow: 0 0 8px var(--danger-glow);
}

