/* ==========================================================================
   Grey Sky Capital: MF Monitor (mf-monitor.html, served at /mf-monitor)
   --------------------------------------------------------------------------
   Technical Summary
   - Loads after marketpulse.css and shares Telescope's frame with Market
     Pulse and PMS Monitor: the dark hero, the sticky bar of mono segmented
     controls, ruled stat cells, the "read" block and the disclaimer band.
     This file adds only what MF Monitor needs on top.
   - Paper sections with a tone shift (paper-100, paper-200). Mono for data,
     labels and figures; Archivo for names and prose.
   - Scheme keys on the chart, legend, chips and table heads: rust, ink,
     moss and ink-muted lines, then rust dotted and ink dash-dot for the
     fifth and sixth, so colour is never the only difference. The benchmark
     is azure-ink dashed with the square benchmark marker; money paid in on
     the SIP view is a grey-500 step line.
   - Depth from tokens.css: lines lift on a tight ink shadow, the gap to the
     benchmark is a moss or ember-ink wash, hover markers are lit beads
     (--lit-bead), the allocation bar is a stacked bar in a recessed well
     (--lit-well, --lit-bar) with light seams, and the ranking's return bars
     reuse Market Pulse's lit split bars.
   - Tables scroll inside their own frame, so the page never scrolls sideways
     at phone width. Nothing animates except the loading ring, which stops
     under reduced motion.
   - Colour and type from tokens.css only.
   ========================================================================== */

