/* ============================================================
   EdgeStacker design system — tokens + shared components.
   Dark-first "signal green + carbon". Source of truth:
   docs/design_handoff (redesign bundle) — tokens/*.css.
   ============================================================ */
:root {
  /* --- Signal green (primary brand) --- */
  --green-300: #6df3b8;
  --green-400: #3df0a0;
  --green-500: #2ee08a;
  --green-600: #24d67f;
  --green-700: #12b866;
  --green-800: #0f9354;
  --green-900: #0b8f50;

  /* --- Carbon (dark neutrals) --- */
  --ink-950: #070b0a;
  --ink-900: #080d0b;
  --ink-850: #0a110e;
  --ink-800: #0c1712;
  --ink-700: #0e1512;
  --ink-600: #12201a;
  --ink-500: #1a2a23;

  /* --- Paper (light neutrals / text) --- */
  --paper: #eef3f0;
  --paper-bright: #f4fbf7;
  --slate-400: #8ba398;
  --slate-500: #7f938a;
  --slate-600: #6b7f76;
  --slate-700: #5d7169;

  /* --- Status --- */
  --up: #2ee08a;
  --up-soft: rgba(46, 224, 138, 0.14);
  --down: #ff5f6d;
  --down-soft: rgba(255, 95, 109, 0.14);
  --warn: #ffb454;
  --warn-soft: rgba(255, 180, 84, 0.14);
  --info: #4db8ff;
  --info-soft: rgba(77, 184, 255, 0.14);

  /* --- Borders --- */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-accent: rgba(46, 224, 138, 0.28);

  /* --- Gradients --- */
  --gradient-brand: linear-gradient(135deg, #3df0a0, #12b866);
  --glow-radial: radial-gradient(1100px 620px at 22% -8%, rgba(35, 210, 130, 0.10), transparent 60%);

  /* --- Semantic aliases --- */
  --bg-app: var(--ink-950);
  --surface-card: var(--ink-700);
  --surface-elevated: var(--ink-800);
  --surface-well: var(--ink-900);
  --surface-hover: var(--ink-600);
  --text-primary: var(--paper);
  --text-secondary: var(--slate-400);
  --text-muted: var(--slate-600);
  --text-on-accent: #052014;
  --accent: var(--green-500);
  --accent-strong: var(--green-700);
  --accent-pressed: var(--green-800);
  --accent-tint: rgba(46, 224, 138, 0.13);
  --focus-ring: rgba(46, 224, 138, 0.45);
  --focus-shadow: 0 0 0 3px var(--focus-ring);

  /* --- Type --- */
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ls-display: -0.025em;
  --ls-heading: -0.02em;
  --ls-eyebrow: 0.28em;
  --ls-label: 0.16em;

  /* --- Radii --- */
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 18px;
  --radius-2xl: 22px;
  --radius-3xl: 24px;
  --radius-pill: 999px;

  /* --- Shadows & glow --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 26px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.6);
  --glow-sm: 0 4px 14px rgba(45, 220, 140, 0.28);
  --glow-md: 0 8px 20px rgba(45, 220, 140, 0.32);
  --glow-lg: 0 12px 34px rgba(18, 180, 102, 0.40);
  --glow-ring: 0 0 0 1px rgba(46, 224, 138, 0.35), 0 8px 24px rgba(45, 220, 140, 0.28);

  /* --- Motion --- */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-med: 200ms;
  --dur-slow: 320ms;

  /* --- Spacing scale (4px grid) --- */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 56px;
  --space-12: 80px;

  /* --- Control sizing + layout --- */
  --control-h-sm: 32px;
  --control-h-md: 40px;
  --control-h-lg: 48px;
  --control-pad-x: 16px;
  --container-max: 1400px;
  --sidebar-w: 248px;
  --gutter: 24px;

  --border-w: 1px;
  --shadow-inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  /* ----------------------------------------------------------
     Legacy aliases — pre-redesign templates (Improve, Discover,
     jobs/market partials) still reference these names. Values
     point at the new palette so those screens inherit the
     refresh without a rewrite. Remove once all screens are
     ported to the new tokens.
     ---------------------------------------------------------- */
  --canvas-bg: var(--ink-950);
  --app-bg: var(--ink-950);
  --sidebar-bg: var(--ink-900);
  --panel-bg: var(--ink-700);
  --inset-bg: var(--ink-900);
  --hairline-04: rgba(255, 255, 255, 0.04);
  --hairline-05: rgba(255, 255, 255, 0.05);
  --hairline-06: var(--border-subtle);
  --hairline-07: rgba(255, 255, 255, 0.07);
  --hairline-08: rgba(255, 255, 255, 0.08);
  --hairline-10: var(--border);
  --hairline-12: rgba(255, 255, 255, 0.12);
  --text-secondary-2: #cfe0d8;
  --text-mono-muted: var(--slate-600);
  --text-faint: var(--slate-700);
  --text-faint-2: #4d5f57;
  --green-bright: var(--green-400);
  --green-mid: var(--green-600);
  --green-mid-2: var(--green-600);
  --green-deep: var(--green-700);
  --green-deep-2: var(--green-800);
  --green-nav: var(--green-500);
  --green-gradient: var(--gradient-brand);
  --green-selected-bg: var(--accent-tint);
  --green-selected-border: rgba(46, 224, 138, 0.3);
  --green-selected-text: var(--green-400);
  --nav-active-bg: var(--accent-tint);
  --nav-active-border: var(--border-accent);
  --green-tint-bg: rgba(46, 224, 138, 0.09);
  --green-tint-border: var(--border-accent);
  --green-tint-text: #c9f2dd;
  --red-candle: #ef5350;
  --red-text: var(--down);
  --amber: var(--warn);
  --amber-tint-bg: var(--warn-soft);
  --amber-tint-border: rgba(255, 180, 84, 0.3);
  --amber-tint-text: #ffd9a3;
  --candle-up: var(--green-600);
  --candle-down: #ef5350;
  --radius-btn: var(--radius-md);
  --radius-input: var(--radius-md);
  --radius-card: var(--radius-2xl);
  --radius-frame: var(--radius-xl);
  --space-main: 30px 36px;
  --space-card: 20px 22px;
  --space-card-compact: 14px 16px;
  --space-divider: 28px;
  --space-sidebar-gap: 24px;
  --font-ui: var(--font-display);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font-body);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-shadow);
  border-radius: var(--radius-sm);
}

