/* ---------- Báo cáo v1.3.1: chữ lớn theo màn hình, vừa một màn hình không cuộn, rê chuột xem chi tiết ---------- */
.main.rpt-main {
  --rf: clamp(14px, 0.45vw + 0.95vh, 26px);
  font-size: var(--rf); font-weight: 400; line-height: 1.4;
  height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; gap: .6em; padding: .8em 1.1em;
  --muted2: #555B7E;
}
.rpt-main .sub { font-size: .88em; color: var(--muted2); }
.rpt-main .btn { font-size: 1em; padding: .5em 1.1em; }
.rpt-main .pill { font-size: .9em; padding: .3em .85em; }
.rpt-main .err { margin: 0; font-size: .9em; }

/* ----- chọn báo cáo: bấm là đọc ----- */
.rpt-setup { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 1em; max-width: 78em; width: 100%; margin: 0 auto; justify-content: center; }
.rpt-hello h1 { margin: 0; font-size: 1.9em; font-weight: 500; color: var(--navy); }
.rpt-hello p { margin: .2em 0 0; color: var(--muted2); font-size: 1em; }
.rpt-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9em; }
.rpt-tile { text-align: left; border: 1px solid var(--line); border-top: 5px solid var(--navy); background: #fff; border-radius: 1em; padding: 1.1em 1.3em; cursor: pointer; display: grid; gap: .35em; align-content: start; min-height: 7em; transition: box-shadow .12s, transform .12s; }
.rpt-tile:hover { box-shadow: 0 .5em 1.4em rgba(39, 55, 120, .14); transform: translateY(-2px); }
.rpt-tile b { font-size: 1.3em; font-weight: 500; color: var(--navy); }
.rpt-tile span { font-size: .95em; color: var(--muted2); line-height: 1.4; }
.rpt-tile:nth-child(2) { border-top-color: var(--gold); } .rpt-tile:nth-child(3) { border-top-color: var(--lime); } .rpt-tile:nth-child(4) { border-top-color: var(--cyan); }
.rpt-tile.busy { opacity: .6; cursor: progress; }
.rpt-adv { padding: .7em 1em; }
.rpt-adv summary { cursor: pointer; color: var(--navy); font-weight: 500; font-size: 1em; }
.rpt-adv-b { display: grid; gap: .8em; margin-top: .8em; }
.rpt-row { display: flex; align-items: baseline; gap: .6em; flex-wrap: wrap; }
.rpt-row.col { flex-direction: column; align-items: stretch; gap: .4em; }
.rpt-row.end { justify-content: flex-end; align-items: center; }
.rpt-row h4 { margin: 0; font-size: 1em; font-weight: 500; color: var(--navy); display: flex; gap: .6em; align-items: baseline; }
.rpt-row h4 .linkbtn { margin-left: auto; font-size: .9em; } .rpt-row h4 .linkbtn + .linkbtn { margin-left: .6em; }
.rpt-dates { display: flex; gap: .6em; align-items: flex-end; flex-wrap: wrap; }
.rpt-f { display: grid; gap: .15em; font-size: .85em; color: var(--muted2); min-width: 0; }
.rpt-f select, .rpt-f input { border: 1px solid var(--line); border-radius: .6em; padding: .35em .6em; background: #fff; font-size: 1.05em; min-width: 0; height: 2.3em; }
.rpt-fl { display: grid; grid-template-columns: repeat(auto-fit, minmax(10em, 1fr)); gap: .6em; align-items: start; }
.rpt-chk { display: flex; gap: .4em; align-items: center; font-size: .95em; cursor: pointer; padding-bottom: .3em; }
.rpt-chk input { accent-color: var(--navy); }
.rpt-blocks { display: flex; flex-wrap: wrap; gap: .4em; }
.rpt-chip { border: 1px solid var(--line); border-radius: 99px; padding: .3em .8em; font-size: .92em; cursor: pointer; background: #fff; color: var(--text); user-select: none; }
.rpt-chip input { display: none; }
.rpt-chip.on { background: color-mix(in srgb, #22B2DA 12%, #fff); border-color: #22B2DA; color: #273778; font-weight: 500; }
.rpt-chip.on::before { content: '✓ '; color: #6D8A12; }

/* ----- báo cáo: một màn hình ----- */
.rpt-view { display: flex; flex-direction: column; gap: .6em; flex: 1; min-height: 0; }
.rpt-top { display: flex; justify-content: space-between; align-items: center; gap: .8em; flex-wrap: wrap; flex: none; }
.rpt-title { display: flex; gap: .7em; align-items: center; min-width: 0; }
.rpt-title img { height: 2.6em; }
.rpt-title b { display: block; font-size: 1.4em; font-weight: 500; color: var(--navy); line-height: 1.2; }
.rpt-title span { display: block; font-size: .9em; color: var(--muted2); }
.rpt-act { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
.rpt-act .pills { display: flex; gap: .3em; }
.rpt-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .6em; }
.rpt-body > * { flex: none; min-width: 0; }
.rpt-main .card { padding: .6em .9em; border-radius: .9em; font-size: 1em; }
.rpt-main .card h3 { font-size: 1.08em; font-weight: 500; color: var(--navy); margin: 0; }
.rpt-main .card .ch { margin-bottom: .25em; flex-wrap: wrap; display: flex; justify-content: space-between; align-items: baseline; gap: .8em; flex: none; }
.rpt-band { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: .6em; align-items: stretch; }
.rpt-band > .rpt-story-main:only-child { grid-column: 1 / -1; }
.rpt-cardsbox { display: flex; flex-direction: column; gap: .5em; min-width: 0; }
.rpt-cardsbox > .rpt-block { padding: .4em .6em; }
.rpt-cardsbox .rpt-story { -webkit-line-clamp: 1; margin-top: .25em; }
.rpt-story-main { display: flex; flex-direction: column; justify-content: center; }
.rpt-story-main { border-left: .3em solid #E5B243; background: color-mix(in srgb, #E5B243 9%, #fff); }
.rpt-story-main ul { margin: .3em 0 0; padding-left: 1.3em; display: grid; gap: .35em; font-size: 1.05em; line-height: 1.4; }
.rpt-mid { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: .6em; }
.rpt-tables { flex: 0 1 auto; min-height: 9em; display: flex; flex-direction: column; gap: .6em; }
.rpt-tables > .rpt-block { flex: 1 1 auto; min-height: 0; }
.rpt-block.k-table .rpt-chart { flex: 1 1 auto; }
.rpt-block.k-table .rpt-fill { position: static; }
.rpt-block.k-cards > .ch { display: none; }
.rpt-block { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.rpt-chart { flex: 1; min-height: 0; position: relative; }
.rpt-fill { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.rpt-block.k-cards .rpt-chart { flex: none; }
.rpt-block.k-cards .rpt-fill { position: static; }
.rpt-story { margin: .3em 0 0; font-size: .88em; line-height: 1.4; color: var(--text); padding: .1em .6em; border-radius: .4em; border-radius: .5em; flex: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rpt-none { margin: auto; color: var(--muted2); font-size: 1em; }
.rpt-ft { font-size: .78em; color: var(--muted2); text-align: center; }
.rpt-leg { display: flex; gap: 1em; font-size: .92em; color: var(--text); flex-wrap: wrap; flex: none; }
.rpt-leg i, .rpt-pie li i { display: inline-block; width: .8em; height: .8em; border-radius: .2em; margin-right: .35em; }

/* thẻ số */
.rpt-cards { display: grid; grid-template-columns: repeat(var(--cc, 3), minmax(0, 1fr)); gap: .5em; }
.rpt-card { border: 1px solid color-mix(in srgb, var(--c, #E5E7EF) 35%, #fff); border-top: .3em solid var(--c, #E5E7EF); background: color-mix(in srgb, var(--c, #fff) 8%, #fff); border-radius: .8em; padding: .25em .7em .35em; display: grid; gap: .05em; cursor: pointer; transition: box-shadow .12s; }
.rpt-card:hover { box-shadow: 0 .3em .9em rgba(39, 55, 120, .16); }
.rpt-card .rl { font-size: .95em; color: var(--text); font-weight: 400; }
.rpt-card .rl::before { content: ''; display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: var(--c, #C9CFE4); margin-right: .4em; }
.rpt-card b { font-size: 1.7em; font-weight: 500; color: var(--navy); line-height: 1.1; }
.rpt-t { font-size: .85em; color: var(--muted2); }
.rpt-d { font-size: .85em; color: var(--muted2); } .rpt-d.up { color: #577008; } .rpt-d.down { color: #B3420A; }

/* cột ngang */
.hb-rows { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .25em; }
.hb-row { flex: 1 1 0; min-height: 0; max-height: 3.6em; display: grid; grid-template-columns: minmax(6em, 34%) minmax(0, 1fr); gap: .7em; align-items: center; }
.hb-l { font-size: 1em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.hb-g { display: grid; grid-auto-rows: minmax(0, 1fr); gap: .2em; height: 100%; max-height: 2.7em; align-content: center; }
.hb-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5em; align-items: center; cursor: pointer; min-height: 0; }
.hb-trk { display: block; height: 100%; max-height: 1.2em; min-height: .6em; background: #F0F2F8; border-radius: .3em; overflow: hidden; }
.hb-trk i { display: block; height: 100%; border-radius: .3em; min-width: 0; }
.hb-bar b { line-height: 1; font-weight: 500; font-size: .95em; min-width: 2.2em; font-variant-numeric: tabular-nums; }
.hb-bar:hover .hb-trk { outline: 2px solid color-mix(in srgb, var(--navy) 35%, transparent); }

/* tròn */
.rpt-pie { flex: 1; min-height: 0; display: flex; gap: 1em; align-items: center; }
.rpt-pie svg { height: 100%; width: auto; aspect-ratio: 1 / 1; max-width: 48%; flex: none; }
.rpt-pie svg path { cursor: pointer; transition: opacity .1s; } .rpt-pie svg path:hover { opacity: .8; }
.rpt-pie ul { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: space-evenly; font-size: 1em; }
.rpt-pie li { display: grid; grid-template-columns: 1.1em minmax(0, 1fr) auto 3em; gap: .3em; align-items: center; cursor: pointer; padding: 0 .2em; border-radius: .4em; }
.rpt-pie li:hover { background: var(--soft); }
.rpt-pie li span { overflow-wrap: anywhere; line-height: 1.15; }
.rpt-pie li b { font-weight: 500; } .rpt-pie li em { font-style: normal; color: var(--muted2); text-align: right; }

/* đường */
.rpt-linehost { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.rpt-linehost svg { display: block; }
.rpt-linehost .lp { cursor: pointer; } .rpt-linehost .lp:hover { fill: rgba(39, 55, 120, .15); }

/* bảng */
.rpt-tbl { flex: 1; min-height: 0; overflow: auto; }
.rpt-tbl table { width: 100%; border-collapse: collapse; font-size: 1em; }
.rpt-tbl th { font-size: .92em; text-align: left; font-weight: 500; color: var(--navy); border-bottom: 2px solid var(--line); padding: .3em .6em; position: sticky; top: 0; background: color-mix(in srgb, #273778 7%, #fff); }
.rpt-tbl td { padding: .32em .6em; border-bottom: 1px solid var(--line); }
.rpt-tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.rpt-tbl tbody tr:nth-child(even) td { background: #F8F9FC; }
.rpt-tbl tbody tr[data-tip] { cursor: pointer; } .rpt-tbl tbody tr[data-tip]:hover td { background: color-mix(in srgb, #22B2DA 12%, #fff); }

/* màu khối */
.rpt-block.k-bar { border-top: .25em solid #273778; } .rpt-block.k-line { border-top: .25em solid #22B2DA; } .rpt-block.k-pie { border-top: .25em solid #824696; } .rpt-block.k-table { border-top: .25em solid #E5B243; } .rpt-block.k-cards { border-top: .25em solid #A4C639; }
.rpt-story { background: color-mix(in srgb, #22B2DA 8%, #fff); border-left: .22em solid #22B2DA; }

/* khung chi tiết khi rê chuột */
.rpt-tip { position: fixed; display: none; z-index: 1000; width: min(30em, 92vw); max-height: min(26em, 70vh); font-size: var(--rf, 15px); font-weight: 400; background: #fff; color: var(--text); border: 1px solid var(--line); border-top: .3em solid var(--navy); border-radius: .8em; box-shadow: 0 .8em 2.4em rgba(20, 30, 80, .28); overflow: hidden; flex-direction: column; }
.tp-h { display: flex; justify-content: space-between; gap: 1em; padding: .55em .9em; background: var(--soft); border-bottom: 1px solid var(--line); flex: none; }
.tp-h b { color: var(--navy); font-weight: 500; } .tp-h span { color: var(--muted2); white-space: nowrap; }
.tp-b { overflow: auto; flex: 1; min-height: 0; }
.tp-row { display: flex; justify-content: space-between; gap: .8em; padding: .4em .9em; border-bottom: 1px solid #EEF0F7; }
.tp-row:last-child { border-bottom: 0; }
.tp-l { min-width: 0; } .tp-l b { font-weight: 500; } .tp-l span { color: var(--muted2); }
.tp-l small { display: block; font-size: .85em; color: var(--muted2); }
.tp-v { font-weight: 500; color: var(--navy); align-self: center; font-variant-numeric: tabular-nums; }
.tp-f, .tp-empty { padding: .5em .9em; font-size: .88em; color: var(--muted2); margin: 0; flex: none; }
.tp-f { border-top: 1px solid var(--line); background: #FAFAFD; }

@media (max-width: 1100px) { .rpt-band { grid-template-columns: 1fr; } .main.rpt-main { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); } .rpt-mid { grid-template-columns: repeat(min(var(--cols, 2), 2), minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .main.rpt-main { overflow: auto; --rf: 15px; }
  .rpt-tiles { grid-template-columns: 1fr; }
  .rpt-mid { grid-template-columns: 1fr; grid-auto-rows: 17em; flex: none; }
  .rpt-tables { flex: none; } .rpt-tables > .rpt-block { flex: none; height: 17em; }
  .rpt-title span { display: none; } .rpt-pie { flex-direction: column; }
  .rpt-pie svg { max-width: 60%; height: auto; }
  .rpt-view, .rpt-body { flex: none; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  .side, .noprint, #toasts, .rpt-tip { display: none !important; }
  .shell { display: block; height: auto; padding: 0; }
  .main.rpt-main { height: auto !important; overflow: visible; padding: 0; display: block; --rf: 12px; }
  .rpt-view, .rpt-body { display: block; }
  .rpt-body > * { margin-bottom: 6px; }
  .rpt-mid { display: grid; height: 70mm; } .rpt-tables > .rpt-block { height: auto; }
  .rpt-block { break-inside: avoid; } .rpt-tbl { overflow: visible; }
}

/* Phone: lean report (customising stays on the computer) */
@media (max-width: 760px) {
  .rpt-adv { display: none; }
  .rpt-phone-note { margin: 4px 2px 0; font-size: 12.5px; color: var(--muted); text-align: center; }
  .rpt-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rpt-cardsbox .rpt-story { -webkit-line-clamp: unset; }
  .rpt-act .pills { flex-wrap: wrap; }
}
