/* ==========================================================================
   Flash Finance — Margin Trading Facility (/mtf/)
   Layered on market.css (ff-*) and mi.css (mi-*): only mtf-* components here,
   every colour from the shared tokens.
   ========================================================================== */

.mtf .mtf-hero h1 { margin-bottom: 6px; display: block; }
.mtf-lead { font-size: 1.02rem; line-height: 1.55; margin: 6px 0 4px; }
.mtf-lead b { color: var(--ff-primary); }
.mtf-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 8px 0 2px; }
.mtf-big .v { font-size: 2.3rem; font-weight: 700; letter-spacing: -1px; color: var(--ff-primary); line-height: 1.05; }
.mtf-big .d { font-size: .95rem; font-weight: 600; }
/* The hero sits on the dark ff-hero panel: light text, light up/down tones. */
.mtf-hero .mtf-big .v, .mtf-hero .mtf-lead b { color: #fff; }
.mtf-hero .mtf-lead { opacity: .95; }
.mtf-hero .mi-pos { color: #86efac !important; }
.mtf-hero .mi-neg { color: #fca5a5 !important; }
.mtf-hero .mtf-band { color: #fde68a !important; }
.mtf-hero .mtf-flag { vertical-align: middle; }
.mtf-sub { font-size: .84rem; color: var(--ff-text-soft); }

.mtf-grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .mtf-grid2 { grid-template-columns: 1fr 1fr; } }
.mtf-grid3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .mtf-grid3 { grid-template-columns: 1fr 1fr 1fr; } }
.mtf-grid2 > .mi-card, .mtf-grid3 > .mi-card { margin-bottom: 0; }
/* Grid items default to min-width:auto, so a wide table inside one stretches the
   whole column past a phone's width; tables scroll inside their own wrapper instead. */
.mtf-grid2 > *, .mtf-grid3 > * { min-width: 0; }
.mtf-kv { width: 100%; }
.mtf-kv td { white-space: normal; }
.mtf-kv td.num { text-align: right; }
.mtf-gap { height: 14px; }

.mtf-sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin: 18px 2px 8px; }
.mtf-sec-h h2 { margin: 0; font-size: 1.12rem; color: var(--ff-primary); }
.mtf-sec-h a { font-size: .85rem; color: var(--ff-accent); text-decoration: none; }

/* tiles: a compact group heading inside the stats grid */
.mtf-tiles-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ff-text-faint); margin: 2px 2px 6px; font-weight: 600; }

/* ------------------------------- badges -------------------------------- */
.mtf-badge { display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .3px;
  padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 1px;
  background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }
.mtf-badge.fo { background: var(--ff-accent-soft); color: #1e40af; }
.mtf-badge.etf { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.mtf-badge.b { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
.mtf-badge.rec { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.mtf-sym-plain { font-weight: 600; }
.mtf-name { display: block; font-size: .74rem; color: var(--ff-text-faint); max-width: 230px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------- charts -------------------------------- */
.mtf-chart { position: relative; height: 300px; }
.mtf-chart.tall { height: 380px; }
.mtf-chart.short { height: 200px; }
.mtf-chart.mini { height: 140px; }
.mtf-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 10px; }
.mtf-tools .grp { display: inline-flex; border: 1px solid var(--ff-border); border-radius: 7px; overflow: hidden; }
.mtf-tools button, .mtf-tools select { background: var(--ff-card); border: 0; padding: 5px 10px;
  font: inherit; font-size: .78rem; color: var(--ff-text-soft); cursor: pointer; }
.mtf-tools select { border: 1px solid var(--ff-border); border-radius: 7px; }
.mtf-tools .grp button + button { border-left: 1px solid var(--ff-border); }
.mtf-tools button.on { background: var(--ff-primary); color: #fff; }
.mtf-tools .lab { font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ff-text-faint); }
.mtf-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--ff-text-soft); margin-top: 6px; }
.mtf-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ----------------------------- calendar heatmap ----------------------------- */
.mtf-cal { overflow-x: auto; padding-bottom: 4px; }
.mtf-cal-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(5, 13px);
  grid-auto-columns: 13px; gap: 3px; }
.mtf-cal-grid span { width: 13px; height: 13px; border-radius: 3px; background: var(--ff-neutral-soft); }
.mtf-cal-grid span.u1 { background: #bbf7d0; } .mtf-cal-grid span.u2 { background: #4ade80; }
.mtf-cal-grid span.u3 { background: #16a34a; } .mtf-cal-grid span.d1 { background: #fecaca; }
.mtf-cal-grid span.d2 { background: #f87171; } .mtf-cal-grid span.d3 { background: #dc2626; }
.mtf-cal-grid span.x { background: transparent; }
.mtf-cal-note { font-size: .8rem; color: var(--ff-text-soft); margin-top: 8px; line-height: 1.5; }
.mtf-cal-pin { font-size: .85rem; margin: 6px 0 0; min-height: 1.3em; }

/* ------------------------------ butterfly bars ------------------------------ */
.mtf-fly { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4px 8px; align-items: center; font-size: .8rem; }
.mtf-fly .h { font-size: .7rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ff-text-faint); }
.mtf-fly .l, .mtf-fly .r { display: flex; align-items: center; gap: 6px; }
.mtf-fly .l { justify-content: flex-end; }
.mtf-fly .bar { height: 12px; border-radius: 3px; min-width: 2px; }
.mtf-fly .l .bar { background: var(--ff-accent); }
.mtf-fly .r .bar { background: var(--ff-danger); }
.mtf-fly .mid { text-align: center; font-weight: 600; color: var(--ff-text-soft); white-space: nowrap; }
.mtf-fly .num { font-variant-numeric: tabular-nums; color: var(--ff-text-soft); min-width: 54px; }
.mtf-fly .l .num { text-align: right; }

/* ---------------------------------- gauge ---------------------------------- */
.mtf-gauge { position: relative; height: 12px; border-radius: 6px; margin: 14px 0 6px;
  background: linear-gradient(90deg, #16a34a 0%, #84cc16 40%, #eab308 50%, #f59e0b 75%, #dc2626 90%, #7f1d1d 100%); }
.mtf-gauge i { position: absolute; top: -5px; width: 4px; height: 22px; border-radius: 2px;
  background: var(--ff-text); transform: translateX(-50%); }
.mtf-gauge-scale { display: flex; justify-content: space-between; font-size: .68rem; color: var(--ff-text-faint); }
.mtf-score { font-size: 3rem; font-weight: 700; letter-spacing: -2px; line-height: 1; color: var(--ff-primary); }
.mtf-score small { font-size: 1rem; color: var(--ff-text-faint); font-weight: 500; letter-spacing: 0; }
.mtf-band { font-weight: 700; }
.mtf-band.Calm { color: var(--ff-success-deep); } .mtf-band.Elevated { color: var(--ff-warning-deep); }
.mtf-band.High { color: var(--ff-danger); } .mtf-band.Extreme { color: var(--ff-danger-deep); }

/* -------------------------------- deciles -------------------------------- */
.mtf-dec { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; align-items: end;
  height: 170px; margin: 10px 0 4px; position: relative; }
.mtf-dec .c { display: flex; flex-direction: column; justify-content: center; height: 100%; position: relative; }
.mtf-dec .b { position: absolute; left: 10%; right: 10%; border-radius: 3px; }
.mtf-dec .b.p { background: var(--ff-success); } .mtf-dec .b.n { background: var(--ff-danger); }
.mtf-dec .v { position: absolute; left: 0; right: 0; text-align: center; font-size: .68rem;
  font-variant-numeric: tabular-nums; color: var(--ff-text-soft); }
.mtf-dec-axis { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; font-size: .68rem;
  text-align: center; color: var(--ff-text-faint); }
.mtf-dec-zero { position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--ff-border); }

/* ------------------------------- seasonality ------------------------------- */
.mtf-season { display: grid; grid-template-columns: repeat(var(--n, 12), 1fr); gap: 4px; align-items: end; height: 120px; }
.mtf-season div { position: relative; height: 100%; }
.mtf-season div b { position: absolute; left: 12%; right: 12%; border-radius: 3px; }
.mtf-season div b.p { background: var(--ff-success); bottom: 50%; }
.mtf-season div b.n { background: var(--ff-danger); top: 50%; }
.mtf-season-axis { display: grid; grid-template-columns: repeat(var(--n, 12), 1fr); gap: 4px;
  font-size: .66rem; text-align: center; color: var(--ff-text-faint); margin-top: 3px; }
.mtf-grid-years { overflow-x: auto; }
.mtf-grid-years table { border-collapse: separate; border-spacing: 2px; font-size: .74rem; }
.mtf-grid-years td, .mtf-grid-years th { padding: 4px 6px; text-align: right; border-radius: 3px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.mtf-grid-years th { color: var(--ff-text-faint); font-weight: 600; }

/* --------------------------------- treemap --------------------------------- */
.mtf-tree { position: relative; height: 460px; border-radius: var(--ff-radius-sm); overflow: hidden; background: var(--ff-neutral-soft); }
.mtf-tree a { position: absolute; display: block; overflow: hidden; color: #fff; text-decoration: none;
  font-size: .7rem; line-height: 1.15; padding: 3px 4px; border: 1px solid rgba(255,255,255,.55); box-sizing: border-box; }
.mtf-tree a b { display: block; font-size: .74rem; }
.mtf-tree-legend { display: flex; gap: 10px; align-items: center; font-size: .74rem; color: var(--ff-text-soft); margin-top: 8px; flex-wrap: wrap; }
.mtf-tree-legend span { display: inline-block; width: 26px; height: 10px; border-radius: 2px; vertical-align: -1px; }

/* ------------------------------ screener form ------------------------------ */
.mtf-filters { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: end; margin-bottom: 10px; }
.mtf-filters label { display: flex; flex-direction: column; gap: 3px; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .4px; color: var(--ff-text-faint); }
.mtf-filters input, .mtf-filters select { font: inherit; font-size: .85rem; padding: 6px 8px;
  border: 1px solid var(--ff-border); border-radius: 7px; background: var(--ff-card); color: var(--ff-text);
  min-width: 90px; }
.mtf-filters input[type=number] { width: 96px; }
.mtf-filters .chk { flex-direction: row; align-items: center; gap: 5px; text-transform: none;
  letter-spacing: 0; font-size: .84rem; color: var(--ff-text-soft); }
.mtf-filters button, .mtf-btn { font: inherit; font-size: .85rem; padding: 7px 14px; border-radius: 7px;
  border: 1px solid var(--ff-primary); background: var(--ff-primary); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
.mtf-btn.ghost { background: var(--ff-card); color: var(--ff-primary); }
.mtf-views { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mtf-views a { font-size: .82rem; padding: 5px 11px; border-radius: 16px; border: 1px solid var(--ff-border);
  color: var(--ff-text-soft); text-decoration: none; background: var(--ff-card); }
.mtf-views a.on { background: var(--ff-primary); color: #fff; border-color: var(--ff-primary); }
.mtf-pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 10px 0 16px; font-size: .85rem; }
.mtf-pager a, .mtf-pager span { padding: 5px 10px; border: 1px solid var(--ff-border); border-radius: 6px; text-decoration: none; color: var(--ff-text-soft); background: var(--ff-card); }
.mtf-pager span.on { background: var(--ff-primary); color: #fff; }
.mtf-spark { display: block; }
.mtf-spark.up polyline { stroke: var(--ff-success); }
.mtf-spark.down polyline { stroke: var(--ff-danger); }

/* -------------------------------- letters -------------------------------- */
.mtf-letters { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 12px; }
.mtf-letters a { min-width: 28px; text-align: center; padding: 4px 6px; border: 1px solid var(--ff-border);
  border-radius: 6px; text-decoration: none; color: var(--ff-text-soft); font-size: .82rem; background: var(--ff-card); }
.mtf-letters a.on { background: var(--ff-primary); color: #fff; }

/* ------------------------------ search + lists ------------------------------ */
.mtf-search { position: relative; max-width: 420px; }
.mtf-search input { width: 100%; box-sizing: border-box; font: inherit; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--ff-border); background: var(--ff-card); color: var(--ff-text); }
.mtf-search ul { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px 0;
  list-style: none; background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: 8px;
  box-shadow: var(--ff-shadow); max-height: 320px; overflow-y: auto; }
.mtf-search li { padding: 7px 12px; cursor: pointer; font-size: .86rem; display: flex; justify-content: space-between; gap: 10px; }
.mtf-search li:hover, .mtf-search li.on { background: var(--ff-neutral-soft); }
.mtf-search li small { color: var(--ff-text-faint); }

.mtf-rank { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.mtf-rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--ff-border); font-size: .85rem; counter-increment: r; }
.mtf-rank li:last-child { border-bottom: 0; }
.mtf-rank li::before { content: counter(r); color: var(--ff-text-faint); font-size: .75rem; text-align: right; }
.mtf-rank .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.mtf-rank .v small { display: block; font-weight: 500; font-size: .72rem; color: var(--ff-text-faint);
  white-space: normal; max-width: 46vw; margin-left: auto; }
.mtf-tabs-mini { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.mtf-tabs-mini button { font: inherit; font-size: .76rem; padding: 4px 9px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--ff-border); background: var(--ff-card); color: var(--ff-text-soft); }
.mtf-tabs-mini button.on { background: var(--ff-primary); color: #fff; border-color: var(--ff-primary); }
[data-pane][hidden] { display: none !important; }

/* ------------------------------- watchlist ------------------------------- */
.mtf-watch-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mtf-watch-list table { width: 100%; }
.mtf-x { border: 0; background: none; color: var(--ff-text-faint); cursor: pointer; font-size: 1rem; }

/* ------------------------------ calculators ------------------------------ */
.mtf-calc { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .mtf-calc { grid-template-columns: 1fr 1fr; } }
.mtf-calc .mi-card { margin: 0; }
.mtf-calc form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.mtf-calc label { display: flex; flex-direction: column; gap: 3px; font-size: .74rem; color: var(--ff-text-soft); }
.mtf-calc input, .mtf-calc select { font: inherit; font-size: .9rem; padding: 6px 8px; border: 1px solid var(--ff-border);
  border-radius: 7px; background: var(--ff-card); color: var(--ff-text); }
.mtf-out { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .86rem; }
.mtf-out div { background: var(--ff-neutral-soft); border-radius: 7px; padding: 7px 9px; }
.mtf-out b { display: block; font-size: 1.02rem; color: var(--ff-primary); font-variant-numeric: tabular-nums; }
.mtf-out .bad b { color: var(--ff-danger-deep); } .mtf-out .good b { color: var(--ff-success-deep); }

/* -------------------------------- records -------------------------------- */
.mtf-recs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 14px; }
.mtf-rec { background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: var(--ff-radius);
  box-shadow: var(--ff-shadow); padding: 12px 14px; }
.mtf-rec .t { font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ff-text-faint); }
.mtf-rec .v { font-size: 1.25rem; font-weight: 700; color: var(--ff-primary); margin: 4px 0 2px; }
.mtf-rec .d { font-size: .8rem; color: var(--ff-text-soft); }
.mtf-rec .n { font-size: .76rem; color: var(--ff-text-faint); margin-top: 3px; }

/* ------------------------------ report pages ------------------------------ */
.mtf-pn { display: flex; justify-content: space-between; gap: 10px; margin: 2px 0 14px; font-size: .86rem; }
.mtf-pn a { color: var(--ff-accent); text-decoration: none; }
.mtf-pn span { color: var(--ff-text-faint); }
.mtf-flag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 5px;
  background: var(--ff-danger-soft); color: var(--ff-danger-deep); margin-left: 6px; }
.mtf-flag.rec { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.mtf-flag.prog { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }

/* ------------------------------ prose (learn) ------------------------------ */
.mtf-prose { max-width: 820px; }
.mtf-prose h2 { font-size: 1.12rem; color: var(--ff-primary); margin: 22px 0 8px; }
.mtf-prose p, .mtf-prose li { line-height: 1.65; font-size: .95rem; }
.mtf-prose code { background: var(--ff-neutral-soft); padding: 1px 5px; border-radius: 4px; font-size: .86rem; }
.mtf-def { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; gap: 6px 16px; font-size: .9rem; }
.mtf-def dt { font-weight: 600; color: var(--ff-primary); }
.mtf-def dd { margin: 0 0 6px; line-height: 1.55; color: var(--ff-text-soft); }
@media (max-width: 640px) { .mtf-def { grid-template-columns: 1fr; } }
.mtf-checks li { margin: 4px 0; }
.mtf-checks .ok { color: var(--ff-success-deep); font-weight: 700; }
.mtf-checks .no { color: var(--ff-danger-deep); font-weight: 700; }
.mtf-fresh a { color: inherit; }

@media (max-width: 640px) {
  .mtf-big .v { font-size: 1.8rem; }
  .mtf-chart { height: 240px; }
  .mtf-tree { height: 360px; }
  .mtf-calc form, .mtf-out { grid-template-columns: 1fr; }
}
