/* RTM OS — Sức khoẻ dữ liệu (js/rtm-health.js)
   Popover + toast KHÔNG có tiền tố #workspace-rtm-os vì chúng gắn thẳng vào
   document.body — ở đó biến --primary của workspace không với tới, nên phải
   viết hex thẳng (cùng lý do đã ghi ở đầu rtm-po.css). */

/* ── Badge bấm được ───────────────────────────────────────────────────────── */
#workspace-rtm-os .rtm-chip.rtmh-chip { cursor: pointer; user-select: none; transition: filter .12s, box-shadow .12s; }
#workspace-rtm-os .rtm-chip.rtmh-chip:hover { filter: brightness(.96); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
#workspace-rtm-os .rtm-chip.rtmh-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 115, 234, .30); }
#workspace-rtm-os .rtm-chip.rtmh-chip::after { content: '▾'; margin-left: 5px; opacity: .65; font-size: 9px; }

/* ── Khối chung ───────────────────────────────────────────────────────────── */
#workspace-rtm-os .rtmh-load,
#workspace-rtm-os .rtmh-err { display: flex; align-items: center; gap: 9px; padding: 22px 16px; color: #64748B; font-size: 13.5px; }
#workspace-rtm-os .rtmh-err { color: #9F1239; background: #FCE8EB; border: 1px solid #F5C2CB; border-radius: 8px; display: block; }

#workspace-rtm-os .rtm-sec.rtmh-h { display: flex; align-items: center; gap: 8px; }
#workspace-rtm-os .rtmh-sum { font-size: 12px; font-weight: 400; color: #676879; margin-left: 4px; }
#workspace-rtm-os .rtmh-h .rtm-mini-btn { margin-left: auto; }

#workspace-rtm-os .rtmh-t-good { color: #0E9F90; }
#workspace-rtm-os .rtmh-t-warn { color: #B45309; }
#workspace-rtm-os .rtmh-t-bad { color: #E2445C; }
#workspace-rtm-os .rtmh-t-mut { color: #676879; }

#workspace-rtm-os .rtmh-foot { font-size: 11.5px; color: #9699A6; margin: 6px 0 0; line-height: 1.55; }
#workspace-rtm-os .rtmh-foot code { background: #F5F6F8; padding: 1px 5px; border-radius: 4px; font-size: 11px; }

#workspace-rtm-os .rtmh-note {
  display: flex; gap: 9px; align-items: flex-start; background: #F5F6F8; border: 1px solid #E6E9EF;
  border-left: 3px solid #579BFC; border-radius: 8px; padding: 10px 13px; margin: 0 0 10px;
  font-size: 12.5px; color: #323338; line-height: 1.55;
}
#workspace-rtm-os .rtmh-note.bad { background: #FCE8EB; border-color: #F5C2CB; border-left-color: #E2445C; }
#workspace-rtm-os .rtmh-note small { color: #676879; }

/* ── Bảng vấn đề ──────────────────────────────────────────────────────────── */
#workspace-rtm-os .rtmh-tbl tbody tr[data-ma] { cursor: pointer; }
#workspace-rtm-os .rtmh-tbl tbody tr[data-ma].rtmh-ok { opacity: .62; }
#workspace-rtm-os .rtmh-tbl tbody tr[data-ma].open { background: #E9F2FF; }
#workspace-rtm-os .rtmh-why { display: block; color: #676879; font-size: 11.5px; line-height: 1.5; margin-top: 2px; max-width: 620px; }
#workspace-rtm-os .rtmh-tbl td .rtm-mini-btn + .rtm-mini-btn { margin-left: 4px; }
#workspace-rtm-os .rtmh-tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
#workspace-rtm-os .rtmh-tbl .mut { color: #9699A6; }

#workspace-rtm-os tr.rtmh-det > td { background: #F5F6F8; padding: 0 !important; }
#workspace-rtm-os .rtmh-detbox { padding: 11px 13px; }
#workspace-rtm-os .rtmh-detfix {
  display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: #323338;
  background: #fff; border: 1px solid #E6E9EF; border-radius: 8px; padding: 8px 11px; margin: 0 0 9px; line-height: 1.5;
}
#workspace-rtm-os .rtmh-detw { max-height: 268px; overflow: auto; background: #fff; border: 1px solid #E6E9EF; border-radius: 8px; }
#workspace-rtm-os .rtmh-dtbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#workspace-rtm-os .rtmh-dtbl td { padding: 5px 11px; border-bottom: 1px solid #F1F3F7; }
#workspace-rtm-os .rtmh-dtbl tr:last-child td { border-bottom: 0; }
#workspace-rtm-os .rtmh-dtbl td.mut { color: #9699A6; }
#workspace-rtm-os .rtmh-more { font-size: 11.5px; color: #9699A6; margin-top: 6px; }

