/**
 * Legend-style dashboard styles
 * Production-ready: use CSS variables for theming and future white-label.
 */
:root {
  /* Aliased from static/css/banana-tokens.css (load before this file in legend.html).
     Cyber-Citrus: shell/widget map — docs/cyber-citrus-design-system.md §7 */
  --legend-bg: var(--banana-background);
  --legend-bg-elevated: var(--banana-surface-container);
  /* Dotted canvas — surface-container-low */
  --legend-canvas-bg: var(--banana-surface-container-low);
  --legend-dot-pitch: 16px;
  --legend-bg-widget: var(--banana-surface-container);
  /* Ghost hairlines (outline_variant @ 15%) — prefer tonal surfaces over borders */
  --legend-border: var(--banana-outline-ghost);
  --legend-border-focus: rgba(204, 255, 0, 0.28);
  --legend-primary-gradient: linear-gradient(135deg, var(--banana-primary-fixed) 0%, var(--banana-primary-dim) 100%);
  --legend-text: var(--banana-text-body);
  --legend-text-muted: var(--banana-on-surface-variant);
  --legend-accent: var(--banana-accent-lime);
  --legend-on-primary: var(--banana-on-primary);
  --legend-tab-active-bg: rgba(204, 255, 0, 0.12);
  --legend-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --legend-font-body: var(--legend-font);
  --legend-font-headline: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --legend-assistant-sidebar-width: clamp(260px, 26vw, 320px);

  /* Liquid-glass surface recipe — distilled from the add-widget modal so the
     page chrome (topbar, context bar, sidebar) reads as one cohesive system. */
  --legend-glass-bg: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-surface-container-high) 70%, transparent),
    color-mix(in srgb, var(--banana-surface-container) 64%, transparent)
  );
  --legend-glass-border: color-mix(in srgb, #ffffff 10%, transparent);
  --legend-glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --legend-glass-glow: 0 0 60px color-mix(in srgb, var(--banana-primary-fixed) 4%, transparent);
  --legend-glass-blur: 18px;
  --legend-radius-chrome: var(--banana-radius);
  --legend-focus-ring: 0 0 0 2px color-mix(in srgb, var(--banana-primary-fixed) 40%, transparent);
}

/* Workspace pages port many overlays to document.body; inherit Inter from body,
   not only from .legend-app (modals, wizard, floated dropdowns, toasts). */
html:has(.legend-app) body {
  font-family: var(--legend-font);
}

.legend-app {
  font-family: var(--legend-font);
  margin: 0;
  box-sizing: border-box;
  /* Top nav removed on app pages — sidebar shell owns horizontal offset. */
  padding-top: 0;
  /* One continuous dotted field for the whole workspace shell. The topbar,
     context bar and canvas are transparent over this, so they read as a single
     cohesive surface rather than stacked bands. Layer order (top -> bottom):
     soft edge vignette, dot grid, base color. */
  background-color: var(--legend-canvas-bg);
  background-image:
    radial-gradient(
      135% 120% at 50% 32%,
      transparent 58%,
      color-mix(in srgb, var(--legend-canvas-bg) 70%, transparent) 100%
    ),
    radial-gradient(
      circle,
      rgba(255, 255, 255, 0.085) 1px,
      transparent 1.5px
    );
  background-size:
    100% 100%,
    var(--legend-dot-pitch, 16px) var(--legend-dot-pitch, 16px);
  background-position:
    0 0,
    calc(var(--legend-dot-pitch, 16px) / 2) calc(var(--legend-dot-pitch, 16px) / 2);
  color: var(--legend-text);
  height: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-app > .site-nav {
  flex: 0 0 auto;
  min-width: 0;
  z-index: 1000;
  overflow: visible;
  box-sizing: border-box;
  flex-shrink: 0;
}

.legend-app > .site-nav .site-nav__inner,
.legend-app > .site-nav .site-nav__actions {
  overflow: visible;
}

.legend-app > .site-nav .site-nav__user-menu-panel {
  z-index: 1001;
}

/* Cyber-Citrus: links stay in citrus spectrum, not Material blue (§6) */
.legend-app a {
  color: var(--banana-secondary);
  text-decoration: none;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.legend-app a:hover {
  color: var(--banana-primary);
  text-shadow: 0 0 12px color-mix(in srgb, var(--banana-primary) 25%, transparent);
}

.legend-app .site-nav__brand,
.legend-app .site-nav__brand:hover {
  color: var(--banana-on-surface);
  text-shadow: none;
}

.legend-app .site-nav__brand .site-nav__brand-text {
  color: var(--banana-on-surface);
}

/* Hide all scrollbars in Legend (including GridStack and widget internals) */
.legend-app,
.legend-app * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.legend-app ::-webkit-scrollbar,
.legend-app::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}


@media (min-width: 1024px) {
  .legend-app > .site-nav .site-nav__center-links {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    -ms-overflow-style: auto;
  }

  .legend-app > .site-nav .site-nav__center-links::-webkit-scrollbar {
    display: block;
    height: 4px;
  }

  .legend-app > .site-nav .site-nav__center-links::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: var(--banana-radius);
  }
}

.legend-app > .site-nav .site-nav__inline-form {
  display: inline-flex;
  flex-shrink: 0;
}

.legend-app > .site-nav .site-nav__auth-link {
  white-space: nowrap;
}

.legend-app > .site-nav .site-nav__user-menu-trigger {
  max-width: min(100%, 9rem);
}

@media (min-width: 1024px) {
  .legend-app > .site-nav .site-nav__user-menu-trigger {
    max-width: min(100%, 10rem);
  }
}

/* Mobile drawer must scroll despite global scrollbar hide */
.legend-app .site-nav__center-links {
  scrollbar-width: thin;
  -ms-overflow-style: auto;
}

.legend-app .site-nav__center-links::-webkit-scrollbar {
  display: block;
  width: 6px;
}

/* Top bar — transparent; controls float over the shared dotted field */
.legend-topbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 48px;
  padding: 4px 16px 2px;
  background: transparent;
  border-bottom: none;
  box-shadow: none;
  gap: 8px;
  position: relative;
  z-index: 6;
}

.legend-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

/* Cohesion: unified citrus focus ring across chrome controls */
.legend-tab:focus-visible,
.legend-tab-add:focus-visible,
.legend-btn:focus-visible,
.legend-assistant-toggle-btn:focus-visible,
.legend-llm-status:focus-visible {
  outline: none;
  box-shadow: var(--legend-focus-ring);
}

/* Respect reduced-motion for the polish transitions/lifts added to chrome */
@media (prefers-reduced-motion: reduce) {
  .legend-tab,
  .legend-btn,
  .legend-btn-primary,
  .legend-llm-status {
    transition: none;
  }

  .legend-btn-primary:hover {
    transform: none;
  }
}

.legend-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.legend-brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.legend-brand-text {
  font-family: var(--legend-font-headline);
  font-size: 15px;
  font-weight: 700;
  color: var(--legend-accent);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.legend-tab {
  font-family: var(--legend-font-headline);
  padding: 7px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--legend-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--banana-radius);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-tab[draggable="true"] {
  cursor: grab;
}

.legend-tab.legend-tab--dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.legend-tab.legend-tab--drag-over {
  color: var(--legend-text);
  background: rgba(204, 255, 0, 0.08);
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 25%, transparent);
}

.legend-tab:hover {
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.06);
}

.legend-tab.active {
  color: var(--banana-on-surface);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-primary-fixed) 18%, transparent),
    color-mix(in srgb, var(--banana-primary-fixed) 9%, transparent)
  );
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 30%, transparent);
  box-shadow:
    var(--legend-glass-highlight),
    0 0 18px color-mix(in srgb, var(--banana-primary-fixed) 14%, transparent);
}

.legend-tab-add {
  padding: 8px 10px;
  color: var(--legend-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  border-radius: var(--banana-radius);
  flex-shrink: 0;
}

.legend-tab-add:hover {
  color: var(--legend-accent);
  background: rgba(255, 255, 255, 0.08);
}

.legend-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.legend-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 12rem;
  margin-right: 4px;
}

.legend-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.legend-user-name {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--banana-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .legend-user-name {
    display: none;
  }
}

/* Secondary actions: glass surface + primary label, hairline rim */
.legend-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--legend-glass-border);
  background: color-mix(in srgb, var(--banana-surface-container-highest) 70%, transparent);
  color: var(--banana-primary);
  cursor: pointer;
  border-radius: var(--banana-radius);
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.legend-btn:hover {
  background: var(--banana-surface-bright);
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 28%, transparent);
  box-shadow: var(--banana-shadow-neon-hum);
  color: var(--banana-primary-fixed);
}

.legend-btn-primary {
  font-family: var(--legend-font-headline);
  background: var(--legend-primary-gradient);
  color: var(--legend-on-primary);
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--banana-primary-fixed) 24%, transparent);
}

.legend-btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--banana-primary-fixed) 32%, transparent);
}

.legend-btn-primary:active {
  transform: translateY(0);
}

.legend-btn.is-disabled,
.legend-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

.legend-btn.is-disabled:hover,
.legend-btn:disabled:hover {
  background: var(--banana-surface-container-highest);
  color: var(--banana-primary);
  box-shadow: none;
  filter: none;
  transform: none;
}

.legend-btn-primary.is-disabled,
.legend-btn-primary:disabled {
  background: var(--banana-surface-container-highest);
  color: var(--legend-text-muted);
  box-shadow: none;
}

.legend-btn-primary.is-disabled:hover,
.legend-btn-primary:disabled:hover {
  background: var(--banana-surface-container-highest);
  color: var(--legend-text-muted);
  box-shadow: none;
  transform: none;
}

/* Grid container — Stitch-style dotted canvas + cursor spotlight */
.legend-workspace-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.legend-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  /* Transparent so the single dotted field painted on .legend-app shows
     through continuously — no separate canvas band. */
  background: transparent;
}

.legend-content::-webkit-scrollbar {
  display: none;
}

/* Assistant sidebar: push layout beside canvas */
.legend-assistant-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-assistant-toggle-btn__icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.legend-assistant-toggle-btn.is-active {
  border-color: color-mix(in srgb, var(--legend-accent) 35%, var(--legend-border));
  background: rgba(204, 255, 0, 0.08);
  color: var(--legend-text);
}

.legend-assistant-toggle-btn--locked {
  border-color: color-mix(in srgb, var(--legend-accent) 22%, var(--legend-border));
  opacity: 0.92;
}

.legend-assistant-toggle-btn--locked .legend-assistant-toggle-btn__label {
  color: var(--legend-text-muted);
}

.legend-assistant-toggle-btn--locked .legend-assistant-toggle-btn__icon-wrap {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
}

.legend-assistant-toggle-btn--locked .legend-assistant-toggle-btn__chat {
  opacity: 0.45;
}

.legend-assistant-toggle-btn--locked .legend-assistant-toggle-btn__lock {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  color: var(--legend-accent);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--legend-accent) 35%, transparent));
}

.legend-llm-panel {
  flex: 0 0 var(--legend-assistant-sidebar-width);
  width: var(--legend-assistant-sidebar-width);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  border-left: 1px solid var(--legend-glass-border);
  background: var(--legend-glass-bg);
  background-color: var(--banana-surface-container-high);
  backdrop-filter: blur(var(--legend-glass-blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--legend-glass-blur)) saturate(1.2);
  box-shadow: var(--legend-glass-highlight);
  pointer-events: auto;
  overflow: hidden;
  transition: flex-basis 0.2s ease, width 0.2s ease, padding 0.2s ease, border-color 0.2s ease;
}

.legend-llm-panel.is-collapsed {
  flex: 0 0 0;
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-left-color: transparent;
  overflow: hidden;
  pointer-events: none;
}

@media (max-width: 768px) {
  .legend-llm-panel:not(.is-collapsed) {
    flex: 0 0 min(100%, 100vw);
    width: min(100%, 100vw);
  }
}

.legend-llm-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.legend-llm-panel-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.legend-llm-panel .legend-assistant-disclaimer {
  display: none;
}

.legend-llm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 0 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--legend-border);
  flex-shrink: 0;
  min-height: 34px;
  overflow: hidden;
}

.legend-llm-panel-header-start {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.legend-llm-panel-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 0;
  gap: 2px;
  overflow: hidden;
}

.legend-llm-panel-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
  margin: 0;
  padding: 0 2px;
  font-family: var(--legend-font-headline);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--legend-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-llm-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.legend-llm-header-btn--text {
  width: auto;
  max-width: 100%;
  height: auto;
  padding: 4px 6px;
  font-family: var(--legend-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--legend-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-llm-header-btn:hover,
.legend-llm-header-btn--text:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--legend-text);
}

.legend-llm-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-llm-view[hidden] {
  display: none !important;
}

.legend-llm-view--chat {
  position: relative;
  padding-top: 2px;
}

.legend-llm-view-intro {
  flex-shrink: 0;
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--legend-text-muted);
}

.legend-llm-empty {
  position: absolute;
  inset: 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  pointer-events: none;
}

.legend-llm-empty[hidden] {
  display: none !important;
}

.legend-llm-empty-title {
  margin: 0;
  font-family: var(--legend-font-headline);
  font-size: 14px;
  font-weight: 600;
  color: var(--legend-text);
}

.legend-llm-empty-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--legend-text-muted);
  max-width: 22ch;
}

.legend-llm-panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.legend-llm-panel-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--legend-text);
}

.legend-llm-messages {
  pointer-events: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--legend-font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--legend-text);
  scrollbar-width: thin;
}

.legend-llm-view--chat:has(.legend-llm-messages:not(:empty)) .legend-llm-empty {
  display: none !important;
}

.legend-llm-history-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.legend-llm-history-toolbar .legend-llm-view-intro {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.legend-llm-history-toolbar .legend-llm-action-btn {
  flex-shrink: 0;
}

.legend-llm-msg {
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  word-break: break-word;
  white-space: pre-wrap;
}

.legend-llm-msg strong {
  font-weight: 700;
  color: inherit;
}

.legend-llm-msg:last-child {
  margin-bottom: 0;
}

.legend-llm-msg--user {
  margin-left: 8px;
  background: rgba(204, 255, 0, 0.08);
  border: 1px solid rgba(204, 255, 0, 0.2);
}

.legend-llm-msg--assistant {
  margin-right: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--legend-border);
}

.legend-llm-msg--error {
  border-color: rgba(255, 80, 80, 0.5);
  background: rgba(80, 20, 20, 0.35);
}

.legend-llm-msg--loading {
  opacity: 0.75;
  font-style: italic;
}

.legend-llm-telemetry {
  margin: -2px 12px 8px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--legend-text-muted);
  opacity: 0.9;
}

.legend-llm-context-row {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 0 2px;
  font-size: 11px;
  color: var(--legend-text-muted);
}

/* Author display:flex wins over [hidden] otherwise — hide until widgets are attached */
.legend-llm-context-row[hidden] {
  display: none !important;
}

.legend-llm-context-label {
  flex-shrink: 0;
  padding-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legend-llm-context-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.legend-llm-context-size {
  margin-left: auto;
  align-self: center;
  font-size: 11px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-llm-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 10px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--legend-border);
  color: var(--legend-text);
  font-size: 12px;
}

.legend-llm-context-chip-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--legend-text-muted);
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
}

.legend-llm-context-chip-remove:hover {
  background: rgba(255, 100, 100, 0.25);
  color: var(--legend-text);
}

/* AI widget selection overlay (marquee) */
.legend-ai-select-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  cursor: crosshair;
  touch-action: none;
}

.legend-app--ai-select .legend-ai-select-overlay {
  display: block;
}

.legend-ai-marquee {
  position: absolute;
  display: none;
  pointer-events: none;
  border: 1px solid rgba(0, 120, 255, 0.95);
  background: rgba(0, 120, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.legend-ai-select-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: none;
  padding: 8px 14px;
  border-radius: var(--banana-radius);
  background: rgba(18, 18, 22, 0.92);
  border: 1px solid var(--legend-border);
  color: var(--legend-text);
  font-size: 13px;
  font-family: var(--legend-font);
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.legend-app--ai-select .legend-ai-select-banner {
  display: block;
}

/* Bottom LLM prompt bar */
.legend-llm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.legend-llm-bar {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  pointer-events: none;
}

.legend-llm-bar-inner {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--banana-glass-surface);
  backdrop-filter: blur(var(--banana-glass-blur));
  -webkit-backdrop-filter: blur(var(--banana-glass-blur));
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.legend-llm-composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.legend-llm-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--banana-radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--legend-text-muted);
  font-family: var(--legend-font);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.legend-llm-action-btn svg {
  flex-shrink: 0;
}

.legend-llm-action-btn--secondary {
  border-color: var(--legend-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--legend-text);
}

.legend-llm-action-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: color-mix(in srgb, var(--legend-accent) 25%, var(--legend-border));
}

.legend-llm-action-btn--secondary.is-active {
  border-color: color-mix(in srgb, var(--legend-accent) 45%, var(--legend-border));
  background: rgba(204, 255, 0, 0.1);
  color: var(--legend-accent);
}

.legend-llm-action-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--legend-text);
}

.legend-llm-action-btn--primary {
  border-color: color-mix(in srgb, var(--legend-accent) 35%, var(--legend-border));
  background: rgba(204, 255, 0, 0.12);
  color: var(--legend-text);
}

.legend-llm-action-btn--primary:hover {
  background: rgba(204, 255, 0, 0.18);
}

.legend-llm-composer-actions .legend-llm-submit {
  margin-left: auto;
}

.legend-llm-status {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid var(--legend-glass-border);
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 45%, transparent);
  color: var(--legend-text-muted);
  font-family: var(--legend-font);
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.legend-llm-status:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 22%, transparent);
  color: var(--legend-text);
}

.legend-llm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--legend-text-muted);
}

.legend-llm-status-dot--ready {
  background: var(--legend-accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--legend-accent) 45%, transparent);
}

.legend-llm-status-dot--missing {
  background: #e8a030;
}

.legend-llm-status-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-llm-status-sep {
  opacity: 0.5;
}

.legend-llm-settings-label {
  display: block;
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-llm-settings-label:first-of-type {
  margin-top: 0;
}

.legend-llm-settings-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--legend-text);
  font-family: var(--legend-font);
  font-size: 13px;
}

.legend-llm-settings-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--legend-accent) 35%, var(--legend-border));
}

.legend-llm-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--legend-border);
}

.legend-llm-panel--subview .legend-llm-panel-footer {
  display: none;
}

.legend-llm-panel--subview .legend-llm-panel-title {
  display: none;
}

.legend-llm-panel--subview .legend-llm-panel-header-start {
  flex: 0 0 auto;
}

.legend-llm-panel--subview .legend-llm-panel-header-actions {
  flex: 1 1 auto;
}

.legend-llm-settings-btn {
  width: 32px;
  height: 32px;
  color: var(--legend-text-muted);
}

.legend-llm-settings-btn:hover {
  color: var(--banana-primary);
  background: rgba(255, 255, 255, 0.08);
}

.legend-llm-panel--settings-view #legend-llm-settings-btn {
  display: none;
}

.legend-llm-input {
  width: 100%;
  min-height: 0;
  height: 22px;
  max-height: 120px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--legend-text);
  font-family: var(--legend-font);
  font-size: 13px;
  line-height: 1.35;
  resize: none;
  outline: none;
  overflow-y: hidden;
}

.legend-llm-input.is-expanded {
  overflow-y: auto;
}

.legend-llm-input::placeholder {
  color: var(--legend-text-muted);
}

.legend-llm-toolbar {
  display: none;
}

.legend-chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.legend-chat-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.legend-chat-history-row.is-active {
  border-color: color-mix(in srgb, var(--legend-accent) 35%, var(--legend-border));
  background: rgba(204, 255, 0, 0.06);
}

.legend-chat-history-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--legend-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-chat-history-row-meta {
  font-size: 11px;
  color: var(--legend-text-muted);
}

.legend-chat-history-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: color-mix(in srgb, var(--banana-primary) 25%, transparent);
}

.legend-chat-history-row-info {
  flex: 1;
  min-width: 0;
}

.legend-chat-history-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.legend-chat-history-delete:hover {
  background: rgba(255, 80, 80, 0.15);
  color: #ff8a8a;
}

.legend-llm-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 0;
  padding: 0;
  border: none;
  border-radius: var(--banana-radius);
  background: var(--legend-primary-gradient);
  color: var(--banana-on-primary);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  flex-shrink: 0;
}

.legend-llm-submit:hover {
  filter: brightness(1.08);
  box-shadow: var(--banana-shadow-neon-hum);
}

.legend-llm-submit:active {
  transform: scale(0.96);
}

.legend-llm-submit.is-sending {
  background: rgba(255, 255, 255, 0.16);
  color: var(--legend-text);
}

.legend-canvas {
  --legend-dot-pitch: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  width: 100%;
  isolation: isolate;
}

.legend-canvas-bg {
  /* Base fill + dim dots now come from the shared .legend-app field. */
  display: none;
}

.legend-canvas-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Fixed attachment anchors the grid to the viewport so it aligns exactly with
     the dotted field painted on .legend-app (single continuous grid). */
  background-attachment: fixed;
  background-size: var(--legend-dot-pitch, 16px) var(--legend-dot-pitch, 16px);
  background-position: calc(var(--legend-dot-pitch, 16px) / 2) calc(var(--legend-dot-pitch, 16px) / 2);
}

/* Dim base dots are provided by .legend-app now; this layer is retired. */
.legend-canvas-dots--dim {
  display: none;
}

.legend-canvas-dots--glow {
  z-index: 2;
  background-image: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.36) 1px,
    transparent 1.5px
  );
  mask-image: radial-gradient(
    circle var(--legend-spotlight-radius, 340px) at var(--legend-cursor-x, 50%) var(--legend-cursor-y, 50%),
    #000 0%,
    rgba(0, 0, 0, 0.45) 42%,
    transparent 72%
  );
  -webkit-mask-image: radial-gradient(
    circle var(--legend-spotlight-radius, 340px) at var(--legend-cursor-x, 50%) var(--legend-cursor-y, 50%),
    #000 0%,
    rgba(0, 0, 0, 0.45) 42%,
    transparent 72%
  );
  mask-mode: alpha;
  -webkit-mask-mode: alpha;
  transition: opacity 0.15s ease;
}

.legend-layouts-host {
  position: relative;
  z-index: 3;
  flex: 1;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.legend-layout {
  display: none;
  min-height: 400px;
  height: 100%;
}

.legend-layout.active {
  display: block;
}

/* GridStack overrides — Bento slot: tonal card + subtle depth (§5, §9) */
.grid-stack {
  background: transparent;
  min-height: 100%;
}

.grid-stack-item-content {
  background: var(--legend-bg-widget);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  overflow: hidden;
  left: 4px !important;
  right: 4px !important;
  top: 4px !important;
  bottom: 4px !important;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.grid-stack-item-content > .legend-widget,
.grid-stack-item-content > .legend-widget-stack {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}

.grid-stack-item.ui-draggable-dragging .grid-stack-item-content,
.grid-stack-item.ui-resizable-resizing .grid-stack-item-content {
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--legend-border-focus),
    var(--banana-shadow-neon-hum);
}

/* Label sits above the bordered card (outside .legend-widget) */
.grid-stack-item-content:has(> .legend-widget-stack) {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  overflow: visible;
}

.legend-widget-stack {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.legend-widget-stack > .legend-widget {
  flex: 1;
  min-height: 0;
  position: relative;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  background: var(--legend-bg-widget);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  overflow: hidden;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.legend-widget-name {
  flex: 0 0 auto;
  padding: 0 2px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--legend-text-muted);
  letter-spacing: 0.02em;
}

/* Widget chrome */
.legend-widget {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  min-height: 0;
  position: relative;
}

.legend-widget-header {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  align-items: center;
  cursor: move;
  justify-content: space-between;
  padding: 8px 12px;
  min-height: 36px;
  box-sizing: border-box;
  flex-shrink: 0;
  border-bottom: none;
  background: var(--banana-surface-container-highest);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--banana-outline-variant) 18%, transparent);
  cursor: grab;
}

.legend-widget-header:active {
  cursor: grabbing;
}

.legend-widget-title {
  font-family: var(--legend-font-headline);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--legend-text);
  flex-shrink: 0;
  min-width: 0;
}

.legend-widget-title[title] {
  cursor: help;
}

.legend-live-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  margin-right: 10px;
  padding: 1px 6px;
  border-radius: var(--banana-radius);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--legend-bg, #0a0a0a);
  background: var(--legend-accent-lime, #c3f400);
  animation: legend-live-pulse 2s ease-in-out infinite;
}

@keyframes legend-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.legend-widget-title--sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.legend-widget-ticker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.legend-widget-ticker-global {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 500;
  border: 1px solid var(--legend-border);
  background: transparent;
  color: var(--legend-text-muted);
  cursor: pointer;
  border-radius: var(--banana-radius);
}

.legend-widget-ticker-global:hover {
  color: var(--legend-text);
  border-color: var(--legend-border-focus);
}

.legend-widget-ticker-global.active {
  background: color-mix(in srgb, var(--banana-chart-call) 22%, transparent);
  color: var(--banana-chart-call);
  border-color: color-mix(in srgb, var(--banana-chart-call) 55%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--banana-chart-call) 35%, transparent);
}

.legend-widget-ticker-input {
  width: 56px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--banana-surface-container-lowest);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-widget-ticker-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary) 40%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--banana-primary) 22%, transparent);
}

.legend-chart-symbol-wrap {
  position: relative;
}

.legend-chart-symbol-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 140;
  min-width: 210px;
  max-width: min(280px, 70vw);
  padding: 8px;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: var(--banana-surface-container);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.legend-chart-symbol-picker[hidden] {
  display: none !important;
}

.legend-chart-symbol-picker.legend-chart-symbol-picker--floating.is-open {
  position: fixed;
  z-index: 10050;
  pointer-events: auto;
}

.legend-chart-symbol-picker-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--legend-text);
  margin-bottom: 2px;
}

.legend-chart-symbol-picker-hint {
  font-size: 10px;
  color: var(--legend-text-muted);
  margin-bottom: 6px;
}

.legend-chart-symbol-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.legend-chart-symbol-pick {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  font-size: 11px;
  border: none;
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text);
  cursor: pointer;
}

.legend-chart-symbol-pick:hover,
.legend-chart-symbol-pick:focus {
  background: color-mix(in srgb, var(--banana-primary) 16%, transparent);
  color: var(--banana-primary);
  outline: none;
}

.legend-widget-contract-row .legend-widget-contract-input {
  width: min(220px, 36vw);
  max-width: 100%;
  padding: 2px 8px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  border: 1px solid var(--legend-border);
  background: var(--banana-surface-container-lowest);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-widget-contract-row .legend-widget-contract-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary) 40%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--banana-primary) 22%, transparent);
}

.legend-widget-oci-interval {
  margin-left: 6px;
  margin-right: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--legend-text);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
  min-width: 52px;
}

.legend-widget-oci-interval:hover {
  border-color: var(--legend-border-focus);
}

.legend-widget-ocf-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.legend-widget-ocf-filters label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-ocf-lab {
  white-space: nowrap;
}

.legend-ocf-limit,
.legend-ocf-min-premium {
  width: 56px;
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
}

