/* ═══════════════════════════════════════════════════════════════════════════
   EduMarkets — Options Module CSS
   ═══════════════════════════════════════════════════════════════════════════ */


/* ── Layout ─────────────────────────────────────────────────────────────── */

.options-module {
  display: flex;
  height: calc(100vh - 64px);
  overflow: hidden;
  position: relative;
  padding-left: var(--workspace-gutter);
}
/* Vertical divider line — matches the `border-left` on .workspace-content
   used by every other module (base.css:286-294). Options can't use that
   rule because .options-reference is max-width:1320 + margin auto and
   .options-content is conditionally hidden, so neither spans the full
   width needed for a border. The pseudo sits at the same X
   (var(--workspace-gutter)) the line lives at in other modules, and only
   renders when the sidebar isn't visible — same condition under which
   .workspace-content's border is "exposed" as the page-edge line in the
   shared layout. */
.options-module.sidebar-tab-hidden::before,
.options-module.sidebar-collapsed::before {
  content: '';
  position: absolute;
  left: var(--workspace-gutter);
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  pointer-events: none;
  z-index: 1;
}

.options-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  /* no transition — instant collapse avoids layout reflow jank */
  display: flex;
  flex-direction: column;
  /* Divider line lives on .workspace-content (base.css) — single source of truth. */
}

.options-sidebar-inner {
  padding: 20px 16px;
  min-width: var(--sidebar-width);
}

.options-module.sidebar-collapsed .options-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

/* Sidebar collapse toggle button */
.options-sidebar-toggle {
  position: absolute;
  top: 20px;
  left: calc(var(--workspace-gutter) + var(--sidebar-width) - 12px);
  z-index: var(--z-dropdown);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: left 220ms ease, background var(--transition), border-color var(--transition), color var(--transition);
  font-family: var(--font);
  line-height: 1;
}
.options-sidebar-toggle:hover {
  background: var(--bg-elevated);
  border-color: var(--color-accent);
  color: var(--color-accent-light);
}
.options-module.sidebar-collapsed .options-sidebar-toggle {
  left: calc(var(--workspace-gutter) - 12px);
}

/* Hide sidebar smoothly when switching to reference tab */
.options-module.sidebar-tab-hidden .options-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
}
.options-module.sidebar-tab-hidden .options-sidebar-toggle {
  left: calc(var(--workspace-gutter) - 12px);
}

.options-content {
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow-x: auto;
  overflow-y: auto;
}

.options-reference {
  display: none;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 1320px;  /* Match platform convention: equities.css, fi.css, credit.css */
  margin: 0 auto;     /* Centre within the workspace once sidebar is hidden */
  min-height: 0;
  overflow: hidden;
  /* Mirror .tab-content-area:has(.ref-sub-tabs-wrap) in base.css so the
     sub-tab nav bar (Learn / Conventions / Glossary …) lands at the
     same 20px horizontal inset as every other module. Other modules
     get this padding from .tab-content-area; the options reference
     tab uses its own wrapper instead, so it has to set it here. */
  padding: 16px 20px 0;
}

.options-reference > .ref-sub-panel {
  /* Horizontal inset comes from .options-reference's padding above —
     don't double it here. */
  padding-bottom: 48px;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
/* .sidebar-section, .sidebar-select are defined in components.css
   (authoritative source). */

.sidebar-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
.collapse-arrow {
  font-size: 0.6rem;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Uniform sidebar element sizing ──────────────────────────────────── */
.sidebar-section.opt-no-divider {
  border-bottom: none;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

#options-sidebar .sidebar-select {
  padding: 8px 14px;
  min-height: 38px;
  box-sizing: border-box;
}

/* Compact select used inside chart config grid */
.sidebar-select-sm {
  width: 100%;
  padding: 4px 6px;
  font-size: 0.8rem;
  font-family: var(--font);
  background-color: var(--bg-input);
  color: var(--text);

  border: 1px solid var(--sidebar-accent-dim);
  border-radius: var(--r-md);
  outline: none;
  cursor: pointer;
  margin-top: 2px;
  transition: border-color var(--transition);
}
.sidebar-select-sm:focus {
  border-color: var(--sidebar-accent);
}

.sidebar-select-sm option {
  background-color: var(--bg-input);
  color: var(--text);
}

/* 2-column grid for chart config labels */
.chart-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.chart-config-label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--text-secondary);
  gap: 2px;
}