/* ---------------------------------------------------------------- Sections */
.mf-sec { background: var(--paper-100); padding: clamp(36px, 4.5vw, 56px) 0; }
.mf-sec--alt { background: var(--paper-200); border-top: 1px solid var(--paper-300); border-bottom: 1px solid var(--paper-300); }
.mf-sec--board { padding-top: clamp(28px, 3.5vw, 44px); min-height: 220px; }
.mf-lead { margin: 0 0 20px; max-width: 72ch; font-size: var(--body-size); line-height: var(--body-lh); color: var(--ink-body); }
.mf-hint { margin: 12px 0 0; max-width: 90ch; font-size: 14px; line-height: 1.6; color: var(--ink-muted); }
.mf-hint b { color: var(--ink-head); font-weight: 600; }
.mf-hint--inline { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.mf-hint--bench { display: flex; align-items: baseline; gap: 8px; color: var(--ink-body); }
.mf-err { margin: 14px 0 0; font-size: 14px; color: var(--ember-ink); }
.mf-err:empty { display: none; }
.mf-asof, .mf-note { margin: -4px 0 16px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; letter-spacing: .02em; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.mf-notes { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.6; color: var(--ink-muted); }
.mf-notes li + li { margin-top: 4px; }
.mf-dim { color: var(--ink-muted); }
.mp-status .mf-spin { margin-right: 10px; }

/* ---------------------------------------------------------------- Period bar */
.mf-seg { flex-wrap: wrap; border: 0; }
.mf-seg button { border: 1px solid var(--paper-300); margin: 0 -1px -1px 0; }
.mf-seg button + button { border-left: 1px solid var(--paper-300); }
.mf-custom { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 10px 20px; }
.mf-custom[hidden] { display: none; }
.mf-field { display: grid; gap: 6px; }
.mf-field--inline { display: inline-flex; align-items: center; gap: 10px; }
.mf-date { flex: none; width: auto; min-height: 40px; font-family: var(--font-mono); font-size: 13px; }

/* ---------------------------------------------------------------- Schemes and amounts */
.mf-setup { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px 48px; align-items: start; }
.mf-amounts { display: flex; flex-wrap: wrap; gap: 16px; }
.mf-amounts .mf-field { flex: 1 1 150px; }
.mf-num, .mf-select { width: 100%; min-height: 48px; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.mf-num { text-align: right; }
.mf-select { padding-right: 10px; cursor: pointer; }
.mf-select--sm { width: auto; min-height: 36px; font-size: 12px; }

/* Search combobox */
.mf-combo { position: relative; }
.mf-combo__input { width: 100%; min-height: 52px; font-size: 16px; }
.mf-combo__input:disabled { background: var(--paper-200); color: var(--ink-muted); cursor: not-allowed; }
.mf-combo__list {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; max-height: 340px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--paper-100); border: 1px solid var(--ink-head); box-shadow: var(--lit-drop);
}
.mf-combo__list li { padding: 10px 12px; font-size: 14px; line-height: 1.45; color: var(--ink-head); cursor: pointer; }
.mf-combo__list li.is-active { background: var(--paper-200); box-shadow: inset 3px 0 0 var(--ink-head); }
.mf-combo__list mark { background: color-mix(in srgb, var(--lime) 55%, var(--paper-100)); color: var(--ink-head); }
.mf-combo__code { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.mf-combo__list li.mf-combo__msg { cursor: default; color: var(--ink-muted); }
.mf-combo__list li.mf-combo__msg.is-err { color: var(--ember-ink); }
.mf-combo__count { min-height: 1.6em; margin: 6px 0 0; font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.mf-combo--pf { max-width: 560px; margin-bottom: 18px; }

/* Board chips and quick picks */
.mf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.mf-chipf { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 40px; padding: 4px 4px 4px 12px; border: 1px solid var(--paper-300); background: var(--paper-100); font-size: 14px; color: var(--ink-head); }
.mf-chipf.is-err { border-color: var(--ember-ink); }
.mf-chipf__n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-chipf__err { font-size: 12px; color: var(--ember-ink); }
.mf-chipf__btn { min-height: 30px; padding: 0 10px; border: 1px solid var(--ink-head); background: none; color: var(--ink-head); cursor: pointer; font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.mf-pick { min-height: 36px; padding: 6px 12px; border: 1px solid var(--paper-300); background: var(--paper-100); color: var(--ink-head); cursor: pointer; font: inherit; font-size: 13px; }
.mf-pick:hover, .mf-chipf__btn:hover { border-color: var(--ink-head); background: var(--ink-head); color: var(--paper-100); }
.mf-x { flex: none; width: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--ink-muted); cursor: pointer; font-size: 20px; line-height: 1; }
.mf-x:hover { color: var(--ember-ink); }
.mf-pick:focus-visible, .mf-chipf__btn:focus-visible, .mf-x:focus-visible, .mf-chart:focus-visible, .mf-tablewrap:focus-visible,
.mf-num:focus-visible, .mf-select:focus-visible, .mf-cell:focus-visible, .mf-combo__input:focus-visible { outline: 3px solid var(--azure-ink); outline-offset: 1px; }

/* ---------------------------------------------------------------- Scheme keys */
.mf-k1 { --c: var(--rust); }
.mf-k2 { --c: var(--ink-head); }
.mf-k3 { --c: var(--moss); }
.mf-k4 { --c: var(--ink-muted); }
.mf-k5 { --c: var(--rust); --dash: 1.5 3.5; }
.mf-k6 { --c: var(--ink-head); --dash: 7 3 1.5 3; }
.mf-kb { --c: var(--azure-ink); --dash: 7 4; }
.mf-ki { --c: var(--grey-500); --dash: 3 3; }
.mf-kp { --c: var(--ink-head); }

.mf-sw { display: inline-block; flex: none; width: 20px; height: 0; border-top: 3px solid var(--c); vertical-align: middle; }
.mf-sw.mf-k5 { border-top-style: dotted; }
.mf-sw.mf-k6, .mf-sw.mf-ki { border-top-style: dashed; border-top-width: 2px; }
.mf-sw.mf-kb { width: 8px; height: 8px; border: 0; background: var(--azure-ink); }   /* the benchmark marker */

.mf-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink-body); }
.mf-legend li { display: inline-flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- Chart */
.mf-chartsec { margin-top: clamp(40px, 5vw, 56px); }
.mf-chartsec--pf { margin-top: 28px; }
.mf-chartsec--pf .mp-eyebrow { margin: 0 0 10px; }
.mf-chartbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 16px; }
.mf-chart-host { width: 100%; min-height: 200px; }
.mf-chart { position: relative; }
.mf-svg { display: block; max-width: 100%; height: auto; font-family: var(--font-mono); overflow: visible; }
.mf-grid { stroke: var(--paper-300); stroke-width: 1; stroke-dasharray: 3 4; }
.mf-zero { stroke: var(--ink-head); stroke-width: 1; }
.mf-tick { fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mf-line {
  fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: var(--dash, none);
  filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--ink-head) 22%, transparent));
}
.mf-line.mf-kb, .mf-line.mf-ki { stroke-width: 1.6; filter: none; }
.mf-gap.is-pos { fill: color-mix(in srgb, var(--moss) 16%, transparent); }
.mf-gap.is-neg { fill: color-mix(in srgb, var(--ember-ink) 16%, transparent); }
.mf-guide { stroke: var(--ink-head); stroke-width: 1; stroke-dasharray: 2 3; }
.mf-svg .mf-bead { fill: var(--c); stroke: var(--paper-100); stroke-width: 1.5; }
.mf-bead-hi { stop-color: var(--paper-100); stop-opacity: .6; }
.mf-bead-lo { stop-color: var(--paper-100); stop-opacity: 0; }
.mf-tip {
  position: absolute; top: 8px; z-index: 5; min-width: 200px; max-width: min(320px, calc(100% - 8px)); padding: 10px 12px;
  background: var(--paper-100); border: 1px solid var(--ink-head); box-shadow: var(--lit-drop); pointer-events: none;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-body); font-variant-numeric: tabular-nums;
}
.mf-tip__d { margin: 0 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.mf-tip__r { display: flex; align-items: center; gap: 8px; margin: 3px 0 0; }
.mf-tip__n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-sans); }
.mf-tip b { color: var(--ink-head); font-weight: 600; }