.legend-ocf-side {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-ocf-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-ocf-summary strong {
  color: var(--legend-text-muted);
  font-weight: 600;
  margin-right: 4px;
}

/* Option contract flow: scroll the trades table inside the widget, not the shell */
.legend-widget[data-type-id="option_contract_flow"] .legend-widget-body {
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_flow"] .legend-widget-inner {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_flow"] .legend-ocf-summary {
  flex: 0 0 auto;
}

.legend-widget[data-type-id="option_contract_flow"] .legend-ocf-table-host {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_flow"] .legend-ocf-table-host .legend-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.legend-os-contract-row {
  cursor: pointer;
}

.legend-os-contract-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.legend-os-contract-row:focus {
  outline: 1px solid var(--legend-border-focus);
  outline-offset: -1px;
}

.legend-widget-ticker-select,
.legend-widget-etf-select {
  min-width: 56px;
  max-width: 180px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-ticker-select:focus,
.legend-widget-etf-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-sector-wrap {
  min-width: 0;
  max-width: min(280px, 100%);
}

.legend-widget-sector-select {
  min-width: 140px;
  max-width: 280px;
  width: 100%;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-sector-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-group-flow-wrap {
  min-width: 0;
  max-width: min(220px, 100%);
}

.legend-widget-ggf-group-select {
  min-width: 120px;
  max-width: 220px;
  width: 100%;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-ggf-group-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-cross-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  max-width: min(100%, 420px);
}

.legend-cross-ctrl select {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  max-width: 120px;
}

.legend-gf-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-gf-toolbar .legend-gf-metrics-label {
  font-size: 10px;
  color: var(--legend-text-muted, #999);
  white-space: nowrap;
}

/* Greek flow: dropdown button + checkbox panel (multi-select) */
.legend-gf-msdd {
  position: relative;
}

.legend-gf-msdd-inner {
  position: relative;
}

.legend-gf-msdd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  max-width: min(156px, 100%);
  width: max-content;
  font-size: 10px;
  padding: 4px 6px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
}

.legend-gf-msdd-btn:hover {
  border-color: var(--legend-accent, #666);
}

.legend-gf-msdd-btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-gf-msdd-caret {
  flex-shrink: 0;
  font-size: 9px;
  opacity: 0.75;
}

.legend-gf-msdd-panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  min-width: 260px;
  max-width: min(320px, 92vw);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.legend-gf-msdd-panel.is-open {
  display: block;
  z-index: 200;
}

.legend-gf-msdd-panel.legend-msdd-panel--floating.is-open,
.legend-fpe-msdd-panel.legend-msdd-panel--floating.is-open,
.legend-fps-msdd-panel.legend-msdd-panel--floating.is-open,
.legend-fpsi-msdd-panel.legend-msdd-panel--floating.is-open,
.legend-chart-ind-msdd-panel.legend-msdd-panel--floating.is-open {
  z-index: 10050;
}

/* Keep open series dropdown above the chart body (panel hangs below the header). */
.legend-widget-header:has(.legend-fpe-msdd-panel.is-open),
.legend-widget-header:has(.legend-gf-msdd-panel.is-open),
.legend-widget-header:has(.legend-fps-msdd-panel.is-open),
.legend-widget-header:has(.legend-fpsi-msdd-panel.is-open),
.legend-widget-header:has(.legend-chart-ind-msdd-panel.is-open) {
  position: relative;
  z-index: 50;
}

.legend-gf-msdd-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px;
  font-size: 10px;
  color: var(--legend-text);
  cursor: pointer;
  border-radius: var(--banana-radius);
}

.legend-gf-msdd-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.legend-gf-msdd-row .legend-gf-msdd-cb {
  margin-top: 2px;
  flex-shrink: 0;
}

.legend-gf-msdd-row-label {
  line-height: 1.25;
}

.legend-fpe-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-fpe-toolbar .legend-fpe-metrics-label {
  font-size: 10px;
  color: var(--legend-text-muted, #999);
  white-space: nowrap;
}

.legend-fpe-msdd { position: relative; }
.legend-fpe-msdd-inner { position: relative; }

.legend-fpe-msdd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 220px;
  max-width: min(320px, 100%);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
}

.legend-fpe-msdd-btn:hover { border-color: var(--legend-accent, #666); }
.legend-fpe-msdd-btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-fpe-msdd-caret { flex-shrink: 0; font-size: 9px; opacity: 0.75; }

.legend-fpe-msdd-panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  min-width: 280px;
  max-width: min(360px, 92vw);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.legend-fpe-msdd-panel.is-open {
  display: block;
  z-index: 200;
}

/* Portaled to document.body while open — escapes widget overflow / chart hit targets */
.legend-msdd-panel--floating {
  display: none;
  position: fixed;
  z-index: 10050;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.legend-msdd-panel--floating.is-open {
  display: block;
}
.legend-fpe-msdd-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px;
  font-size: 10px;
  color: var(--legend-text);
  cursor: pointer;
  border-radius: var(--banana-radius);
}
.legend-fpe-msdd-row:hover { background: rgba(255, 255, 255, 0.06); }
.legend-fpe-msdd-row .legend-fpe-msdd-cb { margin-top: 2px; flex-shrink: 0; }
.legend-fpe-msdd-row-label { line-height: 1.25; }

.legend-widget-gex-view {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-gex-view-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-gex-view-select {
  min-width: 90px;
  max-width: 120px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-gex-view-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-gex-strike-window-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 8px;
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-gex-strike-window-label {
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-widget-gex-strike-window {
  width: 48px;
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
}

.legend-widget-gex-strike-window:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-gex-expiry {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-gex-expiry-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-gex-expiry-select {
  min-width: 110px;
  max-width: 180px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-gex-expiry-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-greek-view {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-greek-view-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-greek-view-select {
  min-width: 120px;
  max-width: 160px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-greek-view-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-greek-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-greek-metric-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-greek-metric-select {
  min-width: 100px;
  max-width: 140px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-greek-metric-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-greek-expiry {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-greek-expiry-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-greek-expiry-select {
  min-width: 110px;
  max-width: 160px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-greek-expiry-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-gex-type {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.legend-widget-gex-type-label {
  font-size: 10px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-widget-gex-type-select {
  min-width: 100px;
  max-width: 200px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-gex-type-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-widget-gex-flip-btn {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 500;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text-muted);
  border-radius: var(--banana-radius);
  cursor: pointer;
  white-space: nowrap;
}

.legend-widget-gex-flip-btn:hover {
  color: var(--legend-text);
  border-color: var(--legend-border-focus);
}

.legend-widget-gex-flip-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--legend-text);
  border-color: var(--legend-border-focus);
}

.legend-widget-header-spacer {
  flex: 1;
  min-width: 0;
}

.legend-widget-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-widget-menu-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--legend-text-muted);
  cursor: pointer;
  border-radius: var(--banana-radius);
  font-size: 14px;
}

.legend-widget-menu-btn:hover {
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.08);
}

.legend-widget-menu-btn.active {
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.12);
}

.legend-widget-nf-toggle-btn {
  width: auto;
  min-width: 24px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--legend-font-headline);
}

.legend-widget-nf-toggle-btn.active {
  color: var(--banana-accent-lime);
  background: color-mix(in srgb, var(--banana-accent-lime) 14%, transparent);
}

.legend-widget-menu-btn svg {
  display: block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.legend-widget-menu-btn.legend-widget-copy-image-btn--busy {
  pointer-events: none;
  opacity: 0.55;
}

.legend-widget-filters-btn {
  margin-left: auto;
  margin-right: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--legend-text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-filters-btn:hover {
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.1);
}

.legend-chart-ticker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}

.legend-chart-logo {
  width: 24px;
  height: 24px;
  border-radius: var(--banana-radius);
  object-fit: contain;
}

.legend-chart-info-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--legend-text-muted);
  background: transparent;
  border: none;
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-chart-info-btn:hover {
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.08);
}

.legend-stock-info-popover {
  position: fixed;
  z-index: 2000;
  width: min(380px, calc(100vw - 16px));
  max-height: min(70vh, 520px);
  overflow: auto;
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 0 0 16px;
}

.legend-stock-info-popover-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--legend-border);
  background: rgba(255, 255, 255, 0.02);
}

.legend-stock-info-popover-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--banana-radius);
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--legend-border);
}

.legend-stock-info-popover-headtext {
  min-width: 0;
  flex: 1;
}

.legend-stock-info-popover-symbol {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--legend-bg, #111);
  background: var(--legend-accent-lime, #c3f400);
}

.legend-stock-info-popover-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  color: var(--legend-text);
}

.legend-stock-info-popover-meta {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--legend-text-muted);
}

.legend-stock-info-popover-desc {
  margin: 0;
  padding: 12px 14px 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--legend-text-muted);
}

.legend-stock-info-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px 0;
}

.legend-stock-info-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.legend-stock-info-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-stock-info-stat-value {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--legend-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-stock-info-flags {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  padding: 12px 14px 4px;
}

.legend-stock-info-flag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.legend-stock-info-flag-label {
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-stock-info-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.legend-stock-info-flag.is-yes {
  color: #d7ff8a;
  background: rgba(195, 244, 0, 0.12);
  border: 1px solid rgba(195, 244, 0, 0.22);
}

.legend-stock-info-flag.is-no {
  color: var(--legend-text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-stock-info-flag.is-muted {
  color: var(--legend-text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.legend-stock-info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px 0;
}

.legend-stock-info-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 600;
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--legend-border);
  text-transform: lowercase;
}

.legend-stock-info-footnote {
  padding: 10px 14px 0;
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-stock-info-section-label {
  padding: 10px 14px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-stock-info-fundamentals {
  border-top: 1px solid var(--legend-border);
  margin-top: 4px;
}

.legend-stock-info-research-link {
  color: #c3f400;
  text-decoration: none;
  font-weight: 600;
}

.legend-stock-info-research-link:hover {
  text-decoration: underline;
}

.legend-widget[data-type-id="price_data"] > .legend-widget-header {
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  position: relative;
}

.legend-widget[data-type-id="price_data"] .legend-live-price-note {
  margin-left: auto;
  min-width: 10.5rem;
  font-size: 10px;
  color: var(--legend-accent-lime, #c3f400);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  flex: 0 0 auto;
  opacity: 0.92;
}

.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-widget-ticker,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-widget-date,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-ticker-wrap,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-rth-btn,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-interval,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-ind-msdd,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-gex-overlay,
.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-gex-controls {
  margin-left: 0;
  margin-right: 0;
}

.legend-widget[data-type-id="price_data"] > .legend-widget-header .legend-chart-interval {
  margin-left: 8px;
}

.legend-widget[data-type-id="price_data"] > .legend-widget-body {
  overflow: hidden;
}

.legend-chart-rth-btn {
  margin-left: auto;
  margin-right: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--legend-text-muted);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-chart-rth-btn:hover {
  color: var(--legend-text);
  border-color: var(--legend-border-focus);
}

.legend-chart-rth-btn.active {
  color: var(--legend-accent);
  background: rgba(204, 255, 0, 0.12);
  border-color: rgba(204, 255, 0, 0.35);
}

.legend-chart-interval {
  margin-left: 0;
  margin-right: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--legend-text);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
  min-width: 52px;
}

.legend-chart-interval:hover {
  border-color: var(--legend-border-focus);
}

/* Chart widget: technical indicator picker (themed like Greek flow msdd). */
.legend-chart-ind-msdd {
  position: relative;
  margin-left: 6px;
  margin-right: 6px;
}

.legend-chart-ind-msdd-inner {
  position: relative;
}

.legend-chart-ind-msdd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 120px;
  max-width: min(200px, 100%);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
}

.legend-chart-ind-msdd-btn:hover {
  border-color: var(--legend-border-focus);
}

.legend-chart-etf-indicator-note {
  flex: 0 0 auto;
  margin: 0 0 6px;
  padding: 4px 8px;
  font-size: 10px;
  line-height: 1.35;
  color: var(--legend-text-muted, #9aa0a6);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--legend-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--banana-radius);
}

.legend-chart-ind-msdd-btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-chart-ind-msdd-caret {
  flex-shrink: 0;
  font-size: 9px;
  opacity: 0.75;
}

.legend-chart-ind-msdd-panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  min-width: 380px;
  max-width: min(480px, 92vw);
  max-height: min(420px, 60vh);
  overflow: hidden;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.legend-chart-ind-msdd-panel.is-open {
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.legend-chart-ind-msdd-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--legend-border);
  background: rgba(255, 255, 255, 0.02);
}

.legend-chart-ind-msdd-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text);
  white-space: nowrap;
}

.legend-chart-ind-msdd-search {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--legend-text);
  background: var(--legend-bg);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-chart-ind-msdd-search:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-chart-ind-msdd-active {
  border-bottom: 1px solid var(--legend-border);
  padding: 6px 8px 8px;
}

.legend-chart-ind-msdd-active-head,
.legend-chart-ind-msdd-catalog-head {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
  margin-bottom: 6px;
}

.legend-chart-ind-msdd-catalog-head {
  padding: 8px 8px 0;
}

.legend-chart-ind-msdd-active-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(180px, 28vh);
  overflow-y: auto;
}

.legend-chart-ind-msdd-active-empty {
  font-size: 10px;
  color: var(--legend-text-muted);
  padding: 4px 10px 6px;
}

.legend-chart-ind-msdd-active-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 26px;
  align-items: start;
  column-gap: 8px;
  row-gap: 0;
  padding: 8px;
  font-size: 10px;
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.03);
}

.legend-chart-ind-msdd-active-row.is-interval-only {
  align-items: center;
}

.legend-chart-ind-msdd-active-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.legend-chart-ind-msdd-active-row.is-interval-only .legend-chart-ind-msdd-active-main {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-chart-ind-msdd-active-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-chart-ind-msdd-active-color {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: transparent;
  cursor: pointer;
}

.legend-chart-ind-msdd-active-row.is-interval-only .legend-chart-ind-msdd-active-color {
  margin-top: 0;
}

.legend-chart-ind-msdd-active-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.legend-chart-ind-msdd-active-color::-webkit-color-swatch {
  border: none;
  border-radius: var(--banana-radius);
}

.legend-chart-ind-msdd-active-color::-moz-color-swatch {
  border: none;
  border-radius: var(--banana-radius);
}

.legend-chart-ind-msdd-active-name {
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  min-width: 0;
}

.legend-chart-ind-msdd-active-meta {
  font-size: 9px;
  color: var(--legend-text-muted);
  line-height: 1.2;
}

.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-active-period,
.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-active-series {
  height: 22px;
  box-sizing: border-box;
  line-height: 1.2;
}

.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-active-period {
  width: 48px;
  padding: 2px 6px;
}

.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-active-series {
  min-width: 72px;
  padding: 2px 6px;
}

.legend-chart-ind-msdd-active-row .legend-chart-ind-msdd-remove {
  margin-top: 1px;
}

.legend-chart-ind-msdd-active-row.is-interval-only .legend-chart-ind-msdd-remove {
  margin-top: 0;
}

.legend-chart-ind-msdd-remove,
.legend-chart-ind-msdd-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: var(--legend-bg);
  color: var(--legend-text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.legend-chart-ind-msdd-add-btn:hover,
.legend-chart-ind-msdd-remove:hover {
  border-color: var(--legend-border-focus);
  background: rgba(255, 255, 255, 0.06);
}

.legend-chart-ind-msdd-list {
  overflow-y: auto;
  padding: 6px 8px 8px;
  max-height: min(280px, 40vh);
}

.legend-chart-ind-msdd-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 10px;
  color: var(--legend-text);
  border-radius: var(--banana-radius);
}

.legend-chart-ind-msdd-row.is-filtered-out {
  display: none;
}

.legend-chart-ind-msdd-row.is-interval-blocked {
  opacity: 0.42;
}

.legend-chart-ind-msdd-row.is-interval-blocked .legend-chart-ind-msdd-add-btn {
  cursor: not-allowed;
}

.legend-chart-ind-msdd-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.legend-chart-ind-msdd-name {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.legend-chart-ind-msdd-code {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--legend-text-muted);
  text-transform: uppercase;
}

.legend-chart-ind-msdd-params {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.legend-chart-ind-msdd-params.is-interval-only {
  justify-content: center;
  color: var(--legend-text-muted);
  font-size: 10px;
}

.legend-chart-ind-msdd-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-chart-ind-msdd-field-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--legend-text-muted);
  text-transform: uppercase;
}

.legend-chart-ind-msdd-period,
.legend-chart-ind-msdd-series,
.legend-chart-ind-msdd-active-period,
.legend-chart-ind-msdd-active-series {
  font-size: 10px;
  color: var(--legend-text);
  background: var(--legend-bg);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  padding: 2px 4px;
}

.legend-chart-ind-msdd-period,
.legend-chart-ind-msdd-active-period {
  width: 44px;
}

.legend-chart-ind-msdd-period:disabled,
.legend-chart-ind-msdd-series:disabled,
.legend-chart-ind-msdd-active-period:disabled,
.legend-chart-ind-msdd-active-series:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.legend-chart-ind-msdd-period:focus,
.legend-chart-ind-msdd-series:focus,
.legend-chart-ind-msdd-active-period:focus,
.legend-chart-ind-msdd-active-series:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-chart-gex-overlay {
  margin-left: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: Inter, system-ui, sans-serif;
  font-weight: 500;
  color: var(--legend-text);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
  min-width: 72px;
  max-width: 160px;
  line-height: 1.3;
  box-sizing: border-box;
}

.legend-chart-gex-overlay:hover {
  border-color: var(--legend-border-focus);
}

.legend-chart-gex-overlay:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

/* Scrollable filter strips (flow alerts, options / stock / analyst screeners share inner markup). */
.legend-flow-alerts-filters,
.legend-options-screener-filters,
.legend-stock-screener-filters,
.legend-analyst-screener-filters,
.legend-news-headlines-filters {
  background: var(--legend-bg-elevated);
  border-bottom: 1px solid var(--legend-border);
  max-height: none;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 10px;
  -webkit-overflow-scrolling: touch;
}

.legend-analyst-screener-filters-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 12px;
  min-width: min-content;
}

.legend-analyst-screener-filters-bar .legend-filter-row {
  flex: 0 0 auto;
  white-space: nowrap;
}

.legend-analyst-screener-filters-bar .legend-filter-row--choices {
  grid-column: auto;
  flex-wrap: nowrap;
  align-items: center;
}

.legend-filter-row--choices-inline {
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px 10px;
  flex: 0 0 auto;
}

.legend-filter-row--choices-inline .legend-filter-row-label--split {
  margin-left: 8px;
}

.legend-analyst-screener-filters-bar .legend-filter-row--choices-inline .legend-filter-choices {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.legend-analyst-screener-filters-bar .legend-filter-row-label {
  min-width: 0;
  margin-right: 4px;
}

.legend-analyst-screener-filters-bar .legend-filter-choices {
  flex-wrap: nowrap;
}

.legend-analyst-screener-filters-bar .legend-filter-row--ticker input {
  width: 72px;
  flex: 0 0 auto;
}

.legend-analyst-screener-filters-bar .legend-filter-row--limit input {
  width: 56px;
  flex: 0 0 auto;
}

.legend-analyst-screener-filters-bar .legend-analyst-screener-filters-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  box-shadow: none;
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.legend-news-headlines-filters-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 12px;
  min-width: min-content;
}

.legend-news-headlines-filters-bar .legend-filter-row {
  flex: 0 0 auto;
  white-space: nowrap;
}

.legend-news-headlines-filters-bar .legend-filter-row--search input {
  width: 140px;
  flex: 0 0 auto;
}

.legend-news-headlines-filters-bar .legend-filter-row--ticker input {
  width: 72px;
  flex: 0 0 auto;
}

.legend-news-headlines-filters-bar .legend-news-headlines-filters-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  box-shadow: none;
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.legend-news-headlines-table .legend-news-time {
  white-space: nowrap;
  width: 1%;
}

.legend-news-headlines-table .legend-news-headline {
  min-width: 200px;
}

.legend-news-headlines-table .legend-news-headline--clickable {
  cursor: pointer;
}

.legend-news-headlines-table .legend-news-headline--clickable:hover,
.legend-news-headlines-table .legend-news-headline--clickable:focus-visible {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--legend-accent, #ccff00) 55%, transparent);
  outline: none;
  background: color-mix(in srgb, var(--legend-accent, #ccff00) 8%, transparent);
}

.legend-news-headlines-table .legend-news-headline--major {
  color: var(--legend-accent, #f5c542);
  font-weight: 600;
}

.legend-news-sentiment--positive { color: #3dd68c; }
.legend-news-sentiment--negative { color: #f07178; }
.legend-news-sentiment--neutral { color: var(--legend-text-muted, #888); }

.legend-news-tickers {
  white-space: nowrap;
  font-size: 0.9em;
}

.legend-flow-alerts-filters-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 14px;
  align-items: center;
}

.legend-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--legend-text);
}

.legend-filter-row label {
  flex: 0 0 auto;
  min-width: 0;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-filter-row input[type="text"],
.legend-filter-row input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--legend-bg-widget);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  color: var(--legend-text);
}

.legend-filter-row--choices {
  flex-wrap: wrap;
  align-items: flex-start;
  grid-column: 1 / -1;
}

.legend-filter-row-label {
  flex: 0 0 auto;
  min-width: 88px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-filter-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.legend-filter-choice {
  appearance: none;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--legend-bg-widget) 88%, transparent);
  color: var(--legend-text-muted);
  font-family: var(--legend-font);
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.legend-filter-choice:hover {
  border-color: color-mix(in srgb, var(--banana-lime) 45%, var(--legend-border));
  color: var(--legend-text);
}

.legend-filter-choice.is-active {
  border-color: color-mix(in srgb, var(--banana-lime) 70%, var(--legend-border));
  background: color-mix(in srgb, var(--banana-lime) 18%, var(--legend-bg-widget));
  color: var(--legend-text);
  font-weight: 600;
}

/* Stock screener: checkbox dropdown filters (sectors, issue types, order) */
.legend-filter-row--multicheck {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 140px;
}

.legend-filter-multicheck {
  position: relative;
  min-width: 0;
}

.legend-filter-multicheck-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 120px;
  max-width: 220px;
  padding: 6px 10px;
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, var(--legend-text-muted) 28%, transparent);
  background: rgba(255, 255, 255, 0.04);
  color: var(--legend-text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.legend-filter-multicheck-btn:hover {
  border-color: color-mix(in srgb, var(--banana-accent-lime, #ccff00) 35%, transparent);
  background: rgba(255, 255, 255, 0.06);
}

.legend-filter-multicheck-btn__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.legend-filter-multicheck-btn__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--legend-text-muted);
  flex-shrink: 0;
}

.legend-filter-multicheck-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 120;
  min-width: 100%;
  max-width: min(280px, 90vw);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, var(--legend-text-muted) 22%, transparent);
  background: var(--legend-surface, #12141a);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.legend-filter-multicheck-menu[hidden] {
  display: none;
}

.legend-filter-multicheck-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--banana-radius);
  font-size: 11px;
  color: var(--legend-text);
  cursor: pointer;
  user-select: none;
}

.legend-filter-multicheck-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.legend-filter-multicheck-option input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--banana-accent-lime, #ccff00);
}

.legend-filter-multicheck-option span {
  line-height: 1.3;
}

.legend-flow-alerts-filters-inner .legend-filter-row--multicheck {
  min-width: 150px;
}

.legend-flow-alerts-filters-inner .legend-filter-multicheck-btn {
  max-width: 200px;
}

.legend-flow-alerts-filters-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: none;
  box-shadow: 0 -1px 0 var(--legend-border);
  display: flex;
  gap: 8px;
}

.legend-widget-body {
  grid-row: 2;
  grid-column: 1;
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  display: flex;
  flex-direction: column;
}

.legend-widget-body::-webkit-scrollbar {
  display: none;
}

/* Option contract intraday: crop overflow when small (same idea as option contract historic) */
.legend-widget[data-type-id="option_contract_intraday"] .legend-widget-body {
  padding: 12px 14px 18px;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-widget-inner {
  overflow: hidden;
  min-height: 0;
}

.legend-widget[data-type-id="greek_exposure"] .legend-widget-body {
  padding: 6px 8px;
}

.legend-widget[data-type-id="greek_exposure"] .legend-widget-inner {
  min-height: 0;
}

.legend-widget[data-type-id="flow_per_strike"] .legend-widget-body,
.legend-widget[data-type-id="flow_per_expiry"] .legend-widget-body,
.legend-widget[data-type-id="flow_per_strike_intraday"] .legend-widget-body {
  padding: 6px 8px;
  overflow: hidden;
}

.legend-widget[data-type-id="flow_per_strike"] .legend-widget-inner,
.legend-widget[data-type-id="flow_per_expiry"] .legend-widget-inner,
.legend-widget[data-type-id="flow_per_strike_intraday"] .legend-widget-inner {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.legend-widget[data-type-id="flow_per_strike"] .legend-nfexp-meta,
.legend-widget[data-type-id="flow_per_expiry"] .legend-nfexp-meta,
.legend-widget[data-type-id="flow_per_strike_intraday"] .legend-nfexp-meta {
  flex: 0 0 auto;
  padding: 2px 0 4px;
  margin-bottom: 2px;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-premium-chart {
  box-sizing: border-box;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-chart-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-chart-pane-main {
  position: relative;
}

.legend-oci-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  padding: 2px 2px 4px;
  min-height: 22px;
}

.legend-oci-chart-header-title {
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
}

.legend-oci-vol-strip-wrap {
  position: relative;
  flex: 0 1 200px;
  width: 200px;
  max-width: 48%;
  min-width: 100px;
  z-index: 8;
}

.legend-oci-vol-strip {
  height: 14px;
}

.legend-oci-vol-strip-wrap .legend-progress-segment {
  min-width: 0;
  flex: 0 0 auto;
  transition: filter 0.12s ease, opacity 0.12s ease;
}

.legend-oci-vol-seg--ask {
  background: color-mix(in srgb, var(--banana-chart-call) 88%, transparent);
}

.legend-oci-vol-seg--bid {
  background: color-mix(in srgb, var(--banana-chart-put) 88%, transparent);
}

.legend-oci-vol-seg--mid {
  background: color-mix(in srgb, var(--banana-chart-price) 70%, transparent);
}

.legend-oci-vol-seg--noside {
  background: color-mix(in srgb, var(--banana-chart-volume) 88%, transparent);
}

.legend-oci-vol-strip-wrap[data-hover-side] .legend-oci-vol-seg {
  opacity: 0.45;
}

.legend-oci-vol-strip-wrap[data-hover-side="ask"] .legend-oci-vol-seg--ask,
.legend-oci-vol-strip-wrap[data-hover-side="mid"] .legend-oci-vol-seg--mid,
.legend-oci-vol-strip-wrap[data-hover-side="noside"] .legend-oci-vol-seg--noside,
.legend-oci-vol-strip-wrap[data-hover-side="bid"] .legend-oci-vol-seg--bid {
  opacity: 1;
  filter: brightness(1.12);
}

.legend-oci-vol-strip-tip {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 172px;
  padding: 8px 10px;
  background: var(--banana-glass-surface, var(--legend-bg-elevated));
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(var(--banana-glass-blur, 12px));
  -webkit-backdrop-filter: blur(var(--banana-glass-blur, 12px));
  pointer-events: none;
}

.legend-oci-vol-strip-wrap:hover .legend-oci-vol-strip-tip,
.legend-oci-vol-strip-wrap:focus-within .legend-oci-vol-strip-tip {
  display: block;
}

.legend-oci-vol-strip-tip-head {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--legend-text-muted);
  margin-bottom: 6px;
}

.legend-oci-vol-strip-tip-total {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--legend-border);
}

.legend-oci-vol-strip-tip-empty {
  font-size: 11px;
  color: var(--legend-text-muted);
}

.legend-oci-vol-strip-tip-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-oci-vol-strip-tip-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  color: var(--legend-text);
}

