/* Stock header. Reacts to its own width: phones stack identity, price and stats; from 640px the price sits
   to the right of the name, as on a quote board. Pro is one dense line that scrolls sideways if it must. */
.tm-shead { container: tm-shead / inline-size; font-variant-numeric: tabular-nums; }
.tm-shead__in { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "id actions" "quote quote" "halt halt" "stats stats" "explain explain"; gap: var(--tm-space-12) var(--tm-space-16); }
.tm-shead__id { grid-area: id; min-width: 0; display: grid; gap: 4px; align-content: start; }
.tm-shead__quote { grid-area: quote; display: grid; gap: 6px; align-content: start; }
.tm-shead__actions { grid-area: actions; display: flex; align-items: center; gap: var(--tm-space-8); align-self: start; }
.tm-shead__halt { grid-area: halt; }
.tm-shead__stats { grid-area: stats; }
.tm-shead__explain { grid-area: explain; }

.tm-shead__switch-wrap { position: relative; justify-self: start; }
.tm-shead__switch { display: inline-flex; align-items: center; gap: 8px; margin: -4px -8px; padding: 4px 8px; border: 0; border-radius: var(--lk-r-control, var(--tm-radius-sm)); background: none; color: var(--tm-color-text); font: inherit; cursor: pointer; }
.tm-shead__switch:hover { background: var(--tm-color-hover); }
.tm-shead__switch:focus-visible { outline: 2px solid var(--tm-color-focus); outline-offset: 2px; }
.tm-shead__switch .tm-icon { color: var(--tm-color-text-secondary); }
.tm-shead__code { font-size: var(--tm-type-title-size); line-height: var(--tm-type-title-line); font-weight: var(--tm-font-weight-semibold); letter-spacing: -0.01em; }
.tm-shead__name { display: flex; flex-wrap: wrap; gap: 0 6px; color: var(--tm-color-text-secondary); font-size: var(--tm-density-font-body); min-width: 0; }
.tm-shead__company { color: var(--tm-color-text-secondary); }
/* Narrow: name and sector on their own lines, so a wrapped line never starts with the dot. */
.tm-shead__name { flex-direction: column; }
.tm-shead__name > [aria-hidden] { display: none; }

.tm-shead__menu { position: absolute; z-index: var(--tm-z-dropdown, 30); top: calc(100% + 8px); left: -8px; width: max-content; min-width: 260px; max-width: min(360px, 90vw); padding: 6px; border: 1px solid var(--tm-color-divider); border-radius: var(--lk-r-md, var(--tm-radius-md)); background: var(--lk-glass, var(--tm-color-raised)); backdrop-filter: blur(16px); box-shadow: var(--lk-float, var(--tm-shadow-overlay)); }
.tm-shead__mgroup { padding: 8px 10px 4px; font-size: var(--tm-density-font-label); color: var(--tm-color-text-secondary); }
.tm-shead__menu [role="menuitem"] { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: calc(var(--lk-r-md, var(--tm-radius-md)) - 6px); background: none; color: var(--tm-color-text); font: inherit; font-size: var(--tm-density-font-small); text-align: left; cursor: pointer; }
.tm-shead__menu [role="menuitem"]:hover, .tm-shead__menu [role="menuitem"]:focus-visible { background: var(--tm-color-hover); outline: none; }
.tm-shead__mcode { font-weight: var(--tm-font-weight-semibold); }
.tm-shead__mname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tm-color-text-secondary); }
.tm-shead__msearch { grid-template-columns: auto 1fr !important; margin-top: 4px; border-top: 1px solid var(--tm-color-divider) !important; color: var(--tm-color-primary-text) !important; }

.tm-shead__move { display: flex; align-items: center; gap: var(--tm-space-8); flex-wrap: wrap; }
.tm-shead__today { font-size: var(--tm-density-font-small); color: var(--tm-color-text-secondary); }
.tm-shead__fresh { display: flex; align-items: center; gap: 6px; font-size: var(--tm-density-font-small); color: var(--tm-color-text-secondary); white-space: nowrap; }
.tm-shead__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tm-color-up); box-shadow: 0 0 0 3px var(--tm-color-up-tint); }
.tm-shead__dot.is-paused { background: var(--tm-color-warning); box-shadow: 0 0 0 3px var(--tm-color-warning-tint); }
.tm-shead__star[aria-pressed="true"] { color: var(--tm-color-warning); }
.tm-shead__star[aria-pressed="true"] svg { fill: currentColor; }