/* ---- motion primitives ---- */
@keyframes es-spin { to { transform: rotate(360deg); } }
@keyframes es-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes es-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes es-shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
.es-fade { animation: es-fade var(--dur-slow) var(--ease-out); }
.es-pulse { animation: es-pulse 1.4s ease-in-out infinite; }
.es-skel {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.07) 50%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 600px 100%;
  animation: es-shimmer 1.3s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .es-fade, .es-pulse, .es-skel { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---- text roles ---- */
.mono,
.es-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.es-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
}
.es-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow { /* legacy name */
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--accent);
}
.es-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: var(--ls-display);
  line-height: 1.05;
  margin: 0;
  color: var(--text-primary);
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-divider) 0;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  height: 40px;
  padding: 0 16px;
  border: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard), box-shadow var(--dur-med) var(--ease-standard), background var(--dur-fast);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: var(--gradient-brand);
  color: var(--text-on-accent);
  box-shadow: var(--glow-sm);
}
.btn-primary:hover { box-shadow: var(--glow-md); }
.btn-ghost {
  background: var(--surface-well);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 500;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-quiet {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
}
.btn-quiet:hover { border-color: var(--border-strong); color: var(--text-primary); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: var(--radius-sm); }

/* ---- semantic value colors ---- */
.value-positive { color: var(--up); }
.value-negative { color: var(--down); }
.value-neutral { color: var(--text-primary); }
.value-muted { color: var(--text-muted); }

/* ---- app shell ---- */
.es-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  background: var(--bg-app);
  background-image: var(--glow-radial);
}