.sidebar-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.sidebar-checkbox input[type="checkbox"] {
  accent-color: var(--color-accent);
}

.legs-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legs-controls span {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* ── Direction toggle (options-specific variants; base buy/sell in components.css) ── */

.dir-toggle-btn.active {
  background: rgba(79, 143, 247, 0.2);
  border-color: rgba(79, 143, 247, 0.5);
  color: #e8eaf0;
}

.dir-toggle-btn.active-equity {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(37, 99, 235, 0.55);
  color: #e8eaf0;
}

.dir-toggle-btn.active-fx {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
  color: #e8eaf0;
}

/* ── Call/Put toggle ──────────────────────────────────────────────────── */

.cp-toggle {
  display: flex;
  gap: 4px;
  width: 100%;
}

.cp-toggle-btn {
  flex: 1;
  padding: 5px 4px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font, Inter, sans-serif);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--sidebar-accent-dim);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  outline: none;
  border-radius: 4px;
  box-sizing: border-box;
  min-height: 36px;
}

.cp-toggle-btn.active-call {
  background: rgba(96, 165, 250, 0.25);
  border-color: rgba(96, 165, 250, 0.6);
  color: #e8eaf0;
}

.cp-toggle-btn.active-put {
  background: rgba(251, 191, 36, 0.22);
  border-color: rgba(251, 191, 36, 0.6);
  color: #e8eaf0;
}

.cp-toggle-btn:hover:not(.active-call):not(.active-put) {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

[data-theme="light"] .dir-toggle-btn.active {
  background: rgba(79, 143, 247, 0.12);
  border-color: rgba(79, 143, 247, 0.45);
  color: #2563eb;
}
[data-theme="light"] .dir-toggle-btn.active-equity {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  color: #1d4ed8;
}
[data-theme="light"] .dir-toggle-btn.active-fx {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
  color: #0284c7;
}
[data-theme="light"] .cp-toggle-btn.active-call {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.5);
  color: #2563eb;
}
[data-theme="light"] .cp-toggle-btn.active-put {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.5);
  color: #b45309;
}

/* FX currency subtitle under Call/Put */
.cp-fx-sub {
  display: block;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  opacity: 0.7;
  margin-top: 1px;
  line-height: 1.1;
}

/* (legacy .pricer-action-btn removed — replaced by shared .btn .btn-ghost) */

/* ── Portfolio summary ──────────────────────────────────────────────────── */

.portfolio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.portfolio-label {
  font-size: 0.85rem;
  color: var(--text);
}