/* ---------------------------------------------------------------- Tables */
.mf-tablewrap { position: relative; background: var(--paper-100); }   /* relative: clips the screen-reader labels inside cells, which are absolutely positioned */
.mf-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; color: var(--ink-body); font-variant-numeric: tabular-nums; }
.mf-table thead th { position: sticky; top: 0; z-index: 2; padding: 11px 12px; background: var(--ink-head); color: var(--paper-100); text-align: left; vertical-align: bottom; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.mf-table td, .mf-table tbody th { padding: 10px 12px; border-top: 1px solid var(--paper-300); vertical-align: top; text-align: left; }
.mf-table .mf-c-num { text-align: right; white-space: nowrap; }
.mf-sub { display: block; margin-top: 3px; font-family: var(--font-mono); font-size: 11px; font-weight: 400; line-height: 1.45; color: var(--ink-muted); white-space: normal; }
.mf-table strong { color: var(--ink-head); font-weight: 600; }
.mf-table .is-pos { color: var(--pos); }
.mf-table .is-neg { color: var(--neg); }

/* Comparison: metrics down, schemes across, the metric column pinned */
.mf-table--compare { table-layout: fixed; }
.mf-table--compare thead th { background: var(--paper-200); color: var(--ink-head); border-bottom: 1px solid var(--ink-head); font-family: var(--font-sans); font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.mf-table--compare thead th.mf-table__corner { color: var(--ink-muted); font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.mf-table--compare th:first-child, .mf-table--compare td:first-child { width: 210px; }
.mf-table--compare tbody th { position: sticky; left: 0; z-index: 1; background: var(--paper-200); color: var(--ink-head); font-weight: 600; font-size: 14px; }
.mf-table--compare thead th:first-child { position: sticky; left: 0; z-index: 3; }
.mf-table--compare td.is-best { background: color-mix(in srgb, var(--lime) 24%, var(--paper-100)); font-weight: 600; color: var(--ink-head); }
.mf-fund { display: inline-flex; align-items: center; gap: 8px; }
.mf-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mf-badge { display: inline-block; padding: 2px 7px; background: var(--paper-200); color: var(--ink-head); font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; }
.mf-badge.is-warn { background: var(--flare); color: var(--fill-ink); }
.mf-table--pf .mf-badge { margin-top: 5px; }
.mf-chip { display: inline-block; padding: 3px 7px; background: var(--paper-200); color: var(--ink-head); font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

/* Category ranking */
.mf-fieldbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 18px; }
.mf-fieldbar .mf-select { width: auto; min-width: 220px; min-height: 40px; font-size: 13px; }
.mf-progress { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-body); font-variant-numeric: tabular-nums; }
.mf-rankwrap { max-height: 640px; }
.mf-table--rank { min-width: 860px; }
.mf-table--rank td { vertical-align: middle; }
.mf-table--rank .mf-c-rank { width: 48px; text-align: right; font-family: var(--font-mono); color: var(--ink-muted); }
.mf-table--rank .mf-c-name { min-width: 240px; }
.mf-table--rank .mf-c-bar { width: 160px; }
.mf-table--rank .mp-split { height: 12px; }
.mf-table--rank tr.is-mine td { background: color-mix(in srgb, var(--lime) 18%, var(--paper-100)); }
.mf-name { color: var(--ink-head); font-weight: 600; }
.mf-yours { display: inline-block; margin-left: 8px; padding: 1px 6px; background: var(--lime); color: var(--fill-ink); font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; vertical-align: 1px; }
.mf-c-act { width: 1%; white-space: nowrap; text-align: right; }

/* Buttons */
.mf-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.mp-btn:disabled { border-color: var(--paper-300); color: var(--ink-muted); cursor: not-allowed; background: none; }
.mf-btn--sm { min-height: 32px; padding: 4px 10px; font-size: 10px; }

/* Written reading and verdict */
.mf-read { margin-top: 24px; }
.mf-read ul { margin: 10px 0 0; padding: 0 0 0 18px; font-size: 15px; line-height: 1.65; color: var(--ink-body); }
.mf-read li + li { margin-top: 6px; }

/* ---------------------------------------------------------------- Portfolio */
.mf-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin-bottom: 22px; padding: 0 1px 1px 0; background: none; border: 0; }
.mf-kpis .mp-cell { margin: 0 -1px -1px 0; border: 1px solid var(--paper-300); border-top-width: 3px; }
.mf-kpis .mp-cell:not(.is-pos):not(.is-neg) { border-top-color: var(--paper-300); }
.mf-kpis .mp-cell.is-pos { border-top-color: var(--pos); }
.mf-kpis .mp-cell.is-neg { border-top-color: var(--neg); }
.mf-kpi { font-size: 26px; }
.mf-kpi.is-pos { color: var(--pos); }
.mf-kpi.is-neg { color: var(--neg); }
.mf-kpis .mp-eyebrow { margin: 0; }
.mf-kpis .mp-cell__sd { margin: 0; }
.mf-table--pf { min-width: 1080px; }
.mf-table--pf td { vertical-align: middle; }
.mf-table--pf .mf-c-name { min-width: 220px; }
.mf-cell { width: 116px; min-height: 38px; padding: 6px 9px; font-family: var(--font-mono); font-size: 13px; text-align: right; flex: none; }
.mf-cell--date { width: auto; text-align: left; }

/* Allocation: a stacked bar in a recessed well, with light seams */
.mf-alloc { margin-bottom: 24px; }
.mf-alloc__bar { display: flex; height: 14px; overflow: hidden; border-radius: 7px; background: var(--paper-200); box-shadow: var(--lit-well); }
.mf-alloc__bar span { display: block; height: 100%; background: var(--lit-bar), var(--c); box-shadow: inset -1px 0 0 color-mix(in srgb, var(--paper-100) 70%, transparent); }
.mf-alloc__bar span:last-child { box-shadow: none; }
.mf-alloc .mf-legend { font-size: 13px; }
.mf-bead { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--lit-bead), var(--c); box-shadow: var(--lit-drop); }
.mf-a1 { --c: var(--lime); }
.mf-a2 { --c: var(--azure-ink); }
.mf-a3 { --c: var(--flare); }
.mf-a4 { --c: var(--moss); }
.mf-a5 { --c: var(--rust); }
.mf-a6 { --c: var(--ink-head); }
.mf-a7 { --c: var(--azure); }
.mf-a8 { --c: var(--grey-500); }
.mf-a9 { --c: var(--ember); }
.mf-a10 { --c: var(--ink-muted); }

