/* ==========================================================================
   F&O Market Movers (/admin/fno-market-movers)
   Pixel-matched to StockMojo "Live Future Market Movers" (light theme values
   read from their computed styles, Oct 2026). Dark theme is an adaptation.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&display=swap');

.fm {
    /* light = StockMojo exact */
    --fm-card: #ffffff;
    --fm-line: #d1d5db;
    --fm-input-line: #d1d5dc;
    --fm-text: #111827;
    --fm-text-2: #374151;
    --fm-muted: #6b7280;
    --fm-faint: #9ca3af;
    --fm-up: #15803d;
    --fm-down: #b91c1c;
    --fm-accent: #2b7fff;
    --fm-row-hover: #f9fafb;

    --fm-h-yellow: #fefce8;
    --fm-h-blue: #eff6ff;
    --fm-h-green: #ecfdf5;
    --fm-h-purple: #faf5ff;
    --fm-h-amber: #fffbeb;

    --fm-dd-bg: #ffffff;
    --fm-dd-sel-bg: #eaf2ff;
    --fm-dd-sel-fg: #1d4ed8;
    --fm-dd-hover: #f3f4f6;
    --fm-pop-bg: #f8f8f9;

    --fm-l-bg: linear-gradient(to right, #86efac, #4ade80);  --fm-l-fg: #166534;  --fm-l-bd: #86efac;
    --fm-sc-bg: linear-gradient(to right, #dcfce7, #bbf7d0); --fm-sc-fg: #166534; --fm-sc-bd: #86efac;
    --fm-s-bg: linear-gradient(to right, #fee2e2, #fecaca);  --fm-s-fg: #991b1b;  --fm-s-bd: #fca5a5;
    --fm-lu-bg: linear-gradient(to right, #ffedd5, #fed7aa); --fm-lu-fg: #9a3412; --fm-lu-bd: #fdba74;
    --fm-na-bg: linear-gradient(to right, #f3f4f6, #e5e7eb); --fm-na-fg: #4b5563; --fm-na-bd: #d1d5db;

    color: var(--fm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 14px;
}

/* dark adaptation (app default theme) */
[data-theme="dark"] .fm, :root:not([data-theme="light"]) .fm {
    --fm-card: #1e222d;
    --fm-line: #363a45;
    --fm-input-line: #3a3f4b;
    --fm-text: #e5e7eb;
    --fm-text-2: #cbd5e1;
    --fm-muted: #9ca3af;
    --fm-faint: #6b7280;
    --fm-up: #22c55e;
    --fm-down: #f87171;
    --fm-row-hover: #262b37;
    --fm-h-yellow: #2a2818;
    --fm-h-blue: #1b2436;
    --fm-h-green: #16281f;
    --fm-h-purple: #241c33;
    --fm-h-amber: #2b2416;
    --fm-dd-bg: #1e222d;
    --fm-dd-sel-bg: rgba(43,127,255,.18);
    --fm-dd-sel-fg: #93c5fd;
    --fm-dd-hover: #262b37;
    --fm-pop-bg: #232733;
    --fm-l-bg: linear-gradient(to right, #166534, #15803d);  --fm-l-fg: #dcfce7;  --fm-l-bd: #166534;
    --fm-sc-bg: linear-gradient(to right, rgba(34,197,94,.16), rgba(34,197,94,.26)); --fm-sc-fg: #86efac; --fm-sc-bd: rgba(34,197,94,.35);
    --fm-s-bg: linear-gradient(to right, rgba(239,68,68,.2), rgba(239,68,68,.32));   --fm-s-fg: #fca5a5;  --fm-s-bd: rgba(239,68,68,.4);
    --fm-lu-bg: linear-gradient(to right, rgba(251,146,60,.16), rgba(251,146,60,.28)); --fm-lu-fg: #fdba74; --fm-lu-bd: rgba(251,146,60,.4);
    --fm-na-bg: rgba(156,163,175,.16); --fm-na-fg: #cbd5e1; --fm-na-bd: #4b5563;
}

.fm-card { background: var(--fm-card); border: 1px solid var(--fm-line); border-radius: 8px; }

/* ── Header card ─────────────────────────────────────────────────────── */
.fm-header { margin-bottom: 10px; }
.fm-title-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px; border-bottom: 1px solid var(--fm-line);
}
.fm-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; margin: 0; color: var(--fm-text); line-height: 1.4; }
.fm-title svg { color: #ec4899; }
.fm-asof { display: flex; align-items: center; gap: 6px; color: var(--fm-text); font-size: 12px; }
.fm-dot { width: 18px; height: 18px; border-radius: 50%; background: #4b5563; display: inline-block; margin-left: 4px; }
.fm-dot.live { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25); animation: fm-pulse 2s infinite; }
@keyframes fm-pulse { 50% { box-shadow: 0 0 0 6px rgba(34,197,94,.05); } }

.fm-controls { padding: 12px 16px; }
.fm-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.fm-field { display: flex; align-items: center; gap: 8px; color: var(--fm-muted); font-size: 14px; }
.fm-input {
    height: 32px; border: 1px solid var(--fm-input-line); border-radius: 6px; background: var(--fm-card);
    color: var(--fm-text); padding: 0 11px; font-size: 14px; width: 120px; font-family: inherit;
}
.fm-input::placeholder { color: #bfbfbf; }
.fm-input:hover { border-color: #4096ff; }
.fm-input:focus { outline: none; border-color: #4096ff; box-shadow: 0 0 0 2px rgba(5,145,255,.1); }
.fm-spacer { flex: 1; }

/* custom select (antd look) */
.fm-dd { position: relative; }
.fm-dd-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 11px; min-width: 180px;
    border: 1px solid var(--fm-input-line); border-radius: 6px; background: var(--fm-card); color: var(--fm-text);
    font-size: 14px; font-family: inherit; cursor: pointer; text-align: left;
}
.fm-dd-btn:hover, .fm-dd.open .fm-dd-btn { border-color: #4096ff; }
.fm-dd.open .fm-dd-btn { box-shadow: 0 0 0 2px rgba(5,145,255,.1); }
.fm-dd.open .fm-dd-btn .fm-dd-val { color: #bfbfbf; }
.fm-dd-val { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-dd-chev { color: #bfbfbf; display: inline-flex; }
.fm-dd-ico { color: var(--fm-text); display: inline-flex; }
.fm-dd-panel {
    position: absolute; top: 36px; left: 0; z-index: 30; min-width: 100%; max-height: 256px; overflow-y: auto;
    padding: 4px; background: var(--fm-dd-bg); border-radius: 8px;
    box-shadow: 0 6px 16px 0 rgba(0,0,0,.08), 0 3px 6px -4px rgba(0,0,0,.12), 0 9px 28px 8px rgba(0,0,0,.05);
}
.fm-dd-opt {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 12px;
    border: 0; border-radius: 4px; background: none; color: var(--fm-text); font-size: 14px; font-family: inherit;
    text-align: left; cursor: pointer; white-space: nowrap;
}
.fm-dd-opt:hover { background: var(--fm-dd-hover); }
.fm-dd-opt.sel { background: var(--fm-dd-sel-bg); color: var(--fm-dd-sel-fg); font-weight: 600; }
.fm-sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; flex: none; }
.fm-backdrop { position: fixed; inset: 0; z-index: 25; }

.fm-seg { display: inline-flex; border: 1px solid var(--fm-line); border-radius: 6px; overflow: hidden; }
.fm-seg button {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 15px;
    border: 0; background: var(--fm-card); color: var(--fm-text); font-size: 14px; font-family: inherit; cursor: pointer;
}
.fm-seg button + button { border-left: 1px solid var(--fm-line); }
.fm-seg button[aria-pressed="true"] { background: var(--fm-accent); color: #fff; }
.fm-iconbtn {
    height: 32px; width: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--fm-line); border-radius: 6px; background: var(--fm-card); color: var(--fm-text); cursor: pointer;
}
.fm-iconbtn:disabled { opacity: .45; cursor: default; }

.fm-legend { display: flex; align-items: center; flex-wrap: wrap; margin-top: 14px; row-gap: 6px; }
.fm-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 8px 0 0; margin-right: 8px;
    border: 0; border-right: 1px solid var(--fm-line); background: none; color: var(--fm-text-2);
    font-size: 12px; font-weight: 500; font-family: inherit; cursor: pointer; line-height: 18px;
}
.fm-chip:last-of-type { border-right: 0; }
.fm-chip[aria-pressed="true"] { color: var(--fm-accent); text-decoration: underline; text-underline-offset: 3px; }
.fm-hm-sort { display: inline-flex; align-items: center; gap: 6px; margin-left: 16px; color: var(--fm-muted); font-size: 14px; }
.fm-hm-sort button {
    height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--fm-line);
    background: var(--fm-card); color: var(--fm-text); cursor: pointer; font-size: 14px; font-family: inherit;
}
.fm-hm-sort button[aria-pressed="true"] { border-color: var(--fm-accent); background: var(--fm-h-blue); color: var(--fm-accent); }

.fm-banner { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.fm-banner.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.fm-banner.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
[data-theme="dark"] .fm .fm-banner.warn, :root:not([data-theme="light"]) .fm .fm-banner.warn { background: rgba(234,179,8,.1); color: #facc15; border-color: rgba(234,179,8,.3); }
[data-theme="dark"] .fm .fm-banner.err, :root:not([data-theme="light"]) .fm .fm-banner.err { background: rgba(239,68,68,.1); color: #f87171; border-color: rgba(239,68,68,.3); }

/* ── Body grid ───────────────────────────────────────────────────────── */
.fm-body { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 10px; align-items: start; }
@media (max-width: 1100px) { .fm-body { grid-template-columns: 1fr; } }

.fm-tablewrap { overflow: auto; max-height: calc(100vh - 250px); min-height: 360px; }
.fm-table {
    width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums;
    font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.fm-table th {
    position: sticky; top: 0; z-index: 2; color: var(--fm-text); background: var(--fm-card);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500; font-size: 14px; height: 32px; padding: 0 8px; text-align: center; white-space: nowrap;
    border-bottom: 1px solid var(--fm-line); border-right: 1px solid var(--fm-line);
}
.fm-table td {
    padding: 0 8px; height: 40px; text-align: center; white-space: nowrap; font-size: 13px; font-weight: 500;
    color: var(--fm-text); border-bottom: 1px solid var(--fm-line); border-right: 1px solid var(--fm-line);
}
.fm-table th:last-child, .fm-table td:last-child { border-right: 0; }
.fm-table tbody tr:hover td:not(.sym):not(.sec):not(.bld) { background-color: var(--fm-row-hover); }
.fm-table th.g-y { background: var(--fm-h-yellow); }
.fm-table th.g-b { background: var(--fm-h-blue); }
.fm-table th.g-g { background: var(--fm-h-green); }
.fm-table th.g-p { background: var(--fm-h-purple); }
.fm-table th.g-a { background: var(--fm-h-amber); }
.fm-table th.sym, .fm-table td.sym { position: sticky; left: 0; text-align: left; z-index: 1; }
.fm-table th.sym { z-index: 3; text-align: center; }
.fm-table td.sym, .fm-table td.sec { background: var(--fm-h-yellow); }
.fm-th { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.fm-sort { display: inline-flex; flex-direction: column; line-height: 0; color: #bfbfbf; }
.fm-sort svg { display: block; }
.fm-sort .on { color: var(--fm-accent); }
.fm-funnel { border: 0; background: none; color: #8c8c8c; cursor: pointer; padding: 0 2px; display: inline-flex; vertical-align: middle; }
.fm-funnel:hover, .fm-funnel.on { color: var(--fm-accent); }
.fm-thf { display: inline-flex; align-items: center; gap: 6px; position: relative; }

/* column filter popover (ag-grid quartz look) */
.fm-pop {
    position: absolute; top: 24px; left: -12px; z-index: 30; width: 215px; padding: 12px;
    background: var(--fm-pop-bg); border: 1px solid rgba(17,24,39,.2); border-radius: 4px;
    box-shadow: 0 0 16px rgba(0,0,0,.15); text-align: left; font-weight: 400; cursor: default;
}
.fm-pop-sel { position: relative; margin-bottom: 8px; }
.fm-pop-sel select {
    appearance: none; -webkit-appearance: none; width: 100%; height: 32px; padding: 0 28px 0 10px;
    background: var(--fm-card); color: var(--fm-text); border: 1px solid var(--fm-line); border-radius: 5px;
    font-size: 14px; font-family: inherit; cursor: pointer;
}
.fm-pop-sel::after {
    content: ""; position: absolute; right: 10px; top: 13px; pointer-events: none;
    border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--fm-text);
}
.fm-pop-in { position: relative; margin-bottom: 12px; }
.fm-pop-in svg { position: absolute; left: 9px; top: 9px; color: #8c8c8c; }
.fm-pop-in input {
    width: 100%; height: 32px; padding: 0 8px 0 28px; box-sizing: border-box;
    background: var(--fm-card); color: var(--fm-text); border: 1px solid var(--fm-line); border-radius: 4px;
    font-size: 14px; font-family: inherit;
}
.fm-pop-in input::placeholder { color: #9ca3af; }
.fm-pop-in input:focus { outline: none; border-color: #2196f3; box-shadow: 0 0 0 3px rgba(33,150,243,.47); }
.fm-pop-sel select:focus { outline: none; border-color: #2196f3; box-shadow: 0 0 0 3px rgba(33,150,243,.47); }
.fm-pop-actions { display: flex; justify-content: flex-end; }
.fm-pop-actions button {
    height: 32px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--fm-line);
    background: var(--fm-card); color: var(--fm-text); cursor: pointer; font-size: 14px; font-family: inherit;
}
.fm-pop-actions button:hover { background: var(--fm-dd-hover); }

.fm-symcell { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.fm-logo {
    width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: #fff; letter-spacing: -.02em;
}
.fm-symname { font-weight: 500; font-size: 13px; color: var(--fm-text); text-decoration: none; }
.fm-symname:hover { color: var(--fm-accent); }
.fm-chart { color: var(--fm-text); display: inline-flex; opacity: .85; }
.fm-chart:hover { color: var(--fm-accent); opacity: 1; }

.fm-secs { display: flex; gap: 4px; justify-content: center; align-items: center; flex-wrap: nowrap; }
.fm-sec {
    width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 700; color: #fff; background: #1e3a8a; letter-spacing: -.03em;
}
.fm-sec.s-bnk { background: #15803d; } .fm-sec.s-fin { background: #0284c7; } .fm-sec.s-mid { background: #ea580c; }
.fm-sec.s-other { background: transparent; color: var(--fm-text); border: 1.5px solid var(--fm-text); font-size: 7px; }
.fm-muted { color: var(--fm-faint); }

.fm-ohl { font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 4px; border: 1px solid; }
.fm-ohl.ol { color: #166534; background: #dcfce7; border-color: #86efac; }
.fm-ohl.oh { color: #991b1b; background: #fee2e2; border-color: #fca5a5; }

.up { color: var(--fm-up) !important; }
.down { color: var(--fm-down) !important; }

.fm-table td.bld { padding: 0; }
.fm-bld { display: flex; align-items: center; justify-content: center; gap: 4px; height: 39px; font-size: 13px; border: 1px solid transparent; box-sizing: border-box; }
.fm-bld .lbl { font-size: 12px; }
.fm-bld.l { background: var(--fm-l-bg); color: var(--fm-l-fg); border-color: var(--fm-l-bd); }
.fm-bld.sc { background: var(--fm-sc-bg); color: var(--fm-sc-fg); border-color: var(--fm-sc-bd); }
.fm-bld.s { background: var(--fm-s-bg); color: var(--fm-s-fg); border-color: var(--fm-s-bd); }
.fm-bld.lu { background: var(--fm-lu-bg); color: var(--fm-lu-fg); border-color: var(--fm-lu-bd); }
.fm-bld.na { background: var(--fm-na-bg); color: var(--fm-na-fg); border-color: var(--fm-na-bd); }

.fm-empty { padding: 48px 12px; text-align: center; color: var(--fm-muted); }

/* ── Right rail ─────────────────────────────────────────────────────── */
.fm-rail { display: flex; flex-direction: column; gap: 10px; }
.fm-mini { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 500; font-family: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif; }
.fm-mini th { background: var(--fm-h-yellow); font-weight: 500; font-size: 14px; height: 32px; text-align: center; border-bottom: 1px solid var(--fm-line); font-family: -apple-system, "Segoe UI", sans-serif; }
.fm-mini th + th { background: var(--fm-h-blue); border-left: 1px solid var(--fm-line); }
.fm-mini td { padding: 0 10px; height: 36px; border-bottom: 1px solid var(--fm-line); }
.fm-mini td:first-child { background: var(--fm-h-yellow); }
.fm-mini td:last-child { text-align: center; border-left: 1px solid var(--fm-line); }
.fm-mini.sectors td { height: 40px; }
.fm-mini.sectors td:last-child { background: var(--fm-h-blue); }
.fm-mini tr:last-child td { border-bottom: 0; }
.fm-mini.sectors tbody tr { cursor: pointer; }
.fm-mini tbody tr.on td:first-child { box-shadow: inset 3px 0 0 var(--fm-accent); }
.fm-sector-scroll { max-height: calc(100vh - 470px); min-height: 200px; overflow: auto; }
.fm-sector-scroll .fm-mini th { position: sticky; top: 0; z-index: 1; }
.fm-approx { font-size: 10px; color: var(--fm-muted); margin-left: 3px; }

/* ── Heatmap ─────────────────────────────────────────────────────────── */
.fm-heat { position: relative; height: 600px; max-height: calc(100vh - 230px); min-height: 420px; overflow: hidden; }
.fm-tile {
    position: absolute; box-sizing: border-box; border: 0.5px solid var(--fm-card);
    display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
    color: #fff; text-align: center; line-height: 1.25; cursor: pointer; text-decoration: none;
}
.fm-tile:hover { filter: brightness(1.1); z-index: 1; }
.fm-tile .t-logo {
    width: 25px; height: 25px; border-radius: 3px; background: #fff; color: #111827; font-size: 8px; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 2px; font-family: -apple-system, "Segoe UI", sans-serif;
}
.fm-tile .t-sym { font-weight: 500; font-size: 11px; white-space: nowrap; }
.fm-tile .t-pct { font-weight: 600; font-size: 11px; white-space: nowrap; }
/* Labels follow each tile's real rendered size (StockMojo: big → logo+symbol+%, medium → logo+%, small → %, tiny → blank). */
.fm-tile { container-type: size; }
@container (min-width: 95px) and (min-height: 95px) { .t-sym, .t-pct { font-size: 14px !important; } .t-logo { width: 30px !important; height: 30px !important; } }
@container (max-height: 62px) { .t-sym { display: none; } }
@container (max-width: 62px) { .t-sym { display: none; } }
@container (max-height: 46px) { .t-logo { display: none; } }
@container (max-width: 34px) { .t-logo { display: none; } }
@container (max-height: 15px) { .t-pct { display: none; } }
@container (max-width: 34px) { .t-pct { display: none; } }

/* StockMojo's number field shows no spinner arrows */
.fm-pop-in input::-webkit-outer-spin-button, .fm-pop-in input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fm-pop-in input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* A sticky th is its own stacking context — lift it above the click-away backdrop while its popover is open. */
.fm-table th:has(.fm-pop) { z-index: 40; }
.fm-header { position: relative; z-index: 26; }