.legend-oci-vol-strip-wrap[data-hover-side] .legend-oci-vol-strip-tip-row {
  opacity: 0.55;
}

.legend-oci-vol-strip-wrap[data-hover-side="ask"] .legend-oci-vol-strip-tip-row[data-side="ask"],
.legend-oci-vol-strip-wrap[data-hover-side="mid"] .legend-oci-vol-strip-tip-row[data-side="mid"],
.legend-oci-vol-strip-wrap[data-hover-side="noside"] .legend-oci-vol-strip-tip-row[data-side="noside"],
.legend-oci-vol-strip-wrap[data-hover-side="bid"] .legend-oci-vol-strip-tip-row[data-side="bid"] {
  opacity: 1;
  background: color-mix(in srgb, var(--banana-primary, #f3ffca) 8%, transparent);
}

.legend-oci-vol-strip-tip-swatch {
  width: 8px;
  height: 8px;
  border-radius: var(--banana-radius);
  flex-shrink: 0;
}

.legend-oci-vol-strip-tip-swatch.legend-oci-vol-seg--ask {
  background: var(--banana-chart-call);
}

.legend-oci-vol-strip-tip-swatch.legend-oci-vol-seg--bid {
  background: var(--banana-chart-put);
}

.legend-oci-vol-strip-tip-swatch.legend-oci-vol-seg--mid {
  background: var(--banana-chart-price);
}

.legend-oci-vol-strip-tip-swatch.legend-oci-vol-seg--noside {
  background: var(--banana-chart-volume);
}

.legend-oci-vol-strip-tip-label {
  color: var(--legend-text-muted);
}

.legend-oci-vol-strip-tip-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.legend-oci-vol-strip-tip-pct {
  font-variant-numeric: tabular-nums;
  color: var(--legend-text-muted);
  min-width: 38px;
  text-align: right;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-chart-pane .legend-chart-container {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

/* Stacked clip mode: natural chart heights, widget clips (like historic) */
.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-oci-clip-stack .legend-oci-chart-pane {
  flex: 0 0 auto;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-oci-clip-stack .legend-oci-chart-pane .legend-chart-container {
  flex: 0 0 auto;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-oci-split-stack .legend-oci-chart-pane,
.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-pane {
  min-width: 0;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-chart-splitter {
  flex: 0 0 10px;
  cursor: row-resize;
  position: relative;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-chart-splitter::before {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--banana-radius);
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side {
  flex-direction: row;
  align-items: stretch;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-pane {
  flex: 1 1 0;
  min-width: 0;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-pane-premium {
  order: 1;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-splitter {
  order: 2;
  cursor: col-resize;
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-splitter::before {
  left: 50%;
  top: 1px;
  bottom: 1px;
  width: 2px;
  height: auto;
  transform: translateX(-50%);
}

.legend-widget[data-type-id="option_contract_intraday"] .legend-oci-charts-wrap.is-side-by-side .legend-oci-chart-pane-main {
  order: 3;
}

/* Option contract historic: OHLC+volume (resizable split) + premium chart */
.legend-widget[data-type-id="option_contract_historic"] .legend-widget-body {
  padding: 12px 14px 18px;
  overflow: hidden;
}

.legend-widget[data-type-id="option_contract_historic"] .legend-widget-inner {
  overflow: hidden;
  min-height: 0;
}

.legend-och-charts-wrap {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
  overflow: hidden;
}

.legend-och-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.legend-och-pane-price {
  flex: 1 1 58%;
  position: relative;
  min-height: 320px;
}

.legend-och-pane-prem {
  flex: 0 1 42%;
  min-height: 240px;
}

.legend-och-pane .legend-chart-container {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.legend-och-vol-splitter {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  margin-top: -5px;
  cursor: row-resize;
  z-index: 4;
  touch-action: none;
}

.legend-och-vol-splitter::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--banana-radius);
}

.legend-och-vol-splitter:hover::before {
  background: rgba(204, 255, 0, 0.45);
}

.legend-widget-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Chart widget (price_data): legacy layout when GEX was a separate strip; GEX now overlays price (same y = strike). Safe to remove if unused. */
.legend-price-chart-stack {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.legend-price-chart-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.legend-price-chart-gex {
  flex: 0 0 auto;
  min-height: 200px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--legend-border);
}
.legend-price-chart-gex .legend-chart-container {
  min-height: 180px;
  flex: 1;
}

/* Recessed instrument well for ECharts canvas (§8) */
.legend-chart-container {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  background: var(--banana-surface-container-lowest);
  border-radius: var(--banana-radius);
  overflow: hidden;
}

/* Per-chart watermark: clip to canvas; stay behind the series */
.legend-chart-container > .legend-widget-brand-watermark {
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
}

.legend-chart-container > .legend-widget-brand-watermark__ticker,
.legend-chart-container > .legend-widget-brand-watermark__brand {
  max-width: 100%;
}

/* AIS Stream widget: activity + map + safety ticker */
.legend-ais-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 200px;
}
.legend-ais-activity {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--banana-chart-call);
  padding: 4px 0;
}
.legend-ais-hint {
  flex: 0 0 auto;
  font-size: 10px;
  line-height: 1.3;
  color: var(--legend-text-muted);
  padding-bottom: 4px;
  max-width: 100%;
}
.legend-ais-map {
  flex: 1 1 0;
  min-height: 120px;
  position: relative;
  background: var(--legend-bg-elevated);
  border-radius: var(--banana-radius);
  overflow: hidden;
}
.legend-ais-map .leaflet-container {
  height: 100%;
  width: 100%;
  border-radius: var(--banana-radius);
}
.legend-ais-ticker {
  flex: 0 0 56px;
  max-height: 56px;
  overflow-y: auto;
  font-size: 10px;
  color: var(--legend-text-muted);
  padding: 4px 0;
  border-top: 1px solid var(--legend-border);
}
.legend-ais-ticker > div {
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaflet-tooltip.legend-ais-tooltip-wrap {
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  padding: 6px 8px;
  margin: 0;
  font-size: 11px;
  color: var(--legend-text);
  white-space: nowrap;
  max-width: 280px;
}
.legend-ais-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}
.legend-ais-tooltip-time {
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-nfexp-meta {
  font-size: 10px;
  color: var(--legend-text-muted);
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--legend-border);
  margin-bottom: 4px;
}

.legend-widget[data-type-id="net_flow_expiry"] .legend-widget-body {
  padding: 6px 6px 8px;
}

.legend-widget[data-type-id="net_flow_expiry"] .legend-nfexp-meta {
  padding: 2px 0 4px;
  margin-bottom: 2px;
}

.legend-nfexp-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.legend-nfexp-chart-wrap {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-nfexp-chart-wrap .legend-chart-container {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

.legend-widget-inner > .legend-chart-container,
.legend-nfexp-chart-wrap .legend-chart-container {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  height: 0;
}

.legend-market-tide-chart-wrap .legend-chart-container {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
}

.legend-market-tide-chart-wrap {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-fps-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.legend-fps-toolbar .legend-fps-metrics-label {
  font-size: 10px;
  color: var(--legend-text-muted, #999);
  white-space: nowrap;
}

.legend-fps-msdd { position: relative; }
.legend-fps-msdd-inner { position: relative; }

.legend-fps-msdd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 220px;
  max-width: min(320px, 100%);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
}

.legend-fps-msdd-btn:hover { border-color: var(--legend-accent, #666); }

.legend-fps-msdd-btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-fps-msdd-caret { flex-shrink: 0; font-size: 9px; opacity: 0.75; }

.legend-fps-msdd-panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  min-width: 300px;
  max-width: min(380px, 92vw);
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.legend-fps-msdd-panel.is-open {
  display: block;
  z-index: 200;
}

.legend-fps-msdd-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px;
  font-size: 10px;
  color: var(--legend-text);
  cursor: pointer;
  border-radius: var(--banana-radius);
}

.legend-fps-msdd-row:hover { background: rgba(255, 255, 255, 0.06); }

.legend-fps-msdd-row .legend-fps-msdd-cb { margin-top: 2px; flex-shrink: 0; }

.legend-fps-msdd-row-label { line-height: 1.25; }

.legend-fps-toolbar .legend-fpsi-view {
  max-width: 130px;
  font-size: 10px;
  padding: 2px 4px;
  background: var(--legend-bg-widget);
  color: var(--legend-text);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}
.legend-fps-toolbar .legend-fpsi-topn-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--legend-text-muted, #999);
  white-space: nowrap;
}
.legend-fps-toolbar .legend-fpsi-topn {
  width: 44px;
  font-size: 10px;
  padding: 2px 4px;
  background: var(--legend-bg-widget);
  color: var(--legend-text);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-fps-toolbar .legend-fpsi-metrics-label {
  font-size: 10px;
  color: var(--legend-text-muted, #999);
  white-space: nowrap;
}

.legend-fpsi-msdd { position: relative; }
.legend-fpsi-msdd-inner { position: relative; }

.legend-fpsi-msdd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 200px;
  max-width: min(300px, 100%);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
}

.legend-fpsi-msdd-btn:hover { border-color: var(--legend-accent, #666); }

.legend-fpsi-msdd-btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-fpsi-msdd-caret { flex-shrink: 0; font-size: 9px; opacity: 0.75; }

.legend-fpsi-msdd-panel {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 80;
  min-width: 280px;
  max-width: min(360px, 92vw);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.legend-fpsi-msdd-panel.is-open {
  display: block;
  z-index: 200;
}

.legend-fpsi-msdd-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px;
  font-size: 10px;
  color: var(--legend-text);
  cursor: pointer;
  border-radius: var(--banana-radius);
}

.legend-fpsi-msdd-row:hover { background: rgba(255, 255, 255, 0.06); }

.legend-fpsi-msdd-row .legend-fpsi-msdd-cb { margin-top: 2px; flex-shrink: 0; }

.legend-fpsi-msdd-row-label { line-height: 1.25; }

.legend-fpsi-strike-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--legend-text-muted, #aaa);
}
.legend-fpsi-strike-toolbar .legend-fpsi-strike-select {
  min-width: 7.5rem;
  max-width: 12rem;
  font-size: 11px;
  padding: 4px 8px;
  background: var(--legend-bg-widget);
  color: var(--legend-text);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-input {
  width: 6.5rem;
  font-size: 11px;
  padding: 3px 8px;
  background: var(--legend-bg-widget);
  color: var(--legend-text);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-apply {
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  background: var(--legend-bg-elevated, #3a3a3a);
  color: var(--legend-text);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-apply:hover {
  filter: brightness(1.08);
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-err {
  color: #ef9a9a;
  font-size: 10px;
}

.legend-fpsi-strike-toolbar .legend-fpsi-strike-hint {
  font-size: 10px;
  color: var(--legend-text-muted, #888);
}

/* Net Flow (zero_dte): pull charts toward widget edge; axis labels live in grid (legend.js). */
.legend-widget[data-type-id="zero_dte"] .legend-widget-body {
  padding: 6px 6px 8px 0;
  overflow: hidden;
}

.legend-widget[data-type-id="zero_dte"] .legend-widget-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.net-flow-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.net-flow-wrap--main-only .net-flow-chart-main {
  flex: 1 1 0;
  min-height: 0;
}

.net-flow-wrap--two-panels .net-flow-chart-main,
.net-flow-wrap--three-panels .net-flow-chart-main {
  flex: 1 1 0;
  min-height: 0;
}

.net-flow-wrap--two-panels .net-flow-bottom-wrap,
.net-flow-wrap--three-panels .net-flow-bottom-wrap {
  flex: 1 1 0;
  min-height: 0;
}

.net-flow-chart-main {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.net-flow-chart-main .legend-chart-container {
  flex: 1;
  min-height: 160px;
}

.net-flow-resizer {
  flex: 0 0 auto;
  height: 8px;
  min-height: 8px;
  cursor: ns-resize;
  background: var(--legend-border);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.net-flow-resizer:hover {
  background: rgba(255, 255, 255, 0.15);
}

.net-flow-resizer::after {
  content: '';
  display: block;
  width: 24px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--banana-radius);
}

.net-flow-bottom-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.net-flow-chart-delta {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.net-flow-chart-delta .legend-chart-container {
  flex: 1;
  min-height: 80px;
}

.net-flow-chart-volume {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.net-flow-chart-volume .legend-chart-container {
  flex: 1;
  min-height: 100px;
}

/* Raise section when tooltip is visible so it isn't hidden under the chart above */
.net-flow-chart-main.net-flow-chart-tooltip-visible,
.net-flow-chart-delta.net-flow-chart-tooltip-visible,
.net-flow-chart-volume.net-flow-chart-tooltip-visible {
  position: relative;
  z-index: 10;
}

/* Options Volume: horizontal stacked bars + history chart */
.legend-widget[data-type-id="options_volume"] .legend-widget-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.legend-widget[data-type-id="options_volume"] .legend-widget-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.legend-options-volume {
  width: 100%;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}

.legend-widget[data-type-id="options_volume"] .legend-options-volume {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.legend-ov-main {
  flex: 0 0 auto;
}

/* Market Tide: add extra cushion so the top label doesn't clip */
/* Market Tide: summary bars + chart share vertical space in short widgets. */
.legend-widget[data-type-id="market_tide"] .legend-widget-body {
  padding: 6px 8px;
  overflow: hidden;
}

.legend-widget[data-type-id="market_tide"] .legend-widget-inner {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

#legend-market-options-summary.legend-options-volume {
  flex: 0 0 auto;
  height: auto;
  padding-top: 1px;
  padding-bottom: 1px;
  margin-bottom: 0;
}

.legend-progress-bar-wrapper {
  width: 100%;
  margin-bottom: 14px;
}

.legend-progress-bar-wrapper:last-child {
  margin-bottom: 0;
}

.legend-progress-label {
  font-size: 11px;
  color: var(--legend-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-progress-bar-container {
  width: 100%;
  height: 24px;
  background: var(--legend-bg-elevated);
  border-radius: var(--banana-radius);
  overflow: hidden;
  display: flex;
  border: 1px solid var(--legend-border);
}

.legend-progress-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  transition: width 0.2s ease;
}

.legend-progress-segment.green {
  background: var(--banana-chart-call);
  /* Lime segment: dark text for contrast (white on #ccff00 was hard to read) */
  color: var(--banana-on-primary);
}

.legend-progress-segment.red {
  background: var(--banana-chart-put);
}

.legend-progress-segment.blue {
  background: var(--banana-chart-price);
}

.legend-progress-segment.neutral {
  background: #666;
  width: 2px !important;
  flex: none;
  min-width: 2px;
}

.legend-progress-values {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-ov-ctrls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  flex-wrap: wrap;
}

.legend-ov-session-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--legend-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.legend-widget-header .legend-ov-date-select {
  min-width: 130px;
  max-width: 180px;
}

.legend-ov-limit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--legend-text-muted, #aaa);
  white-space: nowrap;
}

.legend-ov-limit {
  width: 42px;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-ov-history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.legend-ov-history-section {
  flex: 1 1 auto;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--legend-border);
  overflow: hidden;
}

.legend-ov-hist-chart-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.legend-ov-hist-chart-wrap .legend-ov-hist-chart {
  flex: 1 1 auto;
  width: 100%;
  min-height: 180px;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* Per-chart watermark only — do not cover summary bars */
.legend-ov-hist-chart-wrap .legend-widget-brand-watermark {
  z-index: 0;
}

.legend-ov-main .legend-progress-bar-wrapper:last-child {
  margin-bottom: 0;
}

.legend-ov-date-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--legend-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.legend-ov-date-select {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  min-width: 150px;
  max-width: 100%;
}

.legend-ov-hist-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  margin-bottom: 0;
}

.legend-ov-hist-table th,
.legend-ov-hist-table td {
  padding: 4px 6px;
  font-size: 10px;
  white-space: nowrap;
}

.legend-ov-hist-table .legend-ov-hist-bars {
  min-width: 120px;
  width: 100%;
}

.legend-ov-row-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.legend-ov-hist-row {
  cursor: pointer;
}

.legend-ov-hist-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.legend-ov-hist-row--active {
  background: rgba(202, 253, 0, 0.08);
}

.legend-ov-hist-row--active td:first-child {
  color: var(--legend-text, #fff);
  font-weight: 600;
}

.legend-ov-mini-bar {
  width: 100%;
  height: 18px;
  background: var(--legend-bg-elevated);
  border-radius: var(--banana-radius);
  overflow: hidden;
  display: flex;
  border: 1px solid var(--legend-border);
}

.legend-ov-mini-bar .legend-progress-segment {
  font-size: 9px;
}

.legend-ov-mini-bar--split {
  height: 14px;
}

.legend-ov-row-bars .legend-ov-mini-bar {
  height: 14px;
}

.legend-ov-date-static {
  font-size: 11px;
  color: var(--legend-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Expiry Breakdown widget */
.legend-eb {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.legend-eb-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--legend-text-muted);
  padding: 0 2px;
}

.legend-eb-meta strong {
  color: var(--legend-text);
  font-weight: 600;
}

.legend-eb-meta-sep {
  opacity: 0.45;
}

.legend-eb-table-wrap {
  flex: 1;
  min-height: 0;
}

.legend-eb-chart-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  gap: 4px;
}

.legend-eb-chart-wrap .legend-chart-container {
  flex: 1 1 auto;
  min-height: 180px;
}

.legend-eb-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.legend-eb-expiry {
  font-weight: 600;
  color: var(--legend-text);
  white-space: nowrap;
}

.legend-eb-metric-cell {
  min-width: 88px;
}

.legend-eb-metric {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 22px;
  padding: 2px 0;
}

.legend-eb-metric-bar {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  border-radius: var(--banana-radius);
  opacity: 0.85;
  pointer-events: none;
}

.legend-eb-metric-bar--oi {
  background: linear-gradient(90deg, rgba(144, 202, 249, 0.08), rgba(144, 202, 249, 0.38));
}

.legend-eb-metric-bar--volume {
  background: linear-gradient(90deg, rgba(204, 255, 0, 0.08), rgba(204, 255, 0, 0.32));
}

.legend-eb-metric-val {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--legend-text);
}

/* Widget body content – Legend table (shared) */
.legend-table-wrap {
  width: 100%;
  overflow: auto;
  font-size: 11px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-height: 60px;
}

/* Table watermark host: scroll happens inside .legend-table-wrap; overlay stays fixed */
.legend-table-wrap-host {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.legend-table-wrap-host > .legend-table-wrap {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
}

.legend-ocf-table-host > .legend-table-wrap {
  position: relative;
  z-index: 1;
}

.legend-table-wrap-host > .legend-widget-brand-watermark,
.legend-ocf-table-host > .legend-widget-brand-watermark {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.legend-table-wrap::-webkit-scrollbar {
  display: none;
}

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

.legend-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--legend-bg-widget);
  box-shadow: 0 1px 0 var(--legend-border);
}

.legend-table th,
.legend-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--legend-border);
  vertical-align: middle;
}

.legend-table th {
  color: var(--legend-text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.legend-table th.numeric,
.legend-table td.numeric {
  text-align: right;
}

/* Resizable / reorderable columns (Legend tables inside .legend-table-wrap) */
.legend-table.legend-table-cols-interactive {
  table-layout: fixed;
}

.legend-table-cols-interactive thead th.legend-th-interactive,
.legend-table-cols-interactive tbody td,
.legend-table-cols-interactive tfoot td {
  max-width: none;
}

.legend-table-cols-interactive thead th.legend-th-interactive {
  position: relative;
  padding-right: 12px;
}

.legend-col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 9px;
  cursor: col-resize;
  z-index: 4;
  touch-action: none;
  pointer-events: auto;
}

.legend-col-resize-handle:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.legend-col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

.legend-table.legend-table-reorder-active {
  cursor: grabbing;
}

.legend-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--banana-surface-container-highest) 35%, transparent);
}

.legend-table tbody tr:hover td {
  background: var(--banana-surface-container-highest);
}

.legend-table td {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--legend-text);
}

.legend-table td.legend-cell-muted {
  color: var(--legend-text-muted);
  font-size: 10px;
}

.legend-table td.legend-cell-emphasis {
  color: var(--legend-text);
  font-weight: 600;
}

.legend-table td.legend-net-pos {
  color: var(--banana-chart-call);
  font-weight: 500;
}

.legend-table td.legend-net-neg {
  color: var(--banana-error);
  font-weight: 500;
}

/* Economic calendar — compact 3-column table */
.legend-widget[data-type-id="economic_calendar"] .legend-widget-body {
  container-type: inline-size;
  container-name: legend-econ;
}

.legend-econ-table-wrap {
  min-height: 0;
  font-size: 10px;
}

.legend-econ-table th,
.legend-econ-table td {
  padding: 3px 6px;
  font-size: 10px;
  line-height: 1.25;
  vertical-align: middle;
}

.legend-econ-table thead th {
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 9px;
}

.legend-econ-table .legend-econ-time {
  width: 1%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--legend-text-muted);
  padding-right: 4px;
}

.legend-econ-table .legend-econ-event {
  max-width: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-econ-event-name {
  color: var(--legend-text);
  font-weight: 500;
}

.legend-econ-event-type {
  color: var(--legend-text-muted);
  font-weight: 400;
}

.legend-econ-table th.numeric,
.legend-econ-table td.legend-econ-est {
  width: 1%;
  white-space: nowrap;
  padding-left: 4px;
  padding-right: 6px;
  font-variant-numeric: tabular-nums;
}

.legend-econ-est-f {
  color: var(--legend-text);
  font-weight: 500;
}

.legend-econ-est-sep {
  margin: 0 3px;
  color: var(--legend-text-muted);
  opacity: 0.5;
}

.legend-econ-est-p {
  color: var(--legend-text-muted);
  font-weight: 400;
}

.legend-econ-day-row td {
  padding: 5px 6px 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
  border-bottom: 1px solid var(--legend-border);
  background: var(--legend-bg-widget);
  white-space: nowrap;
}

.legend-econ-day-row:hover td {
  background: var(--legend-bg-widget);
}

.legend-econ-day-sep {
  font-weight: 400;
  opacity: 0.55;
}

/* Narrow widget: drop date suffix, hide type suffix, tighter cells */
@container legend-econ (max-width: 300px) {
  .legend-econ-day-date,
  .legend-econ-day-sep {
    display: none;
  }

  .legend-econ-event-type {
    display: none;
  }

  .legend-econ-table th,
  .legend-econ-table td {
    padding: 2px 4px;
  }

  .legend-econ-table thead th {
    font-size: 8px;
  }
}

/* Very narrow: single-line rows, time pinned when scrolling */
@container legend-econ (max-width: 220px) {
  .legend-econ-table thead {
    display: none;
  }

  .legend-econ-table .legend-econ-time {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--legend-bg-widget);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.25);
  }

  .legend-econ-table tbody tr:nth-child(even) .legend-econ-time {
    background: color-mix(in srgb, var(--banana-surface-container-highest) 35%, var(--legend-bg-widget));
  }

  .legend-econ-table tbody tr:hover .legend-econ-time {
    background: var(--banana-surface-container-highest);
  }

  .legend-econ-day-row td {
    padding-left: 4px;
  }
}

.legend-econ-table-wrap--earnings {
  container-type: inline-size;
  container-name: legend-earnings;
}

.legend-econ-table--earnings th,
.legend-econ-table--earnings td {
  font-size: 11px;
  padding: 6px 8px;
  vertical-align: middle;
}

.legend-econ-table--earnings .legend-cell-ticker {
  font-weight: 600;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
  white-space: nowrap;
}

.legend-ec-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: var(--banana-radius);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--banana-text-muted);
  background: rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.legend-ec-company,
.legend-ec-sector {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-ec-session {
  width: 2.5rem;
  white-space: nowrap;
}

@container legend-earnings (max-width: 420px) {
  .legend-econ-table--earnings .legend-ec-sector,
  .legend-ec-badge {
    display: none;
  }
}

@container legend-earnings (max-width: 300px) {
  .legend-econ-table--earnings .legend-ec-company {
    max-width: 72px;
  }
}

/* Top Movers (tabbed gainers / losers / most active) */
.legend-movers {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.legend-movers-tabs {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
  padding: 6px 8px 8px;
}

.legend-movers-tab {
  flex: 1 1 auto;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--legend-text-muted);
  background: var(--legend-bg-widget);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.legend-movers-tab:hover {
  color: var(--legend-text);
  border-color: color-mix(in srgb, var(--banana-chart-call) 45%, var(--legend-border));
}

.legend-movers-tab.is-active {
  color: var(--legend-text);
  border-color: color-mix(in srgb, var(--banana-chart-call) 60%, transparent);
  background: color-mix(in srgb, var(--banana-chart-call) 14%, transparent);
}

.legend-movers-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.legend-movers-table .legend-cell-ticker {
  font-weight: 600;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
  white-space: nowrap;
}

.legend-movers-up { color: var(--banana-chart-call); }
.legend-movers-down { color: var(--banana-chart-put); }

/* Call/Put badges */
.legend-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.legend-badge.call {
  background: color-mix(in srgb, var(--banana-chart-call) 28%, transparent);
  color: var(--banana-chart-call);
}

.legend-badge.put {
  background: color-mix(in srgb, var(--banana-chart-put) 28%, transparent);
  color: var(--banana-chart-put);
}

/* Alerts feed (triggered alerts / api/alerts) — card list */
.legend-alerts-feed {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Filter chips live in the widget header (between title and menu). */
.legend-widget-header .legend-alerts-filters {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 4px;
  margin: 0 10px 0 12px;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border: none;
  background: transparent;
}

.legend-widget-header .legend-alerts-filters::-webkit-scrollbar { display: none; }

.legend-alerts-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--legend-border);
  background: color-mix(in srgb, var(--banana-surface-container) 60%, transparent);
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.legend-alerts-filters::-webkit-scrollbar { display: none; }

.legend-widget-header .legend-alerts-filter {
  flex-shrink: 0;
  padding: 2px 7px 2px 9px;
  font-size: 10px;
}

.legend-widget[data-type-id="alerts"] .legend-widget-header .legend-widget-header-spacer {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
}

.legend-alerts-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: transparent;
  color: var(--legend-text-muted);
  font-family: var(--legend-font);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.legend-alerts-filter:hover {
  color: var(--legend-text);
  border-color: color-mix(in srgb, var(--banana-accent-lime) 30%, var(--legend-border));
}

.legend-alerts-filter.is-active {
  color: var(--banana-accent-lime);
  background: color-mix(in srgb, var(--banana-accent-lime) 12%, transparent);
  border-color: color-mix(in srgb, var(--banana-accent-lime) 36%, transparent);
}

.legend-alerts-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-highest) 80%, transparent);
  color: var(--legend-text-muted);
  font-size: 9.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legend-alerts-filter.is-active .legend-alerts-filter-count {
  background: color-mix(in srgb, var(--banana-accent-lime) 22%, transparent);
  color: var(--banana-accent-lime);
}

.legend-alerts-feed-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.legend-alerts-feed-list::-webkit-scrollbar { display: none; }

.legend-alerts-feed-list[data-filter="news"] .legend-alert-card:not([data-kind="news"]),
.legend-alerts-feed-list[data-filter="flow"] .legend-alert-card:not([data-kind="flow"]),
.legend-alerts-feed-list[data-filter="dark"] .legend-alert-card:not([data-kind="dark"]),
.legend-alerts-feed-list[data-filter="greek"] .legend-alert-card:not([data-kind="greek"]),
.legend-alerts-feed-list[data-filter="earnings"] .legend-alert-card:not([data-kind="earnings"]),
.legend-alerts-feed-list[data-filter="analyst"] .legend-alert-card:not([data-kind="analyst"]),
.legend-alerts-feed-list[data-filter="economic"] .legend-alert-card:not([data-kind="economic"]),
.legend-alerts-feed-list[data-filter="fda"] .legend-alert-card:not([data-kind="fda"]),
.legend-alerts-feed-list[data-filter="filing"] .legend-alert-card:not([data-kind="filing"]),
.legend-alerts-feed-list[data-filter="insider"] .legend-alert-card:not([data-kind="insider"]),
.legend-alerts-feed-list[data-filter="volume"] .legend-alert-card:not([data-kind="volume"]),
.legend-alerts-feed-list[data-filter="price"] .legend-alert-card:not([data-kind="price"]),
.legend-alerts-feed-list[data-filter="market"] .legend-alert-card:not([data-kind="market"]),
.legend-alerts-feed-list[data-filter="option"] .legend-alert-card:not([data-kind="option"]),
.legend-alerts-feed-list[data-filter="default"] .legend-alert-card:not([data-kind="default"]) {
  display: none;
}

.legend-alert-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 12px 7px 14px;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-highest) 32%, transparent);
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.legend-alert-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--banana-radius) 0 0 var(--banana-radius);
  background: var(--banana-accent-lime);
  opacity: 0.7;
}

.legend-alert-card[data-kind="news"]::before { background: #7dd3fc; }
.legend-alert-card[data-kind="flow"]::before { background: var(--banana-accent-lime); }
.legend-alert-card[data-kind="dark"]::before { background: #c084fc; }
.legend-alert-card[data-kind="greek"]::before { background: #f0abfc; }
.legend-alert-card[data-kind="earnings"]::before { background: #fbbf24; }
.legend-alert-card[data-kind="analyst"]::before { background: #34d399; }
.legend-alert-card[data-kind="economic"]::before { background: #fb923c; }
.legend-alert-card[data-kind="fda"]::before { background: #f87171; }
.legend-alert-card[data-kind="filing"]::before { background: #94a3b8; }
.legend-alert-card[data-kind="insider"]::before { background: #facc15; }
.legend-alert-card[data-kind="volume"]::before { background: #38bdf8; }
.legend-alert-card[data-kind="price"]::before { background: #4ade80; }
.legend-alert-card[data-kind="market"]::before { background: #a78bfa; }
.legend-alert-card[data-kind="option"]::before { background: #2dd4bf; }

.legend-alert-card:hover {
  border-color: color-mix(in srgb, var(--banana-accent-lime) 35%, var(--legend-border));
  background: color-mix(in srgb, var(--banana-surface-container-highest) 55%, transparent);
}

.legend-alert-card--expandable {
  cursor: pointer;
}

.legend-alert-card--expandable:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--banana-accent-lime) 55%, transparent);
  outline-offset: 2px;
}

.legend-alert-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  max-width: 72px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--banana-radius);
  background: var(--legend-primary-gradient);
  color: var(--legend-on-primary);
  font-family: var(--legend-font-headline);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

/* Icon-only badge (no ticker, e.g. news): square, smaller, with kind color. */
.legend-alert-symbol--icon {
  min-width: 26px;
  max-width: 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  background: color-mix(in srgb, var(--banana-surface-container-highest) 70%, transparent);
  color: var(--legend-text-muted);
  border: 1px solid var(--legend-border);
  box-shadow: none;
  position: relative;
}

.legend-alert-symbol--icon::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--banana-accent-lime);
}

.legend-alert-symbol--icon[data-kind="news"]::after { background: #7dd3fc; }
.legend-alert-symbol--icon[data-kind="flow"]::after { background: var(--banana-accent-lime); }
.legend-alert-symbol--icon[data-kind="dark"]::after { background: #c084fc; }
.legend-alert-symbol--icon[data-kind="greek"]::after { background: #f0abfc; }
.legend-alert-symbol--icon[data-kind="earnings"]::after { background: #fbbf24; }
.legend-alert-symbol--icon[data-kind="analyst"]::after { background: #34d399; }
.legend-alert-symbol--icon[data-kind="economic"]::after { background: #fb923c; }
.legend-alert-symbol--icon[data-kind="fda"]::after { background: #f87171; }
.legend-alert-symbol--icon[data-kind="filing"]::after { background: #94a3b8; }
.legend-alert-symbol--icon[data-kind="insider"]::after { background: #facc15; }
.legend-alert-symbol--icon[data-kind="volume"]::after { background: #38bdf8; }
.legend-alert-symbol--icon[data-kind="price"]::after { background: #4ade80; }
.legend-alert-symbol--icon[data-kind="market"]::after { background: #a78bfa; }
.legend-alert-symbol--icon[data-kind="option"]::after { background: #2dd4bf; }

.legend-alert-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-alert-title {
  color: var(--legend-text);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.legend-alert-title a {
  color: inherit;
}

.legend-alert-title a:hover {
  color: var(--banana-primary);
}

.legend-alert-chip {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: var(--banana-radius);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--banana-accent-lime) 14%, transparent);
  color: var(--banana-accent-lime);
  border: 1px solid color-mix(in srgb, var(--banana-accent-lime) 28%, transparent);
}

.legend-alert-chip[data-kind="news"] { background: rgba(125, 211, 252, 0.12); color: #7dd3fc; border-color: rgba(125, 211, 252, 0.28); }
.legend-alert-chip[data-kind="dark"] { background: rgba(192, 132, 252, 0.12); color: #c084fc; border-color: rgba(192, 132, 252, 0.28); }
.legend-alert-chip[data-kind="greek"] { background: rgba(240, 171, 252, 0.12); color: #f0abfc; border-color: rgba(240, 171, 252, 0.28); }
.legend-alert-chip[data-kind="earnings"] { background: rgba(251, 191, 36, 0.14); color: #fbbf24; border-color: rgba(251, 191, 36, 0.30); }
.legend-alert-chip[data-kind="analyst"] { background: rgba(52, 211, 153, 0.14); color: #34d399; border-color: rgba(52, 211, 153, 0.30); }
.legend-alert-chip[data-kind="economic"] { background: rgba(251, 146, 60, 0.14); color: #fb923c; border-color: rgba(251, 146, 60, 0.30); }
.legend-alert-chip[data-kind="fda"] { background: rgba(248, 113, 113, 0.14); color: #f87171; border-color: rgba(248, 113, 113, 0.30); }
.legend-alert-chip[data-kind="filing"] { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.30); }
.legend-alert-chip[data-kind="insider"] { background: rgba(250, 204, 21, 0.14); color: #facc15; border-color: rgba(250, 204, 21, 0.30); }
.legend-alert-chip[data-kind="volume"] { background: rgba(56, 189, 248, 0.14); color: #38bdf8; border-color: rgba(56, 189, 248, 0.30); }
.legend-alert-chip[data-kind="price"] { background: rgba(74, 222, 128, 0.14); color: #4ade80; border-color: rgba(74, 222, 128, 0.30); }
.legend-alert-chip[data-kind="market"] { background: rgba(167, 139, 250, 0.14); color: #a78bfa; border-color: rgba(167, 139, 250, 0.30); }
.legend-alert-chip[data-kind="option"] { background: rgba(45, 212, 191, 0.14); color: #2dd4bf; border-color: rgba(45, 212, 191, 0.30); }

.legend-alert-body {
  color: var(--legend-text-muted);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.legend-alert-time {
  flex: 0 0 auto;
  color: var(--legend-text-muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: flex-start;
  padding-top: 2px;
}

/* Options screener compact table */
.legend-os-table td {
  max-width: 220px;
}

.legend-os-table th:first-child,
.legend-os-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--legend-bg-widget);
}

.legend-os-table tbody tr:nth-child(even) td:first-child {
  background: rgba(255, 255, 255, 0.02);
}

.legend-os-table tbody tr:hover td:first-child {
  background: rgba(255, 255, 255, 0.06);
}

.legend-os-table th:first-child {
  z-index: 3;
  box-shadow: 1px 0 0 var(--legend-border);
}

.legend-os-option {
  display: inline-block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.legend-os-flow-wrap {
  width: 170px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-os-flow-main {
  display: flex;
  height: 13px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  min-width: 14px;
}

/* Diagonal-stripe (loading-bar) fill: base color set per-class, stripes layered on top */
.legend-os-seg {
  height: 100%;
  display: block;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.26) 0,
    rgba(0, 0, 0, 0.26) 4px,
    transparent 4px,
    transparent 8px
  );
  transition: filter 0.15s ease;
}

/* Thin dark seam between adjacent segments for crisper separation */
.legend-os-seg + .legend-os-seg {
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.32);
}

/* Ask = bullish lime, Bid = bearish coral (company palette) */
.legend-os-seg.ask { background-color: var(--banana-chart-call, #ccff00); }
.legend-os-seg.bid { background-color: var(--banana-chart-put, #ff7351); }
.legend-os-seg.mid { background-color: var(--banana-chart-price, #42a5f5); }
.legend-os-seg.noside { background-color: rgba(173, 170, 170, 0.6); }

.legend-os-flow-wrap:hover .legend-os-seg {
  filter: brightness(1.12) saturate(1.08);
}

.legend-os-flow-overlay {
  height: 7px;
  border-radius: 2px;
  overflow: hidden;
  min-width: 14px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: flex;
}

.legend-os-ov {
  height: 100%;
  display: block;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.26) 0,
    rgba(0, 0, 0, 0.26) 3px,
    transparent 3px,
    transparent 6px
  );
}

.legend-os-ov + .legend-os-ov {
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.32);
}

.legend-os-ov.floor { background-color: rgba(255, 193, 7, 0.95); }
.legend-os-ov.sweep { background-color: rgba(233, 30, 99, 0.92); }
.legend-os-ov.multi { background-color: rgba(156, 39, 176, 0.92); }
.legend-os-ov.sml { background-color: rgba(0, 188, 212, 0.92); }

.legend-os-flow-meta {
  margin-top: 1px;
  font-size: 10px;
  color: var(--legend-text-muted);
}

.legend-os-chip {
  display: inline-block;
  margin: 1px 3px 1px 0;
  padding: 1px 5px;
  border-radius: var(--banana-radius);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #dbe2ea;
  background: rgba(255, 255, 255, 0.08);
}

.legend-os-chip.new { background: rgba(88, 166, 255, 0.24); color: #9ecbff; }
.legend-os-chip.floor { background: rgba(255, 193, 7, 0.2); color: #ffd665; }
.legend-os-chip.sweep { background: rgba(233, 30, 99, 0.22); color: #ff82b0; }
.legend-os-chip.multi { background: rgba(156, 39, 176, 0.25); color: #d59be8; }
.legend-os-chip.sml { background: rgba(0, 188, 212, 0.22); color: #8ee8f4; }

/* Analyst screener chips */
.legend-analyst-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: #dbe2ea;
  background: rgba(255, 255, 255, 0.1);
  text-transform: capitalize;
}

.legend-analyst-chip.pos {
  color: var(--banana-chart-call-muted);
  background: color-mix(in srgb, var(--banana-chart-call) 22%, transparent);
}

.legend-analyst-chip.neg {
  color: var(--banana-chart-put-muted);
  background: color-mix(in srgb, var(--banana-chart-put) 22%, transparent);
}

.legend-analyst-chip.neu {
  color: #b8c0cc;
  background: rgba(149, 156, 168, 0.2);
}

.legend-analyst-chip.muted {
  color: #c5ccd7;
  background: rgba(255, 255, 255, 0.1);
}

/* Stock screener — compact scan rows + expandable panel */
.legend-ss-table {
  table-layout: auto;
  width: 100%;
}

.legend-ss-table td.legend-ss-regime-cell {
  min-width: 252px;
  max-width: 340px;
  width: 30%;
  padding: 8px 10px;
  vertical-align: middle;
}

.legend-ss-col-chevron,
.legend-ss-chevron-cell {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  padding-left: 6px;
  padding-right: 4px;
}

.legend-ss-sticky,
.legend-ss-sticky-h {
  position: sticky;
  z-index: 2;
  background: var(--legend-surface, #12141a);
}

.legend-ss-chevron-cell.legend-ss-sticky {
  left: 0;
  z-index: 3;
}

.legend-ss-data-row .legend-ss-sticky:nth-child(2),
.legend-ss-table thead .legend-ss-sticky-h:nth-child(2) {
  left: 28px;
  min-width: 4.5rem;
}

.legend-ss-data-row .legend-ss-sticky:nth-child(3),
.legend-ss-table thead .legend-ss-sticky-h:nth-child(3) {
  left: calc(28px + 4.5rem);
  min-width: 4.25rem;
}

.legend-ss-data-row {
  cursor: pointer;
}

.legend-ss-data-row td {
  vertical-align: middle;
  padding-top: 7px;
  padding-bottom: 7px;
}

.legend-ss-regime-compact:hover {
  border-color: color-mix(in srgb, var(--banana-accent-lime, #ccff00) 28%, transparent);
}

.legend-ss-data-row:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.legend-ss-data-row.is-expanded td {
  border-bottom-color: transparent;
}

.legend-ss-data-row.is-expanded .legend-ss-sticky,
.legend-ss-data-row.is-expanded td {
  background: rgba(204, 255, 0, 0.06);
}

.legend-ss-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--legend-text-muted);
  transition: transform 0.15s ease;
  vertical-align: middle;
}

.legend-ss-data-row.is-expanded .legend-ss-chevron {
  transform: rotate(90deg);
}

.legend-ss-expand-row td {
  padding: 0;
  border-top: none;
  vertical-align: top;
}

.legend-ss-expand-panel {
  padding: 16px 18px 20px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-accent-lime, #ccff00) 6%, transparent) 0%,
    rgba(255, 255, 255, 0.02) 12%,
    rgba(0, 0, 0, 0.12) 100%
  );
  border-top: 2px solid var(--banana-accent-lime, #ccff00);
}

.legend-ss-expand-heading {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--banana-accent-lime, #ccff00);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legend-ss-regime-full {
  margin-bottom: 4px;
}

.legend-ss-regime-full-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.legend-ss-regime-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--legend-surface, #12141a) 90%, #fff 10%);
  border: 1px solid color-mix(in srgb, var(--legend-text-muted) 14%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.legend-ss-regime-card--sentiment {
  grid-column: span 2;
  min-width: 0;
}

.legend-ss-regime-card--sentiment .legend-ss-stat-tri {
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 10px;
}

.legend-ss-regime-card--sentiment .legend-ss-stat {
  padding: 8px 10px;
}

.legend-ss-regime-card--sentiment .legend-ss-stat__v {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-ss-regime-card__title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.legend-ss-regime-card__viz {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-ss-regime-card__stats {
  margin: 0;
  padding-top: 2px;
}

.legend-ss-split--lg {
  height: 14px;
  border-radius: var(--banana-radius);
}

.legend-ss-split--lg.legend-ss-split--tri {
  height: 14px;
}

.legend-ss-flow4--full {
  height: 14px;
  border-radius: var(--banana-radius);
}

.legend-ss-flow-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 10px;
  color: var(--legend-text-muted);
  line-height: 1.35;
}

.legend-ss-flow-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.legend-ss-flow-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--banana-radius);
  flex-shrink: 0;
}

.legend-ss-flow-legend__dot.call-ask { background: var(--banana-chart-call); }
.legend-ss-flow-legend__dot.call-bid { background: color-mix(in srgb, var(--banana-chart-call) 65%, #0e0e0e); }
.legend-ss-flow-legend__dot.put-ask { background: var(--banana-chart-put); }
.legend-ss-flow-legend__dot.put-bid { background: color-mix(in srgb, var(--banana-chart-put) 65%, #0e0e0e); }

.legend-ss-flow-legend strong {
  margin-left: auto;
  font-weight: 600;
  color: var(--legend-text);
  font-variant-numeric: tabular-nums;
}

.legend-ss-stat-pair,
.legend-ss-stat-tri {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-ss-stat-tri {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.legend-ss-stat {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-ss-stat__k {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--legend-text-muted);
}

.legend-ss-stat__v {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--legend-text);
  line-height: 1.2;
}

.legend-ss-stat--put .legend-ss-stat__v { color: var(--banana-chart-put); }
.legend-ss-stat--call .legend-ss-stat__v { color: var(--banana-chart-call); }
.legend-ss-stat--bear .legend-ss-stat__v { color: var(--banana-chart-put); }
.legend-ss-stat--bull .legend-ss-stat__v { color: var(--banana-chart-call); }
.legend-ss-stat--neutral .legend-ss-stat__v { color: var(--banana-chart-price); }

.legend-ss-oi-full {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-ss-oi-full-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
}

.legend-ss-oi-full-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--legend-text-muted);
  text-transform: uppercase;
}

.legend-ss-oi-full-track {
  height: 8px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-ss-oi-full-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: var(--banana-radius);
}

.legend-ss-oi-full-fill.pos { background: var(--banana-chart-call); }
.legend-ss-oi-full-fill.neg { background: var(--banana-chart-put); }

.legend-ss-oi-full-val {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 4.5em;
  text-align: right;
}

.legend-ss-oi-full-val.pos { color: var(--banana-chart-call); }
.legend-ss-oi-full-val.neg { color: var(--banana-chart-put); }

.legend-ss-gap-track--full {
  height: 10px;
  border-radius: var(--banana-radius);
}

.legend-ss-range-track--full {
  height: 12px;
  border-radius: var(--banana-radius);
}

.legend-ss-range-track--full .legend-ss-range-dot {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.legend-ss-stat-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--legend-text-muted);
}

.legend-ss-stat-line strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--legend-text);
}

.legend-ss-stat-line strong.pos { color: var(--banana-chart-call); }
.legend-ss-stat-line strong.neg { color: var(--banana-chart-put); }

.legend-ss-stat-line__sep {
  opacity: 0.45;
}

.legend-ss-range-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--legend-text-muted);
}

.legend-ss-range-labels span:nth-child(2) {
  color: var(--legend-text);
  font-weight: 600;
}

.legend-ss-metrics-sections {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--legend-text-muted) 16%, transparent);
}

.legend-ss-metrics-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.legend-ss-metrics-card {
  padding: 12px 14px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid color-mix(in srgb, var(--legend-text-muted) 12%, transparent);
  min-width: 0;
}

.legend-ss-metrics-card__title {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--legend-text-muted) 12%, transparent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-ss-metrics-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-ss-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  font-size: 11px;
  line-height: 1.35;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.legend-ss-metric-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.legend-ss-metric-row__label {
  color: var(--legend-text-muted);
  flex: 1 1 auto;
  min-width: 0;
}

.legend-ss-metric-row__value {
  color: var(--legend-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
}

.legend-ss-expand-panel .legend-progress-bar-wrapper,
.legend-ss-expand-panel .legend-ss-regime-block {
  display: none;
}

/* Compact regime: 2×3 labeled mini-tiles (scan row) */
.legend-ss-regime-compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: 6px 8px;
  padding: 8px 10px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--legend-surface, #12141a) 88%, #000 12%);
  border: 1px solid color-mix(in srgb, var(--legend-text-muted) 18%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.legend-ss-mini-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.legend-ss-mini-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--legend-text-muted) 92%, var(--legend-text));
  line-height: 1;
  user-select: none;
}

.legend-ss-mini-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 18px;
}

/* Flex split bars (no inline % text) */
.legend-ss-split {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 10px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  gap: 1px;
}

.legend-ss-split--tri {
  height: 10px;
}

.legend-ss-split__seg {
  display: block;
  min-width: 3px;
  height: 100%;
  transition: flex-grow 0.2s ease;
}

.legend-ss-split__seg--put {
  background: var(--banana-chart-put);
}

.legend-ss-split__seg--call {
  background: var(--banana-chart-call);
}

.legend-ss-split__seg--bear {
  background: var(--banana-chart-put);
}

.legend-ss-split__seg--neutral {
  background: color-mix(in srgb, var(--banana-chart-price) 55%, #555 45%);
}

.legend-ss-split__seg--bull {
  background: var(--banana-chart-call);
}

.legend-ss-flow4--mini {
  height: 10px;
  border-radius: var(--banana-radius);
}

.legend-ss-oi-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-ss-oi-mini-track {
  height: 4px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-ss-oi-mini-fill {
  display: block;
  height: 100%;
  border-radius: var(--banana-radius);
  min-width: 2px;
}

.legend-ss-oi-mini-fill.pos {
  background: var(--banana-chart-call);
}

.legend-ss-oi-mini-fill.neg {
  background: var(--banana-chart-put);
}

.legend-ss-risk-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-ss-gap-track--mini {
  height: 4px;
  border-radius: var(--banana-radius);
}

.legend-ss-range-track--mini {
  height: 6px;
  border-radius: var(--banana-radius);
}

.legend-ss-range-track--mini .legend-ss-range-dot {
  width: 6px;
  height: 6px;
  border-width: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Legacy kv fallback (unused in expand panel) */
.legend-ss-regime-block--compact {
  padding: 1px 2px;
}

.legend-widget[data-type-id="stock_screener"] .legend-ss-col-date {
  display: none;
}

@media (max-width: 960px) {
  .legend-ss-col-date {
    display: none;
  }
  .legend-ss-table thead .legend-ss-col-date {
    display: none;
  }
}

.legend-ss-kv {
  display: block;
  color: var(--legend-text-muted);
  white-space: normal;
  line-height: 1.35;
}

.legend-ss-kv strong {
  color: var(--legend-text);
  font-weight: 600;
}

/* Stock screener regime strip */
.legend-ss-regime {
  display: grid;
  gap: 6px;
}

.legend-ss-regime-block {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--banana-radius);
  padding: 2px 4px;
}

.legend-ss-regime-meta {
  margin-top: 2px;
  font-size: 8px;
  color: var(--legend-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-ss-flow4 {
  height: 7px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  display: flex;
  background: rgba(255, 255, 255, 0.06);
}

.legend-ss-flow4-seg { height: 100%; display: block; }
.legend-ss-flow4-seg.call-ask { background: var(--banana-chart-call); }
.legend-ss-flow4-seg.call-bid { background: color-mix(in srgb, var(--banana-chart-call) 65%, #0e0e0e); }
.legend-ss-flow4-seg.put-ask { background: var(--banana-chart-put); }
.legend-ss-flow4-seg.put-bid { background: color-mix(in srgb, var(--banana-chart-put) 65%, #0e0e0e); }

.legend-ss-oi-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 3px;
  margin-bottom: 1px;
}

.legend-ss-oi-k, .legend-ss-oi-v {
  font-size: 8px;
  color: var(--legend-text-muted);
}

.legend-ss-oi-track {
  height: 6px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-ss-oi-fill {
  height: 100%;
  display: block;
}

.legend-ss-oi-fill.pos { background: var(--banana-chart-call); }
.legend-ss-oi-fill.neg { background: var(--banana-chart-put); }

.legend-ss-gap-track {
  position: relative;
  height: 7px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-ss-gap-mid {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
}

.legend-ss-gap-fill {
  position: absolute;
  top: 0;
  bottom: 0;
}

.legend-ss-gap-fill.pos {
  left: 50%;
  background: var(--banana-chart-call);
}

.legend-ss-gap-fill.neg {
  right: 50%;
  background: var(--banana-chart-put);
}

.legend-ss-range-track {
  position: relative;
  height: 7px;
  border-radius: var(--banana-radius);
  background: linear-gradient(90deg, var(--banana-chart-put) 0%, var(--banana-chart-price) 50%, var(--banana-chart-call) 100%);
}

.legend-ss-range-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #111;
}

.legend-ss-table .legend-progress-bar-wrapper {
  margin-bottom: 0;
}

.legend-ss-table .legend-progress-label {
  font-size: 8px;
  margin-bottom: 2px;
}

.legend-ss-table .legend-progress-bar-container {
  height: 17px;
}

.legend-ss-table .legend-progress-segment {
  font-size: 11px;
  line-height: 1;
  padding: 0 1px;
  box-sizing: border-box;
}

.legend-ss-table .legend-progress-values {
  margin-top: 2px;
  font-size: 8px;
  line-height: 1.25;
}

.legend-loading,
.legend-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  color: var(--legend-text-muted);
  font-size: 13px;
}

.legend-error {
  color: var(--banana-error);
}

/* Add widget modal — glass HUD (§2, §7) */
.legend-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(var(--banana-glass-blur));
  -webkit-backdrop-filter: blur(var(--banana-glass-blur));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: var(--legend-font);
}

.legend-modal {
  font-family: var(--legend-font);
  color: var(--legend-text);
  background: var(--banana-glass-surface);
  backdrop-filter: blur(var(--banana-glass-blur));
  -webkit-backdrop-filter: blur(var(--banana-glass-blur));
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  min-width: 360px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.legend-modal--add-widget {
  position: relative;
  width: min(960px, 94vw);
  min-width: min(560px, 94vw);
  max-height: min(88vh, 900px);
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, #ffffff 11%, transparent);
  background:
    linear-gradient(
      155deg,
      color-mix(in srgb, var(--banana-surface-container-high) 52%, transparent) 0%,
      color-mix(in srgb, var(--banana-surface-container) 40%, transparent) 55%,
      color-mix(in srgb, var(--banana-surface-container-low) 44%, transparent) 100%
    );
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  box-shadow:
    0 40px 90px rgba(0, 0, 0, 0.55),
    0 2px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 80px color-mix(in srgb, var(--banana-primary-fixed) 4%, transparent);
}

/* Soft ambient glows — the "liquid" sheen */
.legend-modal--add-widget::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  background:
    radial-gradient(90% 60% at 18% -8%, color-mix(in srgb, var(--banana-primary-fixed) 16%, transparent), transparent 60%),
    radial-gradient(70% 50% at 100% 0%, color-mix(in srgb, var(--banana-chart-price) 10%, transparent), transparent 55%),
    radial-gradient(120% 80% at 50% 120%, color-mix(in srgb, var(--banana-secondary) 7%, transparent), transparent 60%);
}

/* Thin gradient rim highlight that reads as a glass edge */
.legend-modal--add-widget::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0.02) 30%,
    transparent 60%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.legend-modal--add-widget > * {
  position: relative;
  z-index: 1;
}

#legend-add-modal.legend-modal-backdrop {
  background: radial-gradient(120% 120% at 50% 0%, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.62));
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
}

/* Rename layout modal — compact form */
.legend-modal--rename {
  width: min(420px, 92vw);
  min-width: min(300px, 92vw);
  max-height: none;
}

.legend-modal--settings {
  width: min(560px, 94vw);
  min-width: min(320px, 94vw);
  max-height: min(88vh, 760px);
}

.legend-modal-body--settings {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 20px 20px;
}

/* Account hero */
.legend-settings-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, #ffffff 9%, transparent);
  background:
    radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--banana-primary-fixed) 12%, transparent), transparent 58%),
    color-mix(in srgb, var(--banana-surface-container-high) 32%, transparent);
}

.legend-settings-hero-avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, #ffffff 16%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32);
}

.legend-settings-hero-text {
  min-width: 0;
  flex: 1;
}

.legend-settings-hero-name {
  margin: 0;
  font-family: var(--legend-font-headline);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--legend-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-settings-hero-email {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--legend-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-settings-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.legend-settings-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--banana-primary-fixed);
  border: 1px solid color-mix(in srgb, var(--banana-primary-fixed) 26%, transparent);
  background: color-mix(in srgb, var(--banana-primary-fixed) 9%, transparent);
}

.legend-settings-badge--plan {
  color: var(--legend-text);
  border-color: color-mix(in srgb, #ffffff 16%, transparent);
  background: color-mix(in srgb, var(--banana-surface-container-highest) 60%, transparent);
}

/* Grouped cards */
.legend-settings-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.legend-settings-group-label {
  margin: 0 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-settings-card {
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, #ffffff 8%, transparent);
  background: color-mix(in srgb, var(--banana-surface-container-high) 26%, transparent);
  overflow: hidden;
}

.legend-settings-card--pad {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.legend-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  min-height: 46px;
}

.legend-settings-item + .legend-settings-item {
  border-top: 1px solid color-mix(in srgb, #ffffff 6%, transparent);
}

.legend-settings-item--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.legend-settings-item-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--legend-text);
}

.legend-settings-item-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--legend-text-muted);
}

.legend-settings-item-control {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.legend-settings-item-value {
  font-size: 12px;
  color: var(--legend-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.legend-settings-input {
  width: 110px;
  padding: 7px 10px;
  border-radius: var(--banana-radius);
  border: 1px solid color-mix(in srgb, #ffffff 12%, transparent);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 50%, transparent);
  color: var(--legend-text);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  letter-spacing: 0.02em;
  font-family: var(--legend-font-body);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.legend-settings-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 50%, transparent);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 70%, transparent);
}

.legend-settings-link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--banana-primary-fixed);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.legend-settings-link-btn:hover {
  opacity: 0.78;
  text-decoration: underline;
}

/* Theme segmented control */
.legend-theme-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 55%, transparent);
  border: 1px solid color-mix(in srgb, #ffffff 8%, transparent);
}

.legend-theme-seg__btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--banana-radius);
  padding: 8px 6px;
  font-family: var(--legend-font-headline);
  font-size: 12px;
  font-weight: 600;
  color: var(--legend-text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-theme-seg__btn:hover {
  color: var(--legend-text);
}

.legend-theme-seg__btn.is-active {
  color: var(--banana-on-primary, #0a0a0a);
  background: var(--banana-primary-fixed);
  border-color: color-mix(in srgb, #ffffff 22%, transparent);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--banana-primary-fixed) 35%, transparent);
}

/* Toggle switch */
.legend-settings-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.legend-settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.legend-settings-toggle-ui {
  width: 40px;
  height: 22px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-highest) 75%, transparent);
  border: 1px solid color-mix(in srgb, #ffffff 10%, transparent);
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.legend-settings-toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.legend-settings-toggle input:checked + .legend-settings-toggle-ui {
  background: var(--banana-primary-fixed);
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 60%, transparent);
}

.legend-settings-toggle input:checked + .legend-settings-toggle-ui::after {
  transform: translateX(18px);
}

.legend-settings-toggle input:focus-visible + .legend-settings-toggle-ui {
  outline: 2px solid color-mix(in srgb, var(--banana-primary-fixed) 60%, transparent);
  outline-offset: 2px;
}

/* Billing */
.legend-settings-billing-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.legend-settings-billing-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 45%, transparent);
  border: 1px solid color-mix(in srgb, #ffffff 6%, transparent);
}

.legend-settings-billing-stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
}

.legend-settings-billing-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--legend-text);
  text-transform: capitalize;
}

.legend-settings-empty {
  margin: 0;
  font-size: 12px;
  color: var(--legend-text-muted);
}

.legend-settings-status {
  margin: 0;
  font-size: 11px;
  color: var(--legend-text-muted);
}

.legend-btn--compact {
  padding: 8px 14px;
  font-size: 12px;
  align-self: flex-start;
}

/* Footer */
.legend-settings-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.legend-settings-footer-dot {
  color: var(--legend-text-muted);
  opacity: 0.5;
  font-size: 11px;
}

.legend-settings-footer-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.legend-settings-footer-link:hover {
  color: var(--banana-primary-fixed);
}

.legend-settings-footer-form {
  margin: 0 0 0 auto;
}

.legend-settings-footer-logout {
  border: 1px solid color-mix(in srgb, var(--banana-error) 32%, transparent);
  background: color-mix(in srgb, var(--banana-error) 10%, transparent);
  color: color-mix(in srgb, var(--banana-error) 90%, #ffffff);
  padding: 6px 12px;
  border-radius: var(--banana-radius);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.legend-settings-footer-logout:hover {
  background: color-mix(in srgb, var(--banana-error) 18%, transparent);
  border-color: color-mix(in srgb, var(--banana-error) 50%, transparent);
}

#legend-settings-modal.legend-modal-backdrop {
  background: radial-gradient(120% 120% at 50% 0%, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.62));
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
}

.legend-modal--chat-history {
  width: min(520px, 92vw);
  min-width: min(320px, 92vw);
  max-height: min(72vh, 640px);
}

.legend-modal--alert-detail {
  width: min(560px, 92vw);
  min-width: min(320px, 92vw);
  max-height: min(78vh, 720px);
}

.legend-modal--flow-alert-detail {
  width: min(760px, 96vw);
  min-width: min(320px, 96vw);
  max-height: min(84vh, 820px);
}

.legend-modal--news-headline {
  width: min(640px, 92vw);
  min-width: min(320px, 92vw);
  max-height: min(78vh, 720px);
}

.legend-modal-body--news-headline {
  overflow-y: auto;
  max-height: min(58vh, 560px);
  padding: 16px 20px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 14px;
  color: var(--legend-text);
}

.legend-modal-body--flow-alert-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: min(62vh, 620px);
  padding: 16px 20px;
}

.legend-table tbody tr.legend-table-row-clickable {
  cursor: pointer;
}

.legend-fa-detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 12px;
}

.legend-fa-detail-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.legend-fa-detail-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--legend-text-muted);
}

.legend-fa-detail-v {
  font-size: 13px;
  color: var(--legend-text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-fa-detail-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.legend-fa-detail-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--banana-radius);
  font-size: 11px;
  font-weight: 500;
  background: color-mix(in srgb, var(--banana-primary) 18%, transparent);
  color: var(--legend-text);
}

.legend-fa-detail-more {
  margin: 0;
  font-size: 12px;
  color: var(--legend-text-muted);
}

.legend-fa-detail-trades {
  min-height: 0;
}

.legend-fa-detail-trades .legend-table-wrap {
  max-height: min(40vh, 360px);
  overflow: auto;
}

#legend-flow-alert-detail-footer {
  justify-content: flex-start;
  align-items: flex-end;
}

.legend-fa-detail-footer-widgets {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.legend-fa-widget-action {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  max-width: 220px;
}

.legend-fa-widget-hint {
  font-size: 11px;
  line-height: 1.3;
  color: var(--legend-text-muted);
}

.legend-modal-body--alert-detail {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  color: var(--legend-text);
  overflow-y: auto;
  max-height: min(52vh, 480px);
  padding: 16px 20px;
}

#legend-alert-detail-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#legend-alert-detail-footer .legend-btn-primary {
  text-decoration: none;
}

.legend-modal-body--chat-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 20px 20px;
  overflow: hidden;
  min-height: 0;
}

.legend-chat-history-actions {
  display: flex;
  justify-content: flex-end;
}

.legend-chat-history-empty {
  margin: 0;
  font-size: 13px;
  color: var(--legend-text-muted);
  text-align: center;
  padding: 16px 8px;
}

.legend-chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(50vh, 420px);
  overflow-y: auto;
  padding-right: 4px;
}

.legend-chat-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.legend-chat-history-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: color-mix(in srgb, var(--banana-primary) 25%, transparent);
}

.legend-chat-history-row-info {
  flex: 1;
  min-width: 0;
}

.legend-chat-history-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--legend-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-chat-history-row-meta {
  font-size: 11px;
  color: var(--legend-text-muted);
  margin-top: 4px;
}

.legend-chat-history-open {
  flex-shrink: 0;
  font-size: 12px;
  padding: 6px 12px;
}

.legend-chat-history-delete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--legend-text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.legend-chat-history-delete:hover {
  background: rgba(255, 100, 100, 0.25);
  color: var(--legend-text);
}

.legend-modal-body--rename {
  padding: 12px 20px 4px;
}

.legend-modal-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
  margin-bottom: 8px;
}

.legend-modal-rename-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--banana-surface-container-lowest);
  border: 1px solid var(--legend-border);
  color: var(--legend-text);
  padding: 10px 12px;
  border-radius: var(--banana-radius);
  font-size: 14px;
  font-family: var(--legend-font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-modal-rename-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary) 40%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--banana-primary) 22%, transparent);
}

.legend-modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--legend-border);
  flex-shrink: 0;
}

.legend-modal-header {
  padding: 16px 20px;
  border-bottom: none;
  box-shadow: 0 1px 0 var(--legend-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.legend-modal-header-text {
  flex: 1;
  min-width: 0;
}

.legend-modal-header h2 {
  font-family: var(--legend-font-headline);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
  color: var(--legend-text);
}

.legend-modal-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  font-family: var(--legend-font-body);
  color: var(--legend-text-muted);
  max-width: 52em;
}

/* Body-portaled overlays (JS appendChild) — explicit Inter when outside modals */
.legend-tab-context,
.legend-msdd-panel--floating,
.legend-iv-wizard-overlay,
.legend-delayed-modal-overlay,
#legend-floating-toast {
  font-family: var(--legend-font);
}

.legend-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--banana-radius);
  color: var(--legend-text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  align-self: flex-start;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.legend-modal-close:hover {
  color: var(--banana-on-surface);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--legend-border);
}

/* Add-widget modal header — icon, title, inline key */
.legend-modal-header--add-widget {
  align-items: center;
  gap: 14px;
  padding: 18px 20px 16px;
  box-shadow: 0 1px 0 color-mix(in srgb, #ffffff 7%, transparent);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--banana-primary-fixed) 10%, transparent), transparent 62%);
}

.legend-modal-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--banana-radius);
  color: var(--banana-primary-fixed);
  background: color-mix(in srgb, var(--banana-primary-fixed) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-primary-fixed) 26%, transparent);
}

.legend-modal-header--add-widget .legend-modal-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-modal-header--add-widget h2 {
  margin: 0;
}

.legend-palette-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  padding: 6px 12px;
  border-radius: var(--banana-radius);
  background: var(--banana-surface-container-lowest);
  border: 1px solid var(--legend-border);
}

.legend-palette-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

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

@media (max-width: 720px) {
  .legend-palette-legend {
    display: none;
  }
}

.legend-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.legend-modal-body::-webkit-scrollbar {
  display: none;
}

/* Add-widget modal — master/detail layout */
.legend-aw-body {
  display: flex;
  flex: 1;
  min-height: 0;
  height: min(62vh, 560px);
}

.legend-aw-list {
  flex: 0 0 246px;
  width: 246px;
  overflow-y: auto;
  padding: 12px 10px;
  border-right: 1px solid color-mix(in srgb, #ffffff 7%, transparent);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-surface-container-lowest) 18%, transparent),
    color-mix(in srgb, var(--banana-surface-container-lowest) 8%, transparent)
  );
  scrollbar-width: thin;
}

.legend-aw-list::-webkit-scrollbar { width: 8px; }
.legend-aw-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--legend-text-muted) 24%, transparent);
  border-radius: var(--banana-radius);
}

.legend-aw-list-section { margin: 0 0 14px 0; }
.legend-aw-list-section:last-child { margin-bottom: 0; }

.legend-aw-list-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px 0;
  padding: 0 8px;
}

.legend-aw-list-section-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
  white-space: nowrap;
}

.legend-palette-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--banana-radius);
  font-size: 9px;
  font-weight: 700;
  color: var(--banana-primary-fixed);
  background: color-mix(in srgb, var(--banana-primary-fixed) 12%, transparent);
}

.legend-aw-list-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--legend-border), transparent);
}

/* List rows */
.legend-aw-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text);
  cursor: pointer;
  text-align: left;
  transition: background 0.13s ease, border-color 0.13s ease, color 0.13s ease, box-shadow 0.13s ease;
}

.legend-aw-row + .legend-aw-row { margin-top: 1px; }

/* Multi-select checkbox affordance inside each palette row */
.legend-aw-row-check {
  flex: 0 0 auto;
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid color-mix(in srgb, var(--legend-text-muted) 55%, transparent);
  background: transparent;
  cursor: pointer;
  transition: background 0.13s ease, border-color 0.13s ease;
}

.legend-aw-row-check:hover {
  border-color: var(--banana-primary-fixed);
}

.legend-aw-row-check[data-checked="true"] {
  background: var(--banana-primary-fixed);
  border-color: var(--banana-primary-fixed);
}

.legend-aw-row-check[data-checked="true"]::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--banana-on-primary-fixed, #1a1300);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.legend-aw-row-check--na {
  border-style: dashed;
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.legend-aw-row--checked {
  background: color-mix(in srgb, var(--banana-primary-fixed) 8%, transparent);
}

/* Bottom action bar for batch-add */
.legend-aw-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid color-mix(in srgb, #ffffff 7%, transparent);
  background: color-mix(in srgb, var(--banana-surface-container-lowest) 14%, transparent);
}

.legend-aw-actionbar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--legend-text-muted);
}

.legend-aw-actionbar-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-aw-clear-btn {
  padding: 7px 12px;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: transparent;
  color: var(--legend-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.13s ease, opacity 0.13s ease;
}

.legend-aw-clear-btn:hover:not(:disabled) {
  background: color-mix(in srgb, #ffffff 6%, transparent);
}

.legend-aw-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--banana-radius);
  background: var(--banana-primary-fixed);
  color: var(--banana-on-primary-fixed, #1a1300);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.13s ease, opacity 0.13s ease;
}

.legend-aw-apply-btn:hover:not(:disabled) {
  filter: brightness(1.07);
}

.legend-aw-clear-btn:disabled,
.legend-aw-apply-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.legend-aw-row-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-aw-row-feed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  flex-shrink: 0;
}

.legend-aw-row-feed--live {
  color: var(--banana-primary-fixed);
}

.legend-aw-row-feed--rest {
  color: var(--legend-text-muted);
}

.legend-aw-row-feed--rest .legend-feed-dot {
  animation: none;
  box-shadow: none;
  opacity: 0.45;
}

.legend-aw-row-chevron {
  flex-shrink: 0;
  color: var(--legend-text-muted);
  opacity: 0;
  transform: translateX(-2px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}

.legend-aw-row:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--banana-on-surface);
}

.legend-aw-row:hover .legend-aw-row-chevron {
  opacity: 0.8;
  transform: translateX(0);
}

.legend-aw-row:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 45%, var(--legend-border));
}

.legend-aw-row.is-active {
  background: linear-gradient(
    100deg,
    color-mix(in srgb, var(--banana-primary-fixed) 16%, transparent),
    color-mix(in srgb, var(--banana-primary-fixed) 7%, transparent)
  );
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 34%, transparent);
  color: var(--banana-on-surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 18px color-mix(in srgb, var(--banana-primary-fixed) 12%, transparent);
}

.legend-aw-row.is-active .legend-aw-row-name { font-weight: 600; }

.legend-aw-row.is-active .legend-aw-row-chevron {
  opacity: 1;
  transform: translateX(0);
  color: var(--banana-primary-fixed);
}

/* Detail panel */
.legend-aw-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.legend-aw-detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 16px;
  scrollbar-width: thin;
}

