/* Tái sử dụng gần như nguyên vẹn từ the-gats-danh-gia-nhan-su.html (bản artifact gốc) —
   chỉ thêm vài class mới cho login/nav, không đổi bảng màu/typography gốc. */

:root {
  --ink: #1c1a17;
  --surface: #252220;
  --surface-2: #2e2a26;
  --line: rgba(233, 222, 203, 0.12);
  --cream: #ede4d3;
  --muted: #a89a85;
  --brass: #c9a24b;
  --brass-soft: rgba(201, 162, 75, 0.16);
  --sop: #c9a24b;
  --kpi: #7ca98c;
  --core: #b0794f;
  --danger: #c9614b;
  --ok: #7ca98c;
  --pending: #c9a24b;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
header.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 6px;
}
h1 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 34px;
  margin: 0;
  letter-spacing: -0.01em;
}
.top .meta {
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  line-height: 1.6;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: "Inter";
  font-weight: 600;
  font-size: 13.5px;
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-block;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover {
  color: var(--cream);
}
.tab-btn.active {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
}
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.positions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dept-header {
  font-family: "IBM Plex Mono";
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 14px 0 2px;
  padding-left: 2px;
}
.dept-header:first-child {
  margin-top: 0;
}
.pos-btn {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--cream);
  font-family: "Inter";
  transition: 0.15s;
  width: 100%;
}
.pos-btn:hover {
  border-color: var(--brass);
}
.pos-btn.active {
  background: var(--brass-soft);
  border-color: var(--brass);
}
.pos-btn .name {
  font-weight: 600;
  font-size: 13.5px;
}
.pos-btn .lvl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.pos-btn .weights {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}
.pos-btn .weights span {
  display: block;
  height: 100%;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
  margin-bottom: 22px;
}
.panel h2 {
  font-family: "Fraunces", serif;
  font-size: 20px;
  margin: 0 0 4px;
  font-weight: 600;
}
.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.weight-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 14px 0 10px;
}
.weight-bar span {
  display: block;
  height: 100%;
}
.weight-legend {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.weight-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.crit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 6px;
}
@media (max-width: 760px) {
  .crit-grid {
    grid-template-columns: 1fr;
  }
}
.crit-col h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  font-weight: 600;
}
.crit-col ul {
  margin: 0;
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 760px) {
  .form-row-3 {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
input[type="text"],
input[type="month"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  padding: 10px 12px;
  font-family: "Inter";
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea {
  resize: vertical;
  min-height: 60px;
}
/* Ô lọc nhanh chèn phía trên các <select> danh sách nhân sự dài (người chấm điểm...) */
input.emp-filter {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  padding: 8px 12px;
  font-family: "Inter";
  font-size: 13px;
  margin-bottom: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input.emp-filter:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-soft);
}
select.emp-select optgroup {
  color: var(--muted);
  background: var(--surface);
  font-style: normal;
}
select.emp-select option {
  color: var(--cream);
  background: var(--surface-2);
}

/* Chấm điểm: chế độ tập trung — ẩn bảng danh sách người khác + lịch sử khi đang chấm 1 người. */
.main.score-focus .focus-hide {
  display: none;
}
.main.score-focus.show-all .focus-hide {
  display: block;
}
.focus-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.focus-name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 16px;
  margin-right: 10px;
}
input[type="text"]:hover,
input[type="month"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
textarea:hover,
select:hover {
  border-color: var(--muted);
}
input[type="text"]:focus,
input[type="month"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
input[type="range"]:focus,
select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-soft);
}

.score-group {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px 16px 14px;
  margin-bottom: 14px;
  border-left: 3px solid transparent;
}
.score-group .group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.score-group .group-head h4 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.score-group .group-head .avg {
  font-family: "IBM Plex Mono";
  font-size: 16px;
  font-weight: 600;
  color: var(--brass);
}

.dyn-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}
.kpi-entry,
.core-entry,
.sop-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.entry-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.entry-top .dyn-text {
  flex: 1;
}
/* Dòng SOP: mô tả lỗi + mức độ + điểm trừ gộp chung 1 hàng, gợi ý bằng placeholder chứ không phải nhãn riêng. */
.sop-entry .entry-top {
  margin-bottom: 0;
  flex-wrap: wrap;
}
.sop-entry .entry-top .dyn-text {
  min-width: 200px;
}
.sop-entry .sop-severity {
  flex: 0 0 190px;
  width: auto;
  min-width: 0;
}
.sop-entry .sop-deduct {
  flex: 0 0 90px;
  width: auto;
  min-width: 0;
  text-align: left;
}
@media (max-width: 560px) {
  .sop-entry .sop-severity,
  .sop-entry .sop-deduct {
    flex: 1 1 140px;
  }
}
.entry-bottom {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.entry-bottom .dyn-num,
.entry-bottom .dyn-select {
  width: auto;
  min-width: 0;
  flex: 0 0 130px;
}
.kpi-entry .kpi-target,
.kpi-entry .kpi-actual,
.kpi-entry .kpi-weight {
  flex: 0 0 100px;
}
/* KPI: cách tính tách lên 1 dòng riêng; hàng số bên dưới có nhãn chữ trước từng ô. */
.kpi-typerow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.kpi-typerow .kpi-type {
  flex: 0 1 260px;
}
.kpi-numrow .kpi-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kpi-numrow .kpi-weight {
  flex: 0 0 72px;
}
.kpi-field-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 560px) {
  .kpi-numrow .kpi-pair {
    flex: 1 1 150px;
  }
  .kpi-numrow .kpi-pair .dyn-num {
    flex: 1 1 auto;
  }
}
.core-entry .core-weight {
  flex: 0 0 100px;
}
@media (max-width: 560px) {
  .entry-bottom .dyn-num,
  .entry-bottom .dyn-select {
    flex: 1 1 120px;
  }
}
.calc-badge {
  margin-left: auto;
  font-family: "IBM Plex Mono";
  font-size: 13px;
  font-weight: 600;
  color: var(--brass);
  background: var(--brass-soft);
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.dyn-text,
.dyn-num,
.dyn-select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--cream);
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: "Inter";
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dyn-num {
  text-align: center;
}
.dyn-text:focus,
.dyn-num:focus,
.dyn-select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-soft);
}
.remove-row {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}
.remove-row:hover {
  color: var(--danger);
}
button.add-row {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: "Inter";
  width: 100%;
  transition: border-color 0.15s ease, color 0.15s ease;
}
button.add-row:hover {
  border-color: var(--brass);
  color: var(--brass);
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
}

