:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #131b2e;
  --border-color: #27354f;
  --border-hover: #3b82f6;

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

  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.15);

  --status-green: #10b981;
  --status-green-bg: rgba(16, 185, 129, 0.15);
  --status-amber: #f59e0b;
  --status-amber-bg: rgba(245, 158, 11, 0.15);
  --status-red: #ef4444;
  --status-red-bg: rgba(239, 68, 68, 0.15);
  --status-blue: #0ea5e9;
  --status-blue-bg: rgba(14, 165, 233, 0.15);
  --status-gray: #64748b;
  --status-gray-bg: rgba(100, 116, 139, 0.15);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: #60a5fa;
}

/* Header & Nav */
.navbar {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.brand-badge {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.86rem;
  padding: 0.38rem 0.62rem;
  border-radius: 6px;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border-color: rgba(148, 163, 184, 0.15);
}

.nav-link.active {
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  font-weight: 600;
}

/* Primary Workspace Button Highlight */
.nav-link-primary {
  background: rgba(14, 165, 233, 0.12) !important;
  border: 1px solid rgba(56, 189, 248, 0.45) !important;
  color: #38bdf8 !important;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.12);
}

.nav-link-primary:hover {
  background: rgba(14, 165, 233, 0.22) !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.primary-pill {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: #0284c7;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  margin-left: 3px;
  display: inline-block;
  line-height: 1.2;
}

.dropdown-arrow {
  font-size: 0.65rem;
  color: #64748b;
  transition: transform 0.2s ease;
  margin-left: 2px;
  display: inline-block;
}

.nav-dropdown:hover .dropdown-arrow {
  transform: rotate(180deg);
  color: #38bdf8;
}

/* Dropdown Container & Menu */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 290px;
  background: #090e1a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 4px 10px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 100;
  animation: navDropdownFadeIn 0.15s ease-out;
}

.nav-dropdown-content.dropdown-content-right {
  left: auto;
  right: 0;
}

.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown:focus-within .nav-dropdown-content {
  display: block;
}

@keyframes navDropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-section-title {
  font-size: 0.64rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px 4px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(30, 41, 59, 0.85);
}

.dropdown-item-icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  flex-shrink: 0;
}

.dropdown-item-text {
  display: flex;
  flex-direction: column;
}

.dropdown-item-title {
  font-size: 0.81rem;
  font-weight: 600;
  color: #f1f5f9;
}

.dropdown-item:hover .dropdown-item-title {
  color: #38bdf8;
}

.dropdown-item-sub {
  font-size: 0.70rem;
  color: #94a3b8;
  line-height: 1.25;
  margin-top: 2px;
}

.dropdown-item-divider {
  height: 1px;
  background: #1e293b;
  margin: 4px 6px;
}