.es-sidebar {
  width: 240px;
  flex: none;
  background: var(--ink-900);
  border-right: 1px solid var(--border-subtle);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* lift the rail so nav tooltips (which escape to the right) paint over the
     main column instead of being covered by it */
  position: relative;
  z-index: 5;
}

.es-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  text-decoration: none;
}
.es-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: var(--ls-heading);
  color: var(--text-primary);
}
.es-wordmark .accent { color: var(--accent); }

.es-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.es-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.es-nav-item svg { flex: none; }
.es-nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }

/* hover/focus tooltip: a compact bubble with a caret, to the right of each nav
   item, from its data-tip attribute. The rail has no overflow clip, so it
   escapes cleanly. ::after = bubble, ::before = caret pointing at the item. */
.es-nav-item[data-tip] { position: relative; }
.es-nav-item[data-tip]::after,
.es-nav-item[data-tip]::before {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.13s var(--ease-out), transform 0.13s var(--ease-out);
  transition-delay: 0.1s;
}
.es-nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 11px);
  top: 50%;
  transform: translateY(-50%) translateX(-3px);
  z-index: 60;
  width: max-content;
  max-width: 220px;
  background: var(--surface-elevated, var(--surface-card));
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.es-nav-item[data-tip]::before {
  content: "";
  position: absolute;
  left: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%) translateX(-3px);
  z-index: 61;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 5px solid var(--border-strong);
}
.es-nav-item[data-tip]:hover::after,
.es-nav-item[data-tip]:focus-visible::after,
.es-nav-item[data-tip]:hover::before,
.es-nav-item[data-tip]:focus-visible::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .es-nav-item[data-tip]::after,
  .es-nav-item[data-tip]::before {
    transition: none;
    transform: translateY(-50%);
  }
}
.es-nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary, var(--slate-500));
  padding: 14px 12px 6px;
}
.es-nav-item.active {
  background: var(--accent-tint);
  border-color: var(--border-accent);
  color: var(--text-primary);
  font-weight: 600;
}
.es-nav-item.active svg { stroke: var(--accent); }

.es-user-chip {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
}
.es-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-on-accent);
  font-weight: 700;
  flex: none;
}
.es-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.es-user-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Account menu: the user chip is a <details> summary; the panel opens upward
   (the chip sits at the bottom of the sidebar). Shares es-overflow-menu for
   the close-on-outside-click behavior, but overrides the summary sizing that
   rule sets for the Stack's icon-only trigger. */
.es-user-menu {
  position: relative;
  display: block;
  margin-top: auto;
}
.es-user-menu > summary {
  list-style: none;
  cursor: pointer;
  /* Row layout (avatar / name / caret), padding and border-top all come from
     .es-user-chip. Opaque and stacked above the panel so the popover's shadow
     doesn't bleed through behind the username (the panel floats directly
     above). */
  position: relative;
  z-index: 42;
  background: var(--ink-900);
}
.es-user-menu > summary::-webkit-details-marker { display: none; }
.es-user-menu[open] > summary { background: var(--surface-hover); }
.es-user-caret {
  flex: none;
  color: var(--text-secondary);
  transition: transform var(--dur-fast) var(--ease-standard);
}
.es-user-menu[open] .es-user-caret { transform: rotate(180deg); }

.es-user-menu-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 100%;
  margin-bottom: 8px;
  z-index: 41;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  padding: 6px;
}
.es-user-menu-head { padding: 9px 10px 10px; }
.es-user-menu-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.es-user-menu-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}
.es-user-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}
.es-user-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.35;
}
.es-user-menu-item-label {
  display: flex;
  align-items: center;
  gap: 9px;
}
.es-user-menu-item.is-soon { color: var(--text-muted); }
.es-user-menu-soon {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 2px 6px;
}
.es-user-menu-signout {
  width: 100%;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--down);
}
.es-user-menu-signout:hover { background: var(--down-soft); }

.es-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}
.es-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 32px 96px;
}
.es-page-narrow { max-width: 1000px; }
/* legacy screens (Improve/Discover) render bare into .es-main */
.es-page-legacy { padding: 30px 36px 80px; }

