/* Market context uses the existing notebook palette and its own scroll surface. */
.market-sector-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: .6rem; margin: 1rem 0; }
.market-sector-tile { display: grid; gap: .4rem; padding: .85rem; border: 1px solid #c4cec8; border-radius: .3rem; background: #edf1ee; }
.market-sector-tile.market-up { background: #fcf0ed; border-color: #dcb8b1; }
.market-sector-tile.market-down { background: #ecf4ef; border-color: #b7cfc0; }
.market-sector-tile span { font-size: .87rem; font-weight: 650; color: #293e31; }
.market-sector-tile strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.market-period-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.market-period-picker select { padding: .4rem .65rem; border: 1px solid #aabdaf; border-radius: .3rem; background: #fffefa; color: #253b31; }
.research-app[data-active-panel="market"] #workflow-message { display: none; }
.research-app[data-active-panel="market"] .top-context { display: none; }
.research-app[data-active-panel="market"] .research-topbar { grid-template-columns: minmax(13rem,1fr) auto; }
.research-topbar .workbench-tabs button { white-space: nowrap; }
.market-page { min-height: 0; overflow: auto; padding: 1.4rem clamp(.8rem, 2vw, 2rem) 3rem; grid-row: 1 / -1; background: #f8f6ef; }
.market-page[hidden] { display: none; }
.market-page-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; max-width: 1600px; margin: 0 auto 1.2rem; }
.market-page h2 { margin: .2rem 0 .5rem; font-size: 1.8rem; font-family: "Noto Serif SC", SimSun, serif; }
.market-page h3 { font-size: 1.1rem; margin: 0; }
.market-page h4 { margin: 1rem 0 .7rem; font-size: .9rem; }
.market-page h5 { font-size: .9rem; margin: 0; }
.market-intro { color: #58615c; max-width: 62rem; font-size: .85rem; line-height: 1.7; }
#market-sections { max-width: 1600px; margin: auto; display: grid; gap: 1.2rem; }
.market-section { min-width: 0; padding: 1.25rem; border: 1px solid #d4d1c5; border-radius: .45rem; background: #fffefa; }
.market-section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.market-meta,.market-note,.market-stat small { font-size: .74rem; color: #606962; line-height: 1.6; }
.market-note { padding-left: .6rem; border-left: 2px solid #aebdb5; }
.market-warning { border-left: 3px solid #b28635; color: #765717; background: #fcf4e2; padding: .55rem .75rem; font-size: .78rem; line-height: 1.6; }
.market-badge { flex: 0 0 auto; font-size: .7rem; border: 1px solid #c6d4ca; color: #386048; background: #f2f7f0; border-radius: 1rem; padding: .2rem .6rem; }
.market-badge[data-state="stale"],.market-badge[data-state="unavailable"] { color: #795c23; border-color: #ded0ab; background: #faf4e7; }
.market-update-record { font-size: .75rem; color: #505f56; margin: .55rem 0 .85rem; }
.market-update-record summary,.market-details summary { cursor: pointer; width: fit-content; }
.market-quotes { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: .65rem; }
.market-quote { min-width: 0; padding: .9rem; border: 1px solid #c4cec8; border-radius: .35rem; background: #f0f3f1; color: #253b31; display: flex; flex-direction: column; gap: .4rem; }
.market-quote.market-up { background: #fcf0ed; border-color: #dcb8b1; }
.market-quote.market-down { background: #ecf4ef; border-color: #b7cfc0; }
.market-quote h5 { color: #20362b; font-size: 1rem; font-weight: 750; }
.market-quote .market-meta { display: flex; flex-wrap: wrap; gap: .1rem .5rem; font-size: .75rem; font-weight: 600; color: #495e52; }
.market-quote .market-meta span,.market-quote-range span { white-space: nowrap; }
.market-quote strong { font-size: 1.55rem; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: .3rem; overflow-wrap: anywhere; }
.market-quote p { margin: 0; font-size: .9rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.market-quote small { font-size: .82rem; font-weight: 600; color: #354f41; line-height: 1.6; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.market-quote-range { display: flex; flex-wrap: wrap; gap: 0 .65rem; }
.market-up { color: #a83e36; }
.market-down { color: #237558; }
.market-card-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 1rem; margin: 1rem 0; }
.market-stat { padding: .8rem .9rem; border: 1px solid #c8d2cc; background: #edf1ee; display: flex; flex-direction: column; gap: .45rem; border-radius: .3rem; min-width: 0; }
.market-stat.market-up { background: #fcf0ed; border-color: #dcb8b1; }
.market-stat.market-down { background: #ecf4ef; border-color: #b7cfc0; }
.market-stat-label { color: #344c3f; font-size: .85rem; font-weight: 650; }
.market-stat strong { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.market-stat small { color: #465d4f; font-size: .8rem; font-weight: 600; }
.market-two-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem 1.5rem; }
.market-percentile { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .4rem; padding: .6rem 0; font-size: .85rem; font-weight: 600; }
.market-percentile strong { font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 750; }
.market-track { grid-column: 1 / -1; height: 5px; background: #e7e7dd; border-radius: 3px; overflow: hidden; }
.market-track i { display: block; height: 100%; background: #82978d; }
.market-track i[data-level="high"] { background: #bd6b61; }
.market-track i[data-level="low"] { background: #4f977d; }
.market-gauge { border: 1px solid #c8d2cc; background: #f1f4f1; color: #2d4738; padding: .4rem .75rem; text-align: left; border-radius: .3rem; }
.market-gauge:hover { background: #e6efe9; border-color: #91ad9b; }
.market-gauge[aria-pressed="true"] { border-color: #547c64; background: #dcebe1; }
.market-chart { margin: 1rem 0; border: 1px solid #e1dfd5; border-radius: .35rem; padding: .7rem; background: #fafaf5; }
.market-chart figcaption { color: #42544a; font-size: .83rem; font-weight: 600; margin-bottom: .3rem; }
.market-chart-stage { overflow-x: auto; }
.market-chart svg { display: block; width: 100%; max-height: 310px; height: auto; touch-action: pan-y; }
.market-chart svg text { fill: #646f67; font-size: 11px; font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.market-grid-line { stroke: #e1e4da; stroke-width: 1; }
.market-cursor { stroke: #798b80; stroke-width: 1; stroke-dasharray: 4 4; }
.market-chart-readout { font-size: .85rem; font-weight: 600; color: #354f41; min-height: 1.6em; margin: .3rem .2rem 0; font-variant-numeric: tabular-nums; }
.market-details { margin: .8rem 0; font-size: .8rem; color: #355e53; }
.market-table-wrap { overflow: auto; max-width: 100%; margin: .8rem 0; border: 1px solid #d7dacf; border-radius: .25rem; }
.market-page table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.market-page th { background: #edf1e8; color: #405244; text-align: left; font-weight: 600; }
.market-page th,.market-page td { padding: .6rem .7rem; border-bottom: 1px solid #e0e3d9; white-space: nowrap; }
.market-page td.market-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.market-page tr:nth-child(even) { background: #fafaf5; }
.market-page td { max-width: 26rem; overflow: hidden; text-overflow: ellipsis; }
.market-page td:hover { white-space: normal; overflow-wrap: anywhere; }
.market-search { width: min(100%,26rem); margin-top: .5rem; background: #fffefa; }
.market-empty { font-size: .85rem; color: #6c756b; padding: 1rem; }
.market-page :focus-visible { outline: 2px solid #307864; outline-offset: 3px; }
@media(max-width:1200px) { .market-quotes { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media(max-width:650px) {
  .research-app[data-active-panel="market"] .research-topbar { display: flex; height: auto; padding: .7rem; }
  .research-app[data-active-panel="market"] .top-actions { display: grid; grid-template-columns: minmax(0,1fr) auto; justify-content: flex-start; max-width: 100%; overflow: visible; }
  .research-app[data-active-panel="market"] .workbench-tabs { min-width: 0; max-width: 100%; overflow-x: auto; }
  .market-page { overflow: visible; }
  .market-page-header,.market-section-heading { flex-direction: column; gap: .6rem; }
  .market-page-header h2 { font-size: 1.5rem; }
  .market-section { padding: .8rem; }
  .market-two-columns { grid-template-columns: minmax(0,1fr); }
  .market-quotes { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .market-quote { padding: .75rem .65rem; }
  .market-quote strong { font-size: 1.3rem; }
  .market-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; }
  .market-stat strong { font-size: 1.15rem; }
  .market-percentile { grid-template-columns: minmax(0,1fr); }
  .market-chart { padding: .5rem .2rem; }
  .market-chart svg { min-width: 800px; min-height: 192px; }
  .market-chart svg text { font-size: 12px; }
  .market-chart-readout { font-size: .82rem; }
}
.market-chart-legend{display:flex;flex-wrap:wrap;gap:.35rem 1rem;margin:.3rem 0 .45rem;font-size:.78rem;font-weight:600}