.portfolio-value {
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.portfolio-value.positive { color: var(--positive); }
.portfolio-value.negative { color: var(--negative); }
.portfolio-value.neutral  { color: var(--text-muted); }

/* ── Leg +/− buttons (header) ───────────────────────────────────────────── */

.leg-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* (legacy .pricer-btn-sm removed — replaced by shared .btn .btn-ghost .btn-sm) */

/* Link/unlink button next to row labels in the FX & equity pricers.
   Unlinked is the standout state (accent fill and icon, faint accent border)
   so a broken link is easy to spot. Linked (.active, below) is the muted default. */
.link-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  line-height: 1;
  background: color-mix(in srgb, var(--color-accent) 12%, var(--bg-elevated));
  color: var(--color-accent-text);
  border: 1px solid color-mix(in srgb, var(--color-accent) 25%, var(--border));
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.link-toggle:hover {
  background: color-mix(in srgb, var(--color-accent) 18%, var(--bg-elevated));
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}
/* Linked = the quiet default for most rows: it blends into the elevated
   surface with a muted icon and neutral border. */
.link-toggle.active {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}
.link-toggle.active:hover {
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}

/* Linked follower columns (leg 2+) are disabled so only leg 1, the master,
   stays editable. Dim them + not-allowed cursor so a linked row is visibly
   distinct from an unlinked one. Mirrors the XCS pricer grid. */
.pricer-grid input:disabled,
.pricer-grid select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Pricer Grid — now in components.css */

/* ── Charts tab ─────────────────────────────────────────────────────────── */

.charts-tab-wrapper {
  max-width: 100%;
}

.charts-controls {
  margin-bottom: 12px;
}

.charts-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.charts-control-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.charts-control-row select {
  padding: 5px 8px;
  font-size: 0.85rem;
  font-family: var(--font);
  background-color: var(--bg-input);
  border: 1px solid var(--sidebar-accent-dim);
  border-radius: 4px;
  color: var(--text);
}

/* ── Portfolio tab ──────────────────────────────────────────────────────── */

.portfolio-tab-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.portfolio-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.portfolio-placeholder h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.portfolio-placeholder p {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Multi-Asset tab — scenario comparison ───────────────────────────────────
   Reuses the equity `pricer-grid` and the real #options-sidebar (`sb-*` chrome)
   verbatim. Only the scenario-specific additions live here. */

/* Scenario column header ("<Option type> <letter>"), centred. Specific enough
   to beat `.pricer-grid thead th` (which right-aligns headers). */
.ma-grid thead th.ma-scn-head { text-align: center; text-transform: none; }

/* Two sub-columns per scenario: asset sub-labels + a separator before each
   scenario wrapper. */
/* Specific enough to beat `.pricer-grid thead th` (which right-aligns + enlarges
   headers); keep the asset sub-labels small, muted and centred. */
.ma-grid thead th.ma-sub-head {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 4px;
}
.ma-grid .ma-scn-sep { border-left: 1px solid var(--border); }

/* Inputs/selects fill their (now narrower) sub-cell */
.ma-grid td input.pricer-input,
.ma-grid td select { width: 100%; box-sizing: border-box; }

/* Primary value row */
.ma-primary-row .result-val { font-size: 1.05rem; font-weight: 600; color: var(--text); }

/* All numeric cells + inputs render in the mono font (platform convention) */
.ma-grid .result-val,
.ma-grid input.pricer-input { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Comparison-sidebar tools (rendered inside the real #options-sidebar) */
.ma-side-chart { width: 100%; height: 200px; margin-top: 8px; }
.ma-chart-clickable { cursor: pointer; }
.ma-side-note {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-top: 8px;
}
.ma-chart-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 40px 0;
}

/* ── Var & Vol Swaps tab ─────────────────────────────────────────────────── */

/* Deep-dive buttons live in the real #options-sidebar — stack them vertically
   in the narrow column. */
.vs-deepdive-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.vs-deepdive-btn {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.vs-deepdive-btn:hover {
  background: rgba(79, 143, 247, 0.08);
  border-color: var(--color-accent);
  color: var(--color-accent-text);
}

/* Deep-dive dialog body styling lives in components.css (.deepdive*), shared
   with the credit convertible pricing modal. The deep-dive launch buttons
   (.vs-deepdive-row / .vs-deepdive-btn) above remain options-specific. */

/* ── Var & Vol Swaps — equity pricer-grid reuse ─────────────────────────────
   Scalar input + results tables use the shared `pricer-grid` (grid_kit). Mono
   numbers + a slightly larger primary row mirror the multi-asset tab. */
.vs-grid .result-val,
.vs-grid input.pricer-input { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.vs-primary-row .result-val { font-size: 1.05rem; font-weight: 600; color: var(--text); }

/* Overlay comparison chart in the real #options-sidebar */
.vs-side-chart { width: 100%; height: 200px; margin-top: 8px; cursor: pointer; }
.vs-side-note {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Context rows (Forward, ATM Vol) — informational, subtler than the priced rows */
.vs-grid .vs-ctx-row .result-val { color: var(--text-secondary); }


/* Column header: a centred A/B/C letter above the per-column Buy/Sell toggle.
   Bottom-align every header cell so the toggles line up with the +/- buttons. */
.vs-grid thead th { vertical-align: bottom; }
.vs-grid thead th.vs-col-head { text-align: center; cursor: pointer; }
/* Active column (the one the sidebar sliders edit) is shown by emphasising its
   letter, not with a background. */
.vs-col-head .vs-col-letter { font-weight: 600; color: var(--text-muted); margin-bottom: 9px; transition: color 0.12s; }
.vs-col-head:hover .vs-col-letter { color: var(--text-secondary); }
.vs-col-head.active .vs-col-letter { color: var(--text); font-weight: 700; }

/* Sidebar smile-shape sliders (edit the active column) */
.vs-active-tag { font-weight: 400; }
.vs-active-tag .ma-scn-chip { margin-left: 6px; }
.vs-slider { display: flex; flex-direction: column; gap: 3px; margin-bottom: 11px; }
.vs-slider-label { font-size: 0.75rem; color: var(--text-secondary); }
.vs-slider-row { display: flex; align-items: center; gap: 8px; }
.vs-slider-range { flex: 1; min-width: 0; accent-color: var(--color-accent); cursor: pointer; }
.vs-slider-num {
  width: 58px;
  padding: 3px 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: right;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  outline: none;
}
.vs-slider-num:focus { border-color: var(--color-accent); }

/* Mark-a-live-trade rows live inside the main grid table, so their columns line
   up exactly with the pricing columns. */
.vs-grid .vs-mtm-head { cursor: pointer; user-select: none; }
.vs-grid .vs-mtm-head td { text-transform: none; letter-spacing: 0.02em; font-size: 0.95rem; }
.vs-mtm-head .vs-mtm-caret { font-size: 0.7rem; display: inline-block; width: 0.9em; }
.vs-grid .vs-mtm-value .result-val { font-weight: 700; }

/* Editable contract-strike cell: teal solver input + inline =Fair reset. */
.vs-strike-cell { display: flex; align-items: center; gap: 4px; }
.vs-strike-cell .npv-solver-input { flex: 1; min-width: 0; }
.vs-strike-cell .vs-strike-reset { flex: none; }
.vs-mtm-note {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
  padding: 8px 12px 0;
  max-width: 620px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

[data-theme="light"] .sidebar-heading {
  color: rgba(0,0,0,0.6);
}

.sidebar-select option {
  background-color: var(--bg-input);
  color: var(--text);
}


[data-theme="light"] .sidebar-checkbox {
  color: rgba(0,0,0,0.72);
}

[data-theme="light"] .dir-toggle-btn.active {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.4);
  color: var(--info);
}

[data-theme="light"] .dir-toggle-btn.active-equity {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--info);
}

[data-theme="light"] .dir-toggle-btn.active-fx {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.45);
  color: #0ea5e9;
}

[data-theme="light"] .cp-toggle-btn {
  border-color: rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.02);
  color: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .cp-toggle-btn.active-call {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.5);
  color: #1e3a5f;
}

[data-theme="light"] .cp-toggle-btn.active-put {
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.5);
  color: #78350f;
}

[data-theme="light"] .portfolio-value.neutral  { color: rgba(0,0,0,0.35); }

[data-theme="light"] .charts-control-row label {
  color: rgba(0,0,0,0.55);
}

[data-theme="light"] .portfolio-placeholder {
  color: rgba(0,0,0,0.35);
}

[data-theme="light"] .portfolio-placeholder h2 {
  color: rgba(0,0,0,0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FX OPTIONS — CONTROLS BAR (above standard pricer grid)
   ═══════════════════════════════════════════════════════════════════════════ */

.fx-controls-bar {
  margin-bottom: 12px;
}

.fx-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fx-controls-inner {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--sidebar-accent-dim);
  border-radius: 6px;
}

.fx-ctrl-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.fx-ctrl-select {
  padding: 4px 8px;
  font-size: 0.85rem;
  font-family: var(--font, Inter, sans-serif);
  background-color: var(--bg-input);
  border: 1px solid var(--sidebar-accent-dim);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;

  outline: none;
  transition: border-color var(--transition);
}
.fx-ctrl-select:focus {
  border-color: var(--sidebar-accent);
}
.fx-ctrl-select option {
  background-color: var(--bg-input);
  color: var(--text);
}

.fx-tenor-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.fx-tenor-group .fx-ctrl-label { margin-right: 4px; }

.fx-tenor-pill {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font, Inter, sans-serif);
  letter-spacing: 0.02em;
  border: 1px solid var(--sidebar-accent-dim);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  outline: none;
  border-radius: 4px;
}
.fx-tenor-pill.active {
  background: rgba(79,143,247,0.2);
  border-color: rgba(79,143,247,0.5);
  color: #4f8ff7;
}
.fx-tenor-pill:hover:not(.active) {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.fx-surface-btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font, Inter, sans-serif);
  border: 1px solid rgba(79,143,247,0.35);
  background: rgba(79,143,247,0.1);
  color: #4f8ff7;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}
.fx-surface-btn:hover { background: rgba(79,143,247,0.2); }
.fx-surface-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.fx-hidden { display: none !important; }

/* Vol surface dialog tabs */
.fx-surf-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}
.fx-surf-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font, Inter, sans-serif);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-bottom-color 0.15s;
}
.fx-surf-tab.active {
  color: #4f8ff7;
  border-bottom: 2px solid #4f8ff7;
}
.fx-surf-tab:hover:not(.active) {
  color: var(--text-secondary);
}