.legend-aw-detail-scroll::-webkit-scrollbar { width: 8px; }
.legend-aw-detail-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--legend-text-muted) 24%, transparent);
  border-radius: var(--banana-radius);
}

.legend-aw-detail-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.legend-aw-detail-titlewrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-aw-detail-title {
  margin: 0;
  font-family: var(--legend-font-headline);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--banana-on-surface);
  line-height: 1.2;
}

.legend-aw-detail-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.legend-aw-detail-chip {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 9px;
  border-radius: var(--banana-radius);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.legend-aw-detail-chip--cat {
  color: var(--legend-text-muted);
  background: color-mix(in srgb, var(--legend-text-muted) 12%, transparent);
  border-color: color-mix(in srgb, var(--legend-text-muted) 22%, transparent);
}

.legend-aw-detail-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--legend-text);
}

.legend-aw-detail-sections {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.legend-aw-detail-section h4 {
  margin: 0 0 5px 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--banana-primary-fixed);
}

.legend-aw-detail-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--legend-text-muted);
}

.legend-aw-detail-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 13px 24px;
  border-top: 1px solid color-mix(in srgb, #ffffff 7%, transparent);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-surface-container-high) 10%, transparent),
    color-mix(in srgb, var(--banana-surface-container-high) 26%, transparent)
  );
}