/* ── Thanh tỉ lệ đối chiếu ────────────────────────────────────────────────── */
#workspace-rtm-os .rtmh-bar { position: relative; height: 18px; background: #F1F3F7; border-radius: 4px; overflow: hidden; }
#workspace-rtm-os .rtmh-bar i { display: block; height: 100%; background: #94A3B8; }
#workspace-rtm-os .rtmh-bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 7px; font-size: 11px; font-weight: 700; color: #323338; font-variant-numeric: tabular-nums;
}
#workspace-rtm-os .rtmh-bar.t-good i { background: #00C875; }
#workspace-rtm-os .rtmh-bar.t-warn i { background: #FDAB3D; }
#workspace-rtm-os .rtmh-bar.t-bad i { background: #E2445C; }

/* ── Nhóm 8 Cấu hình RTM ──────────────────────────────────────────────────── */
#workspace-rtm-os .rtmh-src { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
#workspace-rtm-os .rtmh-srcc {
  flex: 1 1 236px; min-width: 236px; background: #fff; border: 1px solid #E6E9EF;
  border-left: 3px solid #94A3B8; border-radius: 8px; padding: 9px 12px;
}
#workspace-rtm-os .rtmh-srcc.t-good { border-left-color: #00C875; }
#workspace-rtm-os .rtmh-srcc.t-warn { border-left-color: #FDAB3D; }
#workspace-rtm-os .rtmh-srcc.t-bad { border-left-color: #E2445C; }
#workspace-rtm-os .rtmh-srcc b { display: block; font-size: 12.5px; color: #323338; }
#workspace-rtm-os .rtmh-srcc > span { display: block; font-size: 12px; font-weight: 700; margin: 2px 0 3px; }
#workspace-rtm-os .rtmh-srcc small { display: block; font-size: 11px; color: #676879; line-height: 1.5; }
#workspace-rtm-os .rtmh-actbar { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin: 0 0 10px; }
#workspace-rtm-os .rtmh-actbar small { font-size: 11.5px; color: #676879; }