/* Flat/SABR mode toggle in surface dialog */
.fx-surf-mode-toggle {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 0;
  margin-right: 0;
}
.fx-mode-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font, Inter, sans-serif);
  font-weight: 600;
  border: 1px solid var(--sidebar-accent-dim);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.fx-mode-btn:first-child { border-radius: 4px 0 0 4px; }
.fx-mode-btn:nth-child(2) { border-radius: 0 4px 4px 0; border-left: none; }
.fx-mode-btn.active {
  background: rgba(79,143,247,0.15);
  border-color: rgba(79,143,247,0.4);
  color: #4f8ff7;
}
.fx-model-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: #4f8ff7;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  opacity: 0.7;
}
.fx-model-info-btn:hover {
  opacity: 1;
  background: rgba(79,143,247,0.12);
}

/* Vol surface table */
.fx-vol-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-family: var(--font, Inter, sans-serif);
}
.fx-vol-table th {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.fx-vol-table td {
  padding: 8px 12px;
  text-align: center;
}
.fx-vt-label {
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center !important;
}
.fx-vt-input {
  width: 80px;
  padding: 5px 7px;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--sidebar-accent-dim);
  border-radius: 4px;
  background: var(--bg-surface);
  color: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.fx-vt-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(46,109,164,0.2);
}
.fx-vt-ro {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.fx-vol-table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 0 4px;
}
.fx-vol-ov-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-family: var(--font, Inter, sans-serif);
  font-weight: 600;
  border: 1px solid rgba(79,143,247,0.4);
  border-radius: 4px;
  background: rgba(79,143,247,0.12);
  color: #4f8ff7;
  cursor: pointer;
  transition: background 0.15s;
}
.fx-vol-ov-btn:hover {
  background: rgba(79,143,247,0.25);
}
.fx-vol-ov-reset {
  border-color: var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.fx-vol-ov-reset:hover {
  background: var(--bg-elevated);
}

/* ── FX Controls Bar — Light Theme ──────────────────────────────────────── */

[data-theme="light"] .fx-controls-inner {
  background: rgba(0,0,0,0.02);
  border-color: var(--sidebar-accent-dim);
}
[data-theme="light"] .fx-ctrl-label { color: rgba(0,0,0,0.55); }
[data-theme="light"] .fx-tenor-pill {
  border-color: var(--sidebar-accent-dim);
  background: rgba(0,0,0,0.02);
  color: rgba(0,0,0,0.4);
}
[data-theme="light"] .fx-tenor-pill.active {
  background: rgba(37,99,235,0.1);
  border-color: rgba(37,99,235,0.4);
  color: #2563eb;
}
[data-theme="light"] .fx-surface-btn {
  border-color: rgba(37,99,235,0.3);
  background: rgba(37,99,235,0.08);
  color: #2563eb;
}
[data-theme="light"] .fx-surf-tabs {
  border-bottom-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .fx-surf-tab {
  color: rgba(0,0,0,0.4);
}
[data-theme="light"] .fx-surf-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}
[data-theme="light"] .fx-mode-btn {
  border-color: var(--sidebar-accent-dim);
  color: rgba(0,0,0,0.35);
}
[data-theme="light"] .fx-mode-btn.active {
  background: rgba(37,99,235,0.1);
  border-color: rgba(37,99,235,0.3);
  color: #2563eb;
}
[data-theme="light"] .fx-model-info-btn {
  color: #2563eb;
}
[data-theme="light"] .fx-model-info-btn:hover {
  background: rgba(37,99,235,0.08);
}
[data-theme="light"] .fx-vol-table th {
  color: rgba(0,0,0,0.5);
  border-bottom-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .fx-vt-label { color: rgba(0,0,0,0.7); }
[data-theme="light"] .fx-vt-input {
  background: rgba(0,0,0,0.03);
  border-color: var(--sidebar-accent-dim);
  color: var(--text);
}
[data-theme="light"] .fx-vt-ro { color: rgba(0,0,0,0.35); }
[data-theme="light"] .fx-vol-ov-btn {
  border-color: rgba(37,99,235,0.3);
  background: rgba(37,99,235,0.08);
  color: #2563eb;
}
[data-theme="light"] .fx-vol-ov-reset {
  border-color: rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.5);
}

/* ── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .options-module .tab-content-area { max-width: 100%; }
}
@media (max-width: 768px) {
  .options-sidebar-toggle { display: none; }
  .pricer-grid { font-size: 0.82rem; }
  .pricer-grid-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Match the standard-module mobile pattern: the outer module wrapper
     becomes the unified scroll container, and inner panels flow content
     visibly. .options-module plays the role of .workspace-content; the
     inner .options-content / .options-reference flow into it just like
     .tab-content-area does in other modules. Without this, the chapter
     indicator listener has no scroll surface to attach to once the
     inner .ref-sub-panel stops scrolling. */
  .options-module {
    overflow-y: auto;
    overflow-x: hidden;
  }
  /* overflow-x: clip (not hidden) keeps the horizontal containment that
     stops touch-drag of the pricer-grid from pulling the whole content
     area sideways — but unlike `hidden`, `clip` doesn't establish a
     scroll context, so vertical scroll falls through to .options-module
     instead of getting trapped inside .options-content. */
  .options-content {
    overflow-x: clip;
    overflow-y: visible;
    /* flex:1 child of the .options-module row; without a min-width the
       flexbox min-content floor lets wide children (the controls bar,
       charts) push the whole column wider than the phone viewport, and
       overflow-x: clip then cuts the right side off with no way to
       scroll to it. min-width: 0 keeps the column at viewport width;
       wide inner content scrolls in its own wrappers instead
       (.pricer-grid-container above). */
    min-width: 0;
  }
  /* The FX/equity controls bar (Asset / Template selectors) held its full
     one-line width and was clipped by .options-content. Wrap it instead
     so every control stays visible and tappable on phones. */
  .fx-controls-row { flex-wrap: wrap; row-gap: 8px; }
  .fx-controls-inner { flex-wrap: wrap; row-gap: 8px; }
  .options-reference {
    overflow: visible;
    flex: none;
    min-height: 0;
  }
  .options-forward-ladder { min-width: 0; overflow-x: auto; }
  .options-chart-container { min-height: 240px; }

  /* Mobile drawer for the options-sidebar — matches the global
     .params-sidebar drawer pattern so the shared mobile FAB can open
     and close it. Without this the sidebar stays in flow at full
     width, pushing the pricer off-screen. */
  .options-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    z-index: var(--z-sidebar);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    background: var(--bg-surface);
  }
  .options-sidebar.drawer-open {
    transform: translateX(0);
  }
}

