:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f1f5f4;
  --surface-hover: #e8f0ee;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-subtle: #eef2f6;
  --accent: #0f766e;
  --accent-hover: #0d9488;
  --accent-soft: #ecfdf5;
  --accent-line: #14b8a6;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-lg: 12px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-workspace {
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-workspace-visual {
  height: 108px;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 55%, #ffffff 100%);
  overflow: hidden;
}

.sidebar-workspace-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.sidebar-workspace-body {
  padding: 0.75rem 1rem 0.875rem;
}

.sidebar-workspace-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-workspace-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.sidebar-workspace-meta {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.sidebar-workspace-ib-status {
  margin: 0.2rem 0 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.sidebar-workspace-ib-status.is-online {
  color: #0f766e;
}

.sidebar-workspace-ib-status.is-offline {
  color: #b45309;
}

.sidebar-workspace-ib-status.is-muted {
  color: var(--text-secondary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
  flex: 1;
  min-height: 0;
}

.sidebar-nav-main,
.sidebar-nav-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-nav-secondary {
  margin-top: auto;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-label {
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.nav-badge {
  margin-left: auto;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-footer {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-brand-logo {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}

.sidebar-footer .emergency {
  width: 100%;
  text-align: center;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: 0.5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.global-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex-shrink: 0;
}

.global-header-center {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.global-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  min-width: 0;
}

.breadcrumb-root {
  color: var(--muted);
  font-weight: 500;
}

.breadcrumb-sep {
  color: var(--muted);
  font-size: 0.75rem;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.pipeline-checklist {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.pipeline-step.done {
  color: var(--text-secondary);
}

.pipeline-step.active {
  color: var(--accent);
  font-weight: 600;
}

.pipeline-step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--muted);
}

.pipeline-step.done .pipeline-step-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.pipeline-step.active .pipeline-step-icon {
  background: var(--accent);
  color: #fff;
}

.header-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.header-icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

.header-icon-btn:hover {
  background: var(--accent-soft);
  border-color: #99f6e4;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.12);
}

.header-icon-btn:active {
  transform: scale(0.96);
}

.header-icon-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.header-icon-btn.is-refreshing svg {
  animation: header-spin 0.75s linear infinite;
}

.header-icon-btn.has-notifications {
  border-color: #99f6e4;
  color: var(--accent);
  background: var(--accent-soft);
}

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

.header-notify-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(15, 118, 110, 0.35);
}

.header-notify-dot.hidden {
  display: none;
}

.header-menu-anchor {
  position: relative;
}

.header-avatar-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.28);
  transition: transform 0.1s, box-shadow 0.15s, outline 0.15s;
}

.header-avatar-btn:hover {
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.38);
  transform: translateY(-1px);
}

.header-avatar-btn:active {
  transform: translateY(0) scale(0.96);
}

.header-avatar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 8px rgba(15, 118, 110, 0.28);
}

.header-avatar-btn.is-open {
  box-shadow: 0 0 0 3px var(--accent-soft), 0 4px 12px rgba(15, 118, 110, 0.38);
}

.header-dropdown {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 50;
  min-width: 16.5rem;
  max-width: 20rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.header-dropdown.hidden {
  display: none;
}

.header-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}

.header-dropdown-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.header-dropdown-meta {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
}

.header-dropdown-list {
  max-height: 16rem;
  overflow-y: auto;
}

.header-dropdown-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.7rem 0.875rem;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.header-dropdown-item:last-child {
  border-bottom: none;
}

.header-dropdown-item:hover {
  background: var(--accent-soft);
}

.header-dropdown-item-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.header-dropdown-item-meta {
  font-size: 0.6875rem;
  color: var(--muted);
}

.header-dropdown-empty {
  padding: 1rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.header-dropdown-action {
  display: block;
  width: calc(100% - 1rem);
  margin: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.header-dropdown-action:hover {
  background: var(--surface-muted);
}

.header-user-menu {
  min-width: 14rem;
}

.header-user-menu-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
}

.header-user-menu-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-user-menu-name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.header-user-menu-role {
  margin: 0.15rem 0 0;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: capitalize;
}

.header-cta {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.header-cta:hover {
  background: var(--accent-hover);
}

.header-version {
  font-size: 0.6875rem;
  color: var(--muted);
}

.header-status-chip.is-emergency {
  background: var(--danger-bg);
  color: var(--danger);
}

@media (max-width: 1100px) {
  .global-header-center {
    display: none;
  }
}

@media (max-width: 900px) {
  .header-version {
    display: none;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0 0 0.2rem;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

h2 {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
}

.status-line {
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  max-width: 52rem;
}

.workspace-progress-detail {
  margin: 0.65rem 0 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.45;
  max-width: 52rem;
}

.workspace-progress-steps {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
  max-width: 52rem;
}

.workspace-progress-steps li {
  margin: 0.2rem 0;
}

.workspace-progress-steps li.is-complete {
  color: var(--text-primary);
}

.workspace-progress-steps li.is-complete::marker {
  content: "? ";
  color: var(--success, #15803d);
}

.workspace-progress-steps li.is-active {
  color: var(--text-primary);
  font-weight: 600;
}

.workspace-progress-steps li.is-pending {
  opacity: 0.72;
}

.test-failure-detail {
  display: block;
  margin-top: 0.25rem;
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.4;
  max-width: 28rem;
  white-space: normal;
  word-break: break-word;
}

.emergency {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
}

.hidden { display: none; }

main {
  padding: 1rem 1.25rem 1.75rem;
  max-width: none;
  width: 100%;
}

.panel-workspace {
  max-width: none;
}

.scraper-subnav {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.scraper-subnav-item {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0;
  padding: 0.65rem 1rem;
  margin-bottom: -1px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.scraper-subnav-item:hover {
  color: var(--text);
  background: transparent;
}

.scraper-subnav-item.active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.analyst-subtabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.analyst-subtab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0;
  padding: 0.65rem 1rem;
  margin-bottom: -1px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.analyst-subtab:hover {
  color: var(--text);
  background: transparent;
}

.analyst-subtab.active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.analyst-view.hidden {
  display: none;
}

.tests-subnav {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tests-subnav-item {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0;
  padding: 0.65rem 1rem;
  margin-bottom: -1px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.tests-subnav-item:hover {
  color: var(--text);
}

.tests-subnav-item.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tests-section.hidden {
  display: none;
}

.table-wrap-scroll-compact {
  max-height: 14.75rem;
  overflow-y: auto;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.table-pagination-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.algorithm-info-page {
  padding: 1.25rem 1.5rem;
}

.algorithm-info-page h3 {
  margin: 0 0 0.35rem;
}

.algorithm-tests-subnav {
  margin-top: 0.75rem;
}

.algorithm-test-tab-panel.hidden {
  display: none;
}

.algorithm-test-tab-panel {
  margin-top: 0.75rem;
}

.algorithm-test-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.algorithm-test-trade-list {
  margin-top: 0.75rem;
}

.run-flow-panel {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
}

.run-flow-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem 0.85rem;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 48%, #fafafa 100%);
  border-bottom: 1px solid #ccfbf1;
}

.run-flow-hero-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 7.5rem;
  height: 5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 24px rgba(29, 78, 145, 0.08);
}

.run-flow-hero-svg {
  width: 100%;
  height: auto;
}

.run-flow-hero-dot--scraper {
  fill: #3b82f6;
  opacity: 0.85;
}

.run-flow-hero-dot--bridge {
  fill: #8b5cf6;
  opacity: 0.55;
}

.run-flow-hero-dot--analyst {
  fill: #7c3aed;
  opacity: 0.9;
}

.run-flow-hero-line {
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linecap: round;
}

.run-flow-hero-text h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
}

.run-flow-hero-meta {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.run-flow-session-select {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.run-flow-session-select select {
  min-width: min(100%, 20rem);
  max-width: 100%;
  font-size: 0.82rem;
}

.run-flow-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem 0;
}

.run-flow-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
}

.run-flow-stat strong {
  font-size: 1.05rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.run-flow-stat span {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.run-flow-stat--buy {
  background: linear-gradient(180deg, #e8f5e9 0%, #f1f8f2 100%);
  border-color: #a5d6a7;
}

.run-flow-stat--buy strong {
  color: #1b5e20;
}

.run-flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem 0.25rem;
}

.run-flow-legend-item {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.run-flow-legend-scraper {
  background: #eef6ff;
  border-color: #c7d7ea;
  color: #1d4f91;
}

.run-flow-legend-analyst {
  background: #f3efff;
  border-color: #d4c7ea;
  color: #4a2d7a;
}

.run-flow-pipeline {
  padding: 0.5rem 1.1rem 1.1rem;
}

.run-flow-pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.run-flow-empty-state {
  margin: 0.5rem 0 0;
}

.run-flow-step-card {
  display: flex;
  flex-direction: column;
  min-height: 15.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.run-flow-step-card-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.run-flow-step-card--scraper {
  border-color: #c7d7ea;
  background: linear-gradient(145deg, #f8fbff 0%, #ffffff 70%);
}

.run-flow-step-card--analyst {
  border-color: #d4c7ea;
  background: linear-gradient(145deg, #faf8ff 0%, #ffffff 70%);
}

.run-flow-step-card--skipped {
  opacity: 0.72;
  border-style: dashed;
  background: linear-gradient(145deg, #f8fafc 0%, #ffffff 70%);
}

.run-flow-step-status {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}

.run-flow-step-status--ran {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}

.run-flow-step-status--skipped {
  background: #f4f4f5;
  color: #71717a;
  border: 1px solid #e4e4e7;
}

.run-flow-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--surface);
  border: 2px solid #c7d7ea;
  color: #1d4f91;
  box-shadow: 0 2px 6px rgba(29, 78, 145, 0.12);
  flex-shrink: 0;
}

.run-flow-step-card--analyst .run-flow-step-badge {
  border-color: #c4b5fd;
  color: #5b21b6;
}

.run-flow-step-icon {
  width: 1.15rem;
  height: 1.15rem;
  color: #64748b;
  flex-shrink: 0;
}

.run-flow-step-card--scraper .run-flow-step-icon {
  color: #2563eb;
}

.run-flow-step-card--analyst .run-flow-step-icon {
  color: #7c3aed;
}

.run-flow-step-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.35rem;
}

.run-flow-step-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}

.run-flow-info-btn {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #c7d7ea;
  background: rgba(255, 255, 255, 0.9);
  color: #1d4f91;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.run-flow-step-card--analyst .run-flow-info-btn {
  border-color: #d4c7ea;
  color: #5b21b6;
}

.run-flow-info-btn:hover {
  background: #eef6ff;
}

.run-flow-step-card--analyst .run-flow-info-btn:hover {
  background: #f3efff;
}

.error-modal {
  width: min(480px, 94vw);
}

.error-modal-message {
  margin: 0.75rem 0 1.25rem;
  line-height: 1.5;
  color: var(--text-secondary, #52525b);
  white-space: pre-wrap;
  word-break: break-word;
}

.algorithm-info-modal {
  width: min(560px, 94vw);
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
}

.algorithm-info-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.algorithm-info-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.algorithm-info-close {
  min-width: 2rem;
  padding: 0.15rem 0.45rem;
  font-size: 1.1rem;
  line-height: 1;
}

.algorithm-info-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 0.15rem;
}

.algorithm-info-tagline {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.algorithm-info-design {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.algorithm-info-section {
  margin-bottom: 0.85rem;
}

.algorithm-info-section h4 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.algorithm-info-section ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.algorithm-info-section li + li {
  margin-top: 0.25rem;
}

.run-flow-step-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
}

.run-flow-step-date {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.run-flow-step-meta {
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.run-flow-step-stocks {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: auto;
}

.run-flow-stock-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 3.1rem;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border-subtle);
}

.run-flow-stock-group-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.run-flow-buy-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}

.run-flow-legend-skipped {
  background: #f4f4f5;
  border-color: #e4e4e7;
  color: #71717a;
}

@media (max-width: 1200px) {
  .run-flow-pipeline-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .run-flow-pipeline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .run-flow-pipeline-grid {
    grid-template-columns: 1fr;
  }

  .run-flow-step-card {
    min-height: 0;
  }
}

.run-flow-stocks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.run-flow-stocks-secondary {
  margin-top: 0.35rem;
  opacity: 0.85;
}

.run-flow-stocks-secondary::before {
  content: "Also analyzed";
  display: block;
  width: 100%;
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.run-flow-stock {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}

.run-flow-stock--buy {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #1b5e20;
}

.run-flow-stock--sell {
  background: #ffebee;
  border-color: #ef9a9aa8;
  color: #b71c1c;
}

.run-flow-stock--scraped {
  background: #eef6ff;
  border-color: #c7d7ea;
  color: #1d4f91;
}

.run-flow-empty {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.congressional-purchases-section {
  border-color: #c5d9f0;
  background: linear-gradient(180deg, #f8fbff 0%, var(--surface) 100%);
}

.congressional-purchase-stats {
  margin-bottom: 0.5rem;
}

.congressional-officials-list,
.congressional-purchase-list {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
}

.congressional-purchase-line {
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

.congressional-purchases-section .detail-subheading {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.scraper-section.hidden {
  display: none;
}

.intraday-basket-table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.intraday-basket-table .meta {
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.intraday-basket-table .intraday-bars-btn {
  white-space: nowrap;
}

.intraday-bars-preview {
  margin-bottom: 0.75rem;
}

.intraday-bars-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.intraday-bars-preview-head .workspace-meta {
  margin: 0;
  flex: 1 1 auto;
}

.intraday-bars-interval-field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.intraday-bars-interval-field select {
  min-width: 7rem;
}

.intraday-bars-table-wrap {
  max-height: 520px;
  overflow: auto;
}

.intraday-bars-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-raised, #fff);
}

.intraday-signals-panel {
  margin-bottom: 0.75rem;
}

.intraday-signals-panel .panel-header h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.intraday-signals-table .meta {
  max-width: 28rem;
  white-space: normal;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.intraday-signal-explanation {
  min-width: 18rem;
  line-height: 1.45;
}

.intraday-paper-explanations .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.intraday-paper-explanations .panel-header h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.intraday-paper-explanations-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.intraday-paper-explanation-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
  background: var(--surface-muted);
}

.intraday-paper-explanation-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.intraday-paper-explanation-text {
  margin: 0 0 0.45rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
}

.intraday-paper-explanation-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.section-toolbar .workspace-meta {
  margin: 0;
}

.algorithm-test-actions {
  align-items: flex-end;
}

.algorithm-test-window-field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.algorithm-test-window-field input {
  width: 4.25rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
}

.algorithm-test-window-suffix {
  color: var(--text-secondary);
}

.algorithm-test-window-hint {
  flex-basis: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.algorithm-test-period-performance {
  margin-bottom: 1rem;
}

.algorithm-test-period-performance h4 {
  margin: 0 0 0.25rem;
}

.config-panel-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.config-section.hidden {
  display: none;
}

.algorithm-test-period-range {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
}

.algorithm-test-coverage-warning {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: var(--text);
  font-size: 0.88rem;
}

.algorithm-test-tuning-note {
  margin-top: 0.35rem;
}

.algorithm-test-performance-section-label {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.workspace-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.workspace-toolbar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.workspace-meta {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 42rem;
}

.workspace-progress {
  margin: 0 0 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface);
}

.workspace-progress.hidden {
  display: none;
}

.workspace-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.workspace-progress-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.workspace-progress-eta {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.workspace-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.workspace-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e 0%, #14b8a6 100%);
  transition: width 0.15s ease-out;
}

.workspace-progress.is-complete .workspace-progress-fill {
  background: linear-gradient(90deg, #15803d 0%, #22c55e 100%);
}

.card-flat {
  padding: 0.75rem 0.875rem;
  margin-bottom: 0;
  box-shadow: none;
}

.scraper-table-panel {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-height: 0;
}

.scraper-stock-table {
  width: 100%;
  border-collapse: collapse;
}

.scraper-stock-table th,
.scraper-stock-table td {
  vertical-align: top;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
}

.scraper-stock-table tbody tr:hover {
  background: var(--surface-muted);
}

.stock-cell {
  min-width: 11rem;
  white-space: nowrap;
}

.stock-cell-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.stock-symbol {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--accent);
}

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

.stock-price-block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.35rem;
}

.btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.6875rem;
  line-height: 1.2;
}

.stock-detail-btn {
  margin-top: 0.15rem;
  width: fit-content;
}

.stock-price-line {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.stock-price {
  font-size: 0.8125rem;
  font-weight: 600;
}

.stock-change {
  font-size: 0.6875rem;
  font-weight: 600;
}

.stock-change.up {
  color: var(--success);
}

.stock-change.down {
  color: var(--danger);
}

.stock-price-asof,
.stock-meta {
  font-size: 0.6875rem;
  color: var(--muted);
}

.stock-sparkline {
  width: 72px;
  height: 22px;
  display: block;
}

.stock-sparkline polyline {
  fill: none;
  stroke: var(--accent-line);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stock-sparkline-empty {
  width: 72px;
  height: 22px;
  display: inline-block;
}

.scraper-stock-table .num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.scraper-stock-table .meta {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.75rem;
}

.scraper-stock-table .col-headlines,
.scraper-stock-table .col-snippets {
  min-width: 16rem;
  width: 20%;
}

.scraper-stock-table .col-headlines .rationale,
.scraper-stock-table .col-snippets .rationale,
.scraper-stock-table td.col-headlines.rationale,
.scraper-stock-table td.col-snippets.rationale {
  max-width: none;
  white-space: normal;
}

.source-links {
  min-width: 5rem;
}

.source-link {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 0.75rem;
  color: var(--accent-line);
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.table-wrap.scraper-table {
  max-height: calc(100vh - 11rem);
}

.table-wrap-fill {
  flex: 1;
  min-height: 280px;
  max-height: calc(100vh - 10rem);
  overflow: auto;
}

.table-wrap-fill th,
.table-wrap-fill td {
  padding: 0.45rem 0.625rem;
  font-size: 0.75rem;
}

.table-wrap-fill th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-wrap-compact {
  margin-top: 0.5rem;
}

.failures-drawer {
  font-size: 0.8125rem;
}

.failures-drawer summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.35rem 0;
  user-select: none;
}

.failures-count {
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
  margin-left: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.6875rem;
  font-weight: 600;
}

.failures-count.has-failures {
  background: var(--danger-bg);
  color: var(--danger);
}

.ccf-panel {
  margin-bottom: 0.75rem;
}

.ccf-panel .panel-header h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.analyst-controls {
  margin-bottom: 0.75rem;
}

.scraper-controls {
  margin-top: 0.25rem;
}

.analyst-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem 1rem;
}

.analyst-stock-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.analyst-stock-search {
  display: flex;
  flex: 1 1 14rem;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  min-width: 0;
}

.analyst-stock-search-label {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.analyst-stock-search input {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.analyst-stock-search-meta {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.analyst-stock-search-meta.is-filtered {
  color: var(--accent);
}

.run-select {
  flex-direction: row;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  margin: 0;
  white-space: nowrap;
}

.run-select select {
  min-width: 12rem;
  max-width: 20rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
}

.analysis-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  flex: 1;
  justify-content: flex-end;
}

.analysis-summary-strip .analysis-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
}

.analysis-summary-strip .analysis-stat strong {
  display: inline;
  font-size: 0.875rem;
  line-height: 1;
}

.analysis-summary-strip .analysis-stat span {
  font-size: 0.6875rem;
  white-space: nowrap;
}

.analysis-cards-dense {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 0.625rem;
}

.analysis-cards-dense .analysis-card {
  padding: 0.75rem 0.875rem;
  gap: 0.5rem;
}

.analysis-cards-dense .analysis-card-symbol {
  font-size: 0.9375rem;
}

.analysis-cards-dense .analysis-card-metrics {
  gap: 0.35rem;
}

.analysis-cards-dense .analysis-card-summary {
  -webkit-line-clamp: 2;
}

.analysis-cards-dense .analysis-card-actions button {
  width: 100%;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.875rem;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card .panel-header,
.report-section .panel-header {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 0.75rem;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card > p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

.emergency-card {
  border-color: #fecaca;
  background: linear-gradient(to bottom, #fffafa, var(--surface));
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

button:active { transform: scale(0.98); }

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

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

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

.secondary:hover {
  background: var(--surface-muted);
  border-color: #d4d4d8;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: #991b1b;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
  font-size: 0.8125rem;
}

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

tbody tr:hover { background: var(--surface-muted); }

th {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-muted);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.CONSIDERED, .badge.INSTRUCTION_CREATED {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.AWAITING_APPROVAL, .badge.APPROVED {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.COMMITTED {
  background: var(--success-bg);
  color: var(--success);
}

.badge.RISK_FAILED, .badge.APPROVAL_DENIED, .badge.REJECTED {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.BUY {
  background: var(--success-bg);
  color: var(--success);
}

.badge.SELL {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.HOLD {
  background: var(--surface-muted);
  color: var(--muted);
}

.badge.web_research {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.technical_momentum, .badge.news_event, .badge.sentiment {
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.row-actions button { margin-right: 0.35rem; margin-bottom: 0.35rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal {
  width: min(480px, 92vw);
  box-shadow: var(--shadow-md);
}

.failures {
  color: var(--danger);
  font-size: 0.8125rem;
}

.section-title {
  margin: 2rem 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.chart-toolbar label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.chart-toolbar select {
  min-width: 120px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chart-card-compact { max-width: 640px; }

.topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.app-version {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.analysis-run-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}

.analysis-run-toolbar label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.analysis-run-toolbar select {
  min-width: min(280px, 100%);
}

.analysis-run-date {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 0.875rem;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.analysis-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.analysis-card-symbol {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.analysis-card-company {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.analysis-card-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.analysis-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  font-size: 0.75rem;
}

.analysis-card-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.analysis-card-actions {
  margin-top: 0.25rem;
}

.stock-detail-panel {
  max-width: none;
}

.stock-detail-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stock-detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.stock-detail-meta {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0.25rem 0;
}

.stock-detail-price {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.stock-detail-price strong {
  font-size: 1.5rem;
}

.positive { color: var(--success); font-size: 0.8125rem; }
.negative { color: var(--danger); font-size: 0.8125rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.detail-section h3 {
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.detail-wide {
  grid-column: 1 / -1;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.detail-stats dt {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-stats dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-size: 0.875rem;
}

.detail-subheading {
  margin: 1rem 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.analyst-consensus-bars {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.consensus-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

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

.consensus-bar {
  height: 0.45rem;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.consensus-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.consensus-fill.strong-buy { background: #15803d; }
.consensus-fill.buy { background: var(--success); }
.consensus-fill.hold { background: var(--muted); }
.consensus-fill.sell { background: #f97316; }
.consensus-fill.strong-sell { background: var(--danger); }

.consensus-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.news-date {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.detail-summary {
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.analysis-detail-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--surface-muted);
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
}

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.news-item {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.news-item p {
  margin: 0.35rem 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.news-item a {
  font-size: 0.8125rem;
}

.stock-chart-section {
  padding-bottom: 1rem;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-toolbar h3 {
  margin: 0;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.chart-range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chart-range-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chart-range-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.chart-range-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.chart-stat strong {
  color: var(--text);
  font-weight: 600;
}

.chart-stat-muted {
  color: var(--muted);
}

.stock-chart-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: linear-gradient(180deg, #fafafa 0%, #fff 100%);
  overflow: hidden;
}

.stock-chart-wrap canvas {
  display: block;
  width: 100%;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  min-width: 140px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.92);
  color: #fafafa;
  font-size: 0.75rem;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.chart-tooltip.hidden {
  display: none;
}

.chart-tooltip-date {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #e4e4e7;
}

.analysis-card-metrics dt {
  color: var(--muted);
  font-weight: 500;
  margin: 0;
}

.analysis-card-metrics dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
  color: var(--text);
}

.analysis-card-headlines {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.analysis-card details {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.analysis-card details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  user-select: none;
}

.analysis-card-body {
  white-space: pre-wrap;
  line-height: 1.45;
  margin-top: 0.5rem;
  max-height: 12rem;
  overflow-y: auto;
}

.analysis-card-rationale {
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.625rem;
  line-height: 1.4;
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.analysis-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
}

.analysis-stat strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.analysis-stat span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

#signalTrendsChart {
  width: 100%;
  max-width: 600px;
  height: auto;
  max-height: 160px;
  display: block;
}

.analysis-cell {
  max-width: 320px;
  white-space: pre-wrap;
}

.rationale {
  max-width: 280px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

code {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 0.75rem;
  background: var(--surface-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text-secondary);
}

.consider-form .panel-header { margin-bottom: 0; }

@media (max-width: 960px) {
  .table-wrap.scraper-table {
    max-height: none;
  }

  .table-wrap-fill {
    max-height: none;
    min-height: 200px;
  }

  .analysis-summary-strip {
    justify-content: flex-start;
    width: 100%;
  }
}

/* Mobile chrome ? hidden on desktop */
.mobile-header,
.mobile-bottom-nav,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .global-header {
    display: none;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    min-height: 3.25rem;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }

  .mobile-header-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-header-version {
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    flex-shrink: 0;
  }

  .mobile-menu-icon,
  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    display: block;
    width: 1.125rem;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    position: relative;
    transition: transform 0.2s, opacity 0.2s;
  }

  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .mobile-menu-icon::before { top: -6px; }
  .mobile-menu-icon::after { top: 6px; }

  body.sidebar-open .mobile-menu-icon { background: transparent; }
  body.sidebar-open .mobile-menu-icon::before {
    top: 0;
    transform: rotate(45deg);
  }
  body.sidebar-open .mobile-menu-icon::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(24, 24, 27, 0.45);
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(24, 24, 27, 0.06);
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.25rem;
    padding: 0.35rem 0.25rem;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
  }

  .mobile-tab:active {
    transform: none;
    background: var(--surface-muted);
  }

  .mobile-tab.active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .mobile-tab-label {
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell {
    flex-direction: column;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: min(18.5rem, 88vw);
    height: 100%;
    height: 100dvh;
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
    padding-top: env(safe-area-inset-top);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: visible;
    overflow-y: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav-main,
  .sidebar-nav-secondary {
    width: 100%;
  }

  .sidebar-nav-secondary {
    margin-top: auto;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border-subtle);
  }

  .nav-item {
    width: 100%;
    min-height: 2.75rem;
    white-space: normal;
    flex-shrink: 1;
    font-size: 0.875rem;
    padding: 0.625rem 0.75rem;
  }

  .sidebar-footer {
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .app-main {
    padding-top: calc(3.25rem + env(safe-area-inset-top));
    padding-bottom: calc(3.25rem + env(safe-area-inset-bottom));
  }

  main {
    padding: 0.75rem 0.875rem 1.25rem;
  }

  .topbar {
    padding: 1rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .topbar h1 {
    font-size: 1.125rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .panel-header h2,
  .panel-header h3 {
    margin-bottom: 0;
  }

  .panel-header .actions,
  .panel-header > button,
  .panel-header > .primary,
  .panel-header > .secondary {
    width: 100%;
  }

  .panel-header .actions button {
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
  }

  .workspace-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .workspace-toolbar .actions {
    width: 100%;
  }

  .workspace-toolbar .actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.75rem;
  }

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .section-toolbar .actions {
    width: 100%;
  }

  .section-toolbar .actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.75rem;
  }

  .analyst-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .run-select {
    flex-direction: column;
    align-items: stretch;
    white-space: normal;
  }

  .run-select select {
    min-width: 0;
    max-width: none;
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .analysis-summary-strip {
    justify-content: flex-start;
  }

  .analyst-stock-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .analyst-stock-search {
    flex-direction: column;
    align-items: stretch;
  }

  .analyst-stock-search input {
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .analysis-run-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .analysis-run-toolbar select {
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .scraper-subnav,
  .analyst-subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    scrollbar-width: none;
  }

  .scraper-subnav::-webkit-scrollbar,
  .analyst-subtabs::-webkit-scrollbar {
    display: none;
  }

  .scraper-subnav-item,
  .analyst-subtab {
    flex-shrink: 0;
    min-height: 2.5rem;
    padding: 0.5rem 0.9rem;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap-fill {
    max-height: none;
    min-height: 12rem;
  }

  .scraper-stock-table {
    min-width: 640px;
  }

  .stock-cell {
    min-width: 9rem;
  }

  .scraper-stock-table .col-headlines,
  .scraper-stock-table .col-snippets {
    min-width: 12rem;
  }

  .analysis-cards,
  .analysis-cards-dense {
    grid-template-columns: 1fr;
  }

  .analysis-card-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .run-flow-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .run-flow-hero-art {
    margin: 0 auto;
  }

  .run-flow-session-select select {
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .run-flow-summary-strip {
    justify-content: center;
  }

  .stock-detail-hero {
    flex-direction: column;
  }

  .stock-detail-price {
    text-align: left;
    align-items: flex-start;
    width: 100%;
  }

  .detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .consensus-row {
    grid-template-columns: 4.5rem 1fr 2rem;
    font-size: 0.75rem;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-flat {
    padding: 0.75rem;
  }

  button,
  .primary,
  .secondary,
  .danger {
    min-height: 2.75rem;
    font-size: 0.875rem;
  }

  .btn-sm {
    min-height: 2.25rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  input,
  select,
  textarea {
    font-size: 1rem;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .error-modal,
  .algorithm-info-modal {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
  }

  .algorithm-info-modal {
    max-height: 85dvh;
  }

  .risk-intel-strip-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

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

  th, td {
    padding: 0.625rem 0.75rem;
  }

  .rationale {
    max-width: none;
  }

  .chart-toolbar {
    flex-wrap: wrap;
  }

  .chart-toolbar select {
    width: 100%;
    min-height: 2.75rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 0.625rem 0.625rem 1rem;
  }

  .mobile-header-title {
    font-size: 0.9375rem;
  }

  .panel-header .actions button,
  .workspace-toolbar .actions button,
  .section-toolbar .actions button {
    flex: 1 1 100%;
    width: 100%;
  }

  .ccf-panel .panel-header .actions button {
    flex: 1 1 100%;
  }

  .analysis-card-metrics {
    grid-template-columns: 1fr;
  }

  .run-flow-stat {
    min-width: calc(50% - 0.25rem);
    flex: 1 1 calc(50% - 0.25rem);
  }

  .login-card {
    padding: 1.5rem 1.25rem;
  }
}

@media (max-width: 768px) {
  .login-page {
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 40%);
}

.login-card {
  width: min(100%, 24rem);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.login-brand h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  color: var(--accent);
}

.login-logo {
  display: block;
  margin-bottom: 1rem;
  border-radius: 12px;
}

.login-brand p {
  margin: 0 0 1.5rem;
  color: var(--text-secondary);
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.login-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.logout-btn {
  width: 100%;
  margin-top: 0.5rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font: inherit;
}

.sidebar-trading-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.sidebar-trading-status {
  margin: 0;
  font-size: 0.75rem;
  text-align: center;
}

.sidebar-trading-status.is-active {
  color: #15803d;
}

.sidebar-trading-status.is-stopped {
  color: var(--muted);
}

.sidebar-trading-btn {
  width: 100%;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid transparent;
}

.sidebar-trading-btn--start {
  color: #14532d;
  background: #dcfce7;
  border-color: #86efac;
}

.sidebar-trading-btn--start:hover:not(:disabled) {
  background: #bbf7d0;
}

.sidebar-trading-btn--stop {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}

.sidebar-trading-btn--stop:hover:not(:disabled) {
  background: #fecaca;
}

.sidebar-trading-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.risk-intel-strip {
  margin-bottom: 0.75rem;
}

.risk-intel-strip-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.risk-intel-strip-stat {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.regime-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.regime-badge--risk-on {
  background: #dcfce7;
  color: #166534;
}

.regime-badge--risk-neutral {
  background: #fef9c3;
  color: #854d0e;
}

.regime-badge--risk-off {
  background: #fee2e2;
  color: #991b1b;
}

.risk-intelligence-panel {
  margin-bottom: 1rem;
}

.risk-intel-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.risk-intel-card {
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.risk-intel-card--risk-on {
  border-color: #86efac;
}

.risk-intel-card--risk-neutral {
  border-color: #fde047;
}

.risk-intel-card--risk-off {
  border-color: #fca5a5;
}

.risk-intel-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.risk-intel-card-value {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.risk-intel-card-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.analysis-card-ensemble {
  margin: 0.35rem 0 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 500;
}

.ensemble-specialists {
  max-width: 28rem;
  white-space: normal;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.logout-btn:hover {
  background: var(--surface-hover);
}

.analytics-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
  white-space: nowrap;
}

.analytics-loading {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-secondary);
}

.analytics-content {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  gap: 0.65rem;
}

.portfolio-at-glance-block {
  margin-top: 1rem;
}

.portfolio-at-glance-block h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.portfolio-at-glance-kpis {
  margin-top: 0.75rem;
}

.analytics-summary-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
}

.analytics-summary-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.analytics-summary-value {
  font-size: 1.25rem;
  line-height: 1.2;
}

.analytics-summary-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.analytics-summary-status {
  margin: 0.15rem 0;
}

.analytics-section {
  margin-bottom: 0;
}

.report-section-head {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.report-section-head:has(+ .report-section-body--collapsed) {
  margin-bottom: 0;
}

.report-section-head-main {
  flex: 1;
  min-width: 0;
}

.report-section-head-main .panel-header {
  margin-bottom: 0.35rem;
}

.report-section-head-main .section-title {
  margin: 0 0 0.35rem;
}

.report-section-head .analytics-section-head {
  flex: 1;
  min-width: 0;
}

.report-collapse-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-top: 0.1rem;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
}

.report-collapse-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.report-collapse-icon {
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.15s ease;
}

.report-collapse-btn[aria-expanded="false"] .report-collapse-icon {
  transform: rotate(-45deg) translateY(1px);
}

.report-section-body--collapsed {
  display: none;
}

.analytics-section.report-section > .report-section-head {
  margin-bottom: 0.75rem;
}

.analytics-section.report-section > .report-section-head:has(+ .report-section-body--collapsed) {
  margin-bottom: 0;
}

.analytics-section-head h3 {
  margin: 0 0 0.35rem;
}

.analytics-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem;
}

.analytics-regime-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-bottom: 1rem;
}

.analytics-regime-stat {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.analytics-benchmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.75rem;
}

.analytics-benchmark-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}

.analytics-benchmark-card--index {
  background: linear-gradient(180deg, #ecfdf5 0%, var(--surface-muted) 100%);
}

.analytics-benchmark-card--quantum {
  background: linear-gradient(180deg, #f3efff 0%, var(--surface-muted) 100%);
}

.analytics-benchmark-card--mega-cap {
  background: linear-gradient(180deg, #ecfdf3 0%, var(--surface-muted) 100%);
}

.analytics-benchmark-card--volatility {
  background: linear-gradient(180deg, #fffbeb 0%, var(--surface-muted) 100%);
}

.analytics-benchmark-symbol {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--accent);
}

.analytics-benchmark-name {
  font-size: 0.75rem;
  color: var(--muted);
}

.analytics-benchmark-price {
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.analytics-benchmark-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.analytics-kpi-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7rem), 1fr));
}

.analytics-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
}

.analytics-kpi-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.analytics-kpi-value {
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.analytics-kpi-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.analytics-meta-row,
.analytics-funnel-rates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.analytics-muted {
  color: var(--muted);
  font-size: 0.8125rem;
}

.analytics-neutral {
  color: var(--text-secondary);
}

.analytics-stock-name {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.analytics-stocks-table {
  min-width: 720px;
}

.analytics-trend-legend {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
}

.analytics-trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.analytics-trend-legend-item::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
}

.analytics-trend-legend-item--scraper::before { background: #14b8a6; }
.analytics-trend-legend-item--analysis::before { background: #7c3aed; }
.analytics-trend-legend-item--signal::before { background: #15803d; }

.analytics-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 9rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.analytics-trend-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 2.2rem;
  flex: 1 1 0;
}

.analytics-trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  height: 7rem;
  width: 100%;
}

.analytics-trend-bar {
  flex: 1;
  min-width: 0.35rem;
  border-radius: 3px 3px 0 0;
  opacity: 0.9;
}

.analytics-trend-bar--scraper { background: #14b8a6; }
.analytics-trend-bar--analysis { background: #7c3aed; }
.analytics-trend-bar--signal { background: #15803d; }

.analytics-trend-label {
  font-size: 0.625rem;
  color: var(--muted);
  white-space: nowrap;
}

.analytics-subheading {
  margin: 1rem 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.analytics-subtabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--surface-muted);
  width: fit-content;
}

.analytics-subtab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.analytics-subtab:hover {
  color: var(--text-primary);
}

.analytics-subtab.active {
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.analytics-view.hidden {
  display: none;
}

.virtual-test-analytics-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}

.virtual-test-analytics-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.virtual-test-analytics-field select {
  width: 100%;
}

.virtual-test-analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.virtual-test-analytics-run-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.virtual-test-analytics-run-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.virtual-test-analytics-run-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
}

.virtual-test-analytics-chart-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  background: var(--surface-elevated);
  padding: 0.5rem;
}

.virtual-test-trade-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
}

.virtual-test-chart-grid {
  stroke: var(--border-subtle);
  stroke-width: 1;
}

.virtual-test-chart-axis-line {
  stroke: var(--border-strong);
  stroke-width: 1.25;
}

.virtual-test-chart-axis,
.virtual-test-chart-axis-label {
  fill: var(--text-secondary);
  font-size: 11px;
}

.virtual-test-chart-point {
  stroke: rgba(15, 23, 42, 0.25);
  stroke-width: 1;
}

.virtual-test-chart-point--win {
  fill: #15803d;
}

.virtual-test-chart-point--loss {
  fill: #dc2626;
}

.virtual-test-chart-point--compare {
  opacity: 0.62;
  stroke-dasharray: 2 1;
}

.virtual-test-analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.virtual-test-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.virtual-test-legend-item::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.15rem;
}

.virtual-test-legend-item--win::before {
  background: #15803d;
}

.virtual-test-legend-item--loss::before {
  background: #dc2626;
}

.virtual-test-legend-item--primary::before {
  background: #15803d;
  opacity: 0.95;
}

.virtual-test-legend-item--compare::before {
  background: #15803d;
  opacity: 0.55;
  border: 1px dashed rgba(15, 23, 42, 0.35);
}

@media (max-width: 768px) {
  .analytics-grid-2 {
    grid-template-columns: 1fr;
  }

  .analytics-toggle {
    width: 100%;
  }

  .virtual-test-analytics-controls {
    grid-template-columns: 1fr;
  }
}

/* Backtest analytics dashboard (feature-flagged) */
.backtest-analytics-root {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.backtest-analytics-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 8rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.backtest-analytics-sidebar-head h3 {
  margin: 0 0 0.25rem;
}

.backtest-analytics-refresh-btn {
  margin-top: 0.5rem;
}

.backtest-analytics-run-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-right: 0.25rem;
}

.backtest-run-card {
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.25));
  border-radius: 12px;
  padding: 0.75rem;
  background: var(--surface-elevated, rgba(15, 23, 42, 0.35));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.backtest-run-card--selected {
  border-color: var(--accent-line, #2563eb);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.backtest-run-select {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.55rem;
  align-items: start;
  cursor: pointer;
}

.backtest-run-color {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.backtest-run-color.inline {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.backtest-run-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.backtest-run-copy strong {
  font-size: 0.92rem;
  line-height: 1.3;
}

.backtest-run-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.backtest-run-visibility {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.backtest-analytics-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.backtest-analytics-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.backtest-analytics-filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}

.backtest-analytics-filters-grid label span {
  color: var(--text-muted);
}

.backtest-analytics-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.backtest-analytics-metrics {
  display: grid;
  gap: 1rem;
}

.backtest-metrics-run {
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.2));
  border-left: 3px solid var(--run-color, #2563eb);
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface-elevated, rgba(15, 23, 42, 0.28));
}

.backtest-metrics-run-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.backtest-metrics-run-head h4 {
  margin: 0;
}

.backtest-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
}

.backtest-metric-grid--hero {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 0.65rem;
}

.backtest-metric-card {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.backtest-metric-card--hero {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
}

.backtest-metric-card--hero .backtest-metric-value {
  font-size: 1.1rem;
}

.backtest-metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.backtest-metric-value {
  font-size: 1rem;
}

.backtest-analytics-chart-card {
  padding: 1rem;
}

.backtest-analytics-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.backtest-analytics-chart-head h3 {
  margin: 0;
}

.backtest-analytics-chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.backtest-chart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.backtest-chart-toggle input {
  accent-color: var(--accent);
}

.backtest-analytics-chart-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0.15));
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.backtest-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  cursor: grab;
  touch-action: pan-y pinch-zoom;
}

.backtest-chart-svg.is-dragging {
  cursor: grabbing;
  touch-action: none;
}

.backtest-chart-svg:active {
  cursor: grabbing;
}

.backtest-chart-grid {
  stroke: rgba(148, 163, 184, 0.12);
  stroke-width: 1;
}

.backtest-chart-grid--x {
  stroke: rgba(148, 163, 184, 0.08);
  stroke-dasharray: 3 4;
}

.backtest-chart-axis--x {
  font-size: 10px;
}

.backtest-chart-axis-line {
  stroke: rgba(148, 163, 184, 0.35);
  stroke-width: 1.2;
}

.backtest-chart-axis,
.backtest-chart-axis-label {
  fill: var(--text-muted);
  font-size: 11px;
}

.backtest-equity-curve {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.95;
}

.backtest-trade-marker {
  stroke: rgba(15, 23, 42, 0.85);
  stroke-width: 1.2;
}

.backtest-trade-marker--win {
  fill: #16a34a;
}

.backtest-trade-marker--loss {
  fill: #dc2626;
}

.backtest-trade-marker--breakeven {
  fill: #94a3b8;
}

.backtest-trade-marker--entry-long {
  fill: #2563eb;
}

.backtest-trade-marker--entry-short {
  fill: #d97706;
}

.backtest-drawdown-area {
  pointer-events: none;
}

.backtest-analytics-tooltip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.78rem;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  white-space: pre-line;
}

.backtest-analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.82rem;
}

.backtest-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.backtest-legend-item--win::before,
.backtest-legend-item--loss::before,
.backtest-legend-item--breakeven::before,
.backtest-legend-item--entry-long::before,
.backtest-legend-item--entry-short::before,
.backtest-legend-item--drawdown::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.backtest-legend-item--drawdown::before {
  border-radius: 2px;
  background: rgba(220, 38, 38, 0.35);
}

.backtest-legend-item--win::before {
  background: #16a34a;
}

.backtest-legend-item--loss::before {
  background: #dc2626;
}

.backtest-legend-item--breakeven::before {
  background: #94a3b8;
}

.backtest-legend-item--entry-long::before {
  width: 0;
  height: 0;
  border-radius: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid #2563eb;
  background: transparent;
}

.backtest-legend-item--entry-short::before {
  width: 0;
  height: 0;
  border-radius: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid #d97706;
  background: transparent;
}

.backtest-analytics-compare h3 {
  margin-top: 0;
}

.backtest-compare-table th,
.backtest-compare-table td {
  white-space: nowrap;
}

.backtest-compare-best {
  background: rgba(37, 99, 235, 0.12);
  font-weight: 600;
}

@media (max-width: 960px) {
  .backtest-analytics-root {
    grid-template-columns: 1fr;
  }

  .backtest-analytics-sidebar {
    position: static;
    max-height: none;
  }
}