.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--brass-soft), transparent);
  border: 1px solid var(--brass);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 16px 0;
}
.total-box .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.total-box .num {
  font-family: "Fraunces", serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--brass);
}

button.primary {
  background: var(--brass);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: "Inter";
  transition: filter 0.15s ease, transform 0.1s ease;
}
button.primary:hover {
  filter: brightness(1.08);
}
button.primary:active:not(:disabled) {
  transform: scale(0.98);
}
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.ghost:hover {
  border-color: var(--brass);
  color: var(--brass);
}
.ghost:active:not(:disabled) {
  background: var(--brass-soft);
}
.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ghost:disabled:hover {
  border-color: var(--line);
  color: var(--muted);
}
.ghost.approve:hover {
  border-color: var(--ok);
  color: var(--ok);
}
.ghost.approve:active:not(:disabled) {
  background: rgba(124, 169, 140, 0.16);
}
/* Chỉ hành động phá hủy thật sự (Xóa, Từ chối) mới cảnh báo đỏ khi hover — không áp cho mọi nút ghost. */
.ghost.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.ghost.danger:active:not(:disabled) {
  background: rgba(201, 97, 75, 0.16);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.15s ease;
}
tr:hover td {
  background: rgba(255, 255, 255, 0.035);
}
.badge {
  font-family: "IBM Plex Mono";
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-2);
}
.status-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.pending {
  background: rgba(201, 162, 75, 0.16);
  color: var(--pending);
}
.status-pill.approved {
  background: rgba(124, 169, 140, 0.16);
  color: var(--ok);
}
.status-pill.rejected {
  background: rgba(201, 97, 75, 0.16);
  color: var(--danger);
}
.status-pill.draft {
  background: rgba(168, 154, 133, 0.16);
  color: var(--muted);
}
.status-pill.skipped {
  background: rgba(168, 154, 133, 0.16);
  color: var(--muted);
}

