    :root {
      color-scheme: light;
      --bg: #f0f2f5;
      --surface: #ffffff;
      --surface-muted: #f7f8fa;
      --text: #1c1e21;
      --muted: #65676b;
      --accent: #1877f2;
      --accent-strong: #166fe5;
      --border: #d9dde3;
      --border-light: #e6e8eb;
      --border-chart: #e6e8eb;
      --input-bg: #ffffff;
      --chart-bg: #ffffff;
      --grid-color: rgba(176,184,196,0.24);
      --hover-bg: rgba(255,255,255,0.98);
      --hover-border: #7f8ea3;
      --legend-bg: rgba(255,255,255,0.96);
      --legend-border: rgba(207,214,228,0.8);
      --marker-edge: #ffffff;
      --status-pill-bg: #edf3ff;
      --status-pill-text: #1b4ea3;
      --status-dot: #31a24c;
      --weekend-line: rgba(244, 128, 36, 0.45);
      --brand-grad-from: #2d88ff;
      --brand-grad-to: #1877f2;
      --shadow: 0 1px 2px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
      --topbar-bg: rgba(255,255,255,0.94);
      --warn: #b8860b;
      --error-text: #b42318;
      --atm-row-bg: #dff5d6;
    }
    [data-theme="dark"] {
      color-scheme: dark;
      --bg: #0d1117;
      --surface: #161b22;
      --surface-muted: #1c2128;
      --text: #e6edf3;
      --muted: #8b949e;
      --accent: #4493f8;
      --accent-strong: #316dca;
      --border: #30363d;
      --border-light: #21262d;
      --border-chart: #21262d;
      --input-bg: #0d1117;
      --chart-bg: #0d1117;
      --grid-color: rgba(110,118,129,0.24);
      --hover-bg: rgba(22,27,34,0.98);
      --hover-border: #444c56;
      --legend-bg: rgba(22,27,34,0.96);
      --legend-border: rgba(48,54,61,0.8);
      --marker-edge: rgba(0,0,0,0);
      --status-pill-bg: rgba(56,139,253,0.15);
      --status-pill-text: #79c0ff;
      --status-dot: #3fb950;
      --weekend-line: rgba(255, 171, 64, 0.5);
      --topbar-bg: rgba(13,17,23,0.94);
      --error-text: #f85149;
      --atm-row-bg: #1c3a22;
    }
    * { box-sizing: border-box; }
    html, body {
      height: 100vh; margin: 0; overflow: hidden;
      font-family: Helvetica, Arial, sans-serif;
      background: var(--bg); color: var(--text);
    }
    .app-shell { display: flex; flex-direction: column; height: 100vh; }
    .topbar {
      height: 60px; background: var(--topbar-bg);
      backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
      border-bottom: 1px solid var(--border-light);
      display: flex; align-items: center;
    }
    .topbar-inner {
      width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 20px;
      display: flex; align-items: center; gap: 12px;
    }
    .brand { display: flex; align-items: center; gap: 12px; }
    .brand-badge {
      width: 38px; height: 38px; border-radius: 12px;
      background: linear-gradient(135deg, var(--brand-grad-from), var(--brand-grad-to));
      color: #fff; display: flex; align-items: center; justify-content: center;
      font-size: 20px; font-weight: 800;
    }
    .brand-title { font-size: 0.98rem; font-weight: 700; line-height: 1.2; }
    .brand-subtitle { font-size: 0.82rem; color: var(--muted); }
    .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
    .theme-toggle {
      width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border);
      background: var(--surface); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center;
    }
    .status-pill {
      display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
      border-radius: 999px; background: var(--status-pill-bg); color: var(--status-pill-text);
      font-size: 0.8rem; font-weight: 600;
    }
    .status-dot {
      width: 8px; height: 8px; border-radius: 50%; background: var(--status-dot);
    }
    /* Inline mini progress bar inside the status pill. Hidden until a fetch /
       reconcile sets a width via setStatusProgress(); collapses back to 0 when
       the job ends so it never lingers as a stray sliver. */
    .status-progress {
      display: none; width: 64px; height: 5px; border-radius: 999px;
      background: var(--border-light); overflow: hidden; margin-left: 2px;
    }
    .status-progress.active { display: inline-block; }
    .status-progress > span {
      display: block; height: 100%; width: 0; background: var(--status-dot);
      border-radius: 999px; transition: width 0.3s;
    }
    .status-progress.indeterminate > span {
      width: 40% !important; animation: status-indet 1.1s ease-in-out infinite;
    }
    @keyframes status-indet {
      0% { margin-left: -40%; } 100% { margin-left: 100%; }
    }
    .workspace {
      flex: 1 1 auto; min-height: 0; display: grid; gap: 16px;
      grid-template-columns: 320px minmax(0, 1fr);
      max-width: 1480px; width: 100%; margin: 0 auto; padding: 16px 20px;
      transition: grid-template-columns 0.3s ease;
    }
    .workspace.sidebar-collapsed {
      grid-template-columns: 48px minmax(0, 1fr);
    }
    .workspace.sidebar-collapsed .sidebar-scroll,
    .workspace.sidebar-collapsed .panel-head h2 {
      display: none;
    }
    .workspace.sidebar-collapsed .panel-head {
      justify-content: center;
      padding: 14px 0;
    }
    .card {
      background: var(--surface); border: 1px solid var(--border-light);
      border-radius: 18px; box-shadow: var(--shadow);
    }
    .sidebar { display: flex; flex-direction: column; min-height: 0; overflow: hidden; transition: all 0.3s ease; }
    .sidebar-scroll { overflow-y: auto; padding: 16px; }
    .panel-head {
      padding: 14px 16px; border-bottom: 1px solid var(--border-light);
      background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
      border-radius: 18px 18px 0 0;
      display: flex; justify-content: space-between; align-items: center;
    }
    .panel-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
    .sidebar-toggle {
      background: none; border: none; color: var(--muted); cursor: pointer;
      font-size: 1.2rem; padding: 0 4px; display: flex; align-items: center; justify-content: center;
      line-height: 1; transition: color 0.2s;
    }
    .sidebar-toggle:hover { color: var(--text); }
    .field { margin-bottom: 14px; }
    .field label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
    .field-head { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
    .field-head label { margin: 0; }
    .field select, .field input[type=date], .field input[type=number] {
      width: 100%; min-height: 42px; border-radius: 10px; border: 1px solid var(--border);
      background: var(--input-bg); color: var(--text); padding: 0 12px; font-size: 0.9rem;
    }
    .field input[type=range] { width: 100%; }
    .range-row { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }
    .range-row .val { font-weight: 700; color: var(--text); }
    .window-group { display: flex; gap: 6px; }
    .window-group button {
      flex: 1; min-height: 36px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.85rem;
    }
    .window-group button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
    .mode-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
    .mode-group label {
      display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
      border: 1px solid var(--border); background: var(--surface); cursor: pointer;
      font-size: 0.85rem; font-weight: 500; color: var(--text); margin: 0;
    }
    .mode-group label:has(input:checked) { background: var(--status-pill-bg); border-color: var(--accent); }
    .overlay-check {
      display: flex; align-items: center; gap: 8px; margin-top: 8px;
      font-size: 0.85rem; font-weight: 500; color: var(--text); cursor: pointer;
    }
    .overlay-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
    .stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 4px; }
    .stat { background: var(--surface-muted); border-radius: 12px; padding: 10px; }
    .stat.full { grid-column: 1 / -1; }
    .stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
    .stat-value { font-size: 0.96rem; font-weight: 700; }
    .stat-value.small { font-size: 0.82rem; font-weight: 600; line-height: 1.35; }
    .model-panel { margin-top: 14px; border-top: 1px solid var(--border-light); padding-top: 12px; }
    .model-panel-title { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
    .stats-title { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
    .model-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
    .model-table th, .model-table td {
      border-bottom: 1px solid var(--border-light); padding: 5px 3px; text-align: right; white-space: nowrap;
    }
    .model-table th:first-child, .model-table td:first-child { text-align: left; }
    .model-table td.params { text-align: left; white-space: normal; line-height: 1.3; }
    .fetch-box { background: var(--surface-muted); border: 1px solid var(--border-light); border-radius: 12px; padding: 12px; margin-top: 8px; }
    .fetch-box .title { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
    .btn {
      width: 100%; min-height: 40px; border-radius: 10px; border: 1px solid var(--accent);
      background: var(--accent); color: #fff; cursor: pointer; font-size: 0.9rem; font-weight: 600;
    }
    .btn:disabled { opacity: 0.6; cursor: default; }
    .btn.secondary { background: var(--surface); color: var(--accent); }
    .progress-bar { height: 8px; background: var(--border-light); border-radius: 999px; overflow: hidden; margin-top: 8px; }
    .progress-bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
    .fetch-msg { font-size: 0.82rem; color: var(--muted); margin-top: 6px; min-height: 1.2em; }
    .fetch-msg.error { color: var(--error-text); }
    .warn { font-size: 0.82rem; color: var(--warn); margin: 4px 0 0; min-height: 1em; }
    .chart-area { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
    .chart-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .chart-toolbar-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
    .series-btn {
      min-height: 32px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text); cursor: pointer; padding: 0 12px; font-size: 0.82rem;
    }
    .series-btn:hover { background: var(--surface-muted); }
    .muted { color: var(--muted); font-size: 0.8rem; }
    /* Tab bar — switches the chart-area between view modes (Epic B). */
    .view-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
    .view-tabs button {
      min-height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.88rem; font-weight: 600;
    }
    .view-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
    /* Per-view control rows; hidden unless their view is active. */
    .view-controls { display: none; flex-wrap: wrap; align-items: center; gap: 12px; }
    .view-controls.active { display: flex; }
    .view-controls .inline-field { display: flex; flex-direction: column; gap: 3px; }
    .view-controls .inline-field label {
      font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
      color: var(--muted); margin: 0;
    }
    .view-controls select, .view-controls input[type=date], .view-controls input[type=number] {
      min-height: 36px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--input-bg); color: var(--text); padding: 0 10px; font-size: 0.85rem;
    }
    .view-controls input[type=number] { width: 80px; }
    /* Info-button tooltips (diagnostics panel descriptions). */
    .info-btn {
      position: relative; display: inline-flex; align-items: center;
      width: 22px; height: 22px; border-radius: 50%; border: none;
      background: transparent; color: var(--muted); font-size: 0.82rem;
      cursor: pointer; user-select: none; flex-shrink: 0;
    }
    .info-btn:hover, .info-btn:focus-visible {
      background: var(--surface-muted); color: var(--text);
    }
    .info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
    .info-popover {
      display: none; position: absolute; top: calc(100% + 6px); left: 50%;
      transform: translateX(-50%); width: 320px; z-index: 20;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px;
      font-size: 0.8rem; line-height: 1.45; color: var(--muted);
    }
    .info-popover::before {
      content: ""; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
      border: 6px solid transparent; border-bottom-color: var(--border);
    }
    .info-popover strong { color: var(--text); font-size: 0.82rem; display: block; margin-bottom: 6px; }
    .info-popover p { margin: 0; }
    .info-popover p + p { margin-top: 7px; }
    .info-popover .info-popover-strategy { color: var(--text); }
    .info-btn:hover .info-popover,
    .info-btn:focus-within .info-popover { display: block; }
    /* Floating variant: escapes sidebar's clipping overflow via position: fixed.
       Coordinates are set inline by initSidebarTooltips(); display is controlled
       by toggling the class instead of the :hover/:focus-within rules above, so
       the popover stays visible while the pointer is over the popover itself. */
    .info-popover.is-floating {
      position: fixed; transform: none; display: block;
    }
    /* Tenor checkbox field: a label span over a checkbox row (mirrors the metric
       toggle row), so it lines up with the other trends controls. */
    .view-controls .tenor-toggles-field { gap: 3px; }
    .view-controls .tenor-toggles-field .tenor-label {
      font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
      color: var(--muted);
    }
    .metric-toggles { display: flex; gap: 10px; flex-wrap: wrap; }
    .metric-toggles label {
      display: flex; align-items: center; gap: 5px; font-size: 0.82rem; cursor: pointer; color: var(--text);
    }
    .metric-toggles input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
    .metric-toggles .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
    .tooltip-check {
      display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
      color: var(--text); cursor: pointer; font-size: 0.82rem; font-weight: 500;
    }
    .tooltip-check input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
    /* Dropdown MultiSelect component for trends controls */
    .dropdown-multiselect { position: relative; display: inline-block; min-width: 220px; max-width: 100%; }
    .dropdown-multiselect__trigger {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; cursor: pointer; font-size: 0.85rem; color: var(--text);
      transition: border-color 0.15s, box-shadow 0.15s;
    }
    .dropdown-multiselect__trigger:hover { border-color: var(--accent); }
    .dropdown-multiselect__trigger:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }
    .dropdown-multiselect__trigger[aria-expanded="true"] { border-color: var(--accent); }
    .dropdown-multiselect__count { background: var(--accent); color: #fff; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; min-width: 1.5em; text-align: center; }
    .dropdown-multiselect__arrow { margin-left: auto; transition: transform 0.15s; font-size: 0.7rem; color: var(--muted); }
    .dropdown-multiselect__trigger[aria-expanded="true"] .dropdown-multiselect__arrow { transform: rotate(180deg); }

    .dropdown-multiselect__panel {
      position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 100;
      background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 8px; max-height: 320px; overflow: auto;
      display: none;
    }
    .dropdown-multiselect__panel--open { display: block; }

    .dropdown-multiselect__search { width: 100%; padding: 6px 10px; margin-bottom: 8px; font-size: 0.85rem; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--text); box-sizing: border-box; }
    .dropdown-multiselect__search:focus { outline: none; border-color: var(--accent); }

    .dropdown-multiselect__group { margin-bottom: 8px; }
    .dropdown-multiselect__group:last-child { margin-bottom: 0; }
    .dropdown-multiselect__group-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0 4px 4px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

    .dropdown-multiselect__option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; transition: background 0.1s; }
    .dropdown-multiselect__option:hover { background: var(--hover-bg); }
    .dropdown-multiselect__option:focus-within { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
    .dropdown-multiselect__swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
    .dropdown-multiselect__dash { width: 16px; height: 0; border-top: 2px solid; flex-shrink: 0; }
    .dropdown-multiselect__item-label { flex: 1; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .dropdown-multiselect__checkbox { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
    .dropdown-multiselect__option--highlighted { background: var(--hover-bg); }
    /* Overlay kinds the backend reported as empty (e.g. DVOL/HV Deribit in
       Binance-only spot mode): grayed out, not hoverable, not toggleable. */
    .dropdown-multiselect__option--disabled { cursor: default; opacity: 0.55; }
    .dropdown-multiselect__option--disabled:hover { background: transparent; }
    .dropdown-multiselect__na { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
    /* Custom trends legend: overlays the chart so adding rows no longer
       shrinks the plot area. Each metric is a row whose tenor chips lay out
       horizontally (one line per metric), unlike Plotly's native legend which
       stacks group entries vertically. Clicking a chip toggles that
       (metric × tenor) line, like a legend entry. Anchored to .chart-card
       (position: relative) and positioned below the export button. */
    .trends-legend {
      position: absolute; top: 8px; left: 12px; z-index: 4;
      max-width: calc(100% - 24px);
      padding: 8px 12px; flex-direction: column; gap: 5px;
      font-size: 0.82rem; font-family: Helvetica, Arial, sans-serif;
      color: var(--text); overflow: hidden;
      background: var(--legend-bg); border: 1px solid var(--legend-border);
      border-radius: 8px; box-shadow: var(--shadow);
    }
    .trends-legend .legend-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .trends-legend .metric-name {
      display: inline-flex; align-items: center; gap: 5px; font-weight: 600; min-width: 120px;
    }
    .trends-legend .metric-name .swatch { width: 12px; height: 12px; border-radius: 3px; }
    .trends-legend .legend-tenors { display: flex; gap: 10px; flex-wrap: wrap; }
    .trends-legend .legend-chip {
      display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
      user-select: none; opacity: 1; color: var(--text);
    }
    .trends-legend .legend-chip.hidden { opacity: 0.35; text-decoration: line-through; }
    .trends-legend .dash-sample {
      display: inline-block; width: 20px; height: 0; border-top-width: 2px; border-top-style: solid;
    }
    .trends-legend .dash-sample.dash { border-top-style: dashed; }
    .trends-legend .dash-sample.dot { border-top-style: dotted; }
    .chart-card {
      flex: 1 1 auto; min-height: 0; background: var(--chart-bg);
      border-radius: 18px; border: 1px solid var(--border-chart);
      overflow: hidden; display: flex; flex-direction: column; position: relative;
    }
    /* Cursor crosshair overlay (15_crosshair.js): a vertical line and a label
       with the resolved X value that follow the mouse over any 2D Plotly chart.
       pointer-events:none keeps it from intercepting clicks/zoom/legend chips;
       each chart container is position:relative, so the overlay anchors to it. */
    .xhair-overlay {
      position: absolute; inset: 0; z-index: 6;
      pointer-events: none; display: none; overflow: hidden;
    }
    .xhair-line {
      position: absolute; top: 0; bottom: 0; width: 0;
      border-left: 1px solid var(--accent); opacity: 0.7;
    }
    .xhair-label {
      position: absolute; top: 4px; transform: translateX(-50%);
      padding: 1px 6px; white-space: nowrap; pointer-events: none;
      font-size: 0.72rem; font-family: Helvetica, Arial, sans-serif;
      color: var(--text); background: var(--hover-bg);
      border: 1px solid var(--hover-border); border-radius: 4px;
    }
    /* Plotly plot containers fill the card; the export overlay (F.5) is sized
       by its own button/menu, not forced to 100%. */
    .chart-card > .js-plotly-plot,
    .chart-card > #chart, .chart-card > #trends-chart, .chart-card > #coverage-chart,
    .chart-card > #coverage-map-chart,
    .chart-card > #term-chart, .chart-card > #intraday-chart, .chart-card > #diag-chart,
    .chart-card > #compare-chart,
    .chart-card > #surface-chart, .chart-card > #termhm-chart, .chart-card > #dist-chart,
    .chart-card > #research-chart {
      width: 100% !important; height: 100% !important;
    }
    .chart-placeholder {
      flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
      color: var(--muted); font-size: 0.95rem;
    }
    @media (max-width: 900px) {
      html, body { overflow: auto; height: auto; }
      .workspace { grid-template-columns: 1fr; }
      .sidebar { max-height: none; }
      .chart-card { min-height: 60vh; }
    }
    /* Strike drill-down modal (Epic D.1). Opened by clicking a smile point;
       shows strike, IV, source, anchor offset, trade id/time and size/flow. */
    .modal-backdrop {
      position: fixed; inset: 0; background: rgba(0,0,0,0.5);
      display: none; align-items: center; justify-content: center; z-index: 1000;
    }
    .modal-backdrop.open { display: flex; }
    .modal {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 16px; box-shadow: var(--shadow);
      width: min(440px, 92vw); max-height: 86vh; overflow-y: auto;
      padding: 18px 20px;
    }
    .modal-head {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 12px;
    }
    .modal-title { font-size: 1.05rem; font-weight: 700; }
    .modal-close {
      width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); cursor: pointer; font-size: 16px;
      color: var(--text);
    }
    .modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
    .modal-field { background: var(--surface-muted); border-radius: 10px; padding: 9px 11px; }
    .modal-field .k { font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.04em; color: var(--muted); }
    .modal-field .v { font-size: 0.92rem; font-weight: 700; color: var(--text); word-break: break-all; }
    .modal-field.full { grid-column: 1 / -1; }
    .modal-hint { font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
    /* Data loading modal: wider than the strike modal so the dates coverage map
       has room; two stacked sections (fetch + coverage map). Opened from the
       topbar "Данные" button so the sidebar stays focused on analysis params. */
    .modal.modal-data { width: min(720px, 94vw); }
    .data-modal-body { display: flex; flex-direction: column; gap: 16px; }
    .data-modal-body .field { margin-bottom: 0; }
    .data-coverage-section { display: flex; flex-direction: column; gap: 6px; }
    .data-coverage-head {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
    }
    .data-coverage-title { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
    .data-coverage-map {
      max-height: 340px; overflow-y: auto; border: 1px solid var(--border-light);
      border-radius: 10px; background: var(--surface-muted);
    }
    .cov-row {
      display: grid; grid-template-columns: 1fr auto auto; align-items: center;
      gap: 10px; padding: 7px 12px; cursor: pointer; border-bottom: 1px solid var(--border-light);
      font-size: 0.84rem;
    }
    .cov-row:last-child { border-bottom: none; }
    .cov-row:hover { background: var(--status-pill-bg); }
    .cov-row.active { background: var(--status-pill-bg); font-weight: 700; }
    .cov-date { font-variant-numeric: tabular-nums; color: var(--text); }
    .cov-cells { display: flex; gap: 6px; }
    .cov-cell {
      display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem;
      font-weight: 600; color: var(--muted);
    }
    .cov-cell .pip { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
    .cov-cell .pip.full { background: var(--status-dot); }
    .cov-cell .pip.partial { background: var(--warn); }
    .cov-cell .pip.none { background: transparent; border: 1px solid var(--border); }
    .data-coverage-hint {
      font-size: 0.74rem; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    }
    .data-coverage-hint .dot {
      display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 2px 0 6px;
    }
    .data-coverage-hint .dot-full { background: var(--status-dot); }
    .data-coverage-hint .dot-partial { background: var(--warn); }
    .data-coverage-hint .dot-none { background: transparent; border: 1px solid var(--border); }
    .data-coverage-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 0.84rem; }
    .data-btn { min-height: 34px; font-size: 0.85rem; padding: 0 14px; }
    .sidebar { position: relative; }
    .sidebar.disabled .sidebar-scroll { opacity: 0.4; pointer-events: none; user-select: none; }
    /* Export dropdown (Epic F.5): floats over the top-right of the chart card,
       visible across all views. PNG via Plotly.downloadImage; CSV/JSON from the
       already-fetched data of the active view (filters applied). */
    .export-wrap { position: absolute; top: 8px; right: 10px; z-index: 5; }
    .export-btn {
      min-height: 30px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text); cursor: pointer;
      padding: 0 10px; font-size: 0.8rem; font-weight: 600;
    }
    .export-btn:hover { background: var(--surface-muted); }
    .export-menu {
      display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; min-width: 130px;
    }
    .export-menu.open { display: block; }
    .export-menu button {
      display: block; width: 100%; text-align: left; border: none;
      background: var(--surface); color: var(--text); cursor: pointer;
      padding: 8px 12px; font-size: 0.82rem;
    }
    .export-menu button:hover { background: var(--surface-muted); }

    /* ---------- Strategy builder (Конструкции) ---------- */
    .strat-fields {
      display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; width: 100%;
    }
    .strat-fields .inline-field { margin-bottom: 2px; }
    .strat-fields .inline-field:has(#strat-presets-bar) { flex: 1 1 100%; }
    .strat-fields #strat-presets-bar { row-gap: 4px; }
    .strat-fields input[type="range"] { width: 120px; vertical-align: middle; }
    /* Strike select: six-digit strikes (100000+) must fit without truncation.
       150px covers 6-значные страйки BTC plus the dropdown chrome. */
    .strat-fields #strat-strike { width: 150px; }
    .strat-fields .val { display: inline-block; min-width: 28px; font-variant-numeric: tabular-nums; }
    .strat-fields #strat-target-slider { width: 180px; }
    .strat-fields #strat-target-slider:disabled { opacity: 0.4; }
    .strat-fields #strat-target-slider-val { min-width: 124px; font-size: 0.78rem; }
    .strat-desk-wrap, .strat-builder-wrap {
      display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0;
    }
    .strat-desk-meta { font-size: 0.82rem; color: var(--text-muted, var(--text)); margin: 2px 0 6px; }
    .strat-desk-scroll, .strat-legs-scroll {
      flex: 1 1 auto; min-height: 0; overflow: auto;
      border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
    }
    .strat-agg {
      font-size: 0.85rem; margin: 2px 0 6px; padding: 4px 8px; border-radius: 6px;
      background: var(--surface-muted); display: inline-block;
    }
    table.strat-desk-table {
      width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums;
    }
    table.strat-desk-table thead th {
      position: sticky; top: 0; background: var(--surface-muted); text-align: right;
      padding: 5px 8px; border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap;
    }
    table.strat-desk-table td { padding: 3px 8px; text-align: right; border-bottom: 1px solid var(--border); }
    .strat-legs-scroll table.strat-desk-table td:nth-child(1),
    .strat-legs-scroll table.strat-desk-table td:nth-child(3),
    .strat-legs-scroll table.strat-desk-table td:nth-child(4) { text-align: center; }
    .strat-legs-scroll table.strat-desk-table thead th:nth-child(1) { text-align: center; }
    table.strat-desk-table tr:hover td { background: var(--surface-muted); }
    table.strat-desk-table tr.strat-atm-row td { background: var(--atm-row-bg); }
    table.strat-desk-chain thead tr:nth-child(2) th { position: static; }
    table.strat-desk-chain .strat-call-h { text-align: center; color: var(--accent); font-size: 0.74rem; letter-spacing: 0.05em; }
    table.strat-desk-chain .strat-put-h { text-align: center; color: #d62728; font-size: 0.74rem; letter-spacing: 0.05em; }
    table.strat-desk-chain .strat-strike-h { text-align: center; }
    table.strat-desk-chain td.strat-strike-td { text-align: center; border-left: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
    table.strat-desk-chain .strat-strike { font-weight: 600; }
    table.strat-desk-chain .strat-money { font-size: 0.68rem; color: var(--muted); font-weight: 400; }
    table.strat-desk-table button { min-height: 24px; padding: 0 8px; }
    #strat-presets-bar input[type="button"] {
      width: auto; min-height: 30px; border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text); cursor: pointer; padding: 0 10px; font-size: 0.78rem; margin-right: 4px;
      flex: 0 0 auto; white-space: nowrap;
    }
    #strat-presets-bar input[type="button"]:hover { background: var(--surface-muted); }

        /* preset books switcher: colour dots shared by the builder switcher,
           the PnL mode group and the builder meta line */
        .strat-preset-dot {
          display: inline-block; width: 9px; height: 9px; border-radius: 50%;
          margin-right: 4px; vertical-align: baseline;
        }
        .strat-preset-dot-0 { background: #1f77b4; }
        .strat-preset-dot-1 { background: #ff7f0e; }
        .strat-preset-dot-2 { background: #9467bd; }

    /* desk add buttons + leg markers */
    .strat-add-grp { display: inline-flex; align-items: center; gap: 2px; }
    .strat-add-long { color: #2ca02c; font-weight: 700; }
    .strat-add-short { color: #d62728; font-weight: 700; }
    .strat-leg-marker {
      cursor: help; font-size: 0.95rem; line-height: 1; margin-left: 3px; vertical-align: middle;
      text-shadow: 0 0 2px var(--surface);
    }
    .strat-leg-marker sup { font-size: 0.62rem; font-weight: 700; vertical-align: super; }
    .strat-leg-long { color: #2ca02c; }
    .strat-leg-short { color: #d62728; }
    .strat-legend { margin-left: 6px; color: var(--muted); font-size: 0.78rem; }
    .strat-legend .strat-leg-marker { cursor: default; margin-left: 0; }
    /* floating desk-leg tooltip */
    .strat-tip {
      position: fixed; z-index: 9999; display: none; pointer-events: none;
      max-width: 320px; padding: 6px 9px; font-size: 0.78rem; line-height: 1.35;
      background: var(--hover-bg, var(--surface-muted)); color: var(--text);
      border: 1px solid var(--hover-border, var(--border)); border-radius: 6px;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    }
    /* editable constructor cells */
    .strat-side-edit, .strat-qty-edit, .strat-iv-edit, .strat-price-edit {
      min-height: 24px; padding: 0 4px; font-size: 0.8rem;
      background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
    }
    .strat-side-edit { cursor: pointer; }
    .strat-qty-edit { width: 52px; text-align: right; }
    .strat-iv-edit { width: 58px; text-align: right; }
    .strat-price-edit { width: 78px; text-align: right; }
    /* per-leg on/off checkbox: a disabled leg stays in the table but is
       excluded from every calculation (PnL, smile, aggregates, markers) */
    .strat-en-edit { cursor: pointer; accent-color: var(--accent); }
    table.strat-desk-table tr.strat-leg-off td { opacity: 0.45; }
    table.strat-desk-table tr.strat-leg-off td.strat-en-td { opacity: 1; }

    /* analytics smile panel: per-metric percentile bullet bars */
    .an-metrics-panel {
      display: none; flex-direction: row; flex-wrap: wrap; gap: 4px 18px;
      align-items: center; padding: 3px 6px; font-size: 0.78rem;
    }
    .an-metric { display: inline-flex; align-items: center; gap: 6px; }
    .an-metric-label { color: var(--muted); min-width: 76px; }
    .an-metric-track {
      position: relative; width: 120px; height: 8px; border-radius: 4px;
      background: var(--surface-muted); overflow: visible;
    }
    .an-metric-band { position: absolute; top: 0; bottom: 0; background: rgba(59, 130, 246, 0.18); }
    .an-metric-band.inner { background: rgba(59, 130, 246, 0.42); }
    .an-metric-marker { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #d62728; }
    .an-metric-value { font-variant-numeric: tabular-nums; }