.user-settings-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.user-settings-icon {
  font-size: 0.95rem;
  opacity: 0.8;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Market Ribbon Bar */
.market-ribbon-bar {
  background: #090e1a;
  border-bottom: 1px solid #1e293b;
  padding: 0 1rem;
  height: 46px;
  min-height: 46px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 45;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.ribbon-scroll-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  width: 100%;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.ribbon-scroll-container::-webkit-scrollbar {
  height: 3px;
}

.ribbon-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.ribbon-group {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.ribbon-provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: 5px;
}

.provider-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.provider-tag-fyers {
  color: #38bdf8;
}

.provider-tag-delta {
  color: #34d399;
}

.provider-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 500;
  cursor: help;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-green {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
}

.dot-amber {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
}

.dot-red {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
}

.dot-blue {
  background-color: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
}

.dot-gray {
  background-color: #64748b;
}

.ribbon-divider {
  width: 1px;
  height: 20px;
  background-color: #334155;
  flex-shrink: 0;
  margin: 0 6px;
}

.ribbon-tickers {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.ribbon-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(26, 38, 57, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.74rem;
  cursor: default;
  transition: all 0.2s ease;
  user-select: none;
}

.ribbon-ticker-item:hover {
  background: rgba(30, 45, 68, 0.95);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

@keyframes flashGreen {
  0% { background: rgba(16, 185, 129, 0.4); border-color: #10b981; }
  100% { background: rgba(26, 38, 57, 0.6); border-color: rgba(255, 255, 255, 0.08); }
}

@keyframes flashRed {
  0% { background: rgba(239, 68, 68, 0.4); border-color: #ef4444; }
  100% { background: rgba(26, 38, 57, 0.6); border-color: rgba(255, 255, 255, 0.08); }
}

.ribbon-ticker-item.flash-up {
  animation: flashGreen 0.7s ease-out;
}

.ribbon-ticker-item.flash-down {
  animation: flashRed 0.7s ease-out;
}

.ticker-name {
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.70rem;
  letter-spacing: 0.03em;
}

.ticker-ltp {
  color: #f8fafc;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: -0.01em;
}

.ticker-change-pill {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
}

.change-pos {
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.change-neg {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.change-neutral {
  color: #94a3b8;
}

.ticker-stale-tag {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 0.58rem;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 700;
}

.ticker-closed-tag {
  background: rgba(100, 116, 139, 0.15);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.25);
  font-size: 0.58rem;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* Layout */
.main-container {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* Alerts */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alert-error {
  background: var(--status-red-bg);
  border: 1px solid var(--status-red);
  color: #fca5a5;
}
.alert-success {
  background: var(--status-green-bg);
  border: 1px solid var(--status-green);
  color: #86efac;
}
.alert-info {
  background: var(--status-blue-bg);
  border: 1px solid var(--status-blue);
  color: #93c5fd;
}
.alert-warning {
  background: var(--status-amber-bg);
  border: 1px solid var(--status-amber);
  color: #fde68a;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-running {
  background: var(--status-green-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-starting {
  background: var(--status-blue-bg);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.badge-completed {
  background: var(--status-green-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-failed {
  background: var(--status-red-bg);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-stopping {
  background: var(--status-amber-bg);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-stopped {
  background: var(--status-gray-bg);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.4);
}

.badge-paper {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-live {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 700;
}

/* Pulsing dot for live status */
.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.25;
}

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

.btn-secondary {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: #374151;
  border-color: #4b5563;
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}
.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.35);
  color: white;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Log Terminal */
.terminal-window {
  background-color: #050811;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.terminal-header {
  background-color: #0b1120;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.terminal-body {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1rem;
  height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #38bdf8;
  line-height: 1.6;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 50;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-content.large {
  max-width: 980px;
  height: 85vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text-primary);
}

/* Output files grid */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.file-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s;
}

.file-card:hover {
  border-color: var(--accent-primary);
}

.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.file-actions {
  display: flex;
  gap: 0.5rem;
}

/* Sandboxed iframe viewer */
.report-frame {
  width: 100%;
  height: calc(85vh - 100px);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #ffffff;
}

/* Code editor */
.code-editor {
  width: 100%;
  height: 480px;
  background-color: #0b0f19;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  resize: vertical;
  line-height: 1.5;
}
.code-editor:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn-success {
  background-color: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #4ade80;
}
.btn-success:hover {
  background-color: rgba(34, 197, 94, 0.3);
  color: #ffffff;
  border-color: #22c55e;
}

.btn-cyan {
  background-color: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.45);
  color: #38bdf8;
}
.btn-cyan:hover {
  background-color: rgba(14, 165, 233, 0.3);
  color: #ffffff;
  border-color: #0ea5e9;
}

.btn-outline-danger {
  background-color: transparent;
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.btn-outline-danger:hover {
  background-color: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ffffff;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.actions-toolbar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.editor-container {
  width: 100%;
  height: 620px;
  min-height: 620px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: #1e1e1e;
}

.editor-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 1.5rem !important;
  box-sizing: border-box !important;
  background: var(--bg-primary) !important;
  overflow: hidden !important;
}

/* Documentation System */
.docs-container {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin-top: 0.5rem;
}

@media (max-width: 960px) {
  .docs-container {
    grid-template-columns: 1fr;
  }
}

.docs-sidebar {
  position: sticky;
  top: 5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem 1rem;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
}

.docs-sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.docs-nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.docs-nav-item a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all 0.15s ease;
  line-height: 1.35;
}

.docs-nav-item a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.docs-nav-item a.active {
  background: var(--accent-light);
  color: #60a5fa;
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.docs-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.docs-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  scroll-margin-top: 5.5rem;
}

.docs-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.docs-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #93c5fd;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.docs-card p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 1rem;
}

.docs-card ul, .docs-card ol {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.docs-card li {
  margin-bottom: 0.35rem;
}

.docs-callout {
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.88rem;
  line-height: 1.55;
  border-left: 4px solid;
}

.docs-callout.tip {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: #10b981;
  color: #d1fae5;
}

.docs-callout.warning {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: #f59e0b;
  color: #fef3c7;
}

.docs-callout.info {
  background: rgba(59, 130, 246, 0.1);
  border-left-color: #3b82f6;
  color: #dbeafe;
}

.code-wrapper {
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  margin: 1.25rem 0;
}

.code-header {
  background: #161b22;
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-header span {
  font-family: var(--font-mono);
  color: #7dd3fc;
}

.code-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #38bdf8;
}

.code-wrapper pre {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem 0;
  font-size: 0.87rem;
}

.docs-table th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-align: left;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.docs-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.docs-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* --- Active Positions & Closed Trades Dashboard Elements --- */
.pnl-positive {
  color: #10b981 !important;
  font-weight: 700;
}
.pnl-negative {
  color: #ef4444 !important;
  font-weight: 700;
}
.pnl-neutral {
  color: var(--text-secondary) !important;
  font-weight: 600;
}

.badge-buy {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: 700;
}

.badge-sell {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 700;
}

.badge-reason {
  background: var(--bg-tertiary);
  color: #94a3b8;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  display: inline-block;
}
.badge-reason-tp {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}
.badge-reason-sl {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}
.badge-reason-trailing {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}
.badge-reason-time {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.35);
}
.badge-reason-circuit {
  background: rgba(239, 68, 68, 0.25);
  color: #ff8888;
  border-color: #ef4444;
}

.collapsible-card {
  transition: all 0.2s ease-in-out;
  margin-bottom: 1.5rem;
}

.collapsible-header-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.chevron-icon {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.chevron-icon.expanded {
  transform: rotate(180deg);
}

.collapsible-body {
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease;
}
.collapsible-body.collapsed {
  display: none;
}

.meta-stats-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.meta-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.meta-stat-pill strong {
  color: var(--text-primary);
}

/* Filter toolbar for closed trades */
.filter-toolbar {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filter-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 130px;
  flex: 1 1 auto;
}

.filter-input-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.filter-control-sm {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.filter-control-sm:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ==========================================================================
   Compact Market Ribbon Bar
   ========================================================================== */
.market-ribbon-bar {
  background-color: #0b111e;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  height: 46px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 45;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ribbon-scroll-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  -webkit-overflow-scrolling: touch;
}

.ribbon-scroll-container::-webkit-scrollbar {
  height: 2px;
}

.ribbon-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.ribbon-group {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.ribbon-provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.provider-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-primary);
}

.provider-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ==========================================================================
   Platform Info & Build Timeline Styles
   ========================================================================== */

.info-container {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 0 3.5rem 0;
}

.info-hero {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.7));
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 2rem 2.25rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}

.info-hero::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15), transparent 70%);
  pointer-events: none;
}

.info-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 9999px;
  margin-bottom: 0.85rem;
}

.info-hero-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.info-hero-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 820px;
}

/* System Specifications Grid */
.system-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.spec-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.spec-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.spec-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  font-family: var(--font-mono);
}

.spec-desc {
  font-size: 0.78rem;
  color: #94a3b8;
}

/* Timeline Architecture */
.timeline-section-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.timeline-section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-wrap {
  position: relative;
  padding-left: 2.5rem;
}

.timeline-wrap::before {
  content: "";
  position: absolute;
  top: 15px;
  bottom: 20px;
  left: 17px;
  width: 2px;
  background: linear-gradient(180deg, #38bdf8 0%, #3b82f6 50%, #1e293b 100%);
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -2.5rem;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  font-weight: 800;
  font-size: 0.75rem;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  z-index: 2;
}

.timeline-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 1.35rem 1.6rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.timeline-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.timeline-milestone-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-tag-version {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #60a5fa;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.timeline-tag-date {
  color: #94a3b8;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 5px;
}

.timeline-desc {
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}

.timeline-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.65rem;
}

.timeline-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #94a3b8;
}

.timeline-feature-item strong {
  color: #f1f5f9;
}

.timeline-check-icon {
  color: #10b981;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Architecture Highlight Box */
.arch-highlight-box {
  background: #090e1a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-top: 2.5rem;
}

.arch-highlight-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.arch-highlight-text {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .info-hero {
    padding: 1.5rem 1.25rem;
  }
  .info-hero-title {
    font-size: 1.45rem;
  }
  .timeline-wrap {
    padding-left: 2rem;
  }
  .timeline-marker {
    left: -2rem;
    width: 28px;
    height: 28px;
    font-size: 0.68rem;
  }
}

/* --- Manual Exit & Toast Notification Styles --- */
.exit-action-btn {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-weight: 700;
  font-size: 0.76rem;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.exit-action-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.exit-action-btn:active {
  transform: translateY(0);
}

.toast-container {
  position: fixed;
  top: 75px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-message {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(-12px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
  max-width: 440px;
}

.toast-message.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.5);
  background: #042417;
  color: #34d399;
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.5);
  background: #2b0b0f;
  color: #f87171;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  display: inline-block;
  animation: spinnerRotate 0.75s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

.text-danger {
  color: #f87171 !important;
}

.text-success {
  color: #34d399 !important;
}

/* Active Position Live WebSocket LTP Flash Animations */
.price-flash-up {
  animation: cellFlashGreen 0.75s ease-out;
}

.price-flash-down {
  animation: cellFlashRed 0.75s ease-out;
}

@keyframes cellFlashGreen {
  0% { color: #34d399 !important; background: rgba(16, 185, 129, 0.28) !important; border-radius: 4px; }
  100% { background: transparent; }
}

@keyframes cellFlashRed {
  0% { color: #f87171 !important; background: rgba(239, 68, 68, 0.28) !important; border-radius: 4px; }
  100% { background: transparent; }
}

/* Dashboard Script Name Copy Button */
.sd-script-name-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.sd-script-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-inline-size: 24px;
  min-block-size: 24px;
  padding: 2px 5px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.55);
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.sd-script-copy-btn .material-symbols-rounded {
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.sd-script-copy-btn:hover,
.sd-script-copy-btn:focus-visible {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.48);
  color: #38bdf8;
  outline: none;
}

.sd-script-copy-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.sd-script-copy-btn[data-copied] {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.65);
  color: #34d399;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}

.sd-script-copy-btn[data-failed] {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.6);
  color: #f87171;
}

@media (prefers-reduced-motion: reduce) {
  .sd-script-copy-btn,
  .sd-btn-click-pulse,
  .sd-copy-toast {
    transition: opacity 0.15s ease !important;
    transform: none !important;
  }
}







