/* Market dashboard (/dashboard). Colours follow the site theme (light, or html[data-theme=dark]);
   the palette matches /css/stocks.css so the dashboard sits with the newer stock pages. */
.market-dash {
  --md-surface: #fff; --md-border: #dfe5ec; --md-text: #162235; --md-muted: #637083;
  --md-soft: #f5f7fa; --md-blue: #315ee7; --md-shadow: 0 1px 2px rgba(22, 34, 53, .04), 0 4px 16px rgba(22, 34, 53, .04);
  --md-band: #eef1f5; --md-band-edge: #fff; --md-dial: #8592a3; --md-dot: #b4bdc9; --md-hub: #fff;
  --md-up: #168447; --md-down: #d14545; --md-up-soft: rgba(22, 132, 71, .1); --md-down-soft: rgba(209, 69, 69, .1);
  max-width: 1380px; margin: 0 auto; padding: 4px 0 8px; color: var(--md-text);
}
[data-theme="dark"] .market-dash {
  --md-surface: #0f1e36; --md-border: #1d3454; --md-text: #e6edf7; --md-muted: #a9b6c8;
  --md-soft: #10223f; --md-blue: #7aa2ff; --md-shadow: none;
  --md-band: #1a2c47; --md-band-edge: #0f1e36; --md-dial: #93a7c4; --md-dot: #3d5578; --md-hub: #0b1830;
  --md-up: #3ddc84; --md-down: #ff6b6b; --md-up-soft: rgba(61, 220, 132, .12); --md-down-soft: rgba(255, 107, 107, .12);
}

/* Page header */
.md-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.md-hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; letter-spacing: -.035em; margin: .1rem 0 .25rem; }
.md-lead { color: var(--md-muted); margin: 0; max-width: 680px; }
.md-eyebrow { font-size: .72rem; letter-spacing: .15em; font-weight: 800; color: var(--md-blue); text-transform: uppercase; margin: 0 0 4px; }
.md-live { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 700; color: var(--md-muted);
           background: var(--md-surface); border: 1px solid var(--md-border); border-radius: 999px; padding: 5px 12px; }
.md-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--md-up);
                   box-shadow: 0 0 0 3px var(--md-up-soft); }

/* Cards and section headings */
.md-card { background: var(--md-surface); color: var(--md-text); border: 1px solid var(--md-border);
           border-radius: 14px; padding: 22px; margin-bottom: 18px; box-shadow: var(--md-shadow); }
.md-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.md-head h2 { font-size: 1.3rem; font-weight: 750; letter-spacing: -.01em; margin: 0 0 4px; }
.md-head p { margin: 0; }
.md-sub { color: var(--md-muted); font-size: .9rem; }
.md-muted { color: var(--md-muted); font-size: .8rem; }
.md-foot { color: var(--md-muted); font-size: .78rem; margin-top: 12px; }
.md-subhead { font-size: .74rem !important; text-transform: uppercase; letter-spacing: .08em; font-weight: 800;
              color: var(--md-muted) !important; margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--md-border); }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--md-up); }
.down { color: var(--md-down); }
.flat { color: var(--md-muted); }

/* (1) Index tiles */
.idx-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1199.98px) { .idx-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.idx-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px;
            background: var(--md-surface); border: 1px solid var(--md-border); box-shadow: var(--md-shadow); min-width: 0; }
.idx-name { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--md-muted);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idx-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.idx-val { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.idx-chg { font-size: .82rem; font-weight: 750; font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 999px;
           background: var(--md-soft); white-space: nowrap; }
.idx-chg.up { background: var(--md-up-soft); }
.idx-chg.down { background: var(--md-down-soft); }
.idx-item .idx-none { font-size: 1rem; color: var(--md-muted); }
.idx-loading { color: var(--md-muted); padding: 14px 2px; }
.idx-asof { display: block; margin: 8px 2px 18px; }

/* (2) Fear & Greed */
.md-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--md-soft); border: 1px solid var(--md-border); }
.md-seg button { border: 0; background: transparent; color: var(--md-muted); font-size: .8rem; font-weight: 700;
                 padding: 5px 14px; border-radius: 7px; cursor: pointer; }