#workspace-rtm-os .rtmh-logw { max-height: 230px; overflow: auto; border: 1px solid #E6E9EF; border-radius: 8px; background: #fff; }
#workspace-rtm-os .rtmh-logw.big { max-height: 340px; }
#workspace-rtm-os .rtmh-lerr { color: #E2445C; font-size: 11px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══ Popover badge — gắn ở <body>, KHÔNG dùng biến của workspace ══════════ */
.rtmh-pop {
  position: fixed; z-index: 10050; width: 416px; max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid #D0D4E4; border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .19); overflow: hidden;
  font-family: 'Public Sans', 'Be Vietnam Pro', 'Figtree', system-ui, sans-serif;
  color: #323338; font-size: 13px;
}
.rtmh-pop-h {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px;
  border-bottom: 1px solid #E6E9EF; border-top: 3px solid #0073EA; background: #fff;
}
.rtmh-pop-h b { flex: 1; font-size: 13.5px; }
.rtmh-x { border: 0; background: transparent; color: #676879; cursor: pointer; padding: 3px; border-radius: 4px; line-height: 0; }
.rtmh-x:hover { background: #F5F6F8; color: #323338; }
.rtmh-pop-b { padding: 11px 13px; max-height: 66vh; overflow: auto; }
.rtmh-pop .rtmh-load,
.rtmh-pop .rtmh-err { display: flex; align-items: center; gap: 8px; padding: 16px 4px; color: #676879; font-size: 13px; }
.rtmh-pop .rtmh-err { color: #9F1239; }
.rtmh-kv { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px solid #F1F3F7; }
.rtmh-kv span { flex: 0 0 152px; color: #676879; font-size: 12px; }
.rtmh-kv b { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.rtmh-kv small { color: #9699A6; font-weight: 400; }
.rtmh-pop .rtmh-t-good { color: #0E9F90; }
.rtmh-pop .rtmh-t-warn { color: #B45309; }
.rtmh-pop .rtmh-t-bad { color: #E2445C; }
.rtmh-pop .rtmh-t-mut { color: #676879; }
.rtmh-errbox { background: #FCE8EB; border: 1px solid #F5C2CB; border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; font-size: 11.5px; color: #9F1239; line-height: 1.5; word-break: break-word; }
.rtmh-pop .rtmh-note { display: flex; gap: 8px; align-items: flex-start; background: #F5F6F8; border: 1px solid #E6E9EF; border-left: 3px solid #579BFC; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.55; }
.rtmh-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #9699A6; font-weight: 700; margin: 12px 0 5px; }
.rtmh-logw { max-height: 176px; overflow: auto; border: 1px solid #E6E9EF; border-radius: 8px; }
.rtmh-log { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.rtmh-log thead th { position: sticky; top: 0; background: #F5F6F8; color: #676879; font-weight: 700; text-align: left; padding: 5px 9px; border-bottom: 1px solid #E6E9EF; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; }
.rtmh-log td { padding: 4px 9px; border-bottom: 1px solid #F1F3F7; white-space: nowrap; }
.rtmh-log td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rtmh-log tr:last-child td { border-bottom: 0; }
.rtmh-pop-f { display: flex; align-items: center; gap: 10px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #E6E9EF; }
.rtmh-pop-f small { font-size: 11px; color: #9699A6; }
.rtmh-pop-f .rtm-mini-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 4px; border: 1px solid #0073EA; background: #fff; color: #0073EA; cursor: pointer;
}
.rtmh-pop-f .rtm-mini-btn:hover:not(:disabled) { background: #F5FAFF; }
.rtmh-pop-f .rtm-mini-btn:disabled { opacity: .55; cursor: default; }

.rtmh-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 10060;
  display: flex; align-items: center; gap: 9px; max-width: 560px;
  background: #323338; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .27); font-size: 13px;
  font-family: 'Public Sans', 'Be Vietnam Pro', 'Figtree', system-ui, sans-serif;
}
.rtmh-toast.bad { background: #9F1239; }
.rtmh-toast .ic { width: 15px; height: 15px; flex: 0 0 auto; }

/* icon dùng chung trong popover (ngoài workspace nên phải khai lại) */
.rtmh-pop .ic, .rtmh-toast .ic { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; width: 16px; height: 16px; }
.rtmh-pop .ic.s14, .rtmh-toast .ic.s14 { width: 14px; height: 14px; }

/* ── Nhóm 9 · Bản tin RTM ─────────────────────────────────────────────────── */
#workspace-rtm-os .rtmh-dg { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
#workspace-rtm-os .rtmh-dgf { display: flex; flex-direction: column; gap: 3px; flex: 1 1 210px; min-width: 210px; }
#workspace-rtm-os .rtmh-dgf > span { font-size: 11.5px; color: #676879; font-weight: 700; }
#workspace-rtm-os .rtmh-dgf > span small { font-weight: 400; color: #9699A6; }
#workspace-rtm-os .rtmh-dgf select,
#workspace-rtm-os .rtmh-dgf input[type=text] {
  border: 1px solid #D0D4E4; border-radius: 4px; padding: 6px 9px; font-size: 12.5px; background: #fff; color: #323338;
}
#workspace-rtm-os .rtmh-dgf select:disabled,
#workspace-rtm-os .rtmh-dgf input:disabled { background: #F5F6F8; color: #9699A6; }
#workspace-rtm-os .rtmh-dgw { flex: 2 1 380px; }
#workspace-rtm-os .rtmh-dgsw {
  flex-direction: row; align-items: center; gap: 9px; background: #fff; border: 1px solid #E6E9EF;
  border-radius: 8px; padding: 8px 12px; flex: 1 1 232px;
}
#workspace-rtm-os .rtmh-dgsw input { width: auto; }
#workspace-rtm-os .rtmh-dgsw span { display: flex; flex-direction: column; }
#workspace-rtm-os .rtmh-dgsw b { font-size: 12.5px; color: #323338; }
#workspace-rtm-os .rtmh-dgsw small { font-size: 11px; color: #676879; }

#workspace-rtm-os .rtmh-dgprev { border: 1px solid #E6E9EF; border-radius: 8px; background: #fff; margin: 4px 0 12px; overflow: hidden; }
#workspace-rtm-os .rtmh-dgprev-h {
  display: flex; align-items: center; gap: 7px; background: #F5F6F8; border-bottom: 1px solid #E6E9EF;
  padding: 7px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: #676879; font-weight: 700;
}
#workspace-rtm-os .rtmh-dgprev pre {
  margin: 0; padding: 13px 15px; font-size: 12.5px; line-height: 1.65; color: #323338;
  white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto;
  font-family: 'Public Sans', 'Be Vietnam Pro', system-ui, sans-serif;
}