.legend-aw-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--banana-radius);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--banana-on-primary);
  background: var(--legend-primary-gradient);
  cursor: pointer;
  transition: transform 0.13s ease, box-shadow 0.13s ease, filter 0.13s ease;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--banana-primary-fixed) 24%, transparent);
}

.legend-aw-add-btn svg { display: block; }

.legend-aw-add-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--banana-primary-fixed) 32%, transparent);
}

.legend-aw-add-btn:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .legend-aw-body { flex-direction: column; height: auto; max-height: 70vh; }
  .legend-aw-list {
    flex: 0 0 auto;
    width: 100%;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--legend-border);
  }
}

/* Feed badge — Live vs REST */
.legend-palette-feed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: var(--banana-radius);
  line-height: 1.2;
  border: 1px solid transparent;
}

.legend-feed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: legend-feed-pulse 2s ease-out infinite;
}

@keyframes legend-feed-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 70%, transparent); }
  70% { box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .legend-feed-dot { animation: none; }
}

.legend-palette-feed--live {
  color: var(--banana-primary-fixed);
  background: color-mix(in srgb, var(--banana-primary-fixed) 14%, transparent);
  border-color: color-mix(in srgb, var(--banana-primary-fixed) 34%, transparent);
}

.legend-palette-feed--live.legend-palette-feed--locked {
  color: var(--legend-text-muted);
  background: color-mix(in srgb, var(--legend-text-muted) 10%, transparent);
  border-color: color-mix(in srgb, var(--legend-text-muted) 22%, transparent);
}

.legend-palette-feed--live.legend-palette-feed--locked .legend-feed-dot {
  animation: none;
  box-shadow: none;
  opacity: 0.6;
}

.legend-palette-feed--rest {
  color: var(--legend-text-muted);
  background: color-mix(in srgb, var(--legend-text-muted) 9%, transparent);
  border-color: color-mix(in srgb, var(--legend-text-muted) 20%, transparent);
}

/* Meta chips — symbol / session linkage */
.legend-palette-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 7px 0 6px;
  border-radius: var(--banana-radius);
  border: 1px solid transparent;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-palette-meta svg {
  display: block;
}

.legend-palette-meta-label {
  line-height: 1;
}

.legend-palette-meta--symbol {
  color: var(--banana-chart-call);
  background: color-mix(in srgb, var(--banana-chart-call) 10%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 24%, transparent);
}

.legend-palette-meta--session {
  color: var(--banana-chart-price);
  background: color-mix(in srgb, var(--banana-chart-price) 10%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-price) 24%, transparent);
}

.legend-context-segment {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  padding: 2px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-surface-container-high) 72%, transparent);
  backdrop-filter: blur(var(--legend-glass-blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--legend-glass-blur)) saturate(1.2);
  border: 1px solid var(--legend-glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 10px rgba(0, 0, 0, 0.28);
}

.legend-context-segment-divider {
  width: 1px;
  align-self: stretch;
  margin: 3px 2px;
  background: var(--legend-border);
}

.legend-context-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 3px 9px;
  border-radius: var(--banana-radius);
  cursor: text;
  transition: background 0.15s ease;
}

.legend-context-field:hover {
  background: rgba(255, 255, 255, 0.03);
}

.legend-context-field:focus-within {
  background: color-mix(in srgb, var(--banana-primary-fixed) 9%, transparent);
}

.legend-context-field-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--legend-text-muted);
  opacity: 0.85;
  flex-shrink: 0;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.legend-context-field:focus-within .legend-context-field-icon {
  color: var(--banana-primary-fixed);
  opacity: 1;
}

.legend-context-field-text {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.legend-context-field-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--legend-text-muted);
  opacity: 0.7;
}

.legend-context-segment input {
  background: transparent;
  border: none;
  color: var(--legend-text);
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.legend-context-segment input::placeholder {
  color: var(--legend-text-muted);
  font-weight: 500;
}

.legend-context-segment input:focus {
  outline: none;
  box-shadow: none;
}

.legend-context-field--symbol input {
  width: 48px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--banana-primary-fixed);
}

.legend-date-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-date-picker-wrap #legend-context-date {
  min-width: 68px;
  width: 68px;
  cursor: pointer;
}

.legend-date-calendar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--banana-radius);
  color: var(--legend-text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.legend-date-calendar-icon {
  display: block;
  flex-shrink: 0;
}

.legend-date-calendar-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--legend-border);
  color: var(--banana-primary-fixed);
}

.legend-calendar-dropdown {
  position: fixed;
  z-index: 2000;
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 10px;
  min-width: 220px;
}

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

.legend-calendar-prev,
.legend-calendar-next {
  padding: 4px 8px;
  background: transparent;
  border: none;
  color: var(--legend-text);
  cursor: pointer;
  font-size: 16px;
}

.legend-calendar-prev:hover,
.legend-calendar-next:hover {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
}

.legend-calendar-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--legend-text);
}

.legend-calendar-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.legend-calendar-grid th {
  color: var(--legend-text-muted);
  font-weight: 500;
  padding: 4px 0;
}

.legend-calendar-grid td {
  text-align: center;
  padding: 2px;
}

.legend-calendar-day {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-calendar-day:hover {
  background: rgba(255, 255, 255, 0.12);
}

.legend-calendar-day--disabled,
.legend-calendar-day:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.legend-calendar-today-wrap {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--legend-border);
}

.legend-calendar-today {
  width: 100%;
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  color: var(--legend-text);
  cursor: pointer;
}

.legend-calendar-today:hover {
  background: rgba(255, 255, 255, 0.12);
}

.legend-widget-date {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}

.legend-widget-date-global {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--legend-text-muted);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  cursor: pointer;
}

.legend-widget-date-global.active {
  color: var(--banana-chart-call);
  background: color-mix(in srgb, var(--banana-chart-call) 22%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 55%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--banana-chart-call) 35%, transparent);
}

.legend-widget-date-global:hover {
  background: rgba(255, 255, 255, 0.08);
}

.legend-widget-date-input {
  width: 100px;
  padding: 2px 4px;
  font-size: 10px;
  background: var(--banana-surface-container-lowest);
  border: 1px solid var(--legend-border);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.legend-widget-date-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-primary) 40%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--banana-primary) 22%, transparent);
}

.legend-widget-date.is-commodity-locked {
  opacity: 0.42;
  pointer-events: none;
  cursor: not-allowed;
}

.legend-widget-date.is-commodity-locked .legend-widget-date-global,
.legend-widget-date.is-commodity-locked .legend-widget-date-input {
  cursor: not-allowed;
  color: var(--legend-text-muted);
}