/* Hàng nút của form chấm điểm + gợi ý autosave */
.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.autosave-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Banner "khôi phục bản nhập chưa lưu" chèn vào đầu form */
.draft-restore-banner {
  font-size: 13px;
  color: var(--cream);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border-left: 3px solid var(--pending);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.draft-restore-banner .spacer {
  flex: 1;
}
.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
select {
  background: var(--surface-2);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: "Inter";
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  min-height: 16px;
}
.status.ok {
  color: var(--kpi);
}
.status.err {
  color: var(--danger);
}
.notice {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 24px;
  border-left: 3px solid var(--brass);
}
.assign-strip {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12.5px;
}
.assign-strip .item span.k {
  color: var(--muted);
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.assign-strip .item span.v {
  color: var(--cream);
  font-weight: 600;
}

.hier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 6px;
}
.hier-table th {
  font-size: 10.5px;
}
.hier-table td {
  padding: 10px;
}
.level-chip {
  font-family: "IBM Plex Mono";
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--brass-soft);
  color: var(--brass);
  font-weight: 600;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 46px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.bar-row .bar-label {
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  background: var(--surface-2);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 6px;
}
.bar-row .bar-val {
  font-family: "IBM Plex Mono";
  color: var(--muted);
  text-align: right;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 14px;
}
.rank-item .who {
  font-size: 13px;
}
.rank-item .who .pos {
  color: var(--muted);
  font-size: 11.5px;
  display: block;
  margin-top: 2px;
}
.rank-item .score {
  font-family: "IBM Plex Mono";
  font-weight: 700;
  font-size: 15px;
  color: var(--brass);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 860px) {
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.metric-card {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px;
}
.metric-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-card .value {
  font-family: "IBM Plex Mono";
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--cream);
}
.metric-card .delta {
  font-size: 11.5px;
  margin-top: 4px;
  color: var(--muted);
}
.metric-card .delta.up {
  color: var(--ok);
}
.metric-card .delta.down {
  color: var(--danger);
}

.chart-wrap {
  position: relative;
  height: 230px;
  margin-top: 10px;
}
.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}
.chart-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 5px;
}

.leader-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.leader-table td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.leader-table td.num {
  font-family: "IBM Plex Mono";
  text-align: right;
  color: var(--muted);
}
.leader-table td.score {
  font-family: "IBM Plex Mono";
  text-align: right;
  font-weight: 700;
  color: var(--brass);
}

.emp-table-wrap {
  overflow-x: auto;
}

/* ===== Bổ sung cho bản Next.js (login, nav, session) — cùng bảng màu gốc ===== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.session-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}
.session-strip .role-chip {
  font-family: "IBM Plex Mono";
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--brass-soft);
  color: var(--brass);
  font-weight: 600;
  text-transform: uppercase;
}
.tabs-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Dropdown chọn nhiều outlet (bảng Phân công phụ trách — tab Chi trả KPI).
   <select multiple> của trình duyệt không nhận theme tối nên tự dựng lại:
   nút mở + panel checkbox, dữ liệu vẫn là input[type=checkbox] thật nên
   form submit chạy bình thường kể cả khi JS lỗi. */