/* ---- page header pattern ---- */
.es-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ---- market panel (sidebar, legacy screens only) ---- */
.es-market-panel {
  margin-top: 18px;
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.es-market-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
.es-market-field { display: flex; flex-direction: column; gap: 5px; }
.es-market-field-label { font-size: 11px; color: var(--text-muted); }
.es-symbol-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  appearance: none;
}
.es-tf-segmented { display: flex; gap: 5px; }
.es-tf-segment {
  flex: 1;
  text-align: center;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.es-tf-segment.selected {
  background: var(--accent-tint);
  border-color: var(--border-accent);
  color: var(--green-400);
  font-weight: 600;
}
.es-history-row { display: flex; justify-content: space-between; }
.es-history-track { height: 4px; border-radius: 3px; background: var(--surface-card); position: relative; }
.es-history-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(90deg, #12b866, #3df0a0);
}
.es-history-thumb {
  position: absolute;
  top: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-400);
}
.es-market-caption { font-size: 10px; line-height: 1.5; color: var(--slate-700); }
.es-tf-segment.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.es-market-err { font-size: 11px; color: var(--down, #ff6b6b); margin-top: 2px; }

/* ---- symbol picker (filter-as-you-type) ---- */
.es-symbol-picker { position: relative; width: 100%; }
.es-symbol-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.35));
}
.es-symbol-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
}
.es-symbol-option.active,
.es-symbol-option:hover { background: var(--accent-tint); }
.es-symbol-opt-sym { font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; }
.es-symbol-opt-name {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Instrument-type group headers inside the dropdown (Crypto / Stocks & ETFs).
   Sticky so the group name stays visible while its options scroll. */
.es-symbol-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--ink-800);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.es-symbol-group-head:first-child { border-top: none; }
.es-symbol-group-name { display: flex; align-items: center; gap: 7px; }
.es-symbol-group-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.es-symbol-group-count { letter-spacing: 0.05em; color: var(--slate-700); }

/* ---- cards ---- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-compact { padding: 14px 16px; }
.card-well {
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 15px;
}

.chip {
  display: inline-block;
  background: var(--surface-well);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.chip:hover { background: var(--surface-hover); color: var(--text-primary); }
.chip.selected { color: var(--text-primary); border-color: var(--border-strong); }

/* mono symbol / origin chips */
.es-sym-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: var(--surface-well);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.es-origin-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.textarea-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color var(--dur-fast);
}
.textarea-card:focus-within { border-color: var(--border-accent); }
.textarea-card textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  min-height: 100px;
}
.textarea-card textarea::placeholder { color: var(--text-muted); }

/* ---- banners ---- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.5;
}
.banner-success {
  background: rgba(46, 224, 138, 0.09);
  border: 1px solid var(--border-accent);
  color: #c9f2dd;
}
.banner-warning {
  background: var(--warn-soft);
  border: 1px solid rgba(255, 180, 84, 0.3);
  color: #ffd9a3;
}
.banner-error {
  background: var(--down-soft);
  border: 1px solid rgba(255, 95, 109, 0.3);
  color: var(--down);
}
.banner-info {
  background: var(--info-soft);
  border: 1px solid rgba(77, 184, 255, 0.3);
  color: #bde2ff;
}

/* ---- metrics ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.metric-cell {
  background: var(--surface-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 700;
}
.metric-value.small { font-size: 20px; }

/* ---- tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.data-table th {
  background: var(--surface-well);
  color: var(--text-muted);
  text-align: left;
  padding: 9px 14px;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.data-table td {
  padding: 10px 14px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.data-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-box {
  width: 100%;
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* ---- backtest trades panel (beside the price & signals chart) ---- */
.bt-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  /* start, not stretch: the panel keeps its own (chart-matched) height and
     scrolls internally, instead of the long trade list stretching the grid
     row to thousands of pixels. */
  align-items: start;
}
/* Collapsed: the chart reflows to full width (today's default view). */
.bt-split.collapsed { grid-template-columns: minmax(0, 1fr); }
.bt-split.collapsed .bt-trades { display: none; }
.bt-split .chart-box { height: 360px; }