/* Stats strip: labels above values, sentence case. In Simple each label explains itself when tapped. */
.tm-shead__stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(144px, 100%), 1fr)); gap: 0 var(--tm-space-16); margin: 0; padding-top: var(--tm-space-4); border-top: 1px solid var(--tm-color-divider); }
.tm-shead__stat { display: grid; gap: 2px; align-content: start; padding: var(--tm-space-8) 0; min-width: 0; }
.tm-shead__stat[hidden] { display: none; }
.tm-shead__stat dt { font-size: var(--tm-density-font-label); line-height: var(--tm-type-label-line); color: var(--tm-color-text-secondary); }
.tm-shead__stat dd { margin: 0; font-size: var(--tm-density-font-data); line-height: var(--tm-density-line-data); font-weight: var(--tm-font-weight-medium); white-space: nowrap; }
.tm-shead__term { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: help; text-decoration: underline dotted color-mix(in srgb, currentColor 55%, transparent); text-underline-offset: 3px; }
.tm-shead__term:hover, .tm-shead__term[aria-expanded="true"] { color: var(--tm-color-text); }
.tm-shead__term:focus-visible { outline: 2px solid var(--tm-color-focus); outline-offset: 2px; border-radius: 2px; }
.tm-shead__stat--more { flex: 0 0 auto; align-content: center; justify-items: start; }
.tm-shead__stat--more .tm-btn { margin-left: -8px; }
.tm-shead__stat--more [aria-expanded="true"] svg { transform: rotate(180deg); }
.tm-shead__rbar { position: relative; display: block; height: 4px; margin-top: 6px; max-width: 120px; border-radius: 2px; background: var(--tm-color-hover); box-shadow: inset 0 0 0 1px var(--tm-color-divider); }
.tm-shead__rbar i { position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--tm-color-text); transform: translate(-50%, -50%); }
.tm-shead__explain { margin: calc(-1 * var(--tm-space-4)) 0 0; padding: var(--tm-space-8) var(--tm-space-12); border-radius: var(--lk-r-xs, var(--tm-radius-sm)); background: var(--tm-color-hover); font-size: var(--tm-density-font-small); color: var(--tm-color-text-secondary); }
.tm-shead__explain b { color: var(--tm-color-text); font-weight: var(--tm-font-weight-semibold); }

@container tm-shead (width >= 640px) {
  .tm-shead__name { flex-direction: row; }
  .tm-shead__name > [aria-hidden] { display: inline; }
  /* Wide: the stats fill the space beside the price as a short scrolling box, most important first. */
  .tm-shead:not(.tm-shead--pro) > .tm-shead__in { grid-template-columns: auto minmax(0, 1fr); column-gap: var(--tm-space-32); grid-template-areas: "id actions" "quote stats" "halt halt" "explain explain"; align-items: start; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__actions { justify-self: end; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stats {
    grid-template-columns: none; grid-template-rows: repeat(2, auto); grid-auto-flow: column; grid-auto-columns: 148px;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding-inline: var(--tm-space-12);
    padding: 2px var(--tm-space-12) 6px; border-top: 0; border-left: 1px solid var(--tm-color-divider);
    --fl: 0px; --fr: 96px; mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%); scrollbar-width: none;
  }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stat { scroll-snap-align: start; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stats:focus-visible { outline: 2px solid var(--tm-color-focus); outline-offset: 2px; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stats.is-end { --fr: 0px; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stats.is-scrolled { --fl: 24px; }
  .tm-shead:not(.tm-shead--pro) .tm-shead__stats::-webkit-scrollbar { display: none; }
}

/* Pro: two dense lines at the top of the chart panel: identity, price and actions; then every stat inline,
   scrolling sideways if the panel is narrow. */
.tm-shead--pro { padding: 6px var(--tm-density-pad-cell) 0; white-space: nowrap; border-bottom: 1px solid var(--tm-color-divider); }
.tm-shead--pro > .tm-shead__in { grid-template-columns: minmax(0, auto) auto minmax(0, 1fr) auto; grid-template-areas: "id quote . actions" "halt halt halt halt" "stats stats stats stats"; gap: 4px var(--tm-space-16); }
.tm-shead--pro .tm-shead__id { display: flex; align-items: center; gap: var(--tm-space-8); min-width: 0; }
.tm-shead--pro .tm-shead__code { font-size: 15px; line-height: 20px; }
.tm-shead--pro .tm-shead__switch { gap: 6px; margin: -2px -6px; padding: 2px 6px; flex: none; }
.tm-shead--pro .tm-shead__name { flex-direction: row; flex-wrap: nowrap; font-size: var(--tm-density-font-small); overflow: hidden; min-width: 0; }
.tm-shead--pro .tm-shead__name > :not(.tm-shead__company) { display: none; }
.tm-shead--pro .tm-shead__company { overflow: hidden; text-overflow: ellipsis; }
.tm-shead--pro .tm-shead__quote { display: flex; align-items: baseline; gap: var(--tm-space-8); }
.tm-shead--pro .tm-shead__price .tm-price { font-size: 17px; font-weight: var(--tm-font-weight-semibold); }
.tm-shead--pro .tm-shead__fresh .tm-shead__dot { width: 6px; height: 6px; box-shadow: none; }
.tm-shead--pro .tm-shead__actions { gap: 2px; align-self: center; }
.tm-shead--pro .tm-shead__stats { display: flex; gap: var(--tm-space-16); padding: 5px 0 6px; border-top: 1px solid var(--tm-color-divider); overflow-x: auto; scrollbar-width: none; }
.tm-shead--pro .tm-shead__stats::-webkit-scrollbar { display: none; }
.tm-shead--pro .tm-shead__stat { display: flex; align-items: baseline; gap: 6px; padding: 0; flex: none; }
.tm-shead--pro .tm-shead__stat dt { font-size: var(--tm-density-font-small); line-height: 16px; }
.tm-shead--pro .tm-shead__stat dd { font-size: var(--tm-density-font-data); line-height: 16px; }
.tm-shead--pro .tm-shead__halt { padding: 4px 8px; }
@container tm-shead (width < 760px) { .tm-shead--pro .tm-shead__fresh { display: none; } }
.tm-shead--pro .tm-shead__company { min-width: 60px; }