/* ---------------------------------------------------------------- Methodology */
.mf-acc { max-width: 880px; }
.mf-acc details { border-bottom: 1px solid var(--paper-300); }
.mf-acc summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 12px 0;
  cursor: pointer; list-style: none; font-weight: 600; color: var(--ink-head);
}
.mf-acc summary::-webkit-details-marker { display: none; }
.mf-acc summary::after { content: '+'; flex: none; font-family: var(--font-mono); font-size: 18px; font-weight: 400; color: var(--ink-muted); }
.mf-acc details[open] summary::after { content: '\2212'; color: var(--rust); }
.mf-acc summary:hover { color: var(--rust); }
.mf-acc summary:focus-visible { outline: 3px solid var(--azure-ink); outline-offset: 2px; }
.mf-acc details > div { padding: 0 0 18px; max-width: 76ch; line-height: 1.7; color: var(--ink-body); }
.mf-acc + .mf-hint, .mf-acc .mf-hint { margin-top: 18px; }

/* ---------------------------------------------------------------- Toast and loading */
.mf-toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 90; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; background: var(--slate-900); color: var(--grey-100); box-shadow: var(--lit-drop); font-size: 14px; line-height: 1.5;
}
.mf-toast[hidden] { display: none; }
.mf-spin { display: inline-block; flex: none; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--paper-300); border-top-color: var(--ink-head); border-radius: 50%; vertical-align: -1px; animation: mf-spin .8s linear infinite; }
@keyframes mf-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Phones */
@media (max-width: 860px) {
  .mf-setup { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .mf-amounts .mf-field { flex: 1 1 100%; }
  .mf-fieldbar .mf-select { min-width: 0; width: 100%; }
  .mf-fieldbar .mp-ctl { flex: 1 1 100%; }
  .mf-kpi { font-size: 22px; }
  .mf-table--compare th:first-child, .mf-table--compare td:first-child { width: 150px; }
  .mf-table--compare tbody th { font-size: 13px; }
  .mf-chipf { font-size: 13px; }
  .mf-tip { min-width: 170px; }
}

@media (prefers-reduced-motion: reduce) {
  .mf-spin { animation: none; border-top-color: var(--ink-muted); }
}

@media print {
  .mf-noprint, .nav, .footer, .ph-badge, .mf-toast, .mf-actions, .mf-chartbar { display: none !important; }
  .mf-tablewrap { overflow: visible !important; }
  .mf-sec { padding: 16px 0; }
}
