/* QFI Terminal — module "summary" (RESEARCH » SUMMARY / FUNDAMENTALS elements)
   Ported from terminal/assets/css/components.css + theme.css, trimmed to what
   these five elements need. All selectors scoped under .qm-summary. Colours
   and font stacks are copied verbatim from the terminal's own variables
   (theme.css :root) rather than re-guessed. */

.qm-summary {
    --bg-secondary: #0c0c0c;
    --border: #333333;
    --text-primary: #F0F0F0;
    --text-secondary: #B0B0B0;
    --text-muted: #666666;
    --accent-primary: #FF9900;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --font-sans: 'Lato', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    --rx-chip: rgba(255,255,255,0.055);
    --rx-mut2: #97a2b0;
    --rx-txt: #e2e6ec;
    --rx-line: #333333;
    --rx-green: #2ebd59;
    --rx-red: #e05252;
    --green: #22c55e;
    --red: #ef4444;
    box-sizing: border-box;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
}
.qm-summary *, .qm-summary *::before, .qm-summary *::after { box-sizing: border-box; }

/* ============================= shared bits ============================= */
.qm-summary .qm-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
    margin: 0 0 10px 0;
}
.qm-summary .qm-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--rx-chip);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--rx-mut2);
    padding: 4px 10px;
    font-family: var(--font-sans);
    white-space: nowrap;
}
.qm-summary .qm-tag b { color: var(--rx-txt); font-family: var(--font-mono); }

/* ===================== summary.performance (E03) ======================= */
.qm-perf {
    display: flex;
    flex-direction: column;
    padding: 4px 2px;
    background: transparent;
    border: 0;
    width: 100%;
    height: 100%;
    position: relative;
}
.qm-perf-watermark {
    position: absolute;
    z-index: 0;
    left: 50%;
    top: 108px;
    transform: translateX(-50%);
    color: rgba(232, 138, 45, .1);
    font: 900 40px/1 'JetBrains Mono', 'Consolas', monospace;
    letter-spacing: .08em;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}
