.market-history { --mh-soft: color-mix(in srgb, var(--accent) 6%, var(--card)); overflow-anchor: none; }
.mh-heading, .mh-mode-bar, .mh-data-status, .mh-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.mh-heading h2 { margin: 6px 0; }
.mh-heading .ops-field { min-width: 130px; }
.mh-eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.mh-mode-bar { margin: 20px 0 16px; flex-wrap: wrap; }
.mh-mode-switch { display: inline-flex; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-inset); }
body.gleaner-app .market-history .mh-mode-switch button { border: 0; background: transparent; color: var(--muted); box-shadow: none; }
body.gleaner-app .market-history .mh-mode-switch button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px #00000012; }
.mh-data-status { align-items: flex-start; background: var(--mh-soft); padding: 15px 18px; border: 1px solid var(--border); border-radius: 10px; }
.mh-data-status strong { font-size: 13px; }
.mh-data-status p { margin: 5px 0 0; }
.mh-stale { border-color: var(--warn); }
.mh-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.mh-toolbar, .mh-chart-toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.mh-toolbar > .ops-field { flex: 1 1 130px; min-width: 110px; max-width: 180px; }
.mh-toolbar > .mh-batch-field { flex-basis: 260px; max-width: 320px; }
.mh-toolbar > .mh-search-field { max-width: 210px; }
.mh-toolbar input, .mh-toolbar select, .mh-chart-toolbar input, .mh-chart-toolbar select { width: 100%; }
.mh-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.mh-summary > div { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--card); }
.mh-summary span { display: block; color: var(--muted); font-size: 12px; }
.mh-summary strong { display: block; margin-top: 8px; font-size: 23px; font-variant-numeric: tabular-nums; font-weight: 600; }
.mh-comparison { margin-bottom: 12px; }
.mh-table { width: 100%; }
body.gleaner-app .market-history .mh-sort { padding: 0; background: transparent; border: 0; color: inherit; font: inherit; box-shadow: none; white-space: nowrap; }
.mh-table small { display: block; margin-top: 5px; }
body.gleaner-app .market-history .mh-symbol { background: transparent; color: var(--accent); border: 0; box-shadow: none; padding: 3px 0; font: inherit; font-weight: 600; }
body.gleaner-app .market-history .mh-symbol:hover { text-decoration: underline; background: transparent; }
.mh-venues { white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1.6; }
.mh-quality { display: inline-block; color: var(--muted); background: var(--surface-inset); border-radius: 5px; padding: 4px 7px; font-size: 11px; white-space: nowrap; font-weight: 400; }
.mh-quality-missing { color: var(--warn); }
.mh-change { font-variant-numeric: tabular-nums; font-size: 12px; }
.mh-up { color: var(--ok); }.mh-down { color: var(--err); }
.mh-detail-head { margin: 24px 0 18px; }
.mh-detail-head a { font-size: 13px; }
.mh-detail-symbol { font-size: 24px; display: flex; align-items: center; gap: 12px; }
.mh-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: 20px 0; }
.mh-facts dt, .mh-raw dt { color: var(--muted); font-size: 12px; }
.mh-facts dd { margin: 7px 0 0; font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mh-chart { min-height: 360px; height: 420px; width: 100%; border: 1px solid var(--border); border-radius: 10px; margin-top: 15px; }
.mh-method { border-top: 1px solid var(--border); padding: 16px 0; }
.mh-method summary { cursor: pointer; font-weight: 500; }
.mh-method ul { color: var(--muted); font-size: 13px; line-height: 1.8; }
.mh-raw > div { display: grid; grid-template-columns: minmax(170px, .6fr) 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.mh-raw dd { margin: 0; overflow-wrap: anywhere; }
.mh-export { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.mh-export a { text-decoration: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; }
@media (max-width: 720px) {
  .mh-heading { align-items: flex-start; }.mh-heading .ops-field { min-width: 100px; }
  .mh-data-status { flex-direction: column; }.mh-actions { width: 100%; }.mh-actions button { flex: 1; }
  .mh-mode-switch { width: 100%; }body.gleaner-app .market-history .mh-mode-switch button { flex: 1; min-height: 42px; }
  .mh-toolbar > .ops-field { flex-basis: calc(50% - 6px); max-width: none; min-width: 0; }
  .mh-toolbar > .mh-batch-field { flex-basis: 100%; }
  .mh-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }.mh-summary > div { padding: 12px; }
  .mh-chart-toolbar > .ops-field { flex: 1 1 45%; }.mh-chart-toolbar { gap: 10px; }
  .mh-chart { height: 340px; min-height: 300px; }
  .mh-raw > div { grid-template-columns: 1fr; gap: 5px; }
  .mh-detail-head { align-items: flex-start; }.mh-detail-head a { text-align: right; max-width: 130px; }
}

.mh-ranking { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mh-reported { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; padding: 14px 16px; margin: 16px 0; border: 1px solid var(--border); border-radius: 8px; }
.mh-reported small { flex-basis: 100%; }
.mh-source-running { color: var(--warn); font-size: 12px; }

/* Keep the market list close to its controls; details retain the full research context. */
.market-history .mh-heading { gap: 12px; align-items: center; margin-bottom: 8px; }
.mh-heading-copy { min-width: 0; }
.mh-heading-controls { display: flex; align-items: center; flex: 0 0 auto; gap: 14px; }
.market-history .mh-heading-controls .ops-field { display: flex; flex-direction: row; align-items: center; gap: 7px; min-width: 0; }
.market-history .mh-heading-controls .ops-field > label { white-space: nowrap; }
.market-history .mh-heading-controls select { width: 115px; }
.market-history .mh-heading h2 { margin: 0; font-size: 20px; line-height: 1.35; }
.market-history .mh-eyebrow { display: none; }
.market-history .mh-heading .section-note { margin: 3px 0 0; }
.market-history .mh-mode-switch { padding: 2px; border-radius: 7px; }
body.gleaner-app .market-history .mh-mode-switch button { min-height: 30px; padding: 5px 10px; font-size: 13px; }
.market-history .mh-data-status { display: block; padding: 8px 10px; border-radius: 7px; }
.mh-status-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; }
.mh-status-line { display: flex; align-items: center; flex: 1; min-width: 0; flex-wrap: wrap; gap: 4px 12px; }
.mh-status-details-panel { margin-top: 4px; color: var(--muted); font-size: 12px; }
body.gleaner-app .market-history .mh-disclosure-toggle { display: inline-flex; align-items: center; justify-content: flex-start; flex: 0 0 auto; gap: 6px; min-height: 32px; margin: 0; padding: 5px 7px; border: 1px solid transparent; background: transparent; color: var(--accent-text); font-size: 13px; line-height: 1.5; font-weight: 400; text-align: left; box-shadow: none; }
body.gleaner-app .market-history .mh-disclosure-toggle:hover { border-color: transparent; background: var(--hover-bg); }
.mh-disclosure-toggle > span { min-width: 0; }
.mh-disclosure-arrow { width: 12px; height: 12px; flex: 0 0 12px; fill: none; stroke: currentColor; stroke-width: 1.5; transform: rotate(0); }
.mh-disclosure-toggle[aria-expanded="true"] > .mh-disclosure-arrow { transform: rotate(90deg); }
.market-history :is(.mh-status-details-panel, .mh-more-filters-panel, .mh-structure-disclosure-panel)[hidden] { display: none; }
.market-history .mh-data-status .err-box { margin: 6px 0 0; }
.market-history .mh-actions { gap: 6px; }
body.gleaner-app .market-history .mh-actions button { min-height: 30px; padding: 5px 9px; font-size: 13px; }
.market-history .mh-toolbar { gap: 8px; margin: 10px 0 6px; }
.market-history .mh-toolbar > .ops-field { flex-basis: 112px; max-width: 150px; min-width: 100px; }
.market-history .mh-toolbar > .mh-batch-field { flex-basis: 220px; max-width: 255px; }
.market-history .mh-toolbar > .mh-search-field { flex-basis: 130px; }
.mh-more-filters { white-space: nowrap; }
.mh-more-filters span { font-variant-numeric: tabular-nums; }
.market-history .mh-secondary-toolbar { margin: 4px 0 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-inset); }
.market-history .mh-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin: 8px 0; }
.market-history .mh-summary > div { display: flex; align-items: baseline; gap: 7px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.market-history .mh-summary strong { margin: 0; font-size: 15px; font-weight: 600; }
.mh-overview-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0; }
.mh-tier-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.mh-tier-toolbar > label { color: var(--muted); font-size: 12px; }
body.gleaner-app .market-history #mh-tier-select { min-height: 30px; padding: 5px 8px; font-size: 13px; }
.mh-selected-tier { color: var(--accent-text); font-size: 12px; }
.mh-structure-disclosure { min-width: 0; max-width: 100%; }
.market-history .mh-structure-disclosure-panel > .mh-structure { margin: 0 0 6px; padding: 12px; }
.market-history .mh-ranking { display: inline-flex; gap: 6px; }
.market-history .mh-comparison { display: inline; margin: 0 0 0 10px; }
.market-history .mh-table-wrap { margin-top: 8px; }
.market-history .mh-table small { margin-top: 1px; line-height: 1.25; }
.market-history .mh-table .mh-symbol-source { display: inline; margin: 0 0 0 7px; font-size: 11px; }
.market-history .mh-venues { display: flex; flex-wrap: wrap; gap: 2px 8px; min-width: 180px; max-width: 205px; font-size: 12px; line-height: 1.35; }
.market-history .mh-venues > span { white-space: nowrap; }
body.gleaner-app .market-history .mh-symbol { min-height: 32px; padding: 0; }
body.gleaner-app .market-history .mh-table td { height: 44px; padding: 5px 9px; line-height: 1.35; }
@media (max-width: 760px) {
  .market-history .mh-heading { flex-wrap: wrap; }
  .mh-heading-controls { flex: 1 1 100%; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; }
  .market-history .mh-heading-controls .mh-mode-switch { width: auto; }
  .market-history .mh-heading-controls select { width: 105px; }
  .mh-status-topline { flex-wrap: wrap; }
  .mh-status-topline > .mh-status-line { flex-basis: 100%; }
  body.gleaner-app .market-history .mh-mode-switch button,
  body.gleaner-app .market-history .mh-actions button,
  body.gleaner-app .market-history #mh-tier-select { min-height: 44px; }
  .market-history .mh-toolbar > .ops-field { flex-basis: calc(50% - 4px); max-width: none; min-width: 0; }
  .market-history .mh-toolbar > .mh-batch-field { flex-basis: 100%; }
  body.gleaner-app .market-history .mh-disclosure-toggle { min-height: 44px; padding: 10px 7px; }
  body.gleaner-app .market-history .mh-symbol { min-height: 44px; }
  body.gleaner-app .market-history .mh-table td { min-height: 44px; }
  .market-history .mh-summary { gap: 6px 14px; }
  .mh-overview-tools { align-items: flex-start; }
  .mh-overview-tools > * { flex-basis: 100%; }
  .market-history .mh-comparison { display: block; margin: 4px 0 0; }
}

.mh-range-window { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 10px; }
.mh-range-pills { display: inline-flex; gap: 6px; flex-wrap: wrap; }
body.gleaner-app .market-history .mh-range-pill,
body.gleaner-app .pos-overview-mcap .mh-range-pill { min-height: 32px; padding: 4px 12px; background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
body.gleaner-app .market-history .mh-range-pill:hover:not(:disabled):not(.active),
body.gleaner-app .pos-overview-mcap .mh-range-pill:hover:not(:disabled):not(.active) { border-color: var(--accent); }
body.gleaner-app .market-history .mh-range-pill.active,
body.gleaner-app .pos-overview-mcap .mh-range-pill.active { background: var(--accent); border-color: var(--accent); color: var(--btn-primary-fg, #fff); }
.mh-range-pos { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.mh-range-pos-track { display: inline-block; width: 3.2rem; height: 0.35rem; border-radius: 99px; background: color-mix(in srgb, var(--text) 12%, var(--card)); overflow: hidden; }
.mh-range-pos-track i { display: block; height: 100%; background: var(--accent); }
.mh-range-incomplete { color: var(--muted); }
