/* ==========================================================================
   OI PHÁI SINH — BÁO CÁO VỊ THẾ (giao diện phẳng, ít khung)
   Nguyên tắc: xanh = tăng/mua/Long, đỏ = giảm/bán/Short; đỏ thương hiệu cho
   điểm nhấn; phân tách bằng khoảng trắng và đường kẻ mảnh thay cho khung card.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--ink-primary);
  font: 400 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num, .kpi-val, .pos-val, td { font-variant-numeric: tabular-nums; }
.t-pos { color: var(--pos); }
.t-neg { color: var(--neg); }
:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; border-radius: 4px; }

.wrap {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- Header (như phaisinh.online) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line-normal);
}
.header-row { display: flex; align-items: center; gap: 24px; height: var(--header-height); }
.brand { display: flex; align-items: center; flex: none; }
.brand-logo { height: 34px; width: auto; display: block; }
:root[data-theme="dark"] .brand-logo { background: #fff; border-radius: 8px; padding: 3px 8px; height: 36px; }
/* ---- ps-nav: menu dùng chung các trang phaisinh.online (quy chuẩn 6.1b; giống hệt signal) ---- */
.nav { display: flex; align-self: stretch; gap: 2px; min-width: 0; }
.nav a {
  position: relative; display: flex; align-items: center; padding: 0 12px;
  font-size: 14.5px; font-weight: 600; color: var(--ink-secondary); text-decoration: none; white-space: nowrap;
}
.nav a:hover { color: var(--ink-primary); }
.nav a.on { color: var(--brand-primary); }
.nav a.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: 2px; background: var(--brand-primary); }
.header-actions .menu-btn { display: none; }
.menu-btn svg { stroke-linecap: round; }
.menu-btn .i-close, .menu-btn[aria-expanded="true"] .i-menu { display: none; }
.menu-btn[aria-expanded="true"] .i-close { display: block; }
@media (max-width: 1080px) {
  .nav a:first-child:not(.on), .nav a:last-child:not(.on) { display: none; }
}
@media (max-width: 860px) {
  .header-actions .menu-btn { display: grid; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0;
    padding: 6px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    background: var(--bg-surface); border-bottom: 1px solid var(--line-normal); box-shadow: var(--shadow-lg);
  }
  .site-header.menu-open .nav { display: flex; }
  .nav a, .nav a:first-child:not(.on), .nav a:last-child:not(.on) { display: flex; }
  .nav a { min-height: 48px; padding: 0 12px; border-radius: var(--radius-sm); font-size: 15px; }
  .nav a + a { border-top: 1px solid var(--line-subtle); }
  .nav a.on { background: var(--brand-soft); }
  .nav a.on::after { display: none; }
}
@media (max-width: 380px) {
  .header-actions .icon-btn, .header-actions .share-btn { width: 36px; height: 36px; }
}
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-normal); background: var(--bg-surface); border-radius: var(--radius-full);
  color: var(--ink-secondary);
}
.icon-btn:hover { color: var(--ink-primary); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .i-moon { fill: currentColor; stroke: none; }
:root[data-theme="dark"] .icon-btn .i-moon, :root:not([data-theme="dark"]) .icon-btn .i-sun { display: none; }
.cta {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: var(--radius-full);
  background: var(--brand-strong); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.cta:hover { background: var(--red-700); }
:root[data-theme="dark"] .cta { background: var(--brand-strong); color: #fff; }

/* ---------- Banner trạng thái ---------- */
.state-banner {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 8px 16px; font-size: 13.5px; background: var(--warn-bg); color: var(--warn);
}
.state-banner .tag { font-weight: 800; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Segmented control (thay cho nút nền đen) ---------- */
.seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-full);
  background: var(--bg-surface-2); border: 1px solid var(--line-normal); flex-wrap: nowrap; max-width: 100%;
}
.seg button {
  border: 0; background: transparent; cursor: pointer; border-radius: var(--radius-full);
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--ink-muted); min-height: 38px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg button:hover { color: var(--ink-primary); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] {
  background: var(--bg-surface); color: var(--brand-primary); box-shadow: 0 1px 3px #11111121;
}
:root[data-theme="dark"] .seg button[aria-selected="true"],
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--bg-surface-3); box-shadow: none; }
.seg button small { font-size: 11.5px; font-weight: 500; color: var(--ink-muted); }
.seg-sm button { padding: 5px 12px; font-size: 13px; min-height: 32px; }