/* ── Market data loading: skeleton + status banner ──────────────────────── */

.market-data-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.market-data-status--error {
  background: rgba(220, 53, 69, 0.08);
  color: var(--negative);
  border-color: rgba(220, 53, 69, 0.35);
}

.market-data-status-msg {
  flex: 1;
  line-height: 1.35;
}

.market-data-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  animation: em-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.market-data-retry {
  margin: 0 !important;
  flex-shrink: 0;
}

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

[data-theme="light"] .market-data-status {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .market-data-status--error {
  background: rgba(220, 53, 69, 0.06);
}

/* Skeleton state: visually hide input/result text and animate shimmer bars.
   Activated by toggling .loading-skeleton on .pricer-grid. */
.pricer-grid.loading-skeleton .pricer-input,
.pricer-grid.loading-skeleton .notional-input {
  pointer-events: none;
  color: transparent !important;
  caret-color: transparent;
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 50%,
    var(--bg-elevated) 100%
  ) !important;
  background-size: 200% 100% !important;
  animation: em-shimmer 1.4s ease-in-out infinite;
}

.pricer-grid.loading-skeleton .result-val {
  display: inline-block;
  min-width: 70%;
  height: 1em;
  border-radius: 3px;
  color: transparent;
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: em-shimmer 1.4s ease-in-out infinite;
  vertical-align: middle;
}

