/* ==========================================================================
   v3.17 - Huấn luyện › Bảng theo dõi chỉ số
   ========================================================================== */
.trk { display: flex; flex-direction: column; gap: 14px; }
.trk .card { margin: 0 !important; }
.trk-muted { color: #94a3b8; font-weight: 400; }

/* KPI */
.trk-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.trk-kpi { position: relative; text-align: left; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px 16px 14px 16px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-height: 104px; transition: border-color .15s, box-shadow .15s; font: inherit; color: inherit; }
.trk-kpi:not([disabled]):hover { border-color: #93c5fd; box-shadow: 0 4px 14px rgba(15, 45, 74, .08); }
.trk-kpi[disabled] { cursor: default; }
.trk-kpi::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--trk-tone); }
.trk-kpi-icon { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: var(--trk-tone); background: var(--trk-tone-bg); }
.trk-kpi-label { font-size: 12.5px; font-weight: 700; color: #64748b; padding-right: 40px; }
.trk-kpi-value { font-size: 28px; font-weight: 800; color: #0F2D4A; line-height: 1.15; margin-top: 4px; }
.trk-kpi-value small { font-size: 14px; color: #94a3b8; font-weight: 700; }
.trk-kpi-sub { font-size: 12px; color: #64748b; }
.trk-tone-navy { --trk-tone: #0F2D4A; --trk-tone-bg: #EBF3FA; }
.trk-tone-blue { --trk-tone: #2563EB; --trk-tone-bg: #EFF6FF; }
.trk-tone-green { --trk-tone: #16A34A; --trk-tone-bg: #DCFCE7; }
.trk-tone-orange { --trk-tone: #E07800; --trk-tone-bg: #FFF4E5; }
.trk-skel { background: linear-gradient(90deg, #f1f5f9, #f8fafc, #f1f5f9); background-size: 200% 100%; animation: trkSk 1.2s infinite; cursor: default; }
@keyframes trkSk { to { background-position: -200% 0; } }

/* Bố cục 2 cột */
.trk-main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.trk-list { padding: 0 !important; overflow: hidden; position: sticky; top: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 110px); }
.trk-list-head { padding: 12px; border-bottom: 1px solid #f1f5f9; display: flex; flex-direction: column; gap: 10px; }
.trk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.trk-chip { border: 1px solid #e2e8f0; background: #f8fafc; color: #475569; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.trk-chip b { color: #94a3b8; font-weight: 700; margin-left: 2px; }
.trk-chip.active { background: #0F2D4A; border-color: #0F2D4A; color: #fff; }
.trk-chip.active b { color: #FFB45C; }
.trk-members { overflow-y: auto; flex: 1; padding: 6px; }
.trk-loading { padding: 26px 14px; text-align: center; color: #94a3b8; font-size: 13.5px; }
.trk-member { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.trk-member:hover { background: #f8fafc; }
.trk-member.active { background: #EFF6FF; border-color: #bfdbfe; }
.trk-avatar { width: 38px; height: 38px; border-radius: 50%; background: #E0ECF8; color: #0F2D4A; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.trk-avatar.f { background: #FFF1E0; color: #B45309; }
.trk-avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.trk-member-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trk-member-name { font-weight: 700; color: #0F172A; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk-member-meta { font-size: 12px; color: #64748b; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.trk-member-meta.trk-stale { color: #C2410C; }
.trk-reached { font-size: 10.5px; font-weight: 800; color: #15803d; background: #DCFCE7; border-radius: 6px; padding: 1px 5px; margin-left: 2px; }
.trk-progress { height: 4px; background: #f1f5f9; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.trk-progress span { display: block; height: 100%; background: #2563EB; border-radius: 4px; }
.trk-member-val { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.trk-member-val b { font-size: 15px; color: #0F2D4A; }
.trk-member-val small { font-size: 11px; color: #94a3b8; margin-left: 2px; }

/* Thay đổi tăng / giảm (luôn có mũi tên + dấu, không chỉ dựa vào màu) */
.trk-delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.trk-good { color: #15803d; background: #DCFCE7; }
.trk-bad { color: #B91C1C; background: #FEE2E2; }
.trk-neutral, .trk-flat { color: #475569; background: #f1f5f9; }
.trk-arrow { font-style: normal; font-size: 9px; margin-left: 3px; padding: 0 2px; border-radius: 3px; vertical-align: 1px; }

/* Khung chi tiết */
.trk-detail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.trk-pane { padding: 16px 18px !important; }
.trk-pane-title { font-weight: 800; color: #0F2D4A; font-size: 15px; margin-bottom: 12px; }
.trk-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.trk-row-link { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 4px; border: none; border-bottom: 1px solid #f1f5f9; background: none; cursor: pointer; font: inherit; color: #0F172A; text-align: left; font-size: 13.5px; }
.trk-row-link:last-child { border-bottom: none; }
.trk-row-link:hover { color: #2563EB; }
.trk-hint { font-size: 13px; color: #0369a1; background: #f0f9ff; border: 1px solid #bae6fd; padding: 10px 12px; border-radius: 10px; display: flex; gap: 6px; align-items: center; }
.trk-back { display: none; border: none; background: none; color: #2563EB; font-weight: 700; padding: 0 0 10px; cursor: pointer; align-items: center; gap: 2px; }
.trk-person { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.trk-person-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.trk-person-info h3 { margin: 0 0 3px; font-size: 19px; font-weight: 800; color: #0F2D4A; }
.trk-person-info .trk-muted { color: #64748b; font-size: 13px; }
.trk-person-goal { font-size: 12.5px; color: #C2410C; margin-top: 4px; display: flex; gap: 4px; align-items: center; }
.trk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.trk-actions .btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 8px; }
.trk-empty-detail { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 34px 18px !important; }

.trk-toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.trk-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trk-range label { display: flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 700; color: #64748b; margin: 0; }
.trk-range input { width: 150px; height: 36px; padding: 4px 8px; }

/* Thẻ chỉ số */
.trk-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.trk-card { text-align: left; border: 1.5px solid #e2e8f0; background: #fff; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.trk-card:hover { border-color: #93c5fd; }
.trk-card.active { border-color: #2563EB; background: #f8fbff; box-shadow: inset 0 0 0 1px #2563EB; }
.trk-card-label { font-size: 12px; font-weight: 700; color: #64748b; line-height: 1.3; min-height: 16px; }
.trk-card-label small { font-weight: 600; color: #94a3b8; }
.trk-card-value { font-size: 22px; font-weight: 800; color: #0F2D4A; line-height: 1.2; }
.trk-card-deltas { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 18px; }
.trk-card-since { font-size: 11px; color: #94a3b8; display: inline-flex; gap: 3px; align-items: center; }
.trk-card-target { font-size: 11.5px; color: #C2410C; }

/* Biểu đồ */
.trk-chart-box { position: relative; width: 100%; }
.trk-svg { display: block; overflow: visible; }
.trk-grid { stroke: #eef2f7; stroke-width: 1; }
.trk-axis { fill: #94a3b8; font-size: 11px; font-family: inherit; }
.trk-line { fill: none; stroke: #2563EB; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trk-dot { fill: #2563EB; stroke: #fff; stroke-width: 2; }
.trk-dot.last { fill: #FF8A00; }
.trk-last-label { fill: #0F2D4A; font-size: 12px; font-weight: 800; }
.trk-target-line { stroke: #E07800; stroke-width: 1.5; stroke-dasharray: 5 4; }
.trk-target-text { fill: #C2410C; font-size: 11px; font-weight: 700; }
.trk-cross { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 3 3; }
.trk-bar { fill: #93B4E8; }
.trk-bar.last { fill: #2563EB; }
.trk-tip { position: absolute; pointer-events: none; background: #0F172A; color: #fff; font-size: 12px; line-height: 1.45; padding: 6px 9px; border-radius: 8px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); z-index: 3; }
.trk-tip span { color: #cbd5e1; }
.trk-chart-empty { padding: 30px; text-align: center; color: #94a3b8; }

/* Bảng như phiếu giấy */
.trk-table th, .trk-table td { text-align: center; white-space: nowrap; padding: 8px 9px !important; }
.trk-table thead th { font-size: 12px; line-height: 1.25; vertical-align: bottom; }
.trk-table thead th small, .trk-entry-table thead th small { display: block; font-weight: 600; color: #94a3b8; font-size: 10.5px; }
.trk-table tbody th { text-align: left; font-weight: 700; color: #0F2D4A; position: sticky; left: 0; background: #fff; z-index: 1; }
.trk-tr-target td, .trk-tr-target th { background: #FFF7ED !important; color: #C2410C !important; font-weight: 700; }
.trk-tr-change td, .trk-tr-change th { background: #F8FAFC !important; border-top: 2px solid #e2e8f0; }
.trk-td-act { display: flex; gap: 4px; justify-content: center; }
.trk-td-count { color: #64748b; }

/* Ảnh phiếu */
.trk-drop { padding: 16px 12px !important; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trk-sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.trk-sheet { margin: 0; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.trk-sheet-thumb { position: relative; aspect-ratio: 3 / 4; background: #f1f5f9; cursor: zoom-in; }
.trk-sheet-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trk-pdf-thumb { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #DC2626; font-size: 20px; }
.trk-sheet figcaption { padding: 8px 10px 4px; font-size: 12.5px; display: flex; flex-direction: column; gap: 1px; }
.trk-sheet figcaption b { color: #0F2D4A; }
.trk-sheet-act { display: flex; gap: 4px; padding: 4px 10px 10px; }

/* Hộp nhập chỉ số */
#app-modal.trk-modal-wide .modal-content, #app-modal.trk-modal-wide .modal-dialog, #app-modal.trk-modal-wide .modal-box { max-width: min(1280px, 96vw) !important; width: 96vw !important; }
.trk-entry.with-image { display: grid; grid-template-columns: minmax(280px, 42%) minmax(0, 1fr); gap: 16px; align-items: start; }
.trk-entry-form { min-width: 0; }
.trk-entry-img { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; background: #0f172a; position: sticky; top: 0; }
.trk-img-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; color: #e2e8f0; font-size: 12.5px; background: #1e293b; }
.trk-img-bar button { background: rgba(255, 255, 255, .14); color: #fff; border: none; border-radius: 6px; padding: 3px 9px; margin-left: 4px; cursor: pointer; font-weight: 700; }
.trk-img-scroll { max-height: 66vh; overflow: auto; text-align: center; }
.trk-img-scroll img { display: block; margin: 0 auto; transition: width .15s; }
.trk-pdf { padding: 40px 16px; color: #e2e8f0; }
.trk-pdf a { color: #93c5fd; }
.trk-entry-table th, .trk-entry-table td { padding: 5px 4px !important; text-align: center; }
.trk-entry-table thead th { font-size: 11.5px; line-height: 1.2; vertical-align: bottom; white-space: normal; min-width: 62px; }
.trk-entry-table input { height: 34px; padding: 4px 6px; text-align: center; font-weight: 600; min-width: 58px; }
.trk-entry-table input.trk-in-date { min-width: 138px; text-align: left; }
.trk-entry-table input.trk-bad { border-color: #DC2626; background: #FEF2F2; }
.trk-entry-table input.trk-dup { border-color: #F59E0B; background: #FFFBEB; }
.trk-warn { margin-top: 8px; font-size: 12.5px; color: #92400E; background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px; padding: 7px 10px; }
.trk-target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.trk-target-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 700; color: #334155; margin: 0; }

@media (max-width: 1280px) { .trk-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
    .trk-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .trk-main { grid-template-columns: 1fr; }
    .trk-list { position: static; max-height: none; }
    .trk-members { max-height: 60vh; }
    /* Trên máy tính bảng / điện thoại: chọn hội viên thì ẩn danh sách, có nút quay lại */
    .trk-main.has-detail .trk-list { display: none; }
    .trk-main.has-detail .trk-back { display: inline-flex; }
    .trk-person { flex-direction: column; align-items: stretch; }
    .trk-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .trk-entry.with-image { grid-template-columns: 1fr; }
    .trk-entry-img { position: static; }
    .trk-img-scroll { max-height: 42vh; }
}
@media (max-width: 640px) {
    .trk-kpi { min-height: 92px; padding: 12px; }
    .trk-kpi-value { font-size: 23px; }
    .trk-two { grid-template-columns: 1fr; }
    .trk-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .trk-card-value { font-size: 19px; }
    .trk-pane { padding: 14px !important; }
    .trk-actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
    .trk-range input { width: 132px; }
    .trk-target-grid { grid-template-columns: 1fr; }
}
.trk-entry-table { min-width: 940px; table-layout: auto; }
.trk-entry-table td:first-child, .trk-entry-table th:first-child { min-width: 150px; }
.trk-entry-table td:first-child, .trk-entry-table th:first-child { position: sticky; left: 0; z-index: 2; }
.trk-entry-table td:first-child { background: #fff; box-shadow: 2px 0 0 #e2e8f0; }