/* ---------- Đầu báo cáo ---------- */
section.report-head {
  background:
    radial-gradient(60% 120% at 0% 0%, var(--red-50) 0%, transparent 60%),
    radial-gradient(40% 90% at 100% 0%, color-mix(in srgb, var(--pos-bg) 70%, transparent) 0%, transparent 60%),
    var(--bg-page);
  padding-block: 28px 26px;
  border-bottom: 1px solid var(--line-normal);
}
.head-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.eyebrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--brand-primary);
}
.status {
  display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0;
  font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--bg-surface-2); color: var(--ink-secondary);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.live { background: var(--pos-bg); color: var(--pos); }
.status.stale, .status.cached, .status.fixture { background: var(--warn-bg); color: var(--warn); }
.status.error { background: var(--neg-bg); color: var(--neg); }
#headline {
  margin-top: 14px; font-size: clamp(1.7rem, 1.1rem + 2.2vw, 2.7rem); font-weight: 800;
  letter-spacing: -0.025em; line-height: 1.15; max-width: 30ch;
}
.deck { margin-top: 12px; font-size: 1.08rem; line-height: 1.6; color: var(--ink-secondary); max-width: 72ch; }
.deck b, .deck .t-pos, .deck .t-neg { font-weight: 700; }
.contract-meta { margin-top: 14px; font-size: 13px; color: var(--ink-muted); }
.contract-meta #sym { font-weight: 700; color: var(--ink-primary); }

/* ---------- KPI (con số lớn, không khung) ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-normal);
}
.kpi { padding: 22px 20px 20px; min-width: 0; position: relative; }
.kpi + .kpi::before { content: ""; position: absolute; left: 0; top: 22px; bottom: 20px; width: 1px; background: var(--line-normal); }
.kpi:first-child { padding-left: 0; }
.kpi-lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-val { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.35rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-val small { font-size: 13px; font-weight: 500; color: var(--ink-muted); letter-spacing: 0; }
.kpi-delta { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-muted); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.chip.pos { background: var(--pos-bg); color: var(--pos); }
.chip.neg { background: var(--neg-bg); color: var(--neg); }
.chip.flat { background: var(--bg-surface-2); color: var(--ink-secondary); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.kpi-expiry { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.ring { width: 64px; height: 64px; flex: none; }
.ring text { font: 800 20px var(--font-sans); fill: var(--ink-primary); }

/* ---------- Khối nội dung ---------- */
.block { margin-top: 40px; }
.block-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.block-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.015em; }
.block-head h2::before { content: ""; display: inline-block; width: 4px; height: 0.95em; background: var(--brand-primary); border-radius: 2px; margin-right: 10px; vertical-align: -0.08em; }
.block-note { font-size: 13px; color: var(--ink-muted); }

/* ---------- Bảng vị thế (infographic thanh lệch quanh 0) ---------- */
.positions { border-top: 1px solid var(--line-strong); }
.pos-row {
  display: grid; align-items: center; gap: 18px;
  grid-template-columns: minmax(150px, 1.1fr) minmax(220px, 2.2fr) minmax(150px, 1.2fr) 120px minmax(110px, .9fr) minmax(110px, .9fr);
  padding: 16px 0; border-bottom: 1px solid var(--line-normal);
}
.pos-row.head { padding: 10px 0; font-size: 12px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; }
.pos-row.head > div:nth-child(n+5) { text-align: right; }
.pos-row.head .info { text-transform: none; }
.grp { display: flex; align-items: center; gap: 10px; min-width: 0; }
.grp-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 800 12px var(--font-sans); color: #fff; }
:root[data-theme="dark"] .grp-dot { color: var(--bg-page); }
.grp-name { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.grp-desc { font-size: 12.5px; color: var(--ink-muted); }
.pos-cell { min-width: 0; }
.pos-val { display: flex; align-items: baseline; gap: 8px; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.side { font-size: 11.5px; font-weight: 800; letter-spacing: .04em; padding: 2px 7px; border-radius: 4px; }
.side.long { background: var(--pos-bg); color: var(--pos); }
.side.short { background: var(--neg-bg); color: var(--neg); }
.dbar { position: relative; height: 10px; margin-top: 8px; background: var(--bg-surface-2); border-radius: 5px; }
.dbar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1.5px; background: var(--line-strong); }
.dbar i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.dbar i.long { left: 50%; background: var(--pos); }
.dbar i.short { right: 50%; background: var(--neg); }
.sub { display: block; margin-top: 6px; font-size: 12.5px; color: var(--ink-muted); line-height: 1.4; }
.today-val { font-size: 1.05rem; font-weight: 700; }
.spark { display: block; width: 120px; height: 36px; }
.r { text-align: right; }
.r .big { font-size: 1.1rem; font-weight: 700; }
.zero-sum { margin-top: 10px; font-size: 12.5px; color: var(--ink-muted); }

.pos-note { margin: 0 0 10px; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; }
body.no-data .kpis, body.no-data main > .block { display: none; }

/* ---------- Điểm nhấn ---------- */
.highlights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.hl { padding-top: 14px; border-top: 3px solid var(--line-strong); min-width: 0; }
.hl.pos { border-top-color: var(--pos); }
.hl.neg { border-top-color: var(--neg); }
.hl.warn { border-top-color: var(--warn); }
.hl-big { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.hl.pos .hl-big { color: var(--pos); }
.hl.neg .hl-big { color: var(--neg); }
.hl.warn .hl-big { color: var(--warn); }
.hl-lbl { margin-top: 6px; font-weight: 700; font-size: 14.5px; }
.hl-note { margin-top: 4px; font-size: 13px; color: var(--ink-muted); }
.gauge { position: relative; height: 6px; margin-top: 12px; border-radius: 3px; background: linear-gradient(90deg, var(--neg), var(--bg-surface-3) 50%, var(--pos)); }
.gauge i { position: absolute; top: -5px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--ink-primary); }
.gauge-l { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--ink-muted); }