.pricer-grid.loading-skeleton select.option-type,
.pricer-grid.loading-skeleton .link-toggle,
.pricer-grid.loading-skeleton .dir-toggle,
.pricer-grid.loading-skeleton .cp-toggle,
.pricer-grid.loading-skeleton .formula-btn {
  pointer-events: none;
  opacity: 0.55;
}

@keyframes em-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

[data-theme="light"] .pricer-grid.loading-skeleton .pricer-input,
[data-theme="light"] .pricer-grid.loading-skeleton .notional-input,
[data-theme="light"] .pricer-grid.loading-skeleton .result-val {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.04) 0%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 100%
  ) !important;
  background-size: 200% 100% !important;
}

/* ════════════════════════════════════════════════════════════════════════
   Portfolio tab (Equity & FX Options book)
   Metric/table primitives mirror the rates portfolio tab but are themed with
   CSS variables so they work in both light and dark without per-theme blocks.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar metrics ── */
.pf-sidebar { display: flex; flex-direction: column; }

.pf-metrics-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pf-metrics-section:last-child { border-bottom: none; }

.pf-section-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.pf-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 0.92rem;
}
.pf-metric-label { color: var(--text-secondary); font-weight: 500; }
.pf-metric-value {
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
  font-family: var(--font-mono);
  color: var(--text);
}
.pf-metric-value.positive { color: var(--positive); }
.pf-metric-value.negative { color: var(--negative); }
.pf-metric-value.neutral  { color: var(--text-muted); }