.bt-trades {
  display: flex;
  flex-direction: column;
  height: 360px; /* matches the chart so the internal list, not the row, scrolls */
  min-height: 0;
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.bt-trades-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.bt-trades-head .es-label { margin: 0; }
.bt-filters { display: flex; gap: 5px; }
.bt-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.bt-chip:hover { color: var(--text-primary); border-color: var(--border-strong); }
.bt-chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-tint);
}
.bt-list-head {
  display: grid;
  grid-template-columns: 24px 1fr 54px 58px;
  gap: 8px;
  align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bt-list-head .r { text-align: right; }
.bt-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
}
.bt-empty {
  padding: 22px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.bt-trade {
  display: grid;
  grid-template-columns: 24px 1fr 54px 58px;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: background .12s ease, border-color .12s ease;
}
.bt-trade:hover { background: var(--surface-hover); }
.bt-trade[aria-selected="true"] {
  background: linear-gradient(90deg, var(--accent-tint), transparent 72%);
  border-left-color: var(--accent);
}
.bt-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.bt-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bt-line1 { display: flex; align-items: center; gap: 7px; }
.bt-dir {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.5;
}
.bt-dir.long { color: var(--up); background: var(--up-soft); }
.bt-dir.short { color: var(--down); background: var(--down-soft); }
.bt-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.bt-px {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bt-px .arrow { color: var(--text-muted); padding: 0 2px; }
.bt-hold {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bt-ret {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bt-ret.up { color: var(--up); }
.bt-ret.down { color: var(--down); }
.bt-ret.open { color: var(--text-muted); font-weight: 500; }
.bt-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.bt-foot .net b { font-variant-numeric: tabular-nums; color: var(--text-secondary); }

@media (max-width: 860px) {
  .bt-split { grid-template-columns: 1fr; }
  .bt-trades { max-height: 380px; }
}

/* ---- chart section header + fullscreen takeover ---- */
.bt-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
/* Icon-only corner control (expand/collapse arrows). Icon controls on
   tiles/cards are house style; text-only applies to CTAs. */
.bt-xbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.bt-xbtn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.bt-xbtn:focus-visible { outline: none; box-shadow: var(--focus-shadow); }
.bt-xbtn svg { width: 13px; height: 13px; display: block; }

.bt-fs {
  position: fixed;
  inset: 12px;
  z-index: 80;
  background: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  box-shadow: 0 0 0 9999px rgba(4, 7, 6, 0.72);
}
/* !important: the report template sets the resting margins inline
   (style="margin:24px 0 10px"), which would otherwise win and push the
   chart's time axis off the bottom of the takeover. */
.bt-fs .bt-sec-head { margin: 0 0 10px !important; }
.bt-fs .bt-split { flex: 1; min-height: 0; align-items: stretch; }
.bt-fs .bt-trades { height: auto; }
body.bt-fs-open { overflow: hidden; }

/* ---- badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  height: 22px;
  padding: 0 9px;
}
.badge-success { background: var(--up-soft); color: var(--up); border: 1px solid var(--border-accent); }
.badge-warning { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(255, 180, 84, 0.3); }
.badge-error { background: var(--down-soft); color: var(--down); border: 1px solid rgba(255, 95, 109, 0.3); }
.badge-info { background: rgba(77, 184, 255, 0.12); color: var(--info); border: 1px solid rgba(77, 184, 255, 0.3); }
.badge-muted { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); border: 1px solid var(--border); }

/* ---- modal (native <dialog>) ---- */
.es-modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  color: var(--text-primary);
}
.es-modal::backdrop {
  background: rgba(4, 7, 6, 0.68);
  backdrop-filter: blur(8px);
}

/* ---- in-flight feedback (htmx) ---- */
/* When a form issues the request, htmx marks the FORM, so a descendant
   .btn rule would spin every button in it (e.g. Cancel next to Parse).
   Only the submit button actually fired the request. All non-submit
   buttons in templates carry an explicit type="button". */
.htmx-request.btn,
.htmx-request .btn[type="submit"] {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
.htmx-request.btn::after,
.htmx-request .btn[type="submit"]::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: es-spin 0.6s linear infinite;
}

.es-global-error {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-md);
  padding: 13px 16px;
  margin: 0 0 16px;
  font-size: 13.5px;
  background: var(--down-soft);
  border: 1px solid rgba(255, 95, 109, 0.3);
  color: var(--down);
}
.es-global-error button {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

/* ---- details/summary chevron pattern ---- */
details.es-details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
details.es-details > summary::-webkit-details-marker { display: none; }
details.es-details > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur-fast) var(--ease-standard);
}
details.es-details[open] > summary::after {
  transform: rotate(225deg) translateY(-1px);
}

/* ---- Today: quiet-row summary chevron (own layout, not .es-details) ---- */
.es-quiet-row > summary {
  list-style: none;
}
.es-quiet-row > summary::-webkit-details-marker {
  display: none;
}
.es-quiet-row[open] .es-quiet-chevron {
  transform: rotate(90deg);
}

/* ---- Today: track-record calendar ---- */
.es-cal-cell {
  min-height: 74px;
  padding: 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
}
.es-cal-cell.is-today {
  background: var(--accent-tint);
  border-color: var(--border-accent);
}
.es-cal-cell.out-of-month {
  opacity: 0.35;
  background: transparent;
}
.es-cal-marker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.es-legend-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  text-align: left;
  cursor: pointer;
}
.es-legend-chip.active {
  background: var(--accent-tint);
  border-color: var(--border-accent);
}
.es-legend-chip.dimmed {
  opacity: 0.45;
}
.es-year-cell {
  height: 30px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 9px;
}