/* ---------- Biểu đồ ---------- */
.chart-controls { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-bottom: 10px; }
.ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl-lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-muted); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend button {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; min-height: 32px;
  padding: 4px 12px; border-radius: var(--radius-full); border: 1px solid var(--line-normal);
  background: var(--bg-surface); font-size: 13px; font-weight: 600; color: var(--ink-primary);
}
.legend button i { width: 14px; height: 3px; border-radius: 2px; }
.legend button[aria-pressed="false"] { color: var(--ink-faint); background: transparent; }
.legend button[aria-pressed="false"] i { opacity: .3; }
.chart-box { position: relative; border-top: 1px solid var(--line-normal); border-bottom: 1px solid var(--line-normal); padding-block: 8px; }
.chart { width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--ink-muted); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .12s;
  min-width: 230px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px;
  background: var(--bg-surface); border: 1px solid var(--line-normal); box-shadow: var(--shadow-lg);
}
.chart-tip.on { opacity: 1; }
.tip-d { font-weight: 800; margin-bottom: 6px; }
.tip-r { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; line-height: 1.6; }
.tip-r span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-secondary); }
.tip-r span i { width: 9px; height: 9px; border-radius: 2px; }
.tip-r em { font-style: normal; font-weight: 700; margin-left: 4px; }
.tip-r i { color: var(--ink-faint); font-style: italic; font-weight: 400; }
.tip-r small { min-width: 64px; text-align: right; font-size: 11.5px; }
.tip-sep { margin: 6px 0 2px; padding-top: 6px; border-top: 1px solid var(--line-normal); font-size: 11px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; }
.chart-foot { margin-top: 8px; font-size: 12.5px; color: var(--ink-muted); }

/* ---------- Bảng số liệu ---------- */
details > summary { cursor: pointer; font-weight: 700; list-style: none; display: inline-flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--brand-primary); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
.data-table > summary { font-size: 1.05rem; padding: 12px 0; }
.table-scroll { overflow-x: auto; margin-top: 8px; border-top: 1px solid var(--line-strong); }
table { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-normal); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-page); }
th { font-size: 11.5px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover td { background: var(--bg-surface-2); }
td.miss { color: var(--ink-faint); font-style: italic; }

/* ---------- Ghi chú & footer ---------- */
.notes { font-size: 13.5px; color: var(--ink-secondary); padding-bottom: 48px; }
.notes details { margin-top: 10px; }
.notes ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; max-width: 90ch; }
.site-footer { border-top: 1px solid var(--line-normal); padding-block: 22px; font-size: 13px; color: var(--ink-muted); }
.footer-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 8px 18px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--brand-primary); }