.pf-pnl-section {
  background: rgba(20, 184, 166, 0.05);
  border-radius: var(--r-md);
  padding: 10px;
  margin: 2px -10px;
}
.pf-pnl-divider { border-top: 1px solid var(--border); margin: 4px 0; }

.pf-actions { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }

/* ── Shock controls ── */
.pf-shock { margin-bottom: 12px; }
.pf-shock:last-child { margin-bottom: 4px; }
.pf-shock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.pf-shock-label { color: var(--text-secondary); font-weight: 600; }
.pf-shock-input {
  width: 56px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  padding: 2px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
}
.pf-shock-input:focus { border-color: var(--color-accent); outline: none; }
.pf-shock-unit { color: var(--text-muted); font-size: 0.75rem; }

/* ── Content ── */
/* Cap the dashboard width so it does not stretch edge-to-edge on wide monitors.
   Left-aligned, so the analytics stay beside the shock controls in the sidebar
   rather than drifting away from them. */
.pf-content { padding: 4px 2px 24px; max-width: 1500px; }
.pf-muted { color: var(--text-muted); font-size: 0.85rem; }
.pf-book-head { font-size: 0.92rem; color: var(--text-secondary); margin-bottom: 10px; }
.pf-book-head strong { color: var(--text); }

.pf-empty-state {
  text-align: center;
  max-width: 560px;
  margin: 60px auto 0;
  padding: 0 20px;
}
.pf-empty-state h3 { margin: 0 0 14px; font-size: 1.1rem; color: var(--text); }
.pf-empty-state p { margin: 0 0 14px; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; }
.pf-empty-state p.pf-muted { color: var(--text-muted); font-size: 0.85rem; }