.qm-perf-part {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .42s ease, transform .58s cubic-bezier(.16, 1, .3, 1);
}
.qm-perf-part.go { opacity: 1; transform: none; }
.qm-perf-tabs { display: flex; gap: 6px; margin-left: auto; }
.qm-perf-tabs button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 5px 10px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.15s;
}
.qm-perf-tabs button:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.qm-perf-tabs button.on { background: rgba(232,138,45,0.15); border-color: #e88a2d; color: #e88a2d; }
.qm-perf-legends { display: flex; align-items: center; gap: 22px; padding-bottom: 12px; }
.qm-perf-legend { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 800; letter-spacing: 0.8px; color: var(--text-primary); text-transform: uppercase; font-family: var(--font-sans); }
.qm-perf-dot { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.qm-perf-dot.stock { background: #e88a2d; }
.qm-perf-dot.spy { background: rgba(255,255,255,0.45); }
.qm-perf canvas { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; display: block; cursor: crosshair; }

/* ===================== summary.overview (E04) =========================== */
.qm-fin {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    width: 100%;
    height: 100%;
}
.qm-fin-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    align-items: center;
    height: calc(100% - 26px);
    gap: 0;
}
.qm-fin-label { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.qm-fin-name { font-size: 11.5px; font-weight: 800; letter-spacing: 1.2px; font-family: var(--font-sans); text-transform: uppercase; }
.qm-fin-value { font-size: 18px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.qm-fin-sub { font-size: 11px; font-weight: 700; letter-spacing: 0.3px; color: var(--text-muted); white-space: nowrap; font-family: var(--font-sans); }
.qm-fin-sub b { font-family: var(--font-mono); font-weight: 700; color: var(--text-secondary); }
.qm-fin-chart { height: 100%; display: flex; align-items: center; justify-content: center; }
.qm-fin-chart svg { width: 100%; height: 100%; max-width: 220px; max-height: 220px; overflow: visible; }

/* ===================== summary.employees (E05) =========================== */
.qm-emp {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.qm-emp-holder { flex: 1; position: relative; min-height: 0; }
.qm-emp-holder canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }

/* ===================== eq-glance 6-box grid (E06 groups) ==================
   summary.keyStats / .earnings / .balanceSheet / .enterpriseValue /
   .leverage / .shareStats — one terminal renderKeyMetrics() group per
   element, each its own box so the deck engine's own .box stagger (see
   deck3_template.html, transition-delay .35s + k*.18s per el) does the
   "boxes rise one after another" beat with no extra JS needed here. */
.qm-mbox {
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--font-mono);
}
.qm-mbox h3 {
    font-size: 11px;
    color: #e88a2d;
    margin: 0;
    height: 28px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    letter-spacing: 1.4px;
    font-weight: 700;
    text-transform: uppercase;
    font-family: var(--font-mono);
    flex: none;
}
/* Fixed per-row height (box-sizing:border-box is set globally above) instead
   of letting the table's own "height:100%" distribute rows by content: that
   left the last row's true height a few px taller than its share of the box,
   silently clipped by overflow:hidden with no visible seam. A hard row
   height makes every box's total height exactly header + rows*rowH, which
   is what scenes.js's box h is now set to, per row count. */
.qm-mbox table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.qm-mbox tr { opacity: 0; transform: translateX(-6px); transition: opacity .4s ease var(--rd,0ms), transform .4s ease var(--rd,0ms), background-color .3s; height: 28px; }
.qm-mbox.go tr { opacity: 1; transform: none; }
.qm-mbox tr.hl { background: rgba(255,153,0,0.10); }
.qm-mbox tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.qm-mbox tr.hl:nth-child(even) { background: rgba(255,153,0,0.10); }
.qm-mbox td { font-size: 12.5px; height: 28px; padding: 0 8px; font-family: var(--font-mono); border-bottom: 0; vertical-align: middle; }
.qm-mbox td:first-child { width: 58%; color: var(--text-secondary); font-weight: 400; }
.qm-mbox td:last-child { width: 42%; text-align: right; color: var(--text-primary); font-weight: 600; font-size: 13.5px; letter-spacing: 0.3px; }
.qm-mbox td.pos { color: var(--green) !important; }
.qm-mbox td.neg { color: var(--red) !important; }
.qm-num { font-variant-numeric: tabular-nums; }

/* ===================== summary.overviewMini (E04, portrait) =============== */
.qm-fm {
    width: 100%;
    height: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.qm-fm .qm-title { align-self: flex-start; }
.qm-fm-chart { width: 100%; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.qm-fm-chart svg { width: 100%; height: 100%; max-width: 230px; max-height: 230px; overflow: visible; }
.qm-fm-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-top: 1px solid var(--rx-line);
    font-family: var(--font-sans);
}
.qm-fm-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.qm-fm-name { font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-secondary); }
.qm-fm-value { margin-left: auto; font-size: 16px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }

/* ===================== summary.priceEps (E12) ============================ */
.qm-pe {
    width: 100%;
    height: 100%;
    padding: 4px 2px;
    background: transparent;
    border: 0;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
}
.qm-pe-part {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .42s ease, transform .58s cubic-bezier(.16, 1, .3, 1);
}
.qm-pe-part.go { opacity: 1; transform: none; }
.qm-pe-head { display: flex; justify-content: space-between; gap: 28px; align-items: center; }
.qm-pe-identity { display: flex; align-items: center; gap: 18px; min-width: 0; }
.qm-pe-head .qm-pe-name { font-size: 21px; line-height: 1.1; font-weight: 800; color: var(--rx-txt); white-space: nowrap; }
.qm-pe-head .qm-pe-sym { margin-top: 4px; font-size: 13px; color: var(--rx-mut2); font-family: var(--font-mono); }
.qm-pe-meta { display: flex; align-items: center; gap: 16px; min-width: 0; }
.qm-pe-head .qm-tag { padding: 0; background: none; border-radius: 0; font-size: 13px; }
.qm-pe-head .qm-tag + .qm-tag { padding-left: 16px; border-left: 1px solid var(--rx-line); }
.qm-pe-stats { display: flex; gap: 28px; flex: none; }
.qm-pe-bigstat { min-width: 126px; border-left: 1px solid var(--rx-line); padding: 0 0 0 20px; font-size: 12.5px; color: var(--rx-mut2); font-weight: 800; }
.qm-pe-bigstat b { display: block; margin-top: 3px; font-size: 27px; line-height: 1.05; color: var(--rx-txt); font-family: var(--font-mono); }
.qm-pe-chart { flex: 1; margin-top: 18px; min-height: 0; position: relative; }
.qm-pe-chart svg { width: 100%; height: 100%; display: block; cursor: crosshair; }
.qm-pe-chips { display: flex; gap: 0; align-items: stretch; margin-top: 12px; }
.qm-pe-chips .tf {
    flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px;
    appearance: none; background: transparent; border: 0; border-right: 1px solid var(--rx-line); padding: 8px 12px;
    font: 800 13px/1.2 var(--font-sans); cursor: pointer; min-width: 0; color: var(--rx-txt);
}
.qm-pe-chips .tf:last-child { border-right: none; }
.qm-pe-chips .tf span { color: var(--rx-green); font-weight: 700; white-space: nowrap; }
.qm-pe-chips .tf span.neg { color: var(--rx-red); }
.qm-pe-chips .tf.on { color: #ff9900; background: transparent; box-shadow: inset 0 -2px 0 rgba(255,153,0,.75); }
.qm-pe-chips .tf:hover { background: rgba(255,255,255,.035); }
.qm-pe-chips .tf:focus-visible { outline: 2px solid #ff9900; outline-offset: -2px; }
.qm-pe .qm-tip { font-size: 12px; padding: 7px 9px; }

/* ===================== shared SVG entrance animation kit ================
   Ported verbatim from the terminal's .rsx svg .adr/.afd/.agr rules
   (components.css:44613-44623): a path drawn with pathLength=1 and
   stroke-dasharray=1 animates via stroke-dashoffset, plain elements fade,
   bars grow from the baseline. The terminal flips these with an
   IntersectionObserver adding .go; here enter()/idle() add and remove it. */
.qm-summary svg .agr { transform: scaleY(0); transform-box: fill-box; transform-origin: 50% 100%; transition: transform 0.8s cubic-bezier(0.25,0.7,0.3,1) var(--d,0ms); }
.qm-summary svg.go .agr { transform: scaleY(1); }
.qm-summary svg .adr { stroke-dashoffset: 1; transition: stroke-dashoffset var(--dur,1000ms) cubic-bezier(0.45,0.1,0.35,0.95) var(--d,0ms); }
.qm-summary svg.go .adr { stroke-dashoffset: 0; }
.qm-summary svg .afd { opacity: 0; transition: opacity 0.55s ease var(--d,0ms); }
.qm-summary svg.go .afd { opacity: 1; }

/* Tooltip shared by canvas/SVG hover (positioned absolutely inside the
   mounted element, which is the nearest positioned ancestor). */
.qm-summary .qm-tip {
    position: absolute;
    pointer-events: none;
    background: rgba(15,23,42,0.92);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 6px 8px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: #e2e8f0;
    white-space: nowrap;
    z-index: 5;
    display: none;
}
.qm-summary [style*="position: relative"] { }
.qm-perf, .qm-emp-holder, .qm-pe-chart { position: relative; }