/* ---- The Stack: old playbook dims while a rebuild is in flight ---- */
#playbook-bench-section.htmx-request {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-standard);
}

/* ---- The Stack: archive overflow menu ---- */
.es-overflow-menu {
  position: relative;
  display: inline-block;
}
.es-overflow-menu > summary {
  list-style: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.es-overflow-menu > summary::-webkit-details-marker {
  display: none;
}
.es-overflow-menu[open] > summary {
  background: var(--surface-hover);
}
.es-overflow-menu-panel {
  position: absolute;
  top: 32px;
  right: 0;
  z-index: 41;
  width: 230px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  padding: 5px;
}
.es-overflow-menu-panel button {
  cursor: pointer;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.35;
}
.es-overflow-menu-panel button:hover {
  background: var(--surface-hover);
}
.es-overflow-menu-panel button .note {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- utility: hide while preserving content (Define's describe/report toggle) ---- */
.es-hidden { display: none !important; }

/* ---- Define: placeholder shown where results used to be, right after an
   edit invalidates them (esExpandConfirm) ---- */
.es-cleared-placeholder {
  margin-top: 16px;
  padding: 26px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-2xl);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---- borderless text button (DS "ghost": transparent, no border) ---- */
.btn-text {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 500;
}
.btn-text:hover { background: rgba(255, 255, 255, 0.05); }

/* ---- persistent button loading state: survives past a fast job-dispatch and
   keeps spinning until the polled result lands, so async-job buttons behave
   like synchronous ones (see base.html job-button tracking). ---- */
.btn.es-btn-loading,
.sc-btn-primary.es-btn-loading {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
/* Scan buttons (sc-btn-primary) are disabled while their job runs but carry no
   .btn class, so without this they stay bright green with no feedback — the
   trader can't tell the click registered. Mirror the disabled dim here. */
.sc-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.es-btn-loading::after,
.sc-btn-primary.es-btn-loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: es-spin 0.6s linear infinite;
}

/* ---- form field label (Space Grotesk, matches the DS Select + date labels) ---- */
.es-field-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ---- custom select (DS Select: appearance:none + ▾ chevron, Space Grotesk) ---- */
.es-select-wrap { position: relative; display: inline-block; }
.es-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: var(--control-h-md);
  padding: 0 40px 0 14px;
  background: var(--surface-well);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-med) var(--ease-standard), box-shadow var(--dur-med) var(--ease-standard);
}
.es-select:focus { border-color: var(--accent); box-shadow: var(--focus-shadow); }
.es-select-chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
}