.pf-section-block { margin-top: 22px; }

/* Hairline between the holdings (position table) and the analytics below it, so
   the two zones read as distinct. Reuses the shared .section-divider primitive;
   this scope only tightens the rhythm so the first group label sits close. */
.pf-analytics-divider { margin: 14px 0 0; }

/* Family heading above each analytics group (Current risk / Sensitivities /
   Stress & scenarios). Uppercase + tracking ranks it a tier above the
   sentence-case panel titles (.pf-block-title) without adding weight or colour
   noise. Mirrors the sidebar .pf-section-label treatment. */
.pf-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 24px 0 10px;
}
.pf-group-label:first-of-type { margin-top: 16px; }
/* The grid hugs its label — the label supplies the top separation, so drop the
   grid's own top margin when it directly follows a label. */
.pf-group-label + .pf-grid-2 { margin-top: 0; }

/* Two-up layout for the vega grid + charts so they are not stretched full width.
   The position table above stays full width (it has many columns). */
.pf-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  align-items: start;
  margin-top: 22px;
}
.pf-grid-2 > .pf-section-block { margin-top: 0; }
@media (max-width: 1000px) {
  .pf-grid-2 { grid-template-columns: 1fr; }
}

/* Sensitivity-explorer dropdown row */
.pf-expl-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 4px 0 10px;
}
.pf-expl-controls select { width: auto; min-width: 92px; }

.pf-block-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
details.pf-section-block > summary.pf-block-title { cursor: pointer; }

/* ── Position table ── */
.pf-group-header td {
  font-weight: 700;
  font-size: 0.82rem;
  padding: 10px 8px 4px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.pf-error-icon { color: var(--negative); cursor: help; font-size: 0.9rem; margin-right: 4px; }

.pf-pos-row[draggable]:hover { background: rgba(127, 127, 127, 0.06); }
.pf-drop-indicator td {
  height: 2px !important;
  padding: 0 !important;
  background: var(--color-accent) !important;
}

/* ── Drill-down detail ── */
.pf-detail-row td.pf-detail-cell {
  padding: 12px 16px;
  background: rgba(127, 127, 127, 0.05);
  border-bottom: 1px solid var(--border);
}
.pf-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  max-width: 720px;
}
.pf-detail-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pf-detail-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
  font-size: 0.82rem;
}
.pf-detail-key { color: var(--text-muted); white-space: nowrap; }
.pf-detail-val {
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: lining-nums tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* ── Vega-bucket grid (heatmap-style table) ── */
.pf-vega-grid-wrap { overflow-x: auto; }
.pf-vega-grid {
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.pf-vega-grid th {
  padding: 6px 10px;
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pf-vega-grid tbody th { text-align: left; }
.pf-vega-sub {
  display: block;
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.pf-vega-grid td {
  padding: 6px 10px;
  text-align: right;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  min-width: 78px;
}
/* Zero cells: shown as "0.00" but muted so the populated cells stand out. */
.pf-vega-grid td.pf-vega-zero { color: var(--text-muted); }

/* Stress matrix reuses the vega-grid look but has more columns and short values
   (e.g. "-1.3M"), so it would overrun the vega grid's 78px cell floor and need a
   horizontal scrollbar inside its grid cell. Tighten the cells so the whole
   heatmap fits, and read denser, in both books. */
.pf-stress-grid th,
.pf-stress-grid td { min-width: 48px; padding: 5px 7px; }

/* Stress matrix reuses the vega-grid look; outline the live (current) shock cell
   so "you are here" stands out against the green/red P&L shading. */
.pf-stress-grid td.pf-stress-cur {
  box-shadow: inset 0 0 0 2px var(--color-accent);
  font-weight: 700;
}

/* Equity | FX book switch — sits above the position table (reuses .dir-toggle). */
.pf-book-toggle { width: 240px; margin-bottom: 16px; }

/* ── Remove button ── */
