  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #111827;
    --text-dim: #6b7280;
    --text-faint: #9ca3af;
    --primary: #2563eb;
    --primary-dim: #dbeafe;
    --good: #16a34a;
    --good-dim: #dcfce7;
    --warn: #d97706;
    --warn-dim: #fef3c7;
    --bad: #dc2626;
    --bad-dim: #fee2e2;
    --role-nv: #64748b;
    --role-tn: #2563eb;
    --role-tp: #059669;
    --role-od: #7c3aed;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
    --radius: 8px;
    --radius-sm: 6px;
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
  }

  /* Top bar */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }
  .brand-mark {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    letter-spacing: .5px;
  }
  .brand-sub {
    color: var(--text-dim);
    font-size: 13px;
  }
  .userbox {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .role-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
  }
  .role-NV { background: var(--role-nv); }
  .role-TN { background: var(--role-tn); }
  .role-TP { background: var(--role-tp); }
  .role-OD { background: var(--role-od); }
  .user-meta { text-align: right; line-height: 1.2; }
  .user-name { font-weight: 500; font-size: 13px; }
  .user-name.warn { color: var(--warn); }
  .user-email { font-size: 11px; color: var(--text-faint); }

  /* Tabs */
  .tabs {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    overflow-x: auto;
  }
  .tab {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .tab:hover { color: var(--text); }
  .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
  }

  /* Main */
  main { padding: 20px; max-width: 1280px; margin: 0 auto; }
  /* Giao KPI (matrix) rộng hơn — 80% viewport, max 1800px, không khít 2 bên */
  body.wide-main main { max-width: 80%; padding: 20px 24px; }
  @media (max-width: 1400px) { body.wide-main main { max-width: 95%; } }
  .loader { color: var(--text-dim); padding: 40px; text-align: center; }

  /* Page title */
  .page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
  }
  .page-sub {
    color: var(--text-dim);
    margin: 0 0 16px 0;
    font-size: 13px;
  }

  /* Cards */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
  }
  .card-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .card-body { padding: 16px; }

  /* Stat row */
  .stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }
  .stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
  }
  .stat-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
  }
  .stat-val {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text);
  }
  .stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

  /* Table */
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  thead th {
    text-align: left;
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .3px;
  }
  tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  tbody tr:hover { background: var(--surface-2); }
  td.num { text-align: right; font-variant-numeric: tabular-nums; }
  th.num { text-align: right; }

  /* Status chip */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid transparent;
  }
  .chip::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
  }
  .chip-draft { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
  .chip-submitted { background: var(--primary-dim); color: var(--primary); border-color: #bfdbfe; }
  .chip-sent_back { background: var(--warn-dim); color: var(--warn); border-color: #fde68a; }
  .chip-approved_tn { background: var(--good-dim); color: var(--good); border-color: #bbf7d0; }
  .chip-locked { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }

  /* Score pill */
  .score-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }
  .score-good { background: var(--good-dim); color: var(--good); }
  .score-warn { background: var(--warn-dim); color: var(--warn); }
  .score-bad { background: var(--bad-dim); color: var(--bad); }
  .score-empty { color: var(--text-faint); }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
  }
  .btn:hover { background: var(--surface-2); }
  .btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .btn-primary:hover { background: #1d4ed8; }
  .btn-good { background: var(--good); color: #fff; border-color: var(--good); }
  .btn-good:hover { background: #15803d; }
  .btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
  .btn-warn:hover { background: #b45309; }
  .btn-sm { padding: 4px 10px; font-size: 12px; }
  .btn-xs { padding: 3px 8px; font-size: 11px; }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  .btn:disabled:hover { background: inherit; }
  /* Nút Giao lại nổi bật — pulse khi idle, spinner khi busy */
  .btn-reconfirm {
    background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3);
    animation: pulse-reconfirm 2s ease-in-out infinite;
  }
  .btn-reconfirm:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
  .btn-reconfirm.is-busy, .btn-reconfirm:disabled { animation: none; opacity: 0.75; }
  @keyframes pulse-reconfirm {
    0%, 100% { box-shadow: 0 2px 6px rgba(37,99,235,0.3); }
    50% { box-shadow: 0 2px 12px rgba(37,99,235,0.6), 0 0 0 3px rgba(37,99,235,0.15); }
  }
  .btn-primary:disabled { background: var(--primary); color: #fff; border-color: var(--primary); }
  .btn.is-busy { position: relative; }
  .btn-icon { display: inline-flex; align-items: center; gap: 7px; }
  .btn-icon svg { flex: 0 0 auto; }
  .btn-spinner-svg { animation: btn-spin 0.9s linear infinite; }
  @keyframes btn-spin { to { transform: rotate(360deg); } }
  .sticky-bar {
    position: sticky; bottom: 0; left: 0; right: 0; margin-top: 16px;
    background: var(--surface); border-top: 1px solid var(--border-strong);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
    padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
    gap: 16px; z-index: 50; border-radius: 0 0 8px 8px;
  }
  .sticky-info { font-size: 13px; color: var(--text-dim); }
  .sticky-count {
    font-weight: 600; font-size: 16px; color: var(--primary);
    display: inline-block; min-width: 24px; text-align: right;
  }
  .btn-lg { padding: 10px 24px; font-size: 14px; font-weight: 500; }
  .btn-expand {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 14px; padding: 2px 6px;
  }
  .imp-box {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 4px; margin-right: 10px;
    background: var(--bg-alt); border: 1px solid var(--border); border-radius: 4px;
  }
  .imp-box input {
    border: none; background: transparent; outline: none;
    padding: 4px 6px; font-size: 12px; width: 200px; color: var(--text);
  }
  .imp-box input:focus { background: var(--bg); }
  .btn-expand:hover { color: var(--text); }
  .my-kpi-wrap {
    padding: 0; overflow: auto;
    max-height: calc(100vh - 320px); min-height: 300px;
  }
  .my-kpi-table { width: 100%; border-collapse: collapse; }
  .my-kpi-table th, .my-kpi-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 13px; }
  .my-kpi-table thead th { background: var(--bg-alt); font-weight: 500; font-size: 11px; text-transform: uppercase; color: var(--text-dim); position: sticky; top: 0; z-index: 2; }
  .my-kpi-table tbody tr.my-kpi-main:hover { background: var(--bg-hover); }
  .my-kpi-table .num { text-align: right; }
  .my-kpi-detail > td { background: var(--bg-alt); padding: 12px 16px; }
  .rating-compact { display: inline-flex; gap: 2px; }
  .rating-compact .rbtn {
    width: 26px; height: 26px; border: 1px solid var(--border); background: var(--bg);
    cursor: pointer; font-size: 12px; border-radius: 3px; color: var(--text-dim);
  }
  .rating-compact .rbtn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
  .rating-compact .rbtn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
  .rating-compact .rbtn:disabled { cursor: not-allowed; opacity: .5; }
  .card-loading { position: relative; pointer-events: none; opacity: 0.6; }
  .card-loading::after {
    content: '⏳ Đang tải…'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); background: var(--bg); padding: 8px 16px;
    border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
    color: var(--text); z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  /* Form */
  .field { margin-bottom: 12px; }
  .field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 4px;
  }
  input[type="text"], input[type="number"], textarea, select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
  }
  input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  }
  textarea { min-height: 60px; resize: vertical; }

  /* NV row expand */
  .kpi-row { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .kpi-row:last-child { border-bottom: none; }
  .kpi-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 12px;
    flex-wrap: wrap;
  }
  .kpi-title { font-weight: 500; font-size: 14px; }
  .kpi-meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
  .kpi-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
  .kpi-controls input { max-width: 140px; }
  .kpi-feedback {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--warn-dim);
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--warn);
  }
  .kpi-feedback strong { display: block; margin-bottom: 2px; }

  /* Modal */
  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
  }
  .modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 440px;
    width: calc(100% - 40px);
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
  }
  .modal h3 { margin: 0 0 12px 0; font-size: 15px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  .confirm-modal { max-width: 400px; }
  @keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }
  .queue-badge {
    position: fixed; bottom: 20px; right: 20px; z-index: 200;
    background: var(--surface); border: 1px solid var(--border);
    padding: 10px 16px; border-radius: 24px; font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex; align-items: center; gap: 8px;
  }
  .queue-badge.syncing { background: #fef3c7; border-color: #fbbf24; color: #92400e; }
  .queue-badge.failed { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
  .queue-badge.done { background: #dcfce7; border-color: #22c55e; color: #166534; }
  .queue-badge a { color: inherit; text-decoration: underline; }
  @keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
  }
  .pulse-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #fbbf24; margin-right: 6px;
    animation: pulse-dot 1.2s ease-in-out infinite;
  }
  .chip-submitted { background: #fef3c7; color: #92400e; }
  /* Dashboard — charts grid */
  .dash-filters {
    display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0 16px 0;
    padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px;
  }
  .dash-filters label { font-size: 12px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
  .dash-filters select {
    padding: 4px 8px; font-size: 13px; border: 1px solid var(--border);
    border-radius: 4px; background: var(--bg); color: var(--text);
  }
  .chart-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
  }
  @media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
  .chart-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .chart-card h3 {
    margin: 0 0 12px 0; font-size: 13px; font-weight: 500;
    color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 8px;
  }
  .chart-card canvas { max-width: 100%; }

  /* Rubric table — Excel template style */
  .rubric-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .rubric-table th {
    background: var(--bg-alt); font-weight: 600; font-size: 11px;
    text-transform: uppercase; color: var(--text-dim);
    padding: 8px 10px; border: 1px solid var(--border); position: sticky; top: 0;
  }
  .rubric-table td {
    padding: 6px 10px; border: 1px solid var(--border); vertical-align: middle;
  }
  /* Severity cells — CHỈ dòng current có màu, nhạt */
  .rubric-table td.tt-sev-pass { background: #ecfdf5; color: #065f46; font-weight: 700; }
  .rubric-table td.tt-sev-light { background: #fef9c3; color: #713f12; font-weight: 700; }
  .rubric-table td.tt-sev-heavy { background: #fee2e2; color: #991b1b; font-weight: 700; }
  /* Cổng chặn: dòng đỏ đậm nhấp nháy để nổi bật */
  .rubric-table td.tt-sev-kill { background: #fecaca; color: #7f1d1d; font-weight: 800; border-left: 3px solid #dc2626; }
  .rubric-table tr.tt-row-kill td { background: #fef2f2; animation: pulse-kill 2s ease-in-out infinite; }
  .rubric-table tr.tt-row-kill td.tt-sev-kill { background: #fecaca; }
  @keyframes pulse-kill { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(220,38,38,0); } 50% { box-shadow: inset 2px 0 0 0 rgba(220,38,38,0.6); } }
  .tt-vp-chip-kill { background: #dc2626 !important; color: #fff !important; font-weight: 800 !important; letter-spacing: 0.5px !important; animation: pulse-kill-chip 1.5s ease-in-out infinite; }
  @keyframes pulse-kill-chip { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.3); } 50% { box-shadow: 0 0 0 4px rgba(220,38,38,0.15); } }
  .rubric-table td.tt-level-cell { font-size: 12.5px; font-weight: 500; }
  .rubric-table td.tt-point-cell { font-variant-numeric: tabular-nums; }

  .tt-sev-arrow { font-weight: 800; margin-right: 2px; }
  .tt-sev-tag { font-size: 10.5px; opacity: 0.65; margin-left: 2px; font-weight: 500; }

  .rubric-table tr.tt-rubric-clickable { cursor: pointer; }
  .rubric-table tr.tt-rubric-clickable:hover td.tt-sev-pass,
  .rubric-table tr.tt-rubric-clickable:hover td.tt-sev-light,
  .rubric-table tr.tt-rubric-clickable:hover td.tt-sev-heavy { filter: brightness(0.96); }

  .tt-vp-banner { display: flex; gap: 12px; align-items: flex-start; background: #fef2f2; border: 1px solid #fecaca; border-left: 4px solid var(--bad); border-radius: 8px; padding: 12px 16px; margin: 12px 0; }
  .tt-vp-banner-ico { font-size: 20px; line-height: 1; }
  .tt-vp-banner-body { flex: 1; font-size: 13px; color: var(--text); line-height: 1.5; }
  .tt-vp-banner-body b { color: var(--bad); }

  .tt-vp-chip { display: inline-block; background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 700; margin-left: 6px; white-space: nowrap; }
  .tt-rubric-expand { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--primary); font-weight: 600; user-select: none; }

  .tt-log-detail td { padding: 0 !important; }
  .tt-log-detail-inner { padding: 12px 16px; border-left: 4px solid var(--warn); background: #fffbeb; }
  .tt-log-detail-head { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.3px; }
  .tt-mini-log { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; font-size: 12.5px; }
  .tt-mini-log th { background: #fafbfc; font-weight: 700; color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
  .tt-mini-log td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .tt-mini-log tr:last-child td { border-bottom: none; }
  .tt-mini-log tr:hover td { background: #fafbfc; }
  .tt-mini-log .num { text-align: center; font-variant-numeric: tabular-nums; }
  /* Tuân thủ matrix — layout cards + progress steps */
  .tt-grid { display: grid; gap: 16px; }
  .tt-group-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .tt-group-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
  }
  .tt-group-title { font-size: 14px; font-weight: 600; color: var(--text); }
  .tt-group-score {
    font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 12px;
  }
  .tt-group-score.good { background: var(--good-dim); color: #166534; }
  .tt-group-score.warn { background: var(--warn-dim); color: #92400e; }
  .tt-group-score.bad { background: var(--bad-dim); color: #991b1b; }

  .tt-content {
    padding: 12px 0; border-bottom: 1px dashed var(--border);
  }
  .tt-content:last-child { border-bottom: none; padding-bottom: 0; }
  .tt-content-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    margin-bottom: 10px;
  }
  .tt-content-title { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.4; flex: 1; }
  .tt-content-score {
    font-size: 18px; font-weight: 700; min-width: 60px; text-align: right;
    white-space: nowrap;
  }
  .tt-content-score.good { color: var(--good); }
  .tt-content-score.warn { color: var(--warn); }
  .tt-content-score.bad { color: var(--bad); }
  .tt-vp-badge {
    display: inline-block; background: var(--bad-dim); color: var(--bad);
    padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 500;
    margin-left: 6px;
  }

  .tt-chosen-badge {
    display: inline-block; background: var(--good-dim); color: var(--good);
    padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 500;
    margin-left: 6px;
  }
  .tt-radios { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 4px; }
  .tt-radio {
    padding: 10px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg); display: flex; gap: 8px; align-items: flex-start;
    cursor: pointer; transition: all 0.12s;
  }
  .tt-radio:hover { background: var(--bg-alt); border-color: var(--border-strong); }
  .tt-radio input { margin-top: 2px; cursor: pointer; }
  .tt-radio.current {
    background: var(--primary-dim); border-color: var(--primary); border-width: 2px;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
  }
  .tt-radio.pass.current { background: var(--good-dim); border-color: var(--good); box-shadow: 0 0 0 3px rgba(22,163,74,0.1); }
  .tt-radio.violation.current { background: var(--bad-dim); border-color: var(--bad); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
  .tt-radio.no-input { cursor: default; opacity: 0.5; }
  .tt-radio.no-input.current { opacity: 1; }
  .tt-radio-diem { font-size: 14px; font-weight: 700; color: var(--text); }
  .tt-radio.pass.current .tt-radio-diem { color: var(--good); }
  .tt-radio.violation.current .tt-radio-diem { color: var(--bad); }
  .tt-radio-label { font-size: 11px; color: var(--text-dim); line-height: 1.3; margin-top: 2px; }

  .tt-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
  .tt-step {
    padding: 8px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg); text-align: center; cursor: default;
    opacity: 0.5; transition: opacity 0.15s;
  }
  .tt-step.passed { opacity: 0.3; background: var(--bg-alt); }
  .tt-step.current {
    opacity: 1; border-width: 2px; border-color: var(--primary);
    background: var(--primary-dim); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  }
  .tt-step-num {
    font-size: 15px; font-weight: 700; color: var(--text);
    margin-bottom: 2px;
  }
  .tt-step.current .tt-step-num { color: var(--primary); }
  .tt-step-label {
    font-size: 10px; color: var(--text-dim); line-height: 1.3;
  }
  .tt-content-actions { text-align: right; margin-top: 4px; }
  .skeleton {
    animation: skeleton-pulse 1.2s ease-in-out infinite;
  }
  .skeleton-line {
    height: 14px; background: var(--border); border-radius: 4px;
    margin-bottom: 8px;
  }
  .skeleton-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 16px; margin-bottom: 12px;
  }
  .landing { display: flex; align-items: center; justify-content: center; min-height: 50vh; padding: 20px; }
  .landing-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 32px; max-width: 480px; width: 100%; text-align: left;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }
  .landing-card h2 { margin: 0 0 12px 0; font-size: 20px; }
  .landing-card input { padding: 10px 12px; font-size: 14px; }
  .modal-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
  .mtab {
    background: none; border: none; padding: 8px 14px; cursor: pointer;
    font-size: 13px; color: var(--text-dim);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  .mtab:hover { color: var(--text); }
  .mtab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
  .confirm-modal .confirm-msg {
    font-size: 14px; color: var(--text); line-height: 1.5;
    padding: 4px 0 8px 0;
    white-space: pre-line;
  }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #111827;
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    opacity: 0;
    transition: all .2s;
    z-index: 200;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.error { background: var(--bad); }

  /* No access */
  .no-access {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
  }
  .no-access h2 { color: var(--text); font-size: 18px; }

  /* Progress bar */
  .pbar {
    background: var(--border);
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
  }
  .pbar .fill {
    height: 100%;
    background: var(--primary);
    transition: width .3s;
  }

  /* v2 additions */
  .page-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
  .assign-card { margin-bottom: 14px; }
  .assign-card .card-head { background: var(--surface-2); }
  .nv-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); color: #fff; font-weight: 600; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
  .weight-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; }
  .weight-ok { background: var(--good-dim); color: var(--good); border-color: #bbf7d0; }
  .weight-warn { background: var(--warn-dim); color: var(--warn); border-color: #fde68a; }
  .weight-empty { background: #f3f4f6; color: var(--text-dim); border-color: var(--border); }
  .add-row { padding: 10px 16px; display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }
  .add-row select, .add-row input { flex: 0 0 auto; max-width: 220px; }
  .filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
  .filter-bar .field { margin: 0; flex: 0 0 auto; min-width: 150px; }
  .filter-bar .filter-actions { margin-left: auto; display: flex; gap: 8px; align-items: end; }
  .pivot-wrap { overflow-x: auto; }
  table.pivot { min-width: 100%; font-size: 12.5px; }
  table.pivot thead th { background: var(--surface-2); color: var(--text); text-transform: none; letter-spacing: 0; font-size: 11.5px; text-align: center; border-right: 1px solid var(--border); }
  table.pivot thead th:first-child { text-align: left; min-width: 200px; }
  table.pivot tbody td { text-align: center; padding: 6px 8px; border-right: 1px solid var(--border); font-variant-numeric: tabular-nums; }
  table.pivot tbody td:first-child { text-align: left; }
  .pivot-cell { display: flex; flex-direction: column; gap: 2px; align-items: center; font-size: 11px; }
  .pivot-cell .pv-actual { color: var(--text-dim); font-size: 10.5px; }
  .check-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; }
  .check-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
  .check-list label:hover { background: var(--surface-2); }
  .check-list input[type="checkbox"] { width: auto; }
  .modal-row { display: flex; gap: 10px; }
  .modal-row .field { flex: 1; }
  .btn-bad { background: transparent; color: var(--bad); border-color: var(--bad-dim); }
  .btn-bad:hover { background: var(--bad-dim); }
  .empty-row { padding: 20px; text-align: center; color: var(--text-faint); font-size: 13px; }
  .mt-group { margin: 16px 0 8px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; }
  .rating-input { display: inline-flex; gap: 4px; align-items: center; }
  .rating-input .rt-btn { width: 28px; height: 28px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-dim); }
  .rating-input .rt-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
  .rating-input .rt-btn:hover:not(.selected) { background: var(--surface-2); }
  .compliance-row { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; align-items: start; }
  .compliance-row:last-child { border-bottom: none; }
  .compl-info { flex: 1; min-width: 0; }
  .compl-title { font-weight: 500; font-size: 13px; }
  .compl-desc { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
  .compl-points { font-size: 12px; font-weight: 600; }
  .score-mini { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
  @media (max-width: 640px) {
    main { padding: 12px; }
    .topbar { padding: 10px 12px; }
    .tabs { padding: 0 12px; }
    .user-email { display: none; }
  }

  /* ============== Giao KPI — Matrix view ============== */
  .matrix-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
  .btn-pulse { position: relative; animation: pulse-btn 1.6s ease-in-out infinite; }
  @keyframes pulse-btn { 0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.5); } 50% { box-shadow: 0 0 0 6px rgba(37,99,235,0); } }

  /* ===== KPI của tôi — bảng flat theo mockup ===== */
  .mykpi-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding: 14px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border: 1px solid #bbf7d0; border-radius: 10px;
  }
  .mykpi-head-left { display: flex; flex-direction: column; gap: 4px; }
  .mykpi-label { font-size: 11px; font-weight: 700; color: var(--good); text-transform: uppercase; letter-spacing: 0.6px; }
  .mykpi-title { font-size: 22px; font-weight: 700; margin: 0; color: var(--text); letter-spacing: -0.3px; }
  .mykpi-head-right { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 10px; }
  .mykpi-meta b { color: var(--text); font-weight: 700; }

  .mykpi-wrap {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    overflow: auto; max-width: 100%; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    max-height: calc(100vh - 260px);
  }
  .mykpi-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 1180px; }
  .mykpi-table thead th {
    background: #f9fafb;
    color: var(--text-dim); font-weight: 700; text-transform: uppercase;
    font-size: 10.5px; letter-spacing: 0.4px;
    padding: 12px 10px; text-align: left; vertical-align: middle;
    border-bottom: 2px solid var(--border); white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
  }
  .mykpi-table thead th.mk-kq,
  .mykpi-table thead th.mk-ct2 { background: #fef3c7; color: #92400e; }
  .mykpi-table tbody td { padding: 14px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; background: var(--surface); }
  .mykpi-table tbody tr:last-child td { border-bottom: none; }
  .mykpi-table tbody tr:nth-child(even) td { background: #fcfcfd; }

  .mk-stt { width: 48px; text-align: center; color: var(--text-dim); font-weight: 600; font-size: 12px; }
  .mk-ma { width: 76px; }
  .mk-ma-badge {
    display: inline-block; color: var(--good); font-weight: 800;
    font-family: ui-monospace, 'SF Mono', monospace; font-size: 13.5px;
    background: #ecfdf5; padding: 4px 10px; border-radius: 6px; letter-spacing: 0.5px;
  }
  .mk-ten { max-width: 260px; min-width: 180px; }
  .mk-ten-txt { font-weight: 600; color: var(--text); line-height: 1.4; font-size: 13px; }
  .mk-mota {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--good); font-size: 11px; font-weight: 500;
    margin-top: 4px; text-decoration: none; cursor: pointer; padding: 2px 0;
  }
  .mk-mota::before { content: '📖'; font-size: 10px; }
  .mk-mota:hover { text-decoration: underline; color: #15803d; }

  .mk-ct, .mk-tt {
    font-variant-numeric: tabular-nums; font-weight: 700; width: 74px;
    color: var(--text); font-size: 13.5px; text-align: center;
  }
  .mk-dv { color: var(--text-dim); font-size: 12px; width: 70px; text-align: center; }
  .mk-tt { color: var(--primary); }

  .mk-kq { width: 112px; }
  .mykpi-table tbody td.mk-kq { background: #fffbeb; }
  .mk-kq-input {
    width: 100%; padding: 8px 10px; border: 1.5px solid #fde68a; border-radius: 6px;
    text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
    background: #fff; color: var(--text); transition: all 0.15s;
  }
  .mk-kq-input:hover:not(:disabled) { border-color: #f59e0b; }
  .mk-kq-input:focus { border-color: var(--primary); outline: 3px solid var(--primary-dim); background: #fff; }
  .mk-kq-input:disabled { background: #f9fafb; color: var(--text-dim); border-color: var(--border); }
  .mk-ratingwrap { display: flex; justify-content: flex-start; gap: 3px; }

  .mk-tlht { width: 86px; text-align: center; font-variant-numeric: tabular-nums; }
  .mk-tlht-pct {
    font-weight: 800; font-size: 14px; display: inline-block;
    padding: 3px 8px; border-radius: 6px;
  }
  .mk-tlht-pct.ok { color: var(--good); background: #ecfdf5; }
  .mk-tlht-pct.warn { color: var(--warn); background: #fef3c7; }
  .mk-tlht-pct.bad { color: var(--bad); background: #fef2f2; }

  .mk-dkpi { width: 96px; text-align: center; font-variant-numeric: tabular-nums; }
  .mk-dkpi-num { font-weight: 800; color: var(--text); font-size: 15px; }
  .mk-dkpi-max { color: var(--text-faint); font-size: 11px; margin-left: 2px; }

  .mk-ct2 { width: 260px; }
  .mykpi-table tbody td.mk-ct2 { background: #fffbeb; }
  .mk-ct2-input {
    width: 100%; min-height: 48px; padding: 8px 10px; border: 1.5px solid #fde68a;
    border-radius: 6px; font-size: 12.5px; background: #fff; resize: vertical;
    font-family: inherit; line-height: 1.5; color: var(--text);
  }
  .mk-ct2-input:hover:not(:disabled) { border-color: #f59e0b; }
  .mk-ct2-input:focus { border-color: var(--primary); outline: 3px solid var(--primary-dim); }
  .mk-ct2-input:disabled { background: #f9fafb; color: var(--text-dim); border-color: var(--border); }

  .mk-gc { width: 160px; }
  .mk-gc-input {
    width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 12.5px; background: var(--surface); color: var(--text); font-family: inherit;
  }
  .mk-gc-input:focus { border-color: var(--primary); outline: 2px solid var(--primary-dim); background: #fff; }

  .mk-row:hover > td { background: #f8fafc !important; }
  .mk-row:hover > td.mk-kq { background: #fef3c7 !important; }
  .mk-row:hover > td.mk-ct2 { background: #fef3c7 !important; }

  .mk-feedback-row td { padding: 0 10px 12px 10px !important; background: #fef2f2 !important; }

  /* Row C02 auto từ compliance — nền vàng nhạt, không edit được */
  .mk-row-auto > td { background: #fef3c7 !important; }
  .mk-row-auto .mk-ten-txt { color: #92400e; }
  .mk-kq-auto {
    display: inline-block; padding: 6px 10px;
    background: #fff; border: 1px dashed #d97706;
    border-radius: 6px; font-weight: 700; font-size: 14px; color: #92400e;
    font-variant-numeric: tabular-nums;
  }

  /* Modal mô tả KPI */
  .kpimota-modal { padding: 24px 28px !important; }
  .kpimota-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
  .kpimota-table tr { border-bottom: 1px solid var(--border); }
  .kpimota-table tr:last-child { border-bottom: none; }
  .kpimota-table th {
    text-align: left; padding: 10px 12px; width: 160px;
    font-size: 11.5px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.3px; vertical-align: top;
  }
  .kpimota-table td { padding: 10px 12px; font-size: 13px; color: var(--text); vertical-align: top; }
  .kpimota-table code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
  .kpimota-h {
    font-size: 11px; font-weight: 700; color: var(--primary);
    text-transform: uppercase; letter-spacing: 0.4px;
    margin: 16px 0 6px 0; padding-bottom: 4px; border-bottom: 2px solid var(--primary-dim);
  }
  .kpimota-text {
    padding: 10px 12px; background: var(--surface-2); border-radius: 6px;
    font-size: 13px; line-height: 1.55; color: var(--text); white-space: pre-wrap;
  }

  @media (max-width: 1200px) {
    .mykpi-wrap { max-height: calc(100vh - 240px); }
  }

  /* ===== Ghi lỗi tuân thủ — form card + clean table ===== */

  /* Form card ghi lỗi mới */
  .tt-form-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
  .tt-form-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .tt-form-title { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.4px; display: flex; align-items: center; gap: 8px; }
  .tt-form-title::before { content: '+'; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: var(--primary); color: #fff; border-radius: 50%; font-size: 14px; font-weight: 700; }
  .tt-form-grid { display: grid; grid-template-columns: 160px 1fr 180px 1.5fr; gap: 10px 12px; align-items: end; }
  .tt-form-grid-row2 { display: grid; grid-template-columns: 2fr 90px 2fr; gap: 10px 12px; align-items: end; margin-top: 10px; }
  .tt-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .tt-field-label { font-size: 10.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.3px; }
  .tt-field input, .tt-field select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--surface); color: var(--text); box-sizing: border-box; transition: border 0.12s, box-shadow 0.12s; }
  .tt-field input:hover, .tt-field select:hover { border-color: var(--border-strong); }
  .tt-field input:focus, .tt-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
  .tt-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
  .tt-preview { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-dim); }
  .tt-preview-item { display: inline-flex; align-items: center; gap: 4px; }
  .tt-preview-label { color: var(--text-faint); text-transform: uppercase; font-size: 10px; letter-spacing: 0.3px; font-weight: 600; }
  .tt-preview-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
  .tt-submit-btn { padding: 8px 18px; font-size: 13px; font-weight: 600; }

  /* Log section */
  .tt-log-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
  .tt-log-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2, #f9fafb); }
  .tt-log-title { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.4px; }
  .tt-log-count { display: inline-block; margin-left: 8px; background: var(--primary-dim); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
  .tt-log-search { width: 240px; padding: 6px 10px 6px 30px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>") no-repeat 10px center; }
  .tt-log-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

  .tt-table-wrap { overflow-x: auto; }
  .tt-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
  .tt-table th, .tt-table td { padding: 10px 12px; vertical-align: middle; border-bottom: 1px solid var(--border); }
  .tt-table thead th { background: #fafbfc; font-weight: 700; color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; text-align: left; position: sticky; top: 0; }
  .tt-table tbody tr:hover td { background: #f8fafc; }
  .tt-table tbody tr:last-child td { border-bottom: none; }

  .tt-stt { width: 44px; text-align: center; color: var(--text-faint); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .tt-ngay { width: 100px; color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .tt-nv-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  .tt-nv-info b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tt-nv-info small { font-size: 10.5px; color: var(--text-faint); font-family: ui-monospace, monospace; }
  .tt-nd-cell { font-size: 12.5px; color: var(--text); max-width: 240px; }
  .tt-mota-cell { font-size: 12px; color: var(--text-dim); max-width: 220px; }
  .tt-mota-cell:empty::before { content: '—'; color: var(--text-faint); }
  .tt-num { text-align: center; font-variant-numeric: tabular-nums; }
  .tt-num-cumul { font-weight: 700; color: var(--text); font-size: 14px; }
  .tt-bc-cell { font-size: 12px; color: var(--text-dim); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tt-bc-link { color: var(--primary); text-decoration: none; }
  .tt-bc-link:hover { text-decoration: underline; }
  .tt-x { width: 48px; text-align: center; }
  .tt-del-btn { width: 26px; height: 26px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--text-faint); font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.12s; padding: 0; }
  .tt-del-btn:hover { background: #fef2f2; color: var(--bad); border-color: #fecaca; }

  .tt-chip-phan { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.2px; }
  .tt-phan-A { background: #dbeafe; color: #1e40af; }
  .tt-phan-B { background: #fef3c7; color: #92400e; }
  .tt-chip-muc { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
  .tt-muc-nhac { background: #dbeafe; color: #1e40af; }
  .tt-muc-canhbao { background: #fef3c7; color: #92400e; }
  .tt-muc-khientrach { background: #fed7aa; color: #9a3412; }
  .tt-muc-buocthoiviec { background: #fee2e2; color: #991b1b; }
  .tt-muc-default { background: #f3f4f6; color: var(--text-dim); }

  .tt-empty-state { padding: 60px 20px; text-align: center; color: var(--text-faint); }
  .tt-empty-ico { font-size: 36px; opacity: 0.5; margin-bottom: 8px; }

  /* ===== Bộ KPI chi tiết — editable inline ===== */
  .set-detail-table input[type="number"], .set-detail-table input[type="text"] {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 13px; font-variant-numeric: tabular-nums; background: var(--surface);
  }
  .set-detail-table input:hover { border-color: var(--border-strong); }
  .set-detail-table input:focus { border-color: var(--primary); outline: 2px solid var(--primary-dim); background: #fff; }
  .set-detail-table .set-cc {
    padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; background: var(--surface);
  }
  .set-tt-wrap { display: inline-flex; align-items: center; gap: 3px; }
  .set-tt-wrap span { font-size: 11px; color: var(--text-faint); font-weight: 600; }
  .set-row-dirty > td { background: #fef3c7 !important; }
  .set-row-dirty > td input { background: #fff; border-color: #f59e0b; }

  /* ===== Review summary panels (theo role: BU → Phòng → Người) ===== */
  .rv-summary-grid { display: grid; gap: 16px; margin-top: 20px; }
  .rv-summary-grid-1 { grid-template-columns: 1fr; }
  .rv-summary-grid-2 { grid-template-columns: minmax(320px, 1fr) 1.5fr; }
  .rv-summary-grid-3 { grid-template-columns: 1fr 1fr 1.6fr; }
  @media (max-width: 1200px) { .rv-summary-grid-3 { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 1000px) { .rv-summary-grid-2, .rv-summary-grid-3 { grid-template-columns: 1fr; } }

  .rv-sum-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
  .rv-sum-h { font-size: 14px; font-weight: 700; margin: 0 0 12px 0; color: var(--text); letter-spacing: -0.1px; }
  .rv-sum-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .rv-sum-table thead th {
    text-align: left; font-size: 11px; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.3px;
    padding: 6px 8px; border-bottom: 1.5px solid var(--border);
    background: var(--surface-2);
  }
  .rv-sum-table thead th.num { text-align: right; }
  .rv-sum-table tbody td { padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .rv-sum-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
  .rv-sum-table tbody tr:last-child td { border-bottom: none; }
  .rv-sum-table tbody tr:hover td { background: var(--surface-2); }
  .rv-sum-total td { background: #f0fdf4 !important; font-size: 13.5px; border-top: 2px solid var(--good) !important; }
  .rv-rank { width: 36px; text-align: center; font-weight: 700; font-size: 14px; color: var(--text-dim); }

  /* ===== Cards view = "Từng người" — 2-panel layout ===== */
  .ta-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; margin-top: 12px; }
  .ta-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; max-height: calc(100vh - 320px); overflow-y: auto; }
  .ta-sidebar-head { padding: 10px 14px; font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
  .ta-nv-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s; }
  .ta-nv-item:last-child { border-bottom: none; }
  .ta-nv-item:hover { background: var(--surface-2); }
  .ta-nv-item.selected { background: #ecfdf5; border-left: 3px solid var(--good); padding-left: 11px; }
  .ta-nv-item.row-reconfirm { background: #eff6ff; border-left: 3px solid var(--primary); padding-left: 11px; }
  .ta-nv-item.row-reconfirm.selected { background: #dbeafe; border-left-color: var(--primary); }
  .ta-nv-item.row-editing { background: #fffbeb; border-left: 3px solid var(--warn); padding-left: 11px; }
  .ta-nv-item.row-editing.selected { background: #fef3c7; border-left-color: var(--warn); }
  .ta-nv-item.row-locked { background: #f1f5f9; border-left: 3px solid #1e293b; padding-left: 11px; opacity: 0.85; }
  .ta-nv-item.row-locked.selected { background: #e2e8f0; border-left-color: #1e293b; }
  .ta-nv-item.row-locked .ta-nv-name { color: var(--text-dim); }
  /* ta-detail-head editing / reconfirm state — tint subtle */
  .ta-detail-head.editing { background: #fffbeb; border-radius: 6px; padding: 10px 12px; margin-left: -12px; margin-right: -12px; }
  .ta-detail-head.reconfirm { background: #eff6ff; border-radius: 6px; padding: 10px 12px; margin-left: -12px; margin-right: -12px; }
  .ta-nv-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-dim); color: var(--primary); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .ta-nv-info { flex: 1; min-width: 0; }
  .ta-nv-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ta-nv-pos { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ta-nv-pct { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .ta-nv-pct.ok { color: var(--good); }
  .ta-nv-pct.warn { color: var(--warn); }
  .ta-nv-pct.over { color: var(--bad); }
  .ta-nv-pct.empty { color: var(--text-faint); }
  .ta-nv-xbtn { opacity: 0; margin-left: 4px; border: none; background: transparent; color: var(--text-faint); font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: opacity 0.1s; }
  .ta-nv-item:hover .ta-nv-xbtn { opacity: 0.6; }
  .ta-nv-xbtn:hover { opacity: 1 !important; background: var(--bad-dim); color: var(--bad); }

  .ta-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px 22px; }
  .ta-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }

  .ta-table { width: 100%; border-collapse: collapse; }
  .ta-table thead th { background: var(--surface-2); font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--border); }
  .ta-h-ma { width: 100px; }
  .ta-h-ct, .ta-h-tt { width: 140px; text-align: right !important; }
  .ta-h-x { width: 40px; }
  .ta-table tbody td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .ta-table tbody tr:hover td { background: var(--surface-2); }
  .ta-ma { font-weight: 600; font-size: 13px; color: var(--text); font-family: ui-monospace, monospace; }
  .ta-ten { font-size: 13px; color: var(--text); line-height: 1.3; }
  .ta-dv { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
  .ta-ct input, .ta-tt input { width: 100%; max-width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; background: var(--surface); }
  .ta-ct input:focus, .ta-tt input:focus { border-color: var(--primary); outline: 1px solid var(--primary-dim); background: #fff; }

  /* Duyệt KPI - Cards view: input Kết quả có border dashed (giống matrix) */
  .ta-kq-edit { padding: 6px 8px; }
  .rv-input-wrap { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 2px 6px; border-radius: 4px; min-width: 90px; }
  .rv-input-wrap.rv-edit { border: 1px dashed #93c5fd; background: #f0f9ff; cursor: text; transition: all 0.12s ease; }
  .rv-input-wrap.rv-edit:hover { background: #dbeafe; border-color: var(--primary); border-style: solid; }
  .rv-input-wrap.rv-edit:focus-within { background: #dbeafe; border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
  .rv-input-wrap input { width: 100% !important; max-width: none !important; border: none !important; background: transparent !important; padding: 2px 2px !important; font-size: 13px; text-align: right; font-weight: 600; color: var(--text); outline: none !important; }
  .rv-input-wrap input:focus { background: transparent !important; outline: none !important; }
  .rv-input-wrap.rv-edit input::placeholder { color: #93c5fd; font-weight: 500; }
  .rv-input-unit { font-size: 11px; color: var(--text-faint); font-weight: 500; white-space: nowrap; }
  .ta-table tr.rv-row-dirty td { background: #fef3c7; }
  .ta-table tr.rv-row-dirty:hover td { background: #fde68a; }
  .ta-tt-wrap { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; background: var(--surface); }
  .ta-tt-wrap.override { background: #fef3c7; }
  .ta-tt-wrap span { font-size: 11px; color: var(--text-faint); font-weight: 600; }
  .ta-tt-wrap input { max-width: 70px; }
  .ta-ct { text-align: right; }
  .ta-tt { text-align: right; }
  .ta-xbtn { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 18px; font-weight: 400; padding: 4px 6px; border-radius: 4px; }
  .ta-xbtn:hover { background: var(--bad-dim); color: var(--bad); }
  .ta-total td { background: var(--surface-2) !important; font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.3px; padding-top: 12px !important; padding-bottom: 12px !important; }
  .ta-total-pct { font-size: 14px; font-variant-numeric: tabular-nums; }
  .ta-total-pct.ok { color: var(--good); }
  .ta-total-pct.warn { color: var(--warn); }
  .ta-total-pct.over { color: var(--bad); }
  .ta-empty { color: var(--text-faint); text-align: center; padding: 40px 20px !important; font-size: 13px; }

  @media (max-width: 1100px) {
    .ta-layout { grid-template-columns: 240px 1fr; }
  }
  @media (max-width: 900px) {
    .ta-layout { grid-template-columns: 1fr; }
    .ta-sidebar { max-height: 320px; }
  }

  /* Floating action bar — dính đáy, zIndex cao đảm bảo không bị cover */
  .mx-fab {
    position: fixed; bottom: 16px; right: 24px; z-index: 9999;
    background: #111827; color: #fff;
    padding: 10px 14px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    font-size: 13px;
  }
  .mx-fab .btn { padding: 6px 14px; font-size: 13px; }
  .mx-fab .btn-primary { background: #22c55e; border-color: #22c55e; color: #052e16; font-weight: 700; }
  .mx-fab .btn-primary:hover { background: #16a34a; border-color: #16a34a; }
  .mx-fab .btn:not(.btn-primary) { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
  .mx-fab .btn:not(.btn-primary):hover { background: rgba(255,255,255,0.08); }
  .matrix-toolbar .mt-mode { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
  .matrix-toolbar .mt-mode button { padding: 5px 10px; font-size: 12px; background: var(--surface); border: none; border-right: 1px solid var(--border); cursor: pointer; color: var(--text-dim); }
  .matrix-toolbar .mt-mode button:last-child { border-right: none; }
  .matrix-toolbar .mt-mode button.active { background: var(--primary); color: #fff; }
  .matrix-toolbar .mt-sp { flex: 1; }

  .matrix-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: calc(100vh - 240px); position: relative; }
  .matrix-table { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; font-variant-numeric: tabular-nums; }

  /* Column widths cố định — box-sizing: border-box */
  .matrix-table, .matrix-table * { box-sizing: border-box; }
  .matrix-corner, .matrix-nvcell { min-width: 220px; max-width: 220px; width: 220px; }
  .matrix-ttcol, .matrix-ttcell { min-width: 80px; max-width: 80px; width: 80px; }
  .matrix-tongcol, .matrix-tongcell { min-width: 80px; max-width: 80px; width: 80px; }
  .matrix-actcol, .matrix-actcell { min-width: 108px; max-width: 108px; width: 108px; }

  .matrix-corner, .matrix-colhead, .matrix-nvcell, .matrix-cell,
  .matrix-ttcell, .matrix-ttcol,
  .matrix-tongcell, .matrix-tongcol, .matrix-actcol, .matrix-actcell {
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 8px; vertical-align: top; background: var(--surface);
  }

  /* Sticky LEFT: corner + cột NV + Tuân thủ */
  .matrix-table { --nvW: 220px; --actW: 108px; --tongW: 80px; }
  .matrix-corner  { position: sticky; left: 0; z-index: 5; background: #f3f4f6; font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; border-right: 1px solid var(--border-strong); }
  .matrix-nvcell  { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border-strong); }
  .matrix-ttcol, .matrix-ttcell { position: sticky; left: var(--nvW); z-index: 2; background: var(--surface); text-align: center; font-variant-numeric: tabular-nums; box-shadow: 3px 0 6px -3px rgba(0,0,0,0.12); border-right: 1px solid var(--border-strong); }
  .matrix-ttcol { background: #f3f4f6; font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; z-index: 5; }

  /* Sticky RIGHT: Trạng thái (right:0) + Tổng (right:actW) */
  .matrix-actcol, .matrix-actcell { position: sticky; right: 0; z-index: 2; background: var(--surface); text-align: center; box-shadow: -3px 0 6px -3px rgba(0,0,0,0.12); border-left: 1px solid var(--border-strong); }
  .matrix-tongcol, .matrix-tongcell { position: sticky; right: var(--actW); z-index: 2; background: var(--surface); text-align: center; font-variant-numeric: tabular-nums; }
  .matrix-actcol { background: #f3f4f6; font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; z-index: 5; }
  .matrix-tongcol { background: #f3f4f6; font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; z-index: 5; }

  /* Header KPI columns — chỉ sticky top, scroll horizontal */
  .matrix-colhead { position: sticky; top: 0; z-index: 3; background: #f3f4f6; min-width: 210px; max-width: 260px; font-weight: 700; color: var(--text); }
  .matrix-defhdr-split { display: block; font-weight: 500; font-size: 10px; color: var(--text-faint); text-transform: none; letter-spacing: 0; margin-top: 2px; }

  .matrix-ma { font-weight: 700; color: var(--text); font-size: 13px; text-align: center; position: relative; padding: 0 18px; letter-spacing: 0.3px; }
  .matrix-ma .matrix-del { position: absolute; right: 0; top: 50%; transform: translateY(-50%); float: none; margin: 0; }
  .matrix-ten { color: var(--text-dim); font-size: 12px; line-height: 1.3; max-height: 2.6em; overflow: hidden; text-align: center; font-weight: 500; }
  .matrix-donvi { color: var(--text-faint); font-size: 10.5px; margin-top: 2px; text-align: center; }
  .hdr-center { text-align: center; }
  .matrix-tytrong { display: inline-block; font-size: 10.5px; background: var(--surface-3, #eef2ff); color: var(--primary); padding: 1px 5px; border-radius: 3px; margin-top: 3px; }
  /* Gộp Tỷ trọng | Chỉ tiêu — không border, label trên input */
  .matrix-def-pair { display: flex; align-items: stretch; background: transparent; }
  .matrix-def-cell { display: flex; flex-direction: column; min-width: 0; }
  .matrix-def-cell:first-child { flex: 0 0 88px; }
  .matrix-def-cell:last-child { flex: 1 1 auto; min-width: 100px; }
  .matrix-def-cell + .matrix-def-cell { border-left: 1px solid var(--border); }
  .matrix-def-label { font-size: 10px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.3px; text-align: center; padding: 2px 4px 2px; line-height: 1.25; max-height: 2.6em; overflow: hidden; word-break: break-word; }
  .matrix-def-row { display: flex; align-items: center; justify-content: flex-end; padding: 2px 6px; min-width: 0; }
  .matrix-def-input { flex: 1 1 auto; width: auto; min-width: 0; border: none; background: transparent; font-size: 13px; font-weight: 700; color: var(--text); text-align: right; padding: 2px 2px; font-variant-numeric: tabular-nums; outline: none; }
  .matrix-def-input:hover { background: #eef2ff; border-radius: 3px; }
  .matrix-def-input:focus { background: #dbeafe; outline: 1px solid var(--primary); border-radius: 3px; }
  .matrix-def-input:disabled { opacity: 0.5; }
  .matrix-def-unit { font-size: 10px; color: var(--text-faint); font-weight: 600; margin-left: 3px; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px; }

  /* Toàn bộ 3 hàng header sticky — top offsets đặt INLINE qua JS sau render
     (vì r2 có content dài có thể cao > 46px, phải đo thật) */
  .matrix-table thead tr.hdr-r1 > *,
  .matrix-table thead tr.hdr-r2 > *,
  .matrix-table thead tr.hdr-r3 > * { position: sticky; z-index: 3; }
  .matrix-table thead tr.hdr-r1 th.matrix-corner,
  .matrix-table thead tr.hdr-r1 th.matrix-ttcol,
  .matrix-table thead tr.hdr-r1 th.matrix-tongcol,
  .matrix-table thead tr.hdr-r1 th.matrix-actcol { z-index: 5; }
  .matrix-table thead tr.hdr-r2 th.matrix-corner,
  .matrix-table thead tr.hdr-r2 th.matrix-ttcol,
  .matrix-table thead tr.hdr-r3 th.matrix-corner { z-index: 5; }
  /* Đơn vị dài bị cắt gọn (…) để r2 không phình quá */
  .matrix-donvi { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* Body cell — 2 sub-input (Tỷ trọng % | Chỉ tiêu) side by side, không border */
  .matrix-cell { padding: 3px 4px !important; }
  /* 4 sub-cells per KPI (TT | CT | KQ | TLHT) */
  .matrix-sub { padding: 4px 6px !important; font-size: 12px; text-align: center; vertical-align: middle; font-variant-numeric: tabular-nums; border-right: 1px solid #f1f5f9; }
  .matrix-sub.tt-col { background: #f0f9ff; color: #0369a1; font-weight: 600; min-width: 48px; }
  .matrix-sub.ct-col { background: #fafafa; color: #334155; font-weight: 500; min-width: 56px; }
  .matrix-sub.kq-col { background: #fff; min-width: 68px; }
  .matrix-sub.tlht-col { background: #fafafa; min-width: 60px; border-right: 2px solid var(--border); }
  .matrix-sub.tlht-editable, .ta-ct.tlht-editable { cursor: pointer; transition: background 0.12s ease; }
  .matrix-sub.tlht-editable:hover, .ta-ct.tlht-editable:hover { background: #faf5ff; outline: 1px dashed #c084fc; outline-offset: -2px; }
  /* Custom tooltip (nhanh hơn title native) — delay ~200ms */
  .has-tip { position: relative; }
  .has-tip[data-tip]:not([data-tip=""])::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: #1e293b; color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
    white-space: normal; max-width: 300px; min-width: 120px; width: max-content; text-align: left; line-height: 1.4;
    pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.15s ease 0.2s, visibility 0s linear 0.35s;
    z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
  .has-tip[data-tip]:not([data-tip=""])::before {
    content: ""; position: absolute; bottom: calc(100% + 1px); left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #1e293b;
    pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.15s ease 0.2s, visibility 0s linear 0.35s;
    z-index: 100;
  }
  .has-tip[data-tip]:not([data-tip=""]):hover::after,
  .has-tip[data-tip]:not([data-tip=""]):hover::before { opacity: 1; visibility: visible; transition-delay: 0.2s, 0s; }
  .matrix-sub.rv-notassigned { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 7px); font-style: italic; color: var(--text-faint); border-right: 2px solid var(--border); }
  .matrix-sub.c02 { font-weight: 600; min-width: 48px; border-right-color: #fde68a; }
  .matrix-sub.c02:last-of-type { border-right: 2px solid var(--border); }
  .matrix-sub .rv-kq-input { width: 100%; border: 1px dashed #93c5fd; background: #f0f9ff; padding: 3px 5px; font-size: 12px; border-radius: 3px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); outline: none; transition: all 0.12s ease; }
  .matrix-sub .rv-kq-input:hover { background: #dbeafe; border-color: var(--primary); border-style: solid; }
  .matrix-sub .rv-kq-input:focus { background: #dbeafe; border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
  .matrix-sub .rv-kq-input:disabled { background: #f3f4f6; border-color: transparent; color: var(--text-dim); cursor: not-allowed; }
  .matrix-sub.kq-dirty { background: #fef3c7; }
  .matrix-sub.kq-dirty .rv-kq-input { background: #fff; border-color: var(--warn); font-weight: 600; }
  /* KQ "Chưa nộp" — NV chưa submit, không hiển thị input */
  .matrix-sub.kq-notsub { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 5px, #f3f4f6 5px, #f3f4f6 6px); }
  .kq-notsub-txt { display: inline-block; font-size: 10.5px; color: var(--text-faint); font-style: italic; letter-spacing: 0.2px; font-weight: 500; padding: 2px 6px; }
  /* Đơn vị (unit) nhỏ, xám */
  .unit-tag { display: inline-block; font-size: 10px; color: var(--text-faint); font-weight: 500; letter-spacing: 0.2px; }
  /* Stack: số trên, đơn vị dưới (CT ở matrix) */
  .num-stack { display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.2; }
  .num-stack .num-main { font-size: 12px; font-weight: 600; color: #334155; }
  .num-stack .unit-tag { margin-left: 0; margin-top: 1px; font-size: 9.5px; line-height: 1; }
  /* Cards view KQ stack: input ở trên, đơn vị dưới */
  .ta-kq-stack { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .ta-kq-stack .rv-input-wrap { width: 100%; }
  .ta-kq-stack .unit-tag { font-size: 10px; line-height: 1; color: var(--text-faint); }
  /* KQ input wrapper — input ở trên, unit ở dưới */
  .kq-input-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
  .kq-input-wrap .rv-kq-input { width: 100%; text-align: center; }
  .kq-input-wrap .unit-tag { margin-left: 0; font-size: 9.5px; line-height: 1; margin-top: 1px; }
  /* Sub-column headers */
  .matrix-subcol { padding: 3px 4px !important; font-size: 10.5px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; text-align: center; background: #f8fafc !important; border-right: 1px solid #e5e7eb; border-top: 1px solid #e5e7eb; cursor: help; }
  .matrix-subcol:nth-child(4n+5) { border-right-color: #cbd5e1; }
  /* Áp bộ KPI — chọn NV */
  .bk-nv-list { border: 1px solid var(--border); border-radius: 6px; max-height: 240px; overflow-y: auto; background: var(--surface); }
  .bk-nv-row { display: grid; grid-template-columns: 20px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 12.5px; }
  .bk-nv-row:last-child { border-bottom: none; }
  .bk-nv-row:hover { background: var(--surface-2); }
  .bk-nv-row input[type=checkbox] { margin: 0; cursor: pointer; }
  .bk-nv-row .bk-nv-name { font-weight: 500; color: var(--text); }
  .bk-nv-row .bk-nv-pos { color: var(--text-faint); font-size: 11px; }
  .bk-nv-row .bk-nv-chip { background: var(--good); color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 8px; font-weight: 600; }
  .bk-nv-row.bk-nv-conf { background: #f9fafb; color: var(--text-dim); }
  .bk-nv-row.bk-nv-conf .bk-nv-name { color: var(--text-dim); }
  /* Summary cards KPI của tôi */
  .my-summary-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 16px 0; }
  .my-sum-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: transform 0.1s; }
  .my-sum-card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.06); }
  .my-sum-card .my-sum-label { font-size: 11px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
  .my-sum-card .my-sum-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; margin: 4px 0 2px 0; }
  .my-sum-card .my-sum-max { font-size: 14px; color: var(--text-faint); font-weight: 500; margin-left: 4px; }
  .my-sum-card .my-sum-sub { font-size: 11px; color: var(--text-dim); font-style: italic; }
  .my-sum-card.ok { border-left: 4px solid var(--good); background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%); }
  .my-sum-card.ok .my-sum-value { color: #166534; }
  .my-sum-card.warn { border-left: 4px solid var(--warn); background: linear-gradient(135deg, #fffbeb 0%, #fff 100%); }
  .my-sum-card.warn .my-sum-value { color: #92400e; }
  .my-sum-card.bad { border-left: 4px solid var(--bad); background: linear-gradient(135deg, #fef2f2 0%, #fff 100%); }
  .my-sum-card.bad .my-sum-value { color: #991b1b; }
  /* Kill-switch banner (vi phạm cổng chặn → TT = 0) */
  .kill-switch-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; margin: 0 0 16px 0; background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%); border: 2px solid #ef4444; border-left: 6px solid #991b1b; border-radius: 8px; box-shadow: 0 2px 8px rgba(239,68,68,0.15); }
  .kill-switch-banner .ksb-ico { font-size: 24px; line-height: 1; }
  .kill-switch-banner .ksb-body { flex: 1; color: #991b1b; }
  .kill-switch-banner .ksb-body b { color: #7f1d1d; font-size: 15px; }
  /* Legend chú thích viết tắt */
  .rv-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 12px; margin: 8px 0 10px 0; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px; color: var(--text-dim); }
  .rv-legend .rv-leg-item { display: inline-flex; align-items: center; gap: 6px; }
  .rv-legend b { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.4px; min-width: 32px; text-align: center; }
  .rv-legend b.lg-tt { background: #dbeafe; color: #0369a1; }
  .rv-legend b.lg-ct { background: #e5e7eb; color: #334155; }
  .rv-legend b.lg-kq { background: #fef3c7; color: #92400e; }
  .rv-legend b.lg-tlht { background: #dcfce7; color: #166534; }
  .rv-legend i { color: var(--text-faint); font-style: italic; font-size: 11px; }
  .cell-pair { display: flex; align-items: stretch; background: transparent; }
  .cell-sub { display: inline-flex; align-items: center; justify-content: flex-end; padding: 2px 6px; background: transparent; min-width: 0; position: relative; }
  .cell-sub.tt { flex: 0 0 88px; border-right: 1px solid var(--border); }
  .cell-sub.ct { flex: 1 1 auto; min-width: 100px; gap: 4px; }
  .cell-ct-unit { font-size: 10.5px; color: var(--text-faint); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; flex: 0 1 auto; }
  .cell-sub input { flex: 1 1 auto; width: auto; min-width: 36px; border: none; background: transparent; font-size: 12px; text-align: right; padding: 1px 0; font-variant-numeric: tabular-nums; color: var(--text); outline: none; }
  .cell-sub input:hover { background: #eef2ff; border-radius: 3px; }
  .cell-sub input:focus { background: #dbeafe; border-radius: 3px; box-shadow: 0 0 0 1px var(--primary); }
  .cell-sub.override input { color: var(--primary); font-weight: 600; }
  .cell-sub.override::after { content: ''; position: absolute; top: 1px; right: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
  .cell-unit { font-size: 9px; color: var(--text-faint); font-weight: 500; margin-left: 2px; }
  .cell-pair.empty-pair { display: flex; align-items: center; justify-content: center; padding: 8px; color: var(--text-faint); font-size: 12px; cursor: pointer; background: transparent; border: 1px dashed var(--border); border-radius: 5px; font-weight: 500; }
  .cell-pair.empty-pair:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); border-style: solid; }

  /* Duyệt KPI: click Mã/Tên KPI → mở modal mô tả */
  .rv-kpi-link { cursor: pointer; }
  .rv-kpi-link:hover { color: var(--primary) !important; text-decoration: underline; }

  /* Duyệt KPI: ô chưa giao — bôi xám + text "Không giao" */
  .matrix-cell.rv-notassigned { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 7px); text-align: center; vertical-align: middle; }
  .rv-notassigned-text { color: var(--text-faint); font-size: 11px; font-style: italic; font-weight: 500; letter-spacing: 0.2px; }

  /* Duyệt KPI: ô có input nhập được — border dashed để báo người dùng click */
  .cell-sub.tt.rv-edit, .cell-sub.ct.rv-edit { border: 1px dashed #93c5fd; border-radius: 4px; background: #f0f9ff; padding: 2px 5px; margin: 1px; cursor: text; transition: all 0.12s ease; }
  .cell-sub.tt.rv-edit:hover, .cell-sub.ct.rv-edit:hover { background: #dbeafe; border-color: var(--primary); border-style: solid; }
  .cell-sub.tt.rv-edit:focus-within, .cell-sub.ct.rv-edit:focus-within { background: #dbeafe; border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
  .cell-sub.tt.rv-edit input, .cell-sub.ct.rv-edit input { background: transparent; }
  .cell-sub.tt.rv-edit input::placeholder, .cell-sub.ct.rv-edit input::placeholder { color: #93c5fd; font-weight: 500; }

  /* TLHT đã QL nhập tay (manual override) — tím/xanh đậm hơn + chữ in nghiêng để phân biệt */
  .cell-sub.ct.tlht-manual.rv-edit { background: #faf5ff; border-color: #c084fc; }
  .cell-sub.ct.tlht-manual.rv-edit:hover { background: #f3e8ff; border-color: #9333ea; }
  .cell-sub.ct.tlht-manual.rv-edit input { font-weight: 700; color: #6b21a8; }
  .cell-sub.ct.tlht-manual.rv-edit::after { content: '✎'; position: absolute; top: 1px; right: 2px; font-size: 9px; color: #9333ea; }
  .rv-input-wrap.tlht-manual.rv-edit { background: #faf5ff; border-color: #c084fc; position: relative; }
  .rv-input-wrap.tlht-manual.rv-edit input { font-weight: 700; color: #6b21a8; }
  .rv-input-wrap.tlht-manual.rv-edit::after { content: '✎ Manual'; position: absolute; top: -8px; right: 4px; font-size: 9px; background: #9333ea; color: #fff; padding: 0 4px; border-radius: 3px; font-weight: 600; letter-spacing: 0.3px; }

  .tlht-input { text-align: right; font-variant-numeric: tabular-nums; }

  /* × bỏ giao per cell — hiện lúc hover */
  .matrix-cell { position: relative; }
  .cell-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; padding: 0; z-index: 1; }
  .matrix-cell:hover .cell-remove { opacity: 0.85; }
  .cell-remove:hover { opacity: 1 !important; transform: scale(1.1); }

  /* + KPI riêng cho NV + × bỏ NV khỏi bảng — nằm dưới row info, hiện khi hover */
  .nv-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity 0.15s; }
  .matrix-table tbody tr:hover .nv-actions { opacity: 1; }
  .nv-add-kpi { display: inline-block; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--primary); font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
  .nv-remove { display: inline-block; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--bad); font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
  .nv-remove:hover { background: var(--bad); color: #fff; border-color: var(--bad); border-style: solid; }
  .matrix-table tbody tr:hover .nv-add-kpi { opacity: 1; }
  .nv-add-kpi:hover { background: var(--primary); color: #fff; border-color: var(--primary); border-style: solid; }

  /* Empty state khi chưa có NV nào trong bảng */
  .matrix-empty { background: var(--surface); border: 2px dashed var(--border-strong); border-radius: 10px; padding: 60px 40px; text-align: center; margin: 20px 0; }
  .matrix-empty-ico { font-size: 48px; margin-bottom: 12px; }
  .matrix-empty h3 { margin: 0 0 8px 0; color: var(--text); font-size: 18px; }
  .matrix-empty p { color: var(--text-dim); font-size: 13px; max-width: 480px; margin: 0 auto 20px; line-height: 1.6; }

  /* Modal + Thêm người: NV list rows */
  .an-nv-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s; }
  .an-nv-row:last-child { border-bottom: none; }
  .an-nv-row:hover { background: var(--surface-2); }
  .an-nv-row input[type="checkbox"] { margin: 0; cursor: pointer; }
  .an-nv-ava { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-dim); color: var(--primary); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

  /* Visual pending badge trên cột/ô chưa lưu */
  .matrix-colhead.col-pending { background: linear-gradient(to bottom, #fef3c7 0, #fef3c7 3px, #f3f4f6 3px); }
  .matrix-colhead.col-pending .matrix-ma::after { content: ' (mới)'; color: var(--warn); font-size: 10px; font-weight: 600; }
  .cell-pair.cell-pending { background: #fef3c7; }
  .cell-pair.cell-pending .cell-sub { background: transparent; }

  /* Modal: KPI info preview */
  .ac-info { background: var(--primary-dim); border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: 4px; margin: 8px 0 12px 0; }
  .ac-info-ten { font-weight: 500; color: var(--text); font-size: 13px; }
  .ac-info-meta { display: flex; gap: 4px; margin-top: 3px; font-size: 11px; color: var(--text-dim); }
  .matrix-del { float: right; background: transparent; border: none; color: var(--text-faint); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
  .matrix-del:hover { color: var(--bad); }

  .matrix-cell input { width: 100%; border: 1px solid transparent; background: transparent; padding: 3px 5px; font-size: 12px; border-radius: 3px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
  .matrix-cell input:hover { border-color: var(--border); background: var(--surface); }
  .matrix-cell input:focus { border-color: var(--primary); background: var(--surface); outline: none; }
  .matrix-cell .matrix-wover { font-size: 10px; color: var(--text-faint); margin-top: 2px; text-align: right; }
  .matrix-cell .matrix-wover.diff { color: var(--primary); font-weight: 500; }

  .matrix-table tbody tr:hover .matrix-nvcell,
  .matrix-table tbody tr:hover .matrix-cell,
  .matrix-table tbody tr:hover .matrix-tongcell { background: var(--surface-2); }

  .matrix-status { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; }
  .matrix-status.ok { color: var(--good, #15803d); }
  .matrix-status.warn { color: var(--warn, #b45309); }

  .matrix-nv-name { font-weight: 500; color: var(--text); font-size: 12px; }
  .matrix-nv-meta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

  /* Row states — nhẹ nhàng: chỉ dải trái + cột Tổng/Trạng thái đỏ, body nền trắng */
  .matrix-table tbody tr.row-invalid .matrix-nvcell { box-shadow: inset 3px 0 0 0 var(--bad); }
  .matrix-table tbody tr.row-invalid .matrix-nv-name { color: var(--bad); }
  .matrix-table tbody tr.row-invalid .matrix-tongcell { background: var(--bad-dim); color: var(--bad); font-weight: 700; }
  .matrix-table tbody tr.row-invalid .matrix-actcell { background: var(--bad-dim); }

  .matrix-table tbody tr.row-confirmed .matrix-nvcell { box-shadow: inset 3px 0 0 0 var(--good); }
  .matrix-table tbody tr.row-confirmed .matrix-nv-name { color: var(--good); }
  .matrix-table tbody tr.row-confirmed .matrix-tongcell { background: var(--good-dim); color: var(--good); font-weight: 700; }
  .matrix-table tbody tr.row-confirmed .matrix-actcell { background: var(--good-dim); }
  .matrix-table tbody tr.row-confirmed .matrix-cell input { color: var(--text-dim); background: transparent; border-color: transparent; }

  /* Row RECONFIRM — đã save thay đổi, chờ giao lại (xanh dương) */
  .matrix-table tbody tr.row-reconfirm .matrix-nvcell { box-shadow: inset 3px 0 0 0 var(--primary); }
  .matrix-table tbody tr.row-reconfirm .matrix-nv-name { color: var(--primary); }
  .matrix-table tbody tr.row-reconfirm .matrix-tongcell { background: var(--primary-dim); color: var(--primary); font-weight: 700; }
  .matrix-table tbody tr.row-reconfirm .matrix-actcell { background: var(--primary-dim); }
  .matrix-table tbody tr.row-reconfirm .matrix-cell { background: #eff6ff; }

  /* Row EDITING — QL vừa click Sửa, inputs unlock (vàng nhạt) */
  .matrix-table tbody tr.row-editing .matrix-nvcell { box-shadow: inset 3px 0 0 0 var(--warn); }
  .matrix-table tbody tr.row-editing .matrix-nv-name { color: #92400e; }
  .matrix-table tbody tr.row-editing .matrix-cell { background: #fffbeb; }
  .matrix-table tbody tr.row-editing .matrix-cell input:not(:disabled) { background: #fff; border: 1px dashed #fbbf24; }
  .matrix-table tbody tr.row-editing .matrix-actcell { background: #fef3c7; }

  /* Confirmed row — nút Sửa chỉ hiện khi hover */
  .confirmed-wrap { display: flex; flex-direction: column; gap: 3px; align-items: center; }
  .btn-edit-nv {
    opacity: 0; transition: opacity 0.15s ease;
    font-size: 10.5px; padding: 2px 8px; border: 1px solid var(--primary);
    background: var(--primary); color: #fff; border-radius: 10px;
    cursor: pointer; font-weight: 600; white-space: nowrap;
  }
  .btn-edit-nv:hover { background: #1d4ed8; border-color: #1d4ed8; }
  .matrix-table tbody tr.row-confirmed:hover .btn-edit-nv { opacity: 1; }
  /* Cards view: nút Sửa luôn hiện (không ẩn hover) */
  .ta-detail-head .btn-edit-nv { opacity: 1; padding: 6px 12px; font-size: 12px; border-radius: 6px; }

  /* Row INVALID khi NV đã confirmed → đỏ ĐẬM hơn */
  .matrix-table tbody tr.row-invalid.row-confirmed .matrix-nvcell,
  .matrix-table tbody tr.row-invalid[data-nv] .matrix-nvcell { animation: pulse-alarm 2s ease-in-out infinite; }
  @keyframes pulse-alarm {
    0%, 100% { box-shadow: inset 3px 0 0 0 var(--bad); }
    50% { box-shadow: inset 4px 0 0 0 var(--bad), 0 0 8px rgba(220,38,38,0.3); }
  }

  /* Banner KPI đã bị QL cập nhật ở màn "KPI của tôi" */
  .kpi-mod-notice {
    display: flex; align-items: center; gap: 8px;
    background: #fff7ed; border: 1px solid #fed7aa; border-left: 3px solid #ea580c;
    border-radius: 6px; padding: 6px 10px; margin: 8px 0;
  }
  .kpi-mod-notice-ico { font-size: 14px; line-height: 1; }
  .kpi-mod-notice-body { flex: 1; font-size: 12px; color: var(--text); line-height: 1.35; }
  .kpi-mod-notice-body b { color: #9a3412; font-size: 12px; }
  .kpi-mod-notice .btn { padding: 3px 8px; font-size: 11px; }

  .matrix-tongcell.ok { color: var(--good); font-weight: 700; }
  .matrix-tongcell.warn { color: var(--bad); font-weight: 700; }
  .matrix-tongcell.empty { color: var(--text-faint); }

  .btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

  .confirm-chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 12px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
  /* Chip khoá — cho phép xuống dòng vì text dài hơn ô act */
  .confirm-chip.chip-locked { background: #1e293b; color: #fff; border: 1px solid #1e293b; white-space: normal; line-height: 1.3; padding: 4px 8px; border-radius: 8px; font-size: 10.5px; letter-spacing: 0.1px; text-align: center; }
  /* Chip NV chưa được giao KPI — xám nhạt (phân biệt với "chưa nộp") */
  .confirm-chip.chip-notassigned { background: #f1f5f9; color: #475569; border: 1px dashed #94a3b8; font-weight: 500; }
  .ta-nv-item.row-notassigned { background: #f8fafc; opacity: 0.75; }
  .ta-nv-item.row-notassigned .ta-nv-name { color: var(--text-dim); font-style: italic; }
  .confirm-chip.ok { background: var(--good-dim); color: var(--good); border: 1px solid #bbf7d0; }
  .confirm-chip.warn { background: var(--warn-dim); color: var(--warn); border: 1px solid #fde68a; }
  .confirm-chip.over { background: var(--bad-dim); color: var(--bad); border: 1px solid #fecaca; }
  .confirm-chip.empty { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }

  .status-pill { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 14px; font-size: 12px; font-weight: 600; }
  .status-pill.ok { background: var(--good-dim); color: var(--good); }
  .status-pill.ready { background: var(--primary-dim); color: var(--primary); }
  .status-pill.warn { background: var(--warn-dim); color: var(--warn); }
  .status-pill.over { background: var(--bad-dim); color: var(--bad); }
  .status-pill.empty { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }

  .matrix-status-pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .matrix-status-cta { display: flex; flex-direction: column; align-items: flex-end; }

  /* Toggle switch (matrix / cards) */
  .assign-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
  .assign-switch button { padding: 6px 12px; font-size: 12px; background: var(--surface); border: none; border-right: 1px solid var(--border); cursor: pointer; color: var(--text-dim); font-weight: 500; }
  .assign-switch button:last-child { border-right: none; }
  .assign-switch button.active { background: var(--primary); color: #fff; }
  .assign-switch button:hover:not(.active) { background: var(--surface-2); }

  /* Cards view — row/card state */
  .assign-card-inner { border-radius: 8px; padding: 2px; }
  .assign-card-inner.is-invalid { background: linear-gradient(to right, var(--bad) 0, var(--bad) 3px, transparent 3px); padding-left: 10px; margin-left: -2px; }
  .assign-card-inner.is-invalid .weight-badge.weight-warn { background: var(--bad); color: #fff; font-size: 13px; padding: 4px 10px; }
  .assign-card-inner.is-valid { background: linear-gradient(to right, var(--good) 0, var(--good) 3px, transparent 3px); padding-left: 10px; margin-left: -2px; }
  .assign-card-inner.is-confirmed { background: linear-gradient(to right, var(--good) 0, var(--good) 3px, transparent 3px); padding-left: 10px; margin-left: -2px; opacity: 0.9; }

  /* Override: tổng != 100% là RED (bad), không phải vàng */
  .weight-badge.weight-warn { background: var(--bad-dim); color: var(--bad); border-color: #fecaca; }

  .draft-hint { background: #fef3c7; border-top: 1px solid #fde68a; color: #92400e; padding: 8px 14px; font-size: 12px; }
  .draft-hint b { color: var(--bad); }