/* ---- date input (DS date field) ---- */
.es-date-input {
  height: var(--control-h-md);
  padding: 0 12px;
  background: var(--surface-well);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
  color-scheme: dark;
  cursor: pointer;
  outline: none;
}
.es-date-input:focus { border-color: var(--accent); box-shadow: var(--focus-shadow); }
.es-date-input:disabled { opacity: 0.6; cursor: default; }

/* ---- range preset chip ---- */
.es-range-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.es-range-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.es-range-chip.selected {
  background: var(--accent-tint);
  border-color: var(--border-accent);
  color: var(--accent);
}

/* ---- Define confirm: inline value editing (strategy prose) ---- */
/* Each parsed number is a real input that reads as prose until touched.
   States per the inline-editing design handoff: faint green tint at rest,
   green ring while editing, bold green + reset dot when edited, red when
   invalid, amber while it's a parser-assumed value the trader hasn't touched. */
.es-iv-wrap { position: relative; display: inline-block; white-space: nowrap; }
.es-iv {
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  field-sizing: content; /* auto-size to digits; JS ch-width fallback */
  min-width: 1ch;
  text-align: center;
  background: rgba(46, 224, 138, 0.08);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 5px;
  margin: 0 1px;
  color: var(--text-primary);
  cursor: text;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.es-iv:hover { background: rgba(46, 224, 138, 0.16); border-color: var(--border-accent); }
.es-iv:focus {
  outline: none;
  background: var(--surface-well);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 224, 138, 0.18);
}
.es-iv.is-assumed { background: rgba(255, 180, 84, 0.12); }
.es-iv.is-assumed:hover { background: rgba(255, 180, 84, 0.2); border-color: var(--warn); }
.es-iv.is-edited {
  color: var(--accent);
  font-weight: 600;
  background: rgba(46, 224, 138, 0.18);
  border-color: var(--border-accent);
}
.es-iv.is-invalid { color: var(--down); background: var(--down-soft); border-color: var(--down); }
.es-iv-reset {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-accent);
  background: var(--surface-card);
  color: var(--accent);
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
  z-index: 5;
}
.es-iv-wrap.is-edited .es-iv-reset { display: inline-flex; }

/* Parser-assumed phrase: persistent amber marker + hover tooltip, cleared the
   moment the value is edited (is-cleared). */