.md-seg button:hover { color: var(--md-text); }
.md-seg button.active { background: var(--md-surface); color: var(--md-blue); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.md-seg button:focus-visible { outline: 2px solid var(--md-blue); outline-offset: 1px; }
.fg-wrap { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 32px; align-items: center; }
@media (max-width: 900px) { .fg-wrap { grid-template-columns: 1fr; gap: 16px; } }
.fg-gauge { max-width: 620px; width: 100%; margin: 0 auto; }
.fg-gauge svg { width: 100%; height: auto; display: block; }
.g-off { fill: var(--md-band); stroke: var(--md-band-edge); }
.g-lbl { fill: var(--md-muted); }
.g-dial { fill: var(--md-dial); }
.g-dot { fill: var(--md-dot); }
.g-ink { fill: var(--md-text); }
.g-line { stroke: var(--md-text); }
.g-hub { fill: var(--md-hub); stroke: var(--md-border); }
#fg-history { background: var(--md-soft); border: 1px solid var(--md-border); border-radius: 12px; padding: 4px 16px; }
.fg-hist-row { display: flex; justify-content: space-between; align-items: center; gap: 12px;
               padding: 11px 0; border-bottom: 1px solid var(--md-border); }
.fg-hist-row:last-child { border-bottom: 0; }
.fg-hist-row .lbl { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--md-muted); }
.fg-hist-row .rt { font-weight: 700; }
.fg-badge { flex: none; width: 2.3rem; height: 2.3rem; border-radius: 50%; display: inline-flex; align-items: center;
            justify-content: center; font-weight: 800; font-size: .85rem; border: 1.5px solid; color: #162235;
            font-variant-numeric: tabular-nums; }
#fg-timeline { padding-top: 4px; }
[data-theme="dark"] .fg-band { opacity: .22; }
.fg-components { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fg-comp { background: var(--md-soft); border: 1px solid var(--md-border); border-radius: 12px; padding: 13px 14px; }
.fg-comp .name { font-weight: 700; font-size: .88rem; }
.fg-comp .detail { font-size: .77rem; color: var(--md-muted); margin-top: .3rem; line-height: 1.45; }
.market-dash .alert { border-radius: 10px; }

/* (3) Heat map */
#heatmap { position: relative; width: 100%; height: 640px; background: #262931; border-radius: 10px;
           overflow: hidden; font-family: Arial, Helvetica, sans-serif; }
@media (max-width: 700px) { #heatmap { height: 900px; } }
.hm-sector { position: absolute; box-sizing: border-box; }
.hm-sector-label { position: absolute; left: 0; right: 0; top: 0; height: 16px; padding: 0 4px;
                   color: #e9ecef; font-size: 11px; font-weight: 700; line-height: 16px; text-transform: uppercase;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-tile { position: absolute; box-sizing: border-box; border: 1px solid #262931; color: #fff; overflow: hidden;
           display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
           line-height: 1.1; cursor: default; }
.hm-tile:hover { outline: 2px solid #ffd43b; outline-offset: -2px; z-index: 2; }
.hm-tile .s { font-weight: 700; }
#hm-tip { position: fixed; pointer-events: none; z-index: 1000; background: var(--md-surface); color: var(--md-text);
          border: 1px solid var(--md-border); border-radius: 10px; padding: .55rem .7rem; font-size: .8rem;
          box-shadow: 0 8px 24px rgba(0, 0, 0, .2); display: none; max-width: 280px; }
.hm-legend { display: flex; align-items: center; gap: 8px; }
.hm-legend-bar { display: flex; border-radius: 6px; overflow: hidden; }
.hm-legend-bar span { color: #fff; font-size: .7rem; font-weight: 700; padding: .2rem .5rem; font-variant-numeric: tabular-nums; }

/* Phones */
@media (max-width: 575.98px) {
  .md-card { padding: 16px; border-radius: 12px; }
  .md-hero { margin-bottom: 14px; }
  .idx-strip { grid-template-columns: 1fr; gap: 8px; }
  .idx-item { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; }
  .idx-row { flex-wrap: nowrap; }
  .idx-val { font-size: 1.15rem; }
  .md-head h2 { font-size: 1.15rem; }
  .md-head > .md-seg { width: 100%; }
  .md-seg button { flex: 1; }
  .hm-legend-bar span { padding: .2rem .32rem; font-size: .65rem; }
  .fg-components { grid-template-columns: 1fr; }
}