.ms {
  position: relative;
  min-width: 230px;
}
.ms-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  padding: 9px 12px;
  font-family: "Inter";
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ms-btn:hover {
  border-color: rgba(201, 162, 75, 0.45);
}
.ms-btn:focus-visible {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-soft);
}
.ms-btn[aria-expanded="true"] {
  border-color: var(--brass);
}
.ms-caret {
  color: var(--muted);
  font-size: 10px;
  flex: none;
  transition: transform 0.15s ease;
}
.ms-btn[aria-expanded="true"] .ms-caret {
  transform: rotate(180deg);
}
.ms-label.is-default {
  color: var(--muted);
}
.ms-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.ms-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--cream);
}
.ms-opt:hover {
  background: var(--surface-2);
}
.ms-opt input {
  accent-color: var(--brass);
  width: 15px;
  height: 15px;
  flex: none;
  cursor: pointer;
}
.ms-opt.is-on {
  background: var(--brass-soft);
}
.ms-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 0;
}

/* Nhãn "Đã lưu" hiện tại chỗ sau khi lưu phân công bằng AJAX (không tải lại trang). */
.ms-saved {
  margin-left: 8px;
  font-size: 12px;
  color: var(--ok);
  white-space: nowrap;
}

/* ------------------------------------------------------------------
   Khối gấp/mở (details)

   Bảng hệ số công có hơn 50 dòng input; để mở sẵn thì phần kết quả KPI bị đẩy
   xuống quá xa, mà bảng đó chỉ dùng lúc nhập. Gấp lại, chừa dòng tóm tắt.
   ------------------------------------------------------------------ */
details.foldable {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.12);
}

details.foldable > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

details.foldable > summary::-webkit-details-marker { display: none; }

details.foldable > summary::before {
  content: '▸';
  color: var(--brass);
  transition: transform 0.15s ease;
  display: inline-block;
}

details.foldable[open] > summary::before { transform: rotate(90deg); }

details.foldable > summary:hover { background: rgba(255, 255, 255, 0.04); }

details.foldable > summary .sub-count {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

details.foldable > .foldable-body { padding: 0 14px 14px; }

/* ------------------------------------------------------------------
   Bảng chi trả KPI

   Mỗi nhóm (mỗi outlet × mỗi phòng ban) render một <table> riêng. Để trình duyệt
   tự co cột thì cột của nhóm này lệch hẳn với nhóm kia — cuộn dọc qua 8 bảng là
   8 lần mắt phải tìm lại cột. Khoá bề rộng để mọi nhóm thẳng một hàng.

   min-width thay vì để co lại: bảng 8 cột mà bóp xuống màn hẹp thì chữ vỡ hết,
   thà cho cuộn ngang trong .emp-table-wrap.
   ------------------------------------------------------------------ */
table.kpi-rows {
  table-layout: fixed;
  width: 100%;
  min-width: 900px;
}

table.kpi-rows th,
table.kpi-rows td {
  vertical-align: top;
}

/* Số liệu căn phải + chữ số đều bề ngang, để so hàng trên hàng dưới bằng mắt. */
table.kpi-rows .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.kpi-rows .num .hint {
  text-align: right;
}

/* Dải tiêu đề nhóm nằm TRONG bảng — thay cho mỗi nhóm một <h3> + một <table> riêng.
   Nhờ vậy mọi nhóm dùng chung một bộ cột, và số tổng của nhóm nằm ngay trên cột tương ứng. */
table.kpi-rows tr.group-row > td {
  background: #3a3733;
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  padding-top: 10px;
  padding-bottom: 10px;
}

table.kpi-rows tr.group-row .hint {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  margin: 2px 0 0;
}

/* Dòng người chưa được duyệt: vẫn đọc được nhưng lùi hẳn ra sau. */
table.kpi-rows tr.row-muted > td {
  opacity: 0.6;
}

table.kpi-rows tbody tr:not(.group-row):hover > td {
  background: rgba(255, 255, 255, 0.03);
}

table.kpi-rows .hint {
  margin: 2px 0 0;
  line-height: 1.35;
}

/* Bản đã chốt có thêm cột "Vị trí" nên rộng hơn bản xem trước. */
table.kpi-rows.kpi-rows-run {
  min-width: 1000px;
}
