/* Báo cáo tổng hợp — Điều hành theo team (dùng biến màu của hub.css). Tiền tố lớp: tm- */

/* ---------- KPI Sale ---------- */
.tm-kpi .card-head { align-items: flex-start; }
.tm-sum { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tm-sum .stat b { font-size: 18px; }
.tm-stack td, .tm-stack th { font-variant-numeric: tabular-nums; }
.tm-kpi-table .tm-meter-col { min-width: 190px; }
.tm-kpi-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: none; }
.tm-locked td { opacity: 0.7; }
.tm-other td { background: var(--surface-2); }

/* Thanh % đạt chỉ tiêu: màu theo trạng thái (kèm chữ), vạch dọc = phần thời gian đã qua của tháng. */
.tm-meter { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.tm-bar { position: relative; flex: 1; min-width: 70px; height: 8px; border-radius: 4px; background: var(--surface-3); }
.tm-bar > i { display: block; height: 100%; max-width: 100%; border-radius: 4px; background: var(--primary); }
.tm-bar-sm { height: 6px; border-radius: 3px; }
.tm-bar-sm > i { border-radius: 3px; background: color-mix(in srgb, var(--primary) 70%, white); }
.tm-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); opacity: 0.45; }
.tm-pct { white-space: nowrap; font-size: 12.5px; min-width: 104px; }
.tm-pct em { font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--dim); }
.tm-good .tm-bar > i { background: var(--good); }
.tm-warn .tm-bar > i { background: var(--warn); }
.tm-bad .tm-bar > i { background: var(--bad); }
.tm-muted .tm-bar > i { background: var(--border-strong); }
.tm-good .tm-pct em { color: var(--good-ink); }
.tm-warn .tm-pct em { color: var(--warn-ink); }
.tm-bad .tm-pct em { color: var(--bad-ink); }

/* ---------- Luồng đơn ---------- */
.tm-steps td { padding-top: 8px; padding-bottom: 8px; font-variant-numeric: tabular-nums; }
.tm-show-sm { display: none; }
.tm-tone { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--surface-3); color: var(--dim); }
.tm-tone-ok { background: var(--good-soft); color: var(--good-ink); }
.tm-tone-info { background: var(--info-soft); color: var(--info-ink); }
.tm-tone-warn { background: var(--warn-soft); color: var(--warn-ink); }
.tm-count { display: inline-flex; align-items: center; gap: 8px; width: 100%; min-width: 120px; }
.tm-count b { min-width: 22px; text-align: right; }

/* ---------- Thẻ từng team: 4 cột trên màn rộng, 2 cột máy tính bảng, 1 cột điện thoại ---------- */
.tm-teams { margin-bottom: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1240px) { .tm-teams { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .tm-teams { grid-template-columns: 1fr; } }
.tm-team { padding: 16px 16px 18px; }
.tm-team .stat b { font-size: 17px; }
.tm-team .stat span { display: block; line-height: 1.35; }
.tm-late li { align-items: center; }
.tm-late li > span { flex: 1; min-width: 0; }
.tm-late .btn { flex-shrink: 0; }
.dash-list.activity.tm-late small { white-space: normal; }
.tm-clear { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--good-ink); }

/* Báo cáo tổng hợp → Nhân viên KD (flow.js): thêm cột chỉ tiêu nên giữ cột tên đủ rộng, thu hẹp lề ô và cho
   tiêu đề cột xuống dòng để cả bảng (tới 19 cột) vừa màn hình máy tính mà không phải cuộn ngang. */
.people-table td:first-child { min-width: 140px; }
.people-table th, .people-table td { padding-left: 7px; padding-right: 7px; }
.people-table thead tr:not(.group-row) th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.people-table td .sub { white-space: nowrap; }

/* ---------- Hộp thoại đặt chỉ tiêu ---------- */
.tm-tg-head { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.tm-tg-head .field { flex: 1 1 200px; max-width: 280px; margin: 0; }
.tm-tg-head .btn { margin-bottom: 3px; }
.tm-tg-list { margin: 14px 0 6px; border-top: 1px solid var(--border); max-height: 55vh; overflow-y: auto; }
.tm-tg-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 240px); gap: 6px 14px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.tm-tg-name { min-width: 0; }
.tm-tg-name small { display: block; color: var(--faint); font-size: 12px; margin-top: 1px; }
.tm-tg-input input { text-align: right; font-variant-numeric: tabular-nums; }
.tm-tg-input small { display: block; min-height: 15px; margin-top: 2px; font-size: 11.5px; text-align: right; }
.tm-tg-input input.tm-invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ---------- Điện thoại: bảng thành thẻ (mỗi dòng 1 thẻ, nhãn cột bên trái) ---------- */
@media (max-width: 640px) {
  .table-wrap .table.tm-stack { min-width: 0; }
  .tm-stack thead { display: none; }
  .tm-stack, .tm-stack tbody, .tm-stack tfoot, .tm-stack tr, .tm-stack td { display: block; width: 100%; }
  .tm-stack tr { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin-bottom: 8px; background: var(--surface); }
  .tm-stack td { position: relative; padding: 5px 0 5px 42%; border: none; text-align: right; min-height: 27px; }
  .tm-stack td::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 40%; text-align: left; color: var(--faint); font-size: 12px; font-weight: 600; }
  .tm-stack td:first-child { padding: 4px 0 7px; margin-bottom: 3px; text-align: left; border-bottom: 1px solid var(--border); }
  .tm-stack td:first-child::before { content: none; }
  .tm-kpi-table tfoot td { border-top: none; }
  .tm-kpi-table tfoot tr { border: 2px solid var(--border-strong); }
  .tm-other td { background: none; }
  .tm-other .tm-hide-sm { display: none; }
  .tm-meter { min-width: 0; flex-wrap: wrap; justify-content: flex-end; gap: 4px 8px; }
  .tm-meter .tm-bar { flex: 1 0 100%; }
  .tm-pct { min-width: 0; }
  /* Bảng luồng đơn: giữ dạng bảng, bỏ cột phụ (team, giá trị hiện dưới tên bước). */
  .table-wrap .table.tm-steps { min-width: 0; }
  .tm-steps .tm-hide-sm { display: none; }
  .tm-steps .tm-show-sm { display: block; }
  .tm-steps th, .tm-steps td { padding-left: 6px; padding-right: 6px; }
  .tm-steps .tm-count { min-width: 0; }
  .tm-steps .tm-count .tm-bar { display: none; }
  .tm-tone { white-space: normal; }
  .tm-kpi .head-actions { width: 100%; justify-content: space-between; }
  .tm-tg-row { grid-template-columns: 1fr; }
  .tm-tg-head .field { max-width: none; }
}