.es-iv-assumed {
  position: relative;
  display: inline;
  border-radius: 4px;
  padding: 1px 2px;
  background: rgba(255, 180, 84, 0.14);
  border-bottom: 1px dashed var(--warn);
  cursor: help;
}
.es-iv-assumed.is-cleared {
  background: transparent;
  border-bottom-color: transparent;
  cursor: auto;
}
.es-iv-tip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translate(-50%, 4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  width: 222px;
  padding: 9px 11px;
  background: var(--ink-800);
  border: 1px solid rgba(255, 180, 84, 0.4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-style: normal;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: left;
  white-space: normal;
  z-index: 20;
}
.es-iv-assumed:not(.is-cleared):hover .es-iv-tip { opacity: 1; transform: translate(-50%, 0); }

/* Live probe strip under the prose: "Entry fires on N of M loaded bars". */
.es-probe-strip {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
}
.es-probe-strip.is-ok { background: var(--up-soft); border-color: rgba(46, 224, 138, 0.32); }
.es-probe-strip.is-low { background: var(--warn-soft); border-color: rgba(255, 180, 84, 0.32); }
.es-probe-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.es-probe-strip.is-ok .es-probe-dot { background: var(--up); box-shadow: 0 0 7px var(--up); }
.es-probe-strip.is-low .es-probe-dot { background: var(--warn); box-shadow: 0 0 7px var(--warn); }
.es-probe-text { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.es-probe-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.es-probe-strip.is-ok .es-probe-count { color: var(--up); }
.es-probe-strip.is-low .es-probe-count { color: var(--warn); }
.es-probe-msg { font-family: var(--font-body); font-size: 12px; color: var(--text-muted); }

/* "Your words" box (left column of the strategy block). */
.es-words-box {
  background: var(--surface-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.es-words-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.es-words-edit-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.es-reset-all-btn {
  display: none;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.es-reset-all-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.es-reset-all-btn.is-visible { display: inline-flex; }
.es-iv-prose strong { color: var(--text-primary); font-weight: 600; }

/* "What can I use?" supported-indicators popover (Define page). Pure CSS:
   the panel shows on hover/focus of the wrapper; the panel's transparent
   padding-top bridges the 8px gap so the pointer can travel into it. */
/* The wrapper is only the hover/focus scope; the panel anchors to the
   header row (position:relative in the template) so it spans the card. */
.es-ind-pop {
  display: inline-block;
  flex: none;
}
.es-ind-pop-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-well);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  cursor: default;
}
.es-ind-pop-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-shadow);
}
.es-ind-pop-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding-top: 8px;
  z-index: 6;
}
.es-ind-pop:hover .es-ind-pop-panel,
.es-ind-pop:focus-within .es-ind-pop-panel {
  display: block;
}
.es-ind-pop-card {
  width: 100%;
  background: var(--ink-800);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 16px 18px;
}
@media (prefers-reduced-motion: no-preference) {
  .es-ind-pop-card { animation: es-ind-pop-in 140ms var(--ease-out); }
  @keyframes es-ind-pop-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
.es-ind-pop-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.es-ind-pop-badge {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  border: 1px solid var(--border-accent);
  color: var(--accent);
}
.es-ind-pop-caption {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.es-ind-pop-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 0;
}
.es-ind-pop-row + .es-ind-pop-row { border-top: 1px solid var(--border-subtle); }
.es-ind-pop-cat {
  flex: none;
  width: 72px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding-top: 4px;
}
.es-ind-pop-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.es-ind-pop-dot-1 { background: var(--accent); }
.es-ind-pop-dot-2 { background: var(--info); }
.es-ind-pop-dot-3 { background: var(--warn); }
.es-ind-pop-dot-4 { background: var(--text-secondary); }
.es-ind-pop-dot-5 { background: var(--text-muted); }
.es-ind-pop-names {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
}

/* ---- circular "?" helper trigger (Define page: indicators + symbol) ---- */
.es-qmark {
  flex: none;
  width: 17px;
  height: 17px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-well);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.es-ind-pop:hover .es-qmark,
.es-ind-pop:focus-within .es-qmark,
.es-help:hover .es-qmark,
.es-help:focus-within .es-qmark {
  color: var(--accent);
  border-color: var(--border-accent);
}
.es-qmark:focus-visible { outline: none; box-shadow: var(--focus-shadow); }

/* ---- supported-markets "?" popover (Symbol field). Same hover/focus
   pattern as es-ind-pop, but anchored to its own trigger and opening
   upward so it never covers the Parse button below the field. ---- */
.es-help { position: relative; display: inline-flex; }
.es-help-panel {
  display: none;
  position: absolute;
  bottom: 100%;
  left: -12px;
  padding-bottom: 9px;
  z-index: 40;
  width: min(360px, 82vw);
}
.es-help:hover .es-help-panel,
.es-help:focus-within .es-help-panel { display: block; }
.es-help-card {
  background: var(--ink-800);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 15px 17px;
}
@media (prefers-reduced-motion: no-preference) {
  .es-help-card { animation: es-ind-pop-in 140ms var(--ease-out); }
}
.es-help-caption {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.es-help-row { display: flex; gap: 11px; padding: 10px 0 2px; align-items: flex-start; }
.es-help-row + .es-help-row { border-top: 1px solid var(--border-subtle); margin-top: 9px; }
.es-help-kind {
  flex: none;
  width: 64px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding-top: 3px;
}
.es-help-kind .es-help-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.es-help-body { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.es-help-body b { color: var(--text-primary); font-weight: 600; }
.es-help-foot {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- "Surprise me" (Define describe card header) ---- */
.es-surprise {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--green-400);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 2px;
}
.es-surprise:hover { color: var(--green-300); }
.es-surprise:focus-visible { outline: none; box-shadow: var(--focus-shadow); border-radius: var(--radius-sm); }