/* ---------- Tooltip giải thích ---------- */
.info {
  display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 4px; padding: 0; cursor: help;
  border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--ink-muted);
  font-size: 10.5px; font-weight: 700; vertical-align: 1px;
}
.pop-tip {
  position: absolute; z-index: 50; max-width: 280px; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  background: var(--ink-primary); color: var(--ink-inverse); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.pop-tip.active { opacity: 1; }

/* ---------- Báo lỗi dữ liệu ---------- */
.link-btn { margin-left: 10px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--brand-primary); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.btn-outline { margin-left: 8px; padding: 6px 14px; border-radius: var(--radius-full); border: 1px solid var(--brand-primary); background: transparent; color: var(--brand-primary); font-weight: 600; cursor: pointer; }
.btn-outline:hover { background: var(--brand-soft); }
.notes-report { margin-bottom: 12px; }
.report-dialog {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 16px;
  background: var(--bg-surface); color: var(--ink-primary); box-shadow: var(--shadow-xl);
}
.report-dialog::backdrop { background: rgba(17, 17, 17, 0.45); }
.report-dialog form { display: grid; gap: 16px; padding: 22px 22px 20px; }
.report-dialog .report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.report-dialog .report-head h2 { font-size: 1.25rem; font-weight: 800; }
.report-ctx { font-size: 13px; color: var(--ink-muted); margin-top: -8px; }
.report-dialog fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.report-dialog legend, .field { font-size: 13px; font-weight: 600; color: var(--ink-secondary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { margin-bottom: 8px; width: 100%; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span { display: inline-block; padding: 7px 14px; border-radius: var(--radius-full); border: 1px solid var(--line-strong); font-size: 13.5px; font-weight: 600; color: var(--ink-secondary); cursor: pointer; }
.chips-sm span { padding: 5px 11px; font-size: 13px; }
.chips input:checked + span { border-color: var(--brand-primary); color: var(--brand-primary); background: var(--brand-soft); }
.chips input:focus-visible + span { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field input, .field select, .field textarea {
  font: 400 14.5px var(--font-sans); color: var(--ink-primary); background: var(--bg-page);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; width: 100%;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-primary); outline-offset: 0; border-color: transparent; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.report-msg { font-size: 13.5px; font-weight: 600; }
.report-msg:empty { display: none; }
.report-msg.ok { color: var(--pos); }
.report-msg.err { color: var(--neg); }
.report-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.report-foot small { color: var(--ink-muted); font-size: 12px; max-width: 36ch; }
.report-foot .cta { border: 0; cursor: pointer; }
.report-foot .cta:disabled { opacity: .6; cursor: wait; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .pos-row { grid-template-columns: minmax(140px, 1fr) minmax(200px, 2fr) minmax(140px, 1.2fr) minmax(100px, .9fr) minmax(100px, .9fr); }
  .pos-row > .spark-cell { display: none; }
}
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { padding-left: 0; }
  .kpi:nth-child(3)::before { display: none; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line-normal); }
  .highlights { grid-template-columns: 1fr; gap: 22px; }
  .pos-row.head { display: none; }
  .pos-row {
    grid-template-columns: 1fr 1fr; gap: 12px 16px;
    grid-template-areas: "grp grp" "hold hold" "today today" "avg pnl";
  }
  .pos-row > .grp { grid-area: grp; }
  .pos-row > .hold-cell { grid-area: hold; }
  .pos-row > .today-cell { grid-area: today; }
  .pos-row > .avg-cell { grid-area: avg; text-align: left; }
  .pos-row > .pnl-cell { grid-area: pnl; }
  .pos-row [data-lbl]::before { content: attr(data-lbl); display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .header-row { gap: 12px; height: 60px; }
  .brand-logo { height: 28px; }
  .cta { display: none; }
  section.report-head { padding-block: 20px; }
  .header-actions { gap: 8px; }
  .share-btn span { display: none; }
  .share-btn { width: 40px; padding: 0; justify-content: center; }
  .head-top { flex-direction: column; align-items: stretch; }
  .head-top .seg button { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13.5px; }
  .chart-controls .seg button { padding: 5px 9px; }
  .kpi { padding: 16px 12px 14px; }
  .kpi:nth-child(odd) { padding-left: 0; }
  .ring { width: 52px; height: 52px; }
  .block { margin-top: 32px; }
  .chart-controls { gap: 10px 18px; }
  .chart-tip { min-width: 200px; }
  .report-grid { grid-template-columns: 1fr; }
  .report-dialog form { padding: 18px 16px; }
  .link-btn { margin-left: 0; display: inline-block; margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Tải ảnh chia sẻ ---------- */
.share-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--brand-primary); border-radius: var(--radius-full); background: var(--brand-soft);
  color: var(--brand-primary); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.share-btn:hover { background: var(--brand-primary); color: #fff; }
.share-btn svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share-dialog {
  width: min(940px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 16px;
  background: var(--bg-surface); color: var(--ink-primary); box-shadow: var(--shadow-xl);
}
.share-dialog::backdrop { background: rgba(17, 17, 17, 0.55); }
.share-top { display: flex; align-items: center; gap: 10px; padding: 16px 22px 0; }
.share-top h2 { font-size: 1.25rem; font-weight: 800; margin-right: auto; }
/* Công tắc nền ảnh: hai biểu tượng, nút trượt nằm sau lựa chọn đang bật */
.share-switch {
  position: relative; display: inline-flex; align-items: center; height: 40px; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-normal); border-radius: var(--radius-full); background: var(--bg-surface-2); color: var(--ink-muted);
}
.share-switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 32px; height: 32px; border-radius: 50%;
  background: #1b1616; box-shadow: var(--shadow-sm); transition: transform .18s ease, background .18s ease;
}
.share-switch[aria-checked="true"]::before { transform: translateX(32px); background: #fff; }
.share-switch svg { position: relative; width: 32px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.share-switch .i-moon { fill: currentColor; stroke: none; }
.share-switch[aria-checked="false"] .i-moon { color: #fff; }
.share-switch[aria-checked="true"] .i-sun { color: #d23922; }
.share-switch:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.share-body {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 24px; row-gap: 14px; padding: 14px 22px 22px;
  grid-template-areas: "prev modes" "prev acts" "prev msg" "prev text"; grid-template-rows: auto auto auto 1fr; align-items: start;
}
.share-modes { grid-area: modes; }
.share-preview { grid-area: prev; display: grid; place-items: start; }
.share-preview canvas { display: block; width: 300px; height: auto; aspect-ratio: 1080 / 1920; border-radius: 6px; box-shadow: 0 0 0 1px var(--line-normal); }
.share-actions { grid-area: acts; display: flex; flex-wrap: wrap; gap: 8px; }
.share-msg { grid-area: msg; font-size: 13.5px; font-weight: 600; }
.share-text { grid-area: text; }
.share-dialog fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.share-dialog legend { font-size: 13px; font-weight: 600; color: var(--ink-secondary); }
.share-dialog textarea { font: 400 13.5px/1.5 var(--font-sans); min-height: 190px; }
.share-act {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 15px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--brand-primary); border-radius: var(--radius-full); background: transparent;
  color: var(--brand-primary); font: 600 14px var(--font-sans);
}
.share-act:hover { background: var(--brand-soft); }
.share-act.primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.share-act.primary:hover { background: var(--red-700); }
.share-act svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share-act .l-short { display: none; }
.share-act[hidden] { display: none; }
.share-act:disabled { opacity: .55; cursor: wait; }
.share-msg:empty { display: none; }
.share-msg.ok { color: var(--pos); }
.share-msg.err { color: var(--neg); }
@media (max-width: 720px) {
  .share-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); border-radius: 14px; }
  .share-top { padding: 8px 8px 0 12px; }
  .share-top h2 { font-size: 1.1rem; }
  .share-body {
    grid-template-columns: minmax(0, 1fr) 56px; column-gap: 8px; row-gap: 8px; padding: 8px 8px 12px;
    grid-template-areas: "modes modes" "prev acts" "msg msg" "text text"; grid-template-rows: auto;
  }
  /* Chip nội dung: 4 ô chia đều đúng một hàng */
  .share-modes { flex-wrap: nowrap; gap: 4px; }
  .share-modes legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .share-modes label { flex: 1 1 0; min-width: 0; }
  .share-modes span { display: block; text-align: center; padding: 6px 2px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .share-preview { justify-self: start; }
  .share-preview canvas { width: min(100%, calc((100dvh - 150px) * 0.5625)); }
  /* Cột nút biểu tượng cân lề phải, cạnh ảnh */
  .share-actions { flex-direction: column; flex-wrap: nowrap; align-items: center; justify-self: end; gap: 12px; }
  .share-act {
    flex-direction: column; gap: 3px; width: 56px; height: auto; padding: 0; border: 0; background: none;
    color: var(--ink-secondary); font-size: 11px; font-weight: 600; white-space: normal; text-align: center; line-height: 1.2;
  }
  .share-act svg {
    width: 44px; height: 44px; padding: 11px; box-sizing: border-box; border-radius: 50%;
    border: 0; background: var(--brand-soft); color: var(--brand-primary);
  }
  .share-act:hover, .share-act.primary, .share-act.primary:hover { background: none; }
  .share-act.primary { color: var(--ink-primary); }
  .share-act.primary svg { background: var(--brand-strong); color: #fff; }
  .share-act .l-long { display: none; }
  .share-act .l-short { display: inline; }
  .share-msg { font-size: 13px; }
}