/* Tab context menu (right-click) */
.legend-tab-context {
  position: fixed;
  background: var(--banana-glass-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  padding: 4px 0;
  min-width: 140px;
  z-index: 1001;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.legend-tab-context button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: none;
  border: none;
  color: var(--legend-text);
  font-size: 12px;
  cursor: pointer;
}

.legend-tab-context button:hover {
  background: var(--banana-surface-container-highest);
}

.legend-tab-context button.danger {
  color: var(--banana-error);
}

/* Leaflet — reskin defaults under Legend (§9) */
.legend-app .leaflet-container {
  font-family: var(--legend-font);
  color: var(--legend-text);
}

.legend-app .leaflet-popup-content-wrapper,
.legend-app .leaflet-popup-tip {
  background: var(--banana-glass-surface) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--legend-text) !important;
  border: 1px solid var(--legend-border) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.legend-app .leaflet-popup-tip {
  box-shadow: none;
}

.legend-app .leaflet-popup-content {
  margin: 10px 12px;
  font-size: 12px;
}

.legend-app .leaflet-control-attribution {
  background: color-mix(in srgb, var(--banana-surface-container-high) 85%, transparent) !important;
  color: var(--legend-text-muted) !important;
  font-size: 10px;
  border-radius: var(--banana-radius);
  box-shadow: 0 1px 0 var(--legend-border);
}

.legend-app .leaflet-control-attribution a {
  color: var(--banana-secondary) !important;
}

/* Free plan: delayed UW data — banner, per-widget badge + watermark, first-visit modal */
.legend-delayed-plan-banner {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 -4px;
  border-radius: var(--banana-radius);
  background: color-mix(in srgb, var(--banana-chart-price, #f59e0b) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-chart-price, #f59e0b) 35%, transparent);
  color: var(--legend-text);
  font-size: 11px;
  line-height: 1.35;
}

.legend-delayed-plan-banner__text strong {
  font-weight: 700;
  color: color-mix(in srgb, var(--banana-chart-price, #f59e0b) 95%, #fff);
}

.legend-delayed-plan-banner__dismiss {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--legend-text);
  cursor: pointer;
}

.legend-delayed-plan-banner__dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
}

.legend-widget-delayed-badge {
  flex-shrink: 0;
  margin-right: 6px;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--banana-radius);
  color: color-mix(in srgb, var(--banana-chart-price, #f59e0b) 95%, #fff);
  background: color-mix(in srgb, var(--banana-chart-price, #f59e0b) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-chart-price, #f59e0b) 40%, transparent);
  cursor: help;
}

.legend-widget-brand-watermark {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  text-align: center;
}

/* Widget-shell overlay: pinned to the body grid row while inner content scrolls */
.legend-widget > .legend-widget-brand-watermark {
  grid-row: 2;
  grid-column: 1;
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
}

.legend-widget-brand-watermark__ticker {
  font-family: 'Space Grotesk', Inter, system-ui, sans-serif;
  font-size: clamp(22px, 4.5vw, 42px);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: rgba(204, 255, 0, 0.22);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.12em;
}

.legend-widget-brand-watermark__brand {
  font-family: 'Space Grotesk', Inter, system-ui, sans-serif;
  font-size: clamp(16px, 3vw, 34px);
  font-weight: 700;
  line-height: 1.05;
  color: rgba(204, 255, 0, 0.16);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
}

.legend-widget-brand-watermark--no-ticker .legend-widget-brand-watermark__ticker {
  display: none;
}

.legend-widget-brand-watermark--compact .legend-widget-brand-watermark__ticker {
  font-size: clamp(16px, 3vw, 28px);
}

.legend-widget-brand-watermark--compact .legend-widget-brand-watermark__brand {
  font-size: clamp(12px, 2.2vw, 22px);
}

.legend-widget-delayed-watermark {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  border-radius: inherit;
  background: repeating-linear-gradient(
    -28deg,
    transparent 0px,
    transparent 52px,
    rgba(255, 255, 255, 0.025) 52px,
    rgba(255, 255, 255, 0.025) 54px
  );
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.12);
}

.legend-widget-delayed-watermark::after {
  content: 'Delayed · Not live';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-size: clamp(11px, 2.2vw, 15px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  user-select: none;
}

.legend-delayed-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.legend-delayed-modal {
  max-width: 420px;
  width: 100%;
  padding: 22px 24px;
  border-radius: var(--banana-radius);
  background: var(--legend-bg-elevated);
  border: 1px solid var(--legend-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.legend-delayed-modal__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
  font-family: var(--banana-font-headline, 'Space Grotesk', sans-serif);
  color: var(--legend-text);
}

.legend-delayed-modal__body {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--legend-text-muted);
}

.legend-delayed-modal__body--muted {
  font-size: 12px;
  opacity: 0.9;
}

.legend-delayed-modal__ok {
  margin-top: 8px;
  width: 100%;
}

/* IV surface loading progress */
.legend-iv-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 14px;
  font-size: 12px;
  color: var(--legend-text-muted);
}
.legend-iv-progress-label {
  font-weight: 600;
  color: #e0e0e0;
}
.legend-iv-progress-bar {
  position: relative;
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
  overflow: hidden;
}
.legend-iv-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #2f9ed8 0%, #fce047 70%, var(--banana-chart-put) 100%);
  border-radius: var(--banana-radius);
  transition: width 200ms linear;
}
.legend-iv-progress-meta {
  font-size: 10px;
  opacity: 0.8;
}

/* IV surface hover readout — fixed crosshair-style panel */
.legend-iv-hover {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 6px;
  padding: 8px 12px;
  border-radius: var(--banana-radius);
  background: rgba(15, 18, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 11.5px;
  color: #d4d8df;
  min-height: 30px;
  align-items: center;
}
.legend-iv-hover--idle {
  opacity: 0.55;
  font-style: italic;
}
.legend-iv-hover__cell {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.legend-iv-hover__label {
  color: var(--legend-text-muted, #9aa0aa);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.legend-iv-hover__value {
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.legend-iv-hover__value--iv {
  color: #fce047;
}
.legend-iv-hover__source {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 10px;
  color: #b6bcc6;
  white-space: nowrap;
}
.legend-iv-hover__source--gap {
  background: rgba(252, 224, 71, 0.08);
  border-color: rgba(252, 224, 71, 0.28);
  color: #f3e08a;
}

/* --- IV Surface Cockpit (Phase 1+ upgrade): hover bar, sidebar, tabs --- */
.legend-iv-cockpit {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 6px;
}
/* Sidebar Selection card — replaces the legacy full-width hover bar. Lives
   at the top of the right sidebar and shows the hovered/pinned cell. */
.legend-iv-sidebar-selection {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  margin: 6px 8px 0;
  border-radius: var(--banana-radius);
  background: rgba(12, 14, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 11px;
  color: #d4d8df;
}
.legend-iv-sidebar-selection--idle {
  opacity: 0.55;
  font-style: italic;
  font-size: 10.5px;
  line-height: 1.4;
}
.legend-iv-sidebar-selection--pinned {
  border-color: rgba(252, 224, 71, 0.45);
  background: rgba(252, 224, 71, 0.04);
}
.legend-iv-sidebar-selection__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.legend-iv-sidebar-selection__title-txt {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9aa0aa;
  font-weight: 600;
}
.legend-iv-sidebar-selection__badge {
  font-size: 8.5px;
  letter-spacing: 0.08em;
  color: #fce047;
  background: rgba(252, 224, 71, 0.12);
  border: 1px solid rgba(252, 224, 71, 0.35);
  padding: 1px 5px;
  border-radius: var(--banana-radius);
  font-weight: 700;
}
.legend-iv-sidebar-selection__row {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: baseline;
  column-gap: 8px;
  line-height: 1.35;
}
.legend-iv-sidebar-selection__lbl {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa0aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-iv-sidebar-selection__val {
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-iv-sidebar-selection__val.val--iv { color: #fce047; }
.legend-iv-sidebar-selection__val.val--z-pos { color: var(--banana-chart-put); }
.legend-iv-sidebar-selection__val.val--z-neg { color: #2f9ed8; }
.legend-iv-sidebar-selection__val.val--gap {
  color: #f3e08a;
  font-style: italic;
}

.legend-iv-cockpit__body {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 8px;
}
.legend-iv-main {
  flex: 1;
  min-width: 0;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  /* Anchor for the absolute-positioned hover/pinned cell overlay card. */
  position: relative;
}

/* Hovered / pinned cell overlay (top-right corner of the chart). */
.legend-iv-sel-overlay {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 280px;
  max-width: 32%;
  z-index: 5;
  pointer-events: auto;
}
/* Bare text on the chart background — no card chrome. */
.legend-iv-sel-overlay .legend-iv-sidebar-selection,
.legend-iv-sel-overlay .legend-iv-sidebar-selection--pinned,
.legend-iv-sel-overlay .legend-iv-sidebar-selection--idle {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  border-radius: 0;
}
.legend-iv-sel-overlay .legend-iv-sidebar-selection__title {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 2px;
}
.legend-iv-sel-overlay .legend-iv-sidebar-selection--idle {
  font-size: 10px;
  opacity: 0.7;
}

/* Hovered vs Pinned compare block — sits directly under the pinned card. */
.legend-iv-sel-compare {
  margin-top: 6px;
  /* Horizontal padding mirrors the pinned card's inset so the labels and
     values line up with the card above. box-sizing keeps the block within the
     overlay's 280px width. */
  padding: 4px 8px 0;
  box-sizing: border-box;
  border-top: 1px dashed rgba(255, 255, 255, 0.18);
  font-size: 10.5px;
  color: #d4d8df;
  font-variant-numeric: tabular-nums;
}
.legend-iv-sel-compare__title {
  font-size: 8.5px;
  color: #fce047;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 2px;
}
.legend-iv-sel-compare__row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.4;
}
.legend-iv-sel-compare__lbl {
  color: #9aa0aa;
  text-transform: uppercase;
  font-size: 8.5px;
  letter-spacing: 0.05em;
}
.legend-iv-sel-compare__val {
  color: #e6eaf0;
  font-weight: 600;
}
.legend-iv-sel-compare__diff {
  color: #9aa0aa;
  font-weight: 400;
  margin-left: 4px;
}
.legend-iv-sel-compare__diff--up {
  color: var(--banana-chart-put);
}
.legend-iv-sel-compare__diff--down {
  color: var(--banana-chart-call);
}
.legend-iv-main .legend-chart-container {
  flex: 1;
  min-height: 200px;
  height: 100%;
}
.legend-iv-sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 8px;
}
@container (max-width: 720px) {
  .legend-iv-cockpit__body {
    flex-direction: column;
  }
  .legend-iv-sidebar {
    flex: 0 0 auto;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 0;
    padding-top: 8px;
    max-height: 280px;
  }
}

.legend-iv-tabs {
  display: flex;
  /* row-gap leaves room for the active tab's glowing underline pseudo-bar so
     it doesn't bleed into tabs that wrap onto subsequent rows. */
  gap: 12px 4px;
  padding: 4px 4px 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid color-mix(in srgb, var(--banana-outline-variant) 30%, transparent);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--banana-surface-container-highest) 70%, transparent) 0%,
    transparent 100%
  );
  border-radius: var(--banana-radius) 0 0;
}
.legend-iv-tab {
  position: relative;
  appearance: none;
  box-sizing: border-box;
  line-height: 1.25;
  background: color-mix(in srgb, var(--banana-surface-container) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-outline-variant) 40%, transparent);
  color: var(--banana-on-surface-variant, #9aa0aa);
  font-family: var(--legend-font-headline, inherit);
  font-size: 9.5px;
  padding: 5px 9px;
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-radius: var(--banana-radius);
  white-space: nowrap;
  transition:
    color 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}
.legend-iv-tab:hover {
  color: var(--banana-primary, #f3ffca);
  background: color-mix(in srgb, var(--banana-chart-call) 8%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 30%, transparent);
  transform: translateY(-1px);
}

/* ── Top tab bar: full-width row across the cockpit head (replaces the 6
   labels wrapping onto two rows inside the 320px sidebar). ─────────────── */
.legend-iv-tabs--top {
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  overflow-y: visible;
  gap: 6px;
  min-height: 38px;
  padding: 6px 10px 12px;
  margin-bottom: 0;
  border-radius: var(--banana-radius) var(--banana-radius) 0 0;
  border-bottom: 1px solid color-mix(in srgb, var(--banana-outline-variant) 35%, transparent);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.legend-iv-tabs--top::-webkit-scrollbar { height: 4px; }
.legend-iv-tabs--top::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }
.legend-iv-tabs--top .legend-iv-tab {
  flex: 0 0 auto;
  font-size: 10.5px;
  padding: 6px 13px;
}
/* Top bar: anchor active tab to the panel with an inset bottom edge (no clipped pseudo-bar). */
.legend-iv-tabs--top .legend-iv-tab--active {
  border-bottom-color: var(--banana-chart-call);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--banana-chart-call) 30%, transparent),
    inset 0 -2px 0 var(--banana-chart-call);
}
.legend-iv-tabs--top .legend-iv-tab--active::after {
  display: none;
}
.legend-iv-tabs--top .legend-iv-tab--active:hover {
  transform: none;
}

/* Light polish: the hover/pinned selection card reads as glass over the chart. */
.legend-iv-sidebar-selection {
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.38);
}

/* ── Flipped cockpit: the STAGE is the big analysis area; the 3D is one tab.
   Panes stack absolutely and stay sized (visibility-toggled, never
   display:none) so the 3D echarts-gl pane can init while hidden. ─────────── */
.legend-iv-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.legend-iv-stage-pane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.legend-iv-stage-pane--active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
/* Rich/Cheap pane: dislocation heatmap stacked over the residual smile. The
   monitor shows in FULL (no inner scroll — the whole heatmap); the smile fills
   the remaining height. If the pair overflows, the pane scrolls, not the map. */
.legend-iv-stack { min-height: 0; }
.legend-iv-stack--top { flex: 0 0 auto; overflow: visible; padding: 6px 6px 2px; }
.legend-iv-stack--bot { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; padding: 2px 6px 4px; }
.legend-iv-stack--top .legend-iv-grid-wrap { overflow: visible; }
.legend-iv-stack--top .legend-iv-grid-table th,
.legend-iv-stack--top .legend-iv-grid-table td { padding: 3px 5px; }
.legend-iv-stack--bot .legend-iv-slice-body { min-height: 150px; }
.legend-iv-stage-pane[data-tab-id="dislocations"] { overflow-y: auto; }
.legend-iv-stage-pane[data-tab-id="smile"],
.legend-iv-stage-pane[data-tab-id="term"],
.legend-iv-stage-pane[data-tab-id="overview"] { overflow-y: auto; padding: 6px 8px; }

/* Rail: persistent pinned-cell HUD + angle switch + ideas (was the sidebar). */
.legend-iv-rail {
  flex: 0 0 384px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 10px;
}
/* Compact pinned-cell card so the ranked ideas get the vertical room. */
.legend-iv-rail .legend-iv-sidebar-selection { margin: 0; flex: 0 0 auto; }
/* The ideas / algorithm-recommendation panel gets the bulk of the rail height. */
.legend-iv-rail .legend-iv-ideas { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Angle switch (Seller / Buyer / Hedger / Spreads). */
.legend-iv-angle { display: flex; gap: 4px; }
.legend-iv-angle-btn {
  flex: 1;
  background: color-mix(in srgb, var(--banana-surface-container) 40%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-outline-variant) 35%, transparent);
  color: var(--banana-on-surface-variant, #9aa0aa);
  font-family: var(--legend-font-headline, inherit);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 4px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.legend-iv-angle-btn:hover { color: var(--banana-primary, #f3ffca); border-color: color-mix(in srgb, var(--banana-chart-call) 30%, transparent); }
.legend-iv-angle-btn--active {
  color: var(--banana-chart-call);
  border-color: color-mix(in srgb, var(--banana-chart-call) 45%, transparent);
  background: color-mix(in srgb, var(--banana-chart-call) 12%, transparent);
}
.legend-iv-tab-sup { font-size: 0.62em; opacity: 0.72; vertical-align: super; margin-left: 1px; }

/* Full-width Overview dashboard — single blended cockpit (rail hidden on this tab). */
.legend-iv-stage-pane[data-tab-id="overview"] {
  display: block;
  overflow-y: auto;
  padding: 12px 14px 16px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash {
  width: 100%;
  max-width: none;
  margin: 0;
  gap: 12px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics .legend-iv-card {
  margin: 0;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics .legend-iv-card--iv-rank {
  grid-column: span 2;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics .legend-iv-rank-range {
  margin-top: 4px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics .legend-iv-rank-range__title {
  font-size: 8px;
  margin-bottom: 2px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__lower {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__detail > .legend-iv-card:only-child {
  grid-column: 1 / -1;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__detail > .legend-iv-card:last-child:nth-child(odd):not(:only-child) {
  grid-column: 1 / -1;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__charts .legend-iv-card,
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__detail .legend-iv-card {
  margin: 0;
}
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash .legend-iv-card--mini { padding: 10px 12px; }
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash .legend-iv-card__value { font-size: 18px; }
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash .legend-iv-card__title { font-size: 10px; }
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__curve .legend-iv-spark,
.legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__charts .legend-iv-spark--vc {
  height: 92px;
  min-height: 92px;
}
@media (max-width: 640px) {
  .legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__metrics .legend-iv-card--iv-rank {
    grid-column: 1 / -1;
  }
  .legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__charts,
  .legend-iv-stage-pane[data-tab-id="overview"] .legend-iv-overview-dash__detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .legend-iv-rail {
    flex: 0 0 auto;
    max-height: 340px;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 0;
    padding-top: 6px;
  }
  .legend-iv-stage { min-height: 300px; }
}
.legend-iv-tab:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--banana-chart-call) 60%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--banana-chart-call) 25%, transparent);
}
.legend-iv-tab--active {
  color: var(--banana-chart-call);
  background: color-mix(in srgb, var(--banana-chart-call) 16%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 50%, transparent);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--banana-chart-call) 30%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--banana-chart-call) 18%, transparent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--banana-chart-call) 55%, transparent);
}
/* Glowing accent bar that visually anchors the active tab to the panel below. */
.legend-iv-tab--active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -7px;
  height: 2px;
  border-radius: var(--banana-radius);
  background: var(--banana-chart-call);
  box-shadow: 0 0 8px var(--banana-chart-call);
  pointer-events: none;
}
.legend-iv-tab--active:hover {
  transform: translateY(-1px);
}

.legend-iv-tabcontent {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 4px 8px 4px;
  font-size: 11.5px;
  color: #d4d8df;
}
.legend-iv-tabcontent::-webkit-scrollbar {
  width: 6px;
}
.legend-iv-tabcontent::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: var(--banana-radius);
}

.legend-iv-card {
  background: rgba(12, 14, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
  padding: 8px 10px;
  margin-bottom: 8px;
}
.legend-iv-card__title {
  font-size: 9.5px;
  color: #9aa0aa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

/* Numeric IV grid (tenor × moneyness matrix). */
.legend-iv-grid-wrap {
  overflow-x: auto;
  margin-top: 4px;
}
.legend-iv-grid-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.legend-iv-grid-table th {
  color: #9aa0aa;
  font-weight: 600;
  text-align: right;
  padding: 2px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}
.legend-iv-grid-th--exp { text-align: left; }
.legend-iv-grid-th--atm { color: #fce047; }
.legend-iv-grid-table td {
  text-align: right;
  padding: 2px 6px;
  color: #d8dce2;
  white-space: nowrap;
}
.legend-iv-grid-td--exp { text-align: left; color: #9aa0aa; }
.legend-iv-grid-cell--atm {
  font-weight: 700;
  box-shadow: inset 1px 0 0 rgba(252, 224, 71, 0.4), inset -1px 0 0 rgba(252, 224, 71, 0.4);
}
.legend-iv-grid-table tbody tr:hover td { background: rgba(255, 255, 255, 0.04); }
.legend-iv-card__value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.legend-iv-card__sub {
  font-size: 10.5px;
  color: #9aa0aa;
  margin-top: 3px;
}
.legend-iv-card__sub--green {
  color: var(--banana-chart-call);
}
.legend-iv-card__sub--red {
  color: var(--banana-chart-put);
}
.legend-iv-card__sub--yellow {
  color: #fce047;
}
.legend-iv-card--mini {
  padding: 6px 8px;
}
.legend-iv-card--mini .legend-iv-card__value {
  font-size: 14px;
}

.legend-iv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  color: #d4d8df;
  font-variant-numeric: tabular-nums;
}
.legend-iv-table th {
  text-align: right;
  font-weight: 600;
  font-size: 9.5px;
  color: #9aa0aa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.legend-iv-table th:first-child {
  text-align: left;
}
.legend-iv-table td {
  text-align: right;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.legend-iv-table td:first-child {
  text-align: left;
  color: #b6bcc6;
}
.legend-iv-table td.pos {
  color: var(--banana-chart-call);
}
.legend-iv-table td.neg {
  color: var(--banana-chart-put);
}

.legend-iv-spark {
  width: 100%;
  height: 60px;
  position: relative;
  overflow: visible;
}

.legend-iv-card--atm-curve {
  padding: 4px 6px 4px;
}

.legend-iv-spark--atm {
  height: 128px;
  min-height: 128px;
}

.legend-iv-spark--vc {
  height: 96px;
  min-height: 96px;
}

.legend-iv-card__sub-inline {
  color: var(--legend-text-muted, #9aa0aa);
  font-size: 10px;
  font-weight: 400;
}

.legend-iv-slice-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.legend-iv-slice-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10.5px;
  color: #9aa0aa;
  margin-bottom: 4px;
  gap: 8px;
}
.legend-iv-slice-header__title {
  color: #fce047;
  font-weight: 600;
  font-size: 11.5px;
}
.legend-iv-slice-header__toggle {
  display: inline-flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
  padding: 1px;
}
.legend-iv-slice-header__toggle button {
  background: transparent;
  border: none;
  color: #9aa0aa;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--banana-radius);
}
.legend-iv-slice-header__toggle button.active {
  background: rgba(252, 224, 71, 0.15);
  color: #fce047;
}
.legend-iv-slice-body {
  flex: 1;
  min-height: 300px;
  position: relative;
  overflow: visible;
}
.legend-echarts-tooltip {
  max-width: min(320px, calc(100% - 8px)) !important;
  white-space: normal !important;
  word-wrap: break-word;
}
.legend-iv-slice-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9aa0aa;
  font-style: italic;
  text-align: center;
  padding: 0 16px;
}

/* Header controls: x-axis, color-mode, camera, export.
   All controls now flow in a single wrapping row. The display/filters
   container divs are kept in the markup (for testability) but collapsed via
   display: contents so their children become direct flex siblings. */
.legend-iv-surface-ctrls {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  /* Override the 420px cap inherited from .legend-cross-ctrl so all IV
     surface controls fit on a single header row. */
  max-width: none;
}
.legend-iv-surface-ctrls__row {
  /* Collapse the row wrapper so children flow into the parent flex line. */
  display: contents;
}
.legend-iv-surface-ctrls__row--filters {
  /* No separator between rows now that everything is one line. */
}
.legend-iv-surface-ctrls__row-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6c727a;
  font-weight: 600;
  margin-right: 2px;
}
.legend-iv-surface-ctrls .legend-iv-xaxis,
.legend-iv-surface-ctrls .legend-iv-colormode,
.legend-iv-surface-ctrls .legend-iv-compare,
.legend-iv-surface-ctrls .legend-iv-side {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  max-width: 130px;
}
.legend-iv-surface-ctrls .legend-iv-dte-min-wrap,
.legend-iv-surface-ctrls .legend-iv-dte-max-wrap,
.legend-iv-surface-ctrls .legend-iv-window-wrap,
.legend-iv-surface-ctrls .legend-iv-interpolate-wrap {
  font-size: 10px;
  color: var(--legend-text-muted, #9aa0aa);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-iv-surface-ctrls .legend-iv-dte-min-wrap input,
.legend-iv-surface-ctrls .legend-iv-dte-max-wrap input,
.legend-iv-surface-ctrls .legend-iv-window-wrap input {
  width: 54px;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}
.legend-iv-surface-ctrls .legend-iv-window-wrap {
  gap: 6px;
}
.legend-iv-surface-ctrls .legend-iv-window-auto-wrap,
.legend-iv-surface-ctrls .legend-iv-window-num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-iv-surface-ctrls .legend-iv-window-wrap input.legend-iv-window-auto {
  width: auto;
  padding: 0;
  margin: 0;
}
.legend-iv-surface-ctrls .legend-iv-window-wrap input.legend-iv-window:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.legend-iv-chart-cameras-wrap {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 12;
  pointer-events: auto;
}
.legend-iv-cameras {
  display: inline-flex;
  gap: 2px;
  background: rgba(10, 12, 16, 0.72);
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  padding: 1px;
  backdrop-filter: blur(4px);
}
.legend-iv-cameras button {
  background: transparent;
  border: none;
  color: var(--legend-text-muted, #9aa0aa);
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--banana-radius);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.legend-iv-cameras button.active {
  background: rgba(252, 224, 71, 0.15);
  color: #fce047;
}
.legend-iv-exports {
  display: inline-flex;
  gap: 4px;
}
.legend-iv-exports button {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text-muted, #9aa0aa);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.legend-iv-exports button:hover {
  color: #fce047;
  border-color: rgba(252, 224, 71, 0.4);
}

/* ─── IV Surface trader-cockpit sidebar (Phase 1) ───────────────────────── */

.legend-iv-sidebar-selection {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-iv-sidebar-selection__idle {
  color: #9aa0aa;
  font-size: 11px;
  padding: 4px 0;
}
.legend-iv-sel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.legend-iv-sel__head-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.legend-iv-sel__strike {
  font-weight: 700;
  font-size: 13px;
  color: #f5f5f5;
}
.legend-iv-sel__money {
  font-weight: 400;
  font-size: 11px;
  color: #9aa0aa;
  margin-left: 4px;
}
.legend-iv-sel__expiry {
  font-size: 11px;
  color: #9aa0aa;
}
.legend-iv-sel__head-right { text-align: right; }
.legend-iv-sel__iv {
  font-weight: 700;
  font-size: 14px;
  color: #fce047;
}
.legend-iv-sidebar-selection__offset {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: #9aa0aa;
  margin-top: 1px;
}
.legend-iv-sel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.legend-iv-sel__greeks {
  font-size: 11px;
  color: #c8c8c8;
  letter-spacing: 0.2px;
}
.legend-iv-sel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.legend-iv-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.06);
  color: #c8c8c8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-transform: uppercase;
}
.legend-iv-chip--rich {
  color: var(--banana-chart-put);
  background: color-mix(in srgb, var(--banana-chart-put) 10%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-put) 30%, transparent);
}
.legend-iv-chip--cheap {
  color: var(--banana-chart-call);
  background: color-mix(in srgb, var(--banana-chart-call) 10%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 30%, transparent);
}
.legend-iv-chip--neutral {
  color: #c8c8c8;
}
.legend-iv-chip--liq-good {
  color: var(--banana-accent-lime);
  border-color: color-mix(in srgb, var(--banana-accent-lime) 28%, transparent);
}
.legend-iv-chip--liq-ok {
  color: #fce047;
  border-color: rgba(252, 224, 71, 0.25);
}
.legend-iv-chip--liq-thin {
  color: var(--banana-chart-put);
  border-color: color-mix(in srgb, var(--banana-chart-put) 30%, transparent);
}

.legend-iv-action {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #e5e5e5;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  text-transform: uppercase;
}
.legend-iv-action:hover {
  background: rgba(252, 224, 71, 0.12);
  border-color: rgba(252, 224, 71, 0.45);
  color: #fce047;
}

/* ─── Tab content shared pieces ─── */

/* Overview tab: flex gap replaces stacked margins (avoids collapse / overlap). */
.legend-iv-tabpane[data-tab-id="overview"] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-iv-tabpane[data-tab-id="overview"] > .legend-iv-tagline,
.legend-iv-tabpane[data-tab-id="overview"] > .legend-iv-regime-strip,
.legend-iv-tabpane[data-tab-id="overview"] > .legend-iv-card {
  margin: 0;
}

/* Unified overview dashboard — KPI strip + blended charts/context grid. */
.legend-iv-overview-dash {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  width: 100%;
}
.legend-iv-overview-dash__metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.legend-iv-overview-dash__metrics .legend-iv-card {
  margin: 0;
  padding: 8px 10px;
  min-height: 0;
}
.legend-iv-overview-dash__metrics .legend-iv-card--iv-rank {
  grid-column: span 2;
}
.legend-iv-overview-dash__metrics .legend-iv-card__stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.legend-iv-overview-dash__metrics .legend-iv-card--iv-rank .legend-iv-card__value {
  font-size: 20px;
  line-height: 1;
}
.legend-iv-overview-dash__metrics .legend-iv-card--iv-rank .legend-iv-card__sub--inline {
  margin-top: 0;
  font-size: 10px;
}
.legend-iv-overview-dash__metrics .legend-iv-card--iv-rank .legend-iv-rank-range {
  margin-top: 4px;
}
.legend-iv-overview-dash__metrics .legend-iv-card--iv-rank .legend-iv-rank-range__title {
  font-size: 8px;
  margin-bottom: 2px;
}
.legend-iv-overview-dash__metrics .legend-iv-card__title {
  font-size: 9px;
  margin-bottom: 3px;
  line-height: 1.2;
}
.legend-iv-overview-dash__metrics .legend-iv-card__value {
  font-size: 15px;
  line-height: 1.15;
}
.legend-iv-overview-dash__metrics .legend-iv-card__sub {
  font-size: 9.5px;
  margin-top: 2px;
  line-height: 1.25;
}
.legend-iv-overview-dash__lower {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.legend-iv-overview-dash__charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.legend-iv-overview-dash__detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.legend-iv-overview-dash__detail > .legend-iv-card:only-child {
  grid-column: 1 / -1;
}
.legend-iv-overview-dash__detail > .legend-iv-card:last-child:nth-child(odd):not(:only-child) {
  grid-column: 1 / -1;
}
.legend-iv-overview-dash__charts .legend-iv-card,
.legend-iv-overview-dash__detail .legend-iv-card {
  margin: 0;
  height: 100%;
  box-sizing: border-box;
}
.legend-iv-overview-dash__charts .legend-iv-spark--vc {
  height: 80px;
  min-height: 80px;
}
.legend-iv-overview-dash__curve {
  margin: 0;
  padding: 8px 10px 6px;
}
.legend-iv-overview-dash__curve .legend-iv-spark--atm {
  height: 80px;
  min-height: 80px;
}
@media (max-width: 640px) {
  .legend-iv-overview-dash__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .legend-iv-overview-dash__metrics .legend-iv-card--iv-rank {
    grid-column: 1 / -1;
  }
  .legend-iv-overview-dash__charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .legend-iv-overview-dash__charts,
  .legend-iv-overview-dash__detail {
    grid-template-columns: 1fr;
  }
}
/* Legacy aliases kept for sidebar embeds that may still reference old structure. */
.legend-iv-overview-dash__rank .legend-iv-card {
  margin: 0;
  padding: 6px 8px;
}
.legend-iv-overview-dash__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.legend-iv-overview-dash__svi-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 2px;
  font-size: 9px;
  color: #9aa0aa;
}
.legend-iv-overview-dash__svi-label {
  font-weight: 700;
  color: #d8dce4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.legend-iv-overview-dash__svi-sub {
  margin-left: auto;
  font-size: 9px;
  color: #9aa0aa;
}

.legend-iv-tagline {
  font-size: 11px;
  color: #9aa0aa;
  margin: 2px 4px 8px;
  letter-spacing: 0.3px;
}
.legend-iv-defaulthint {
  display: inline-block;
  font-size: 10px;
  color: #9aa0aa;
  margin: 0 4px 8px;
  font-style: italic;
}

.legend-iv-verdict {
  border-radius: var(--banana-radius);
  padding: 8px 10px;
  margin: 4px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.legend-iv-verdict__label {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
}
.legend-iv-verdict__sub {
  font-size: 10px;
  color: #9aa0aa;
}
.legend-iv-verdict--rich {
  background: linear-gradient(90deg, color-mix(in srgb, var(--banana-chart-call) 14%, transparent), color-mix(in srgb, var(--banana-chart-call) 4%, transparent));
  border-color: color-mix(in srgb, var(--banana-chart-call) 32%, transparent);
}
.legend-iv-verdict--rich .legend-iv-verdict__label { color: var(--banana-chart-call); }
.legend-iv-verdict--cheap {
  background: linear-gradient(90deg, color-mix(in srgb, var(--banana-chart-put) 14%, transparent), color-mix(in srgb, var(--banana-chart-put) 4%, transparent));
  border-color: color-mix(in srgb, var(--banana-chart-put) 32%, transparent);
}
.legend-iv-verdict--cheap .legend-iv-verdict__label { color: var(--banana-chart-put); }
.legend-iv-verdict--fair {
  background: linear-gradient(90deg, rgba(252, 224, 71, 0.10), rgba(252, 224, 71, 0.02));
  border-color: rgba(252, 224, 71, 0.28);
}
.legend-iv-verdict--fair .legend-iv-verdict__label { color: #fce047; }
.legend-iv-verdict--neutral .legend-iv-verdict__label { color: #c8c8c8; }

.legend-iv-gauge {
  position: relative;
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--banana-radius);
  overflow: hidden;
  margin: 4px 0 2px;
}
.legend-iv-gauge__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #fce047;
  border-radius: var(--banana-radius);
}
.legend-iv-gauge--green .legend-iv-gauge__fill { background: var(--banana-chart-call); }
.legend-iv-gauge--amber .legend-iv-gauge__fill { background: #fce047; }
.legend-iv-gauge--red .legend-iv-gauge__fill { background: var(--banana-chart-put); }
.legend-iv-gauge--neutral .legend-iv-gauge__fill { background: rgba(252, 224, 71, 0.55); }
.legend-iv-gauge__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #1a1a1a;
  font-weight: 600;
}

.legend-iv-rank-range {
  margin-top: 6px;
}
.legend-iv-rank-range__title {
  font-size: 9px;
  color: #9aa0aa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.legend-iv-rank-range__bar {
  position: relative;
  height: 6px;
  width: 100%;
  border-radius: var(--banana-radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--banana-chart-put) 90%, transparent) 0%, rgba(252, 224, 71, 0.9) 50%, color-mix(in srgb, var(--banana-chart-call) 90%, transparent) 100%);
  margin: 2px 0 4px;
}
.legend-iv-rank-range__marker {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 10px;
  background: #ffffff;
  border-radius: var(--banana-radius);
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.legend-iv-rank-range__labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: #9aa0aa;
  font-variant-numeric: tabular-nums;
}
.legend-iv-rank-range__labels span:nth-child(2) {
  color: #e6eaf0;
  font-weight: 600;
}
.legend-iv-rank-range__labels span:last-child {
  text-align: right;
}

.legend-iv-regime-strip {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 6px;
  margin: 4px 4px 8px;
}
.legend-iv-regime-strip--rank {
  margin-bottom: 6px;
}
.legend-iv-regime-strip--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 5px;
  margin: 4px 4px 0 !important;
  /* Padding (not margin) so the gap to the ATM IV curve cannot collapse. */
  padding-bottom: 10px !important;
}
.legend-iv-regime-strip--triple + .legend-iv-card,
.legend-iv-regime-strip--triple + .legend-iv-card--atm-curve {
  margin-top: 0 !important;
}
.legend-iv-regime-strip .legend-iv-card {
  margin: 0;
  align-self: start;
}
.legend-iv-regime-strip--triple .legend-iv-card--mini {
  padding: 5px 6px;
  height: 100%;
}
.legend-iv-regime-strip--triple .legend-iv-card {
  align-self: stretch;
}
.legend-iv-regime-strip--triple .legend-iv-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
}
.legend-iv-regime-strip--triple .legend-iv-card__title .legend-iv-tip {
  margin-left: 2px;
  flex: 0 0 auto;
}
.legend-iv-regime-strip--triple .legend-iv-card__value {
  font-size: 13px;
}
.legend-iv-regime-strip--triple .legend-iv-card__sub {
  margin-top: 2px;
}

.legend-iv-card__value.val--red { color: var(--banana-chart-put); }
.legend-iv-card__value.val--green { color: var(--banana-chart-call); }
.legend-iv-card__value.val--amber { color: #fce047; }
.legend-iv-card__value.val--neutral { color: #c8c8c8; }
.legend-iv-card__sub-inline { color: #9aa0aa; font-size: 10px; font-weight: 400; }

/* ── SVI smile: arb badge + desk-signal header ───────────────────────────── */
.legend-iv-arb-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 9px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  cursor: help;
  white-space: nowrap;
}
.legend-iv-arb-badge--ok {
  color: var(--banana-chart-call);
  background: color-mix(in srgb, var(--banana-chart-call) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--banana-chart-call) 35%, transparent);
}
.legend-iv-arb-badge--warn {
  color: #ffb454;
  background: rgba(255, 180, 84, 0.14);
  border: 1px solid rgba(255, 180, 84, 0.4);
}
.legend-iv-svi-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 700;
  color: #d8dce4;
}
.legend-iv-svi-head__sub {
  margin-left: auto;
  font-size: 9px;
  font-weight: 400;
  color: #9aa0aa;
}

.legend-iv-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #c8c8c8;
  padding: 2px 0;
  gap: 8px;
}
.legend-iv-card__row span:first-child { color: #9aa0aa; }
.legend-iv-card__row span:last-child { font-weight: 600; }

.legend-iv-evrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #c8c8c8;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.legend-iv-evrow:last-child { border-bottom: none; }
.legend-iv-evrow--warn { color: #ff9a76; }
.legend-iv-evdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fce047;
  flex-shrink: 0;
}
.legend-iv-evdte {
  margin-left: auto;
  color: #9aa0aa;
  font-weight: 600;
}

.legend-iv-volarb-section {
  margin: 4px 0;
}
.legend-iv-residual-bar {
  width: 100%;
  height: 120px;
  position: relative;
  overflow: visible;
}
.legend-iv-table tr.legend-iv-row--pinned td {
  background: rgba(252, 224, 71, 0.08);
  font-weight: 600;
}

.legend-iv-hedger-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #f5f5f5;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: var(--banana-radius);
  margin-top: 4px;
}
.legend-iv-hedger-input:focus {
  outline: none;
  border-color: rgba(252, 224, 71, 0.45);
}

.legend-iv-hedger-recs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.legend-iv-hedger-recs__title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9aa0aa;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-iv-hedger-recs__count {
  font-size: 9px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 1px 6px;
  color: #c8c8c8;
}
.legend-iv-hedger-rec {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.legend-iv-hedger-rec:hover {
  border-color: rgba(252, 224, 71, 0.28);
  background: rgba(252, 224, 71, 0.04);
}
.legend-iv-hedger-rec:focus-visible {
  outline: 2px solid rgba(252, 224, 71, 0.45);
  outline-offset: 1px;
}
.legend-iv-hedger-rec--top {
  border-color: rgba(252, 224, 71, 0.35);
  background: linear-gradient(90deg, rgba(252, 224, 71, 0.08), rgba(252, 224, 71, 0.02));
}
.legend-iv-hedger-rec--pinned,
.legend-iv-hedger-rec--custom {
  border-color: rgba(96, 165, 250, 0.35);
}
.legend-iv-hedger-rec__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.legend-iv-hedger-rec__label {
  font-size: 12px;
  font-weight: 700;
  color: #f5f5f5;
}
.legend-iv-hedger-rec__badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(252, 224, 71, 0.18);
  color: #fce047;
}
.legend-iv-hedger-rec__badge--custom,
.legend-iv-hedger-rec__badge--match {
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}
.legend-iv-hedger-rec__strike {
  font-size: 11px;
  color: #c8c8c8;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.legend-iv-hedger-rec__row {
  font-size: 11px;
  padding: 2px 0;
}
.legend-iv-hedger-rec__reasons {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: #9aa0aa;
}

.legend-iv-card--placeholder {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

/* ─── Teaching tooltips ─── */

.legend-iv-tip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #9aa0aa;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  padding: 0;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-style: italic;
  vertical-align: middle;
  margin-left: 4px;
}
.legend-iv-tip:hover {
  background: rgba(252, 224, 71, 0.10);
  border-color: rgba(252, 224, 71, 0.40);
  color: #fce047;
}
/* ─── Wizard explainer overlay ─── */
/* Fixed-positioned overlay that slides the banana wizard in from the right
   with a speech bubble containing the tooltip content. Replaces the old
   plain-text popover so explainers feel like a teaching assistant instead
   of a sterile dropdown. The overlay itself never receives clicks
   (pointer-events: none) — only the bubble and close button do — so clicks
   anywhere else on the page fall through to the dismissal listener. */
.legend-iv-wizard-overlay {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0;
  /* Flush with viewport bottom; opaque-bbox trim applied in JS (legend.js). */
  padding: 0;
  pointer-events: none;
}
.legend-iv-wizard-overlay__stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  line-height: 0;
  pointer-events: none;
}
.legend-iv-wizard-overlay__img {
  width: clamp(240px, 28vw, 380px);
  height: auto;
  display: block;
  margin-bottom: 0;
  /* margin-right set from PNG opaque bbox trim (see ivWizardBindImageTrim). */
  margin-right: -72px;
  /* scaleX(-1) mirrors the character so she faces the other way. Default
     transform-origin (center center) keeps the flip in-place, so the
     translateX slide-in still works unchanged. */
  transform: translateX(120%) scaleX(-1);
  transition: transform 420ms cubic-bezier(0.22, 0.61, 0.36, 1);
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.legend-iv-wizard-overlay.is-open .legend-iv-wizard-overlay__img {
  transform: translateX(0) scaleX(-1);
}
.legend-iv-wizard-overlay__bubble {
  position: absolute;
  right: calc(60% - 8px);
  bottom: 78%;
  /* Bubble shrink-wraps to its content (default behaviour for absolutely
     positioned blocks), so short tooltips render compact and long ones
     expand. The min cap keeps short tooltips from looking like a sliver;
     the max cap is intentionally generous so multi-paragraph explainers
     (residual_z, sticky_strike) can spread wide instead of stacking
     into a tall column. */
  min-width: 240px;
  max-width: min(880px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  padding: 14px 36px 14px 16px;
  background: rgba(18, 18, 18, 0.97);
  color: #f5f5f5;
  border: 1px solid rgba(252, 224, 71, 0.45);
  border-radius: var(--banana-radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.1px;
  white-space: pre-line;
  /* Closed by default: invisible bubbles must NOT intercept clicks on the
     IV sidebar / (i) buttons sitting underneath. pointer-events + visibility
     are toggled only while .is-open is present. */
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 280ms ease 120ms, transform 280ms ease 120ms, visibility 0s linear 400ms;
}
.legend-iv-wizard-overlay.is-open .legend-iv-wizard-overlay__bubble {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 280ms ease 120ms, transform 280ms ease 120ms, visibility 0s linear 0s;
}
.legend-iv-wizard-overlay__tail {
  position: absolute;
  bottom: -10px;
  right: 28px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(18, 18, 18, 0.97);
  filter: drop-shadow(0 1px 0 rgba(252, 224, 71, 0.45));
}
.legend-iv-wizard-overlay__close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f5;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
}
.legend-iv-wizard-overlay__close:hover,
.legend-iv-wizard-overlay__close:focus {
  border-color: rgba(252, 224, 71, 0.55);
  color: #fce047;
  outline: none;
}

/* Landing guided tour — footer actions inside wizard bubble */
.legend-iv-wizard-overlay--tour .legend-iv-wizard-overlay__bubble {
  padding-bottom: 16px;
}
.legend-iv-wizard-tour__title {
  margin: 0 0 8px;
  font-family: var(--font-headline, 'Space Grotesk', sans-serif);
  font-size: 14px;
  font-weight: 700;
  color: #fce047;
  line-height: 1.3;
}
.legend-iv-wizard-tour__body {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #f5f5f5;
}
.legend-iv-wizard-tour__progress {
  margin: 0 0 12px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(245, 245, 245, 0.55);
}
.legend-iv-wizard-overlay__tour-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.legend-iv-wizard-tour__btn {
  font-family: var(--font-headline, 'Space Grotesk', sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: var(--banana-radius);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f5;
  cursor: pointer;
  pointer-events: auto;
}
.legend-iv-wizard-tour__btn:hover:not(:disabled),
.legend-iv-wizard-tour__btn:focus:not(:disabled) {
  border-color: rgba(252, 224, 71, 0.55);
  color: #fce047;
  outline: none;
}
.legend-iv-wizard-tour__btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.legend-iv-wizard-tour__btn--primary {
  background: rgba(252, 224, 71, 0.12);
  border-color: rgba(252, 224, 71, 0.45);
  color: #fce047;
}
.legend-iv-wizard-tour__btn--ghost {
  margin-left: auto;
  background: transparent;
  border-color: transparent;
  color: rgba(245, 245, 245, 0.55);
}
.legend-iv-wizard-tour__btn--ghost:hover:not(:disabled),
.legend-iv-wizard-tour__btn--ghost:focus:not(:disabled) {
  color: #f5f5f5;
  border-color: rgba(255, 255, 255, 0.12);
}

@media (max-width: 768px) {
  .legend-iv-wizard-overlay__img {
    width: clamp(160px, 40vw, 220px);
  }
  .legend-iv-wizard-overlay__bubble {
    min-width: 200px;
    max-width: min(560px, calc(100vw - 16px));
    max-height: 78vh;
    font-size: 11px;
    padding: 12px 32px 12px 14px;
    right: calc(60% - 4px);
  }
}

@media (max-width: 480px) {
  .legend-iv-wizard-overlay {
    left: 0;
    right: 0;
    padding: 0 10px 0 10px;
    justify-content: center;
  }
  .legend-iv-wizard-overlay__img {
    display: none;
  }
  .legend-iv-wizard-overlay__stage {
    width: 100%;
  }
  .legend-iv-wizard-overlay__bubble {
    position: static;
    max-width: 100%;
    width: 100%;
    transform: translateY(16px);
  }
  .legend-iv-wizard-overlay.is-open .legend-iv-wizard-overlay__bubble {
    transform: translateY(0);
  }
  .legend-iv-wizard-overlay__tail {
    display: none;
  }
}

/* ─── Spread Builder ─── */

.legend-iv-spread-tabs {
  display: flex;
  gap: 4px;
  margin: 4px 4px 8px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
}
.legend-iv-spread-tabs--inline {
  margin: 0;
}
.legend-iv-spread-tab {
  appearance: none;
  flex: 1 1 0;
  background: transparent;
  border: 1px solid transparent;
  color: #9aa0aa;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 5px 8px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}
.legend-iv-spread-tab:hover {
  color: #e6eaf0;
  background: rgba(255, 255, 255, 0.05);
}
.legend-iv-spread-tab--active {
  background: rgba(252, 224, 71, 0.14);
  border-color: rgba(252, 224, 71, 0.40);
  color: #fce047;
}
.legend-iv-spread-tab--active:hover {
  background: rgba(252, 224, 71, 0.18);
  color: #fce047;
}

.legend-iv-spread-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 4px 10px;
}
.legend-iv-spread-controls > .legend-iv-spread-tabs {
  flex: 1 1 140px;
  margin: 0;
}
.legend-iv-spread-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 76px;
}
.legend-iv-spread-control__label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa0aa;
}
.legend-iv-spread-control__select,
.legend-iv-spread-control__input {
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #f5f5f5;
  padding: 5px 6px;
  font-size: 12px;
  border-radius: var(--banana-radius);
  font-variant-numeric: tabular-nums;
}
.legend-iv-spread-control__select:focus,
.legend-iv-spread-control__input:focus {
  outline: none;
  border-color: rgba(252, 224, 71, 0.45);
}
.legend-iv-spread-control__input {
  width: 70px;
}

.legend-iv-spread-legs td.numeric,
.legend-iv-spread-legs th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.legend-iv-spread-legs tr.legend-iv-spread-leg--buy td:first-child {
  color: var(--banana-chart-call);
  font-weight: 700;
}
.legend-iv-spread-legs tr.legend-iv-spread-leg--sell td:first-child {
  color: var(--banana-chart-put);
  font-weight: 700;
}

.legend-iv-spread-pl .legend-iv-card__value {
  font-size: 14px;
  margin-bottom: 4px;
}

.legend-iv-spread-heatmap {
  width: 100%;
  height: 220px;
  min-height: 220px;
}

/* ─── Algorithm Recommendation — button, ranked lists, idea cards ─────── */

.legend-iv-recs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 4px 8px;
}
.legend-iv-recs-btn {
  appearance: none;
  background: linear-gradient(180deg, rgba(252, 224, 71, 0.22), rgba(252, 224, 71, 0.10));
  border: 1px solid rgba(252, 224, 71, 0.45);
  color: #fce047;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 5px 10px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-transform: uppercase;
}
.legend-iv-recs-btn:hover {
  background: linear-gradient(180deg, rgba(252, 224, 71, 0.32), rgba(252, 224, 71, 0.18));
  border-color: rgba(252, 224, 71, 0.70);
  color: #fff7c2;
}
.legend-iv-recs-btn--on {
  background: linear-gradient(180deg, rgba(252, 224, 71, 0.42), rgba(252, 224, 71, 0.20));
  border-color: rgba(252, 224, 71, 0.80);
  color: #1a1300;
  box-shadow: 0 0 0 1px rgba(252, 224, 71, 0.30) inset;
}
.legend-iv-recs-btn--on:hover {
  background: linear-gradient(180deg, rgba(252, 224, 71, 0.55), rgba(252, 224, 71, 0.30));
  color: #000;
}
.legend-iv-recs-hint {
  font-size: 10px;
  color: #9aa0aa;
  letter-spacing: 0.2px;
}
.legend-iv-recs-hint--muted { opacity: 0.7; }

.legend-iv-recs-empty {
  font-size: 11px;
  color: #9aa0aa;
  font-style: italic;
  padding: 6px 8px;
  margin: 4px 4px 8px;
  border: 1px dashed rgba(255, 255, 255, 0.10);
  border-radius: var(--banana-radius);
}

.legend-iv-recs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 10px;
  padding: 6px 6px 4px;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(252, 224, 71, 0.18);
  background: linear-gradient(180deg, rgba(252, 224, 71, 0.04), rgba(252, 224, 71, 0.01));
  border-radius: var(--banana-radius);
}
.legend-iv-recs-list__title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fce047;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 4px;
}
.legend-iv-recs-list__title:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}
.legend-iv-recs-list__count {
  display: inline-block;
  font-size: 9px;
  color: #9aa0aa;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--banana-radius);
  padding: 1px 5px;
  font-weight: 600;
}

/* Premium-seller / directional-buyer rec rows. Styled to match the
   Spread Builder idea cards visually (same padding, card chrome, badge
   placement) so the three tabs share a consistent look-and-feel. */
.legend-iv-rec-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--banana-radius);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  outline: none;
  overflow: hidden;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.legend-iv-rec-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(252, 224, 71, 0.40);
}
.legend-iv-rec-row:focus-visible {
  border-color: rgba(252, 224, 71, 0.85);
  box-shadow: 0 0 0 2px rgba(252, 224, 71, 0.20);
}
.legend-iv-rec-row:active { transform: translateY(1px); }
.legend-iv-rec-row--top {
  background: linear-gradient(90deg, rgba(252, 224, 71, 0.14), rgba(252, 224, 71, 0.03));
  border-color: rgba(252, 224, 71, 0.55);
}
.legend-iv-rec-row__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.legend-iv-rec-row__strike {
  font-weight: 700;
  font-size: 12px;
  color: #e8e8e8;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}
.legend-iv-rec-row__side {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--banana-radius);
  margin-left: 2px;
  vertical-align: 1px;
}
.legend-iv-rec-row__side--call {
  background: rgba(80, 200, 120, 0.16);
  color: var(--banana-chart-call);
}
.legend-iv-rec-row__side--put {
  background: rgba(231, 76, 60, 0.16);
  color: var(--banana-chart-put);
}
.legend-iv-rec-row__dte {
  font-size: 10px;
  color: #9aa0aa;
  font-variant-numeric: tabular-nums;
}
/* Relative-value idea kind chip (CAL / SKEW / FLY). */
.legend-iv-rec-row__kind {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #cdd2db;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
}
/* Vol-desk dashboard arb-flag warning card + Builder view constructor. */
.legend-iv-card--warn {
  border-color: rgba(231, 76, 60, 0.45);
  background: rgba(231, 76, 60, 0.08);
}
.legend-iv-card__sub.val--amber { color: #fce047; }
.legend-iv-builder-view .legend-iv-spread-tabs--inline {
  margin: 4px 0;
}
.legend-iv-rec-row__head-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-iv-rec-row__badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #1a1300;
  background: #fce047;
  padding: 2px 7px;
  border-radius: var(--banana-radius);
}
.legend-iv-rec-row__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 10px;
  color: #c8c8c8;
  font-variant-numeric: tabular-nums;
}
.legend-iv-rec-row__meta span { white-space: nowrap; }
.legend-iv-rec-row__reasons {
  font-size: 10px;
  color: #9aa0aa;
  font-style: italic;
}
.legend-iv-rec-play {
  margin-top: 0;
  margin-bottom: 6px;
}
.legend-iv-rec-play__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.legend-iv-rec-play__title {
  font-size: 11px;
  font-weight: 700;
  color: #e8e8e8;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}
.legend-iv-volarb-dir {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 4px;
  line-height: 1.3;
}
.legend-iv-volarb-dir--neutral {
  color: #a8b4c8;
  background: rgba(168, 180, 200, 0.12);
}
.legend-iv-volarb-dir--directional {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.12);
}
.legend-iv-card .legend-iv-rec-play {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.legend-iv-rec-row--pair .legend-iv-rec-row__meta span:first-child {
  color: var(--banana-chart-call);
}
.legend-iv-rec-row--pair .legend-iv-rec-row__meta span:last-child {
  color: var(--banana-chart-put);
}

/* Spread Builder idea cards */
.legend-iv-recs-list--ideas { gap: 6px; }
.legend-iv-rec-idea {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--banana-radius);
  padding: 8px 10px;
  overflow: hidden;
}
.legend-iv-rec-idea--top {
  background: linear-gradient(90deg, rgba(252, 224, 71, 0.14), rgba(252, 224, 71, 0.03));
  border-color: rgba(252, 224, 71, 0.55);
}
.legend-iv-rec-idea__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.legend-iv-rec-idea__name {
  font-weight: 700;
  font-size: 12px;
  color: #e8e8e8;
  letter-spacing: 0.2px;
}
.legend-iv-rec-idea__head-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-iv-rec-idea__apply {
  appearance: none;
  background: rgba(252, 224, 71, 0.16);
  border: 1px solid rgba(252, 224, 71, 0.45);
  color: #fce047;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.12s, color 0.12s;
}
.legend-iv-rec-idea__apply:hover {
  background: rgba(252, 224, 71, 0.32);
  color: #fff7c2;
}
.legend-iv-rec-idea__badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #1a1300;
  background: #fce047;
  padding: 2px 7px;
  border-radius: var(--banana-radius);
}
.legend-iv-rec-idea__legs {
  font-size: 11px;
  color: #d0d0d0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.legend-iv-rec-idea__meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 10px;
  color: #c8c8c8;
  font-variant-numeric: tabular-nums;
}
.legend-iv-rec-idea__meta .val--green { color: var(--banana-chart-call); font-weight: 700; }
.legend-iv-rec-idea__meta .val--red { color: var(--banana-chart-put); font-weight: 700; }
.legend-iv-rec-idea__meta .val--neutral { color: #c8c8c8; font-weight: 700; }
.legend-iv-rec-idea__reasons {
  font-size: 10px;
  color: #9aa0aa;
  font-style: italic;
}
.legend-iv-rec-idea__sub {
  font-size: 9px;
  color: #9aa0aa;
}
.legend-iv-rec-idea__pop,
.legend-iv-rec-row__pop {
  background: rgba(110, 195, 255, 0.12);
  color: #6ec3ff;
  padding: 1px 6px;
  border-radius: var(--banana-radius);
  font-weight: 700;
}
/* Secondary market-implied POP shown beside the primary model POP. Dimmer
   and lighter weight so it reads as a reference value, not the headline. */
.legend-iv-rec-row__pop-mkt {
  margin-left: 5px;
  padding-left: 5px;
  border-left: 1px solid rgba(110, 195, 255, 0.25);
  color: rgba(160, 180, 200, 0.75);
  font-weight: 500;
}
.legend-iv-rec-idea__ev {
  padding: 1px 6px;
  border-radius: var(--banana-radius);
  font-weight: 700;
}
.legend-iv-rec-idea__ev.val--green {
  background: rgba(80, 200, 120, 0.14);
}
.legend-iv-rec-idea__ev.val--red {
  background: rgba(231, 76, 60, 0.14);
}
.legend-iv-rec-row__payoff {
  font-weight: 700;
}
.legend-iv-rec-row__payoff.val--green { color: var(--banana-chart-call); }
.legend-iv-rec-row__payoff.val--red { color: var(--banana-chart-put); }

/* Phase D — stale-quote banner above recommendations lists. */
.legend-iv-recs-stale {
  font-size: 10px;
  color: #ffd166;
  background: rgba(255, 209, 102, 0.10);
  border: 1px solid rgba(255, 209, 102, 0.30);
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.legend-iv-recs-stale--severe {
  color: #ff9966;
  background: rgba(255, 153, 102, 0.10);
  border-color: rgba(255, 153, 102, 0.45);
}

/* Phase B — suggested-quantity row inside an idea card. */
.legend-iv-rec-idea__size {
  font-size: 10px;
  color: #d8d8d8;
  background: rgba(110, 195, 255, 0.06);
  border-left: 2px solid rgba(110, 195, 255, 0.45);
  padding: 3px 8px;
  border-radius: var(--banana-radius);
}
.legend-iv-rec-idea__size strong {
  color: #6ec3ff;
}

/* Phase H — explainable score breakdown. Collapsed by default; revealed
   when the row/card gains the `.legend-iv-rec--show-bd` modifier class
   via the `Why?` toggle. Both bd-toggle variants live inside a
   right-aligned `__head-right` wrapper, so they need no margin tricks. */
.legend-iv-rec-row__bd-toggle,
.legend-iv-rec-idea__bd-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #c8c8c8;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--banana-radius);
  cursor: help;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.legend-iv-rec-row__bd-toggle:hover,
.legend-iv-rec-idea__bd-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.40);
}
.legend-iv-rec-bd {
  display: none;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  margin-top: 4px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--banana-radius);
}
.legend-iv-rec--show-bd .legend-iv-rec-bd {
  display: flex;
}
.legend-iv-rec-bd__row {
  display: grid;
  grid-template-columns: 112px 1fr 50px;
  gap: 6px;
  align-items: center;
}
.legend-iv-rec-bd__intro {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  color: #9aa0aa;
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.legend-iv-rec-bd__label {
  color: #c8c8c8;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  line-height: 1.2;
  font-size: 9px;
}
.legend-iv-rec-bd__label .legend-iv-tip {
  flex-shrink: 0;
}
.legend-iv-rec-row__meta .legend-iv-tip,
.legend-iv-rec-idea__meta .legend-iv-tip {
  margin-left: 2px;
  vertical-align: baseline;
}
.legend-iv-rec-bd__bar {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--banana-radius);
  overflow: hidden;
}
.legend-iv-rec-bd__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: var(--banana-radius);
}
.legend-iv-rec-bd__fill.val--green {
  background: rgba(80, 200, 120, 0.55);
}
.legend-iv-rec-bd__fill.val--red {
  background: rgba(231, 76, 60, 0.55);
}
.legend-iv-rec-bd__val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.legend-iv-rec-bd__stale {
  margin-top: 2px;
  font-size: 9px;
  color: #ffd166;
  font-style: italic;
}
.legend-iv-rec-bd__total {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #fce047;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────────────────────────────────────────────────
   Widget help — clickable "?" in every widget header summons the banana
   wizard with a rich speech bubble. The bubble itself is the existing
   .legend-iv-wizard-overlay__bubble; the styles below format our structured
   help content (title + 3 sections + disclaimer) when it lives INSIDE that
   bubble (signaled by .is-rich on the bubble).
   ───────────────────────────────────────────────────────────────────────── */
.legend-widget-help-btn {
  cursor: help;
}

.legend-iv-wizard-overlay__bubble.is-rich {
  white-space: normal;
  min-width: 280px;
  width: min(420px, calc(100vw - 32px));
  font-size: 12.5px;
  line-height: 1.5;
  padding: 16px 40px 16px 18px;
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-title {
  font-family: var(--legend-font-headline);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(252, 224, 71, 0.22);
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-section {
  margin: 0;
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-section + .legend-widget-help-section {
  margin-top: 12px;
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-h {
  margin: 0 0 4px;
  font-family: var(--legend-font-headline);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fce047;
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-section p {
  margin: 0;
  color: #f5f5f5;
}

.legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-disclaimer {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.45;
}

@media (max-width: 768px) {
  .legend-iv-wizard-overlay__bubble.is-rich {
    min-width: 220px;
    width: min(340px, calc(100vw - 16px));
    font-size: 11.5px;
    padding: 14px 36px 14px 16px;
  }
  .legend-iv-wizard-overlay__bubble.is-rich .legend-widget-help-title {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .legend-iv-wizard-overlay__bubble.is-rich {
    width: 100%;
  }
}

/* --- Sector Flow Share --- */
.legend-sfs-ctrls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.legend-sfs-view-toggle {
  display: inline-flex;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  overflow: hidden;
}

.legend-sfs-view-btn {
  background: transparent;
  border: none;
  color: var(--legend-text-muted, #aaa);
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
  border-right: 1px solid var(--legend-border);
  line-height: 1.4;
}

.legend-sfs-view-btn:last-child {
  border-right: none;
}

.legend-sfs-view-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--legend-text, #fff);
}

.legend-sfs-view-btn.is-active {
  background: rgba(202, 253, 0, 0.18);
  color: var(--legend-text, #fff);
}

.legend-sfs-lookback {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-sfs-leaderboard,
.legend-sfs-multiday {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  height: 100%;
}

.legend-sfs-leaderboard-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px;
}

.legend-sfs-leaderboard-title {
  font-size: 12px;
  color: var(--legend-text, #fff);
  font-weight: 600;
}

.legend-sfs-leaderboard-sub {
  font-size: 10px;
  color: var(--legend-text-muted, #888);
}

.legend-sfs-leaderboard-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1 1 auto;
  padding: 0 4px 6px 4px;
}

.legend-sfs-row {
  display: grid;
  grid-template-columns: 22px 12px 1fr 1fr 56px 64px 196px;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.015);
  font-size: 11px;
  min-height: 26px;
}

.legend-sfs-row--top {
  background: rgba(202, 253, 0, 0.05);
  border-left: 2px solid #cafd00;
  padding-left: 4px;
}

.legend-sfs-row--bottom {
  opacity: 0.7;
}

.legend-sfs-rank {
  color: var(--legend-text-muted, #888);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  text-align: right;
}

.legend-sfs-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--banana-radius);
}

.legend-sfs-sector {
  color: var(--legend-text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-sfs-bar {
  position: relative;
  height: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--banana-radius);
  overflow: hidden;
}

.legend-sfs-bar-fill {
  height: 100%;
  border-radius: var(--banana-radius);
  transition: width 240ms ease-out;
}

.legend-sfs-share {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--legend-text, #fff);
  font-weight: 600;
}

.legend-sfs-delta {
  text-align: right;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.legend-sfs-delta--up {
  color: #9aad6e;
}

.legend-sfs-delta--down {
  color: #b07a6a;
}

.legend-sfs-spark {
  height: 34px;
  min-width: 112px;
}

.legend-sfs-multiday-chart {
  flex: 1 1 auto;
  min-height: 280px;
}

/* --- Top Net Impact --- */
.legend-tni-ctrls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  flex-wrap: wrap;
}

.legend-tni-issue-select {
  min-width: 72px;
  max-width: 120px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  border-radius: var(--banana-radius);
  cursor: pointer;
  color-scheme: dark;
}

.legend-tni-issue-select:focus {
  outline: none;
  border-color: var(--legend-border-focus);
}

.legend-tni-issue-select option {
  background: var(--legend-bg-widget);
  color: var(--legend-text);
}

.legend-tni-limit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--legend-text-muted, #aaa);
  white-space: nowrap;
}

.legend-tni-limit {
  width: 42px;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

/* ── Market widgets: correlations, OI change, sector ETFs ───────────── */
.legend-table td.legend-cell-up { color: var(--banana-chart-call); }
.legend-table td.legend-cell-down { color: var(--banana-chart-put); }

.legend-corr-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.legend-corr-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  flex: 0 0 auto;
}

.legend-corr-toolbar .legend-corr-tickers {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-corr-toolbar .legend-corr-interval {
  flex: 0 0 auto;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-corr-chart {
  flex: 1 1 auto;
  min-height: 0;
}

.legend-oi-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px;
}

.legend-oi-order-btn {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
  cursor: pointer;
}

.legend-oi-order-btn:hover {
  border-color: color-mix(in srgb, var(--banana-accent-lime, #ccff00) 40%, transparent);
}

.legend-oi-chart-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.legend-oi-chart-wrap .legend-chart-container {
  flex: 1 1 auto;
  min-height: 180px;
}

/* ── Sector ETFs market overview (table) ─────────────────────────── */
.legend-sector-overview {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Compact breadth strip above the table */
.legend-se-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-bottom: 1px solid var(--legend-border);
  font-size: 11px;
  flex-wrap: wrap;
}

.legend-se-strip-breadth {
  display: flex;
  gap: 8px;
  font-weight: 700;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
}

.legend-sector-adv { color: var(--banana-chart-call); }
.legend-sector-dec { color: var(--banana-chart-put); }
.legend-sector-flat { color: var(--legend-text-muted, #999); }

.legend-se-strip-bar {
  display: flex;
  width: 120px;
  height: 7px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-se-strip-bar .seg.up { background: var(--banana-chart-call); }
.legend-se-strip-bar .seg.flat { background: rgba(255, 255, 255, 0.18); }
.legend-se-strip-bar .seg.down { background: var(--banana-chart-put); }

.legend-se-strip-stat {
  color: var(--legend-text-muted, #999);
  font-weight: 600;
}

/* Compact table */
.legend-se-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.legend-se-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.legend-se-table th.legend-se-th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--legend-bg-widget, var(--legend-bg-elevated));
  color: var(--legend-text-muted, #888);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 8px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--legend-border);
}

.legend-se-table th.legend-se-th:hover { color: var(--legend-text); }
.legend-se-table th.numeric { text-align: right; }
.legend-se-table th.legend-se-sorted { color: var(--banana-accent-lime, #ccff00); }
.legend-se-arrow { font-size: 8px; }

.legend-se-table tbody td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  vertical-align: middle;
}

.legend-se-table tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
.legend-se-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Ticker chip */
.legend-se-ticker { width: 1%; }
.se-chip {
  display: inline-block;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
  font-weight: 700;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--legend-text);
}

.se-chip.up { color: var(--banana-chart-call); background: color-mix(in srgb, var(--banana-chart-call) 15%, transparent); }
.se-chip.down { color: var(--banana-chart-put); background: color-mix(in srgb, var(--banana-chart-put) 15%, transparent); }

.legend-se-sector {
  color: var(--legend-text-muted, #999);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-se-last { font-weight: 600; color: var(--legend-text); }

/* Change: compact magnitude bar + value */
.legend-se-change {
  font-weight: 700;
  white-space: nowrap;
}

.legend-se-change.up { color: var(--banana-chart-call); }
.legend-se-change.down { color: var(--banana-chart-put); }

.legend-se-change-bar {
  display: inline-block;
  vertical-align: middle;
  width: 34px;
  height: 5px;
  margin-right: 6px;
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.legend-se-change-bar .fill { display: block; height: 100%; border-radius: var(--banana-radius); }
.legend-se-change-bar .fill.up { background: var(--banana-chart-call); }
.legend-se-change-bar .fill.down { background: var(--banana-chart-put); }
.legend-se-change-val { display: inline-block; min-width: 52px; text-align: right; }

/* Volume: value + muted relative-volume multiple */
.legend-se-mult {
  margin-left: 5px;
  font-size: 9px;
  color: var(--legend-text-muted, #777);
}

.legend-se-mult.hot { color: var(--banana-accent-lime, #ccff00); }

/* Bull/bear premium split */
.legend-se-prem-cell { min-width: 116px; }

.legend-se-prem-pct {
  display: inline-block;
  width: 28px;
  font-weight: 700;
  color: var(--legend-text);
}

.legend-se-prem-bar {
  display: inline-flex;
  vertical-align: middle;
  width: calc(100% - 34px);
  height: 7px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-se-prem-bar .bull { background: var(--banana-chart-call); }
.legend-se-prem-bar .bear { background: var(--banana-chart-put); }

/* Range: low [gradient thermometer + caret] high */
.legend-se-range { min-width: 130px; }

.legend-se-range .rlo,
.legend-se-range .rhi {
  display: inline-block;
  font-size: 9px;
  font-family: var(--banana-font-mono, ui-monospace, monospace);
  color: var(--legend-text-muted, #999);
}

.legend-se-range .rlo { width: 40px; text-align: right; padding-right: 6px; }
.legend-se-range .rhi { width: 40px; text-align: left; padding-left: 6px; }

.legend-se-range .rthermo {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  width: calc(100% - 92px);
  height: 5px;
  border-radius: var(--banana-radius);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--banana-chart-put) 36%, transparent),
    rgba(255, 255, 255, 0.08) 50%,
    color-mix(in srgb, var(--banana-chart-call) 36%, transparent)
  );
}

.legend-se-range .rmark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  border-radius: var(--banana-radius);
  background: var(--legend-text);
  box-shadow: 0 0 0 1px var(--legend-bg-elevated);
}

.legend-oci-volprofile-panel {
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 6px;
}

.legend-oci-volprofile-chart {
  min-height: 180px;
  height: 220px;
}

.legend-oci-volprofile-btn.active {
  background: color-mix(in srgb, var(--banana-chart-call) 22%, transparent);
  border-color: color-mix(in srgb, var(--banana-chart-call) 45%, transparent);
}

.legend-oc-volprofile-mini {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.02);
}

.legend-oc-volprofile-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text-muted, #9e9e9e);
  margin-bottom: 8px;
}

.legend-oc-volprofile-row {
  display: grid;
  grid-template-columns: 56px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
}

.legend-oc-volprofile-bar-wrap {
  min-width: 0;
}

.legend-oc-volprofile-bar {
  display: flex;
  height: 10px;
  border-radius: var(--banana-radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.legend-oc-volprofile-seg--ask {
  background: var(--banana-chart-call);
}

.legend-oc-volprofile-seg--bid {
  background: var(--banana-chart-put);
}

.legend-oc-volprofile-price,
.legend-oc-volprofile-vol {
  color: var(--legend-text-muted, #9e9e9e);
}

.legend-oc-volprofile-vol {
  text-align: right;
}

.legend-ticker-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-radius: var(--banana-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--legend-bg-elevated, #1a1a1a);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.legend-ticker-suggest[hidden] {
  display: none !important;
  padding: 0;
  border: 0;
  box-shadow: none;
  min-height: 0;
  height: 0;
  overflow: hidden;
}

.legend-ticker-suggest-item {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 4px 8px;
  border-radius: var(--banana-radius);
  cursor: pointer;
  font-size: 12px;
}

.legend-ticker-suggest-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.legend-widget-ticker {
  position: relative;
}

.legend-widget-ticker-input.legend-ticker-not-optionable {
  border-color: color-mix(in srgb, #ff9800 55%, transparent);
}

.legend-eb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.legend-eb-market-ctrls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-eb-market-ctrls--hidden {
  display: none !important;
}

.legend-eb-page-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: inherit;
  border-radius: var(--banana-radius);
  width: 24px;
  height: 22px;
  cursor: pointer;
}

.legend-eb-page-label {
  font-size: 11px;
  color: var(--legend-text-muted, #9e9e9e);
}

.legend-eb-order-select {
  font-size: 11px;
}

/* ── Seasonality widgets ─────────────────────────────────────────── */
.legend-seasonality-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-seasonality-yearmap-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text-muted, #aaa);
  box-shadow: none;
}

.legend-seasonality-yearmap-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--legend-text, #fff);
  border-color: var(--legend-border-focus);
  box-shadow: none;
  transform: none;
}

.legend-seasonality-yearmap-btn.active {
  background: rgba(202, 253, 0, 0.18);
  color: var(--legend-text, #fff);
  border-color: rgba(204, 255, 0, 0.35);
}

.legend-widget[data-type-id="seasonality"] .legend-widget-inner,
.legend-widget[data-type-id="market_seasonality"] .legend-widget-inner,
.legend-widget[data-type-id="month_performers"] .legend-widget-inner {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.legend-seasonality-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  gap: 6px;
}

.legend-seasonality-bars,
.legend-seasonality-yearmap,
.legend-market-seasonality-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.legend-seasonality-bars {
  min-height: 160px;
}

.legend-seasonality-wrap--split .legend-seasonality-bars {
  flex: 1 1 52%;
  min-height: 140px;
}

.legend-seasonality-yearmap {
  flex: 1 1 48%;
  min-height: 150px;
}

.legend-seasonality-bars .legend-chart-container,
.legend-seasonality-yearmap .legend-chart-container,
.legend-market-seasonality-wrap .legend-chart-container {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: auto;
}

.legend-seasonality-yearmap-empty {
  flex: 0 0 auto;
  padding: 8px 2px;
  font-size: 11px;
  color: var(--legend-text-muted, #9e9e9e);
}

.legend-market-seasonality-wrap {
  flex: 1 1 0;
  min-height: 240px;
}

/* ── Ticker widgets: Open Interest / Price Levels / Chains / NOPE / Recent Flow ── */
.legend-oiw-toolbar,
.legend-pl-toolbar,
.legend-chains-toolbar,
.legend-nope-toolbar,
.legend-rf-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-oiw-changes-table .legend-oiw-row {
  cursor: pointer;
}

.legend-oiw-changes-table .legend-oiw-row:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.legend-chains-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--legend-text-muted);
  padding: 0 2px 4px;
}

.legend-chains-meta strong {
  color: var(--legend-text);
  font-weight: 600;
}

.legend-chains-table td.legend-chains-cell {
  cursor: pointer;
}

.legend-chains-table tr:hover td.legend-chains-cell {
  background: rgba(255, 255, 255, 0.04);
}

.legend-chains-table .legend-chains-strike {
  text-align: center;
  font-weight: 600;
  color: var(--legend-text);
  background: rgba(255, 255, 255, 0.03);
}

.legend-chains-table tr.legend-chains-atm-row td {
  background: rgba(202, 253, 0, 0.08);
}

.legend-rf-min-premium {
  width: 76px;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg-elevated);
  color: var(--legend-text);
}

.legend-rf-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--legend-text-muted);
  padding: 0 2px 6px;
}

.legend-rf-strip-item strong {
  font-weight: 600;
}

.legend-rf-strip-date {
  margin-left: auto;
  opacity: 0.7;
}

.legend-rf-net-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--banana-radius);
  font-size: 10px;
  font-weight: 600;
}

.legend-rf-net-chip.up {
  background: color-mix(in srgb, var(--banana-chart-call, #ccff00) 18%, transparent);
  color: var(--banana-chart-call, #ccff00);
}

.legend-rf-net-chip.down {
  background: color-mix(in srgb, var(--banana-chart-put, #ff7351) 16%, transparent);
  color: var(--banana-chart-put, #ff7351);
}

.legend-rf-table .legend-rf-td-split,
.legend-rf-table .legend-rf-th-split {
  width: 52px;
  min-width: 44px;
}

.legend-rf-split {
  display: inline-flex;
  width: 44px;
  height: 13px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.legend-rf-split .seg {
  height: 100%;
  display: block;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.26) 0,
    rgba(0, 0, 0, 0.26) 4px,
    transparent 4px,
    transparent 8px
  );
}

.legend-rf-split .seg + .seg {
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.32);
}

.legend-rf-split .seg.ask {
  background-color: var(--banana-chart-call, #ccff00);
}

.legend-rf-split .seg.bid {
  background-color: var(--banana-chart-put, #ff7351);
}

/* ── Insider Buy/Sells: hide ticker input in market mode ── */
.legend-widget[data-type-id="insider_buy_sells"] .legend-insider-ticker {
  flex: 0 1 auto;
  min-width: 0;
}

.legend-widget[data-type-id="insider_buy_sells"][data-insider-mode="market"] .legend-insider-ticker {
  display: none;
}

/* ── Sector Tide: ticker drill-down panel ── */
.legend-sfs-view-btn.legend-st-tickers-btn {
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
}

.legend-st-tickers-btn.is-active {
  background: rgba(202, 253, 0, 0.14);
  color: var(--legend-accent, #cafd00);
}

.legend-st-tickers-panel {
  position: absolute;
  top: 34px;
  right: 6px;
  bottom: 6px;
  width: min(300px, calc(100% - 12px));
  display: flex;
  flex-direction: column;
  z-index: 30;
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: var(--legend-bg-elevated, #161616);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.legend-st-tickers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--legend-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--legend-text);
}

.legend-st-tickers-close {
  border: none;
  background: transparent;
  color: var(--legend-text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.legend-st-tickers-close:hover {
  color: var(--legend-text);
}

.legend-st-tickers-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  min-height: 0;
  flex: 1;
}

.legend-st-tickers-filter {
  width: 100%;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: var(--banana-radius);
  border: 1px solid var(--legend-border);
  background: var(--legend-bg, #101010);
  color: var(--legend-text);
}

.legend-st-tickers-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 5px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-bottom: 4px;
}

.legend-st-ticker-chip {
  border: 1px solid var(--legend-border);
  border-radius: var(--banana-radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--legend-text);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 7px;
  cursor: pointer;
}

.legend-st-ticker-chip:hover {
  background: rgba(202, 253, 0, 0.14);
  border-color: rgba(202, 253, 0, 0.4);
  color: var(--legend-accent, #cafd00);
}

/* Standalone IV Surface page: cockpit only (no widget label / menu chrome). */
.legend-app--iv-surface-page {
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.iv-surface-page-main {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.iv-surface-page {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 100%;
  /* Pin cockpit to one viewport band — sidebar scrolls inside, chart stays aligned. */
  height: clamp(480px, calc(100dvh - 88px), 900px);
  min-height: 480px;
  max-height: calc(100dvh - 88px);
}

/* ── Recommendation engine health panel (paid users) ─────────────────────── */
.iv-recs-health {
  flex: 0 0 auto;
  box-sizing: border-box;
  margin-top: 12px;
  padding: 16px 18px 20px;
  border: 1px solid var(--legend-border, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  background: var(--legend-panel, rgba(255, 255, 255, 0.02));
}

.iv-recs-health__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.iv-recs-health__title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.iv-recs-health__sub {
  margin: 4px 0 0;
  max-width: 60ch;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.66;
}

.iv-recs-health__status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iv-recs-health__badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.08);
  color: #cfd3dc;
}

.iv-recs-health__badge[data-verdict="good"] { background: rgba(54, 211, 153, 0.16); color: #36d399; }
.iv-recs-health__badge[data-verdict="warning"] { background: rgba(245, 197, 24, 0.16); color: #f5c518; }
.iv-recs-health__badge[data-verdict="bad"] { background: rgba(248, 113, 113, 0.16); color: #f87171; }
.iv-recs-health__badge[data-verdict="learning"] { background: rgba(96, 165, 250, 0.16); color: #60a5fa; }

.iv-recs-health__meta {
  font-size: 11px;
  opacity: 0.6;
}

.iv-recs-health__tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0 12px;
  flex-wrap: wrap;
}

.iv-recs-health__tab {
  appearance: none;
  border: 1px solid var(--legend-border, rgba(255, 255, 255, 0.1));
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}

.iv-recs-health__tab:hover { opacity: 1; }

.iv-recs-health__tab.is-active {
  opacity: 1;
  border-color: var(--legend-accent, #f5c518);
  background: rgba(245, 197, 24, 0.08);
}

.iv-recs-health__summary {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.iv-recs-health__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.iv-recs-health__stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--legend-border, rgba(255, 255, 255, 0.06));
}

.iv-recs-health__stat-label { font-size: 11px; opacity: 0.6; }
.iv-recs-health__stat-val { font-size: 18px; font-weight: 600; }

.iv-recs-health__chart {
  width: 100%;
  height: 240px;
}

.iv-recs-health__empty {
  margin: 8px 0 0;
  font-size: 12px;
  opacity: 0.6;
}

.legend-widget--iv-surface-page {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
}

.legend-widget--iv-surface-page .legend-widget-inner {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.legend-widget--iv-surface-page .legend-widget-header {
  cursor: default;
  padding: 0 0 4px;
  min-height: 0;
  border-bottom: none;
  background: transparent;
  box-shadow: none;
}

.legend-widget--iv-surface-page .legend-widget-header-spacer,
.legend-widget--iv-surface-page .legend-widget-menu {
  display: none;
}

.legend-widget--iv-surface-page .legend-widget-body {
  padding: 0;
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.legend-widget--iv-surface-page .legend-iv-cockpit {
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

.legend-widget--iv-surface-page .legend-iv-cockpit__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.legend-widget--iv-surface-page .legend-iv-main {
  min-height: 0;
  overflow: hidden;
}

.legend-widget--iv-surface-page .legend-iv-main .legend-chart-container {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.legend-widget--iv-surface-page .legend-iv-sidebar {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.legend-widget--iv-surface-page .legend-iv-tabcontent {
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  -ms-overflow-style: auto;
}

.legend-widget--iv-surface-page .legend-iv-tabpane[data-tab-id="overview"] {
  gap: 6px;
}

.legend-widget--iv-surface-page .legend-iv-tabcontent::-webkit-scrollbar {
  display: block;
  width: 6px;
}

.legend-widget--iv-surface-page .legend-iv-tabcontent::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--banana-radius);
}

/* ── Live opportunity feed (intraday picks) ─────────────────────────────── */
.iv-recs-feed {
  flex: 0 0 auto;
  box-sizing: border-box;
  margin-top: 12px;
  padding: 16px 18px 18px;
  border: 1px solid var(--legend-border, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  background: var(--legend-panel, rgba(255, 255, 255, 0.02));
}

.iv-recs-feed__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.iv-recs-feed__title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.iv-recs-feed__sub {
  margin: 4px 0 0;
  max-width: 60ch;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.66;
}

.iv-recs-feed__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  opacity: 0.7;
  white-space: nowrap;
}

.iv-recs-feed__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #36d399;
  box-shadow: 0 0 0 0 rgba(54, 211, 153, 0.5);
  animation: iv-recs-feed-pulse 2s infinite;
}

@keyframes iv-recs-feed-pulse {
  0% { box-shadow: 0 0 0 0 rgba(54, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(54, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(54, 211, 153, 0); }
}

.iv-recs-feed__filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 8px;
}

.iv-recs-feed__chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}

.iv-recs-feed__chip.is-active {
  opacity: 1;
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.4);
  color: #93c5fd;
}

.iv-recs-feed__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.iv-recs-feed__row {
  display: grid;
  grid-template-columns: 44px 56px 76px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 12px;
}

.iv-recs-feed__row:first-child { border-top: none; }
.iv-recs-feed__row:hover { background: rgba(255, 255, 255, 0.04); }

.iv-recs-feed__time { opacity: 0.55; font-variant-numeric: tabular-nums; }
.iv-recs-feed__tkr { font-weight: 700; letter-spacing: 0.02em; }

.iv-recs-feed__persona {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
}
.iv-recs-feed__persona--premium_seller { background: rgba(54, 211, 153, 0.16); color: #36d399; }
.iv-recs-feed__persona--vol_arb { background: rgba(245, 197, 24, 0.16); color: #f5c518; }
.iv-recs-feed__persona--spread_builder { background: rgba(96, 165, 250, 0.16); color: #60a5fa; }

.iv-recs-feed__desc { display: flex; flex-direction: column; min-width: 0; }
.iv-recs-feed__title-line { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iv-recs-feed__metric { font-size: 11px; opacity: 0.62; }

.iv-recs-feed__score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.85;
}

.iv-recs-feed__gates { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.iv-recs-feed__gate {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  opacity: 0.75;
}

.iv-recs-feed__empty {
  margin: 12px 2px 0;
  font-size: 12px;
  opacity: 0.6;
}

.iv-recs-feed__row--new {
  animation: iv-recs-feed-fadein 0.6s ease;
}

@keyframes iv-recs-feed-fadein {
  from { background: rgba(96, 165, 250, 0.18); }
  to { background: transparent; }
}

.iv-recs-health__gates {
  margin-top: 14px;
}

.iv-recs-health__gates-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.iv-recs-health__gates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.iv-recs-health__gates-table th,
.iv-recs-health__gates-table td {
  padding: 6px 8px;
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.iv-recs-health__gates-table th {
  opacity: 0.65;
  font-weight: 500;
}

@media (max-width: 640px) {
  .iv-recs-feed__row {
    grid-template-columns: 40px 50px 1fr auto;
  }
  .iv-recs-feed__persona,
  .iv-recs-feed__gates { display: none; }
}
