/* SafetyHub v2 — theme tokens + shell (sidebar / top bar / section tabs) + Tổng quan.
   Loaded AFTER styles.css and stage2.css (see ensureStage2Stylesheet in main.js), so it can
   re-point the legacy --brand tokens to "safety orange" and everything already using them follows.
   Orange #c2410c on white = 5.2:1 contrast, so white text on primary buttons stays AA-readable. */
:root {
  --brand: #c2410c;
  --brand-dark: #9a3412;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fff1e8;
  --on-accent: #ffffff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #667085;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --neutral: #475467;
  --neutral-bg: #f2f4f7;
  --sh-radius: 10px;
  --sh-radius-sm: 8px;
  --sh-sidebar: 276px;
  background: var(--bg);
  color: var(--ink);
}
body { background: var(--bg); font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.app-shell--v2 { display: grid; grid-template-columns: var(--sh-sidebar) minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.sh-side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.sh-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sh-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.sh-brand strong { display: block; font-size: 15px; line-height: 1.15; color: var(--ink); }
.sh-brand small { color: var(--ink-3); font-size: 12px; }
.sh-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sh-nav-item {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-radius: var(--sh-radius-sm);
  color: var(--ink-2); font-weight: 500; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.sh-nav-item:hover { background: var(--neutral-bg); color: var(--ink); }
.sh-nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sh-nav-item svg { width: 18px; height: 18px; }
.sh-nav-item > span:not(.sh-badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sh-group .sh-sub { display: none; margin: 2px 0 6px 17px; padding-left: 10px; border-left: 1px solid var(--border); }
.sh-group.open .sh-sub { display: grid; gap: 1px; }
.sh-sub-item { display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: var(--sh-radius-sm); color: var(--ink-2); font-size: 13.5px; font-weight: 500; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
.sh-sub-item:hover { background: var(--neutral-bg); color: var(--ink); }
.sh-sub-item.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.sh-sub-item .ext { font-size: 11px; opacity: .55; }
.sh-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10.5px; line-height: 18px; font-weight: 600; text-align: center; flex: none; }
.sh-badge[hidden] { display: none; }
.sh-me { display: flex; align-items: center; gap: 10px; padding: 10px 6px 4px; margin-top: 8px; border-top: 1px solid var(--border); }
.sh-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--neutral-bg); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.sh-me > div { min-width: 0; flex: 1; }
.sh-me strong { display: block; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-me small { color: var(--ink-3); font-size: 12px; }
.sh-icon-btn { border: 0; background: none; color: var(--ink-3); padding: 6px; border-radius: var(--sh-radius-sm); cursor: pointer; display: grid; place-items: center; }
.sh-icon-btn:hover { background: var(--neutral-bg); color: var(--ink); }
.sh-main { min-width: 0; }
.sh-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.sh-top h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.sh-top .sh-top-logout { display: none; margin-left: auto; }
.sh-tabs { display: flex; gap: 4px; padding: 0 28px; border-bottom: 1px solid var(--border); overflow-x: auto; background: var(--bg); }
.sh-tabs:empty { display: none; }
.sh-tab { padding: 10px 12px; color: var(--ink-2); font-weight: 550; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s; }
.sh-tab:hover { color: var(--ink); }
.sh-tab.active { color: var(--accent); border-color: var(--accent); }
.sh-tab .ext { font-size: 11px; opacity: .6; margin-left: 3px; }
.sh-content { padding: 24px 28px 64px; min-width: 0; }
.app-shell--v2 :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Tổng quan ---------- */
.ov-sample { color: var(--ink-3); font-size: 12px; margin: 0 0 14px; }
.ov-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.ov-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sh-radius); padding: 14px 16px; }
.ov-kpi small { display: block; color: var(--ink-3); font-size: 12px; }
.ov-kpi b { display: block; margin-top: 2px; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; color: var(--ink); }
.ov-kpi span { color: var(--ink-3); font-size: 12px; }
.ov-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 12px; align-items: start; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sh-radius); overflow: hidden; }
.ov-card + .ov-card { margin-top: 12px; }
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ov-head h2 { margin: 0; font-size: 14px; font-weight: 650; color: var(--ink); }
.ov-head span { color: var(--ink-3); font-size: 12px; }
.ov-list { list-style: none; margin: 0; padding: 0; }
.ov-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 16px; border: 0; border-top: 1px solid var(--border); background: none; text-align: left; color: inherit; font: inherit; cursor: pointer; transition: background .15s; }
.ov-list > :first-child .ov-row, .ov-row:first-child { border-top: 0; }
.ov-row:hover { background: var(--surface-2); }
.ov-row .t { flex: 1; min-width: 0; }
.ov-row .t b { display: block; font-weight: 600; color: var(--ink); }
.ov-row .t small { color: var(--ink-3); }
.ov-row .go { color: var(--ink-3); font-weight: 600; font-size: 13px; }
.ov-chip { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 54px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; flex: none; }
.ov-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ov-chip.bad { background: var(--bad-bg); color: var(--bad); }
.ov-chip.warn { background: var(--warn-bg); color: var(--warn); }
.ov-chip.ok { background: var(--ok-bg); color: var(--ok); }
.ov-chip.n { background: var(--neutral-bg); color: var(--neutral); }
.ov-empty { padding: 22px 16px; color: var(--ink-3); text-align: center; }
.ov-group { display: grid; grid-template-columns: minmax(96px, 150px) minmax(60px, 1fr) 74px; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; border: 0; border-top: 1px solid var(--border); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ov-group:first-child { border-top: 0; }
.ov-group:hover { background: var(--surface-2); }
.ov-group em { font-style: normal; text-align: right; color: var(--ink-2); font-size: 13px; }
.ov-bar { height: 6px; border-radius: 99px; background: var(--neutral-bg); overflow: hidden; }
.ov-bar i { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.ov-bar i.w { background: #f79009; }
.ov-bar i.b { background: var(--bad); }
.ov-more { margin-top: 12px; }
.ov-more > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--ink-2); list-style: none; }
.ov-more > summary::-webkit-details-marker { display: none; }
.ov-more > summary::after { content: '▸'; margin-left: 8px; color: var(--ink-3); }
.ov-more[open] > summary::after { content: '▾'; }
.ov-buckets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.ov-buckets > div + div { border-left: 1px solid var(--border); }
.ov-buckets h3 { margin: 0; padding: 12px 16px 4px; font-size: 13px; color: var(--ink-2); }
.ov-tip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 16px; padding: 10px 12px 10px 14px; border: 1px solid var(--border); border-radius: var(--sh-radius); background: var(--surface); color: var(--ink-2); }
.ov-tip a { color: var(--accent); font-weight: 600; text-decoration: none; }
.ov-tip button { margin: 0 0 0 auto; border: 0; background: none; box-shadow: none; color: var(--ink-3); cursor: pointer; padding: 2px 8px; font-size: 18px; line-height: 1; min-height: 0; }

/* ---------- Đào tạo: gọn hơn, ít chữ hơn ---------- */
.app-shell--v2 .sh-content .page-header { margin-bottom: 12px; }
.app-shell--v2 .sh-content .page-header h1 { font-size: 22px; letter-spacing: -.01em; }
.app-shell--v2 .sh-content .page-header p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.app-shell--v2 .training-dashboard-heading small { display: none; }
.app-shell--v2 .training-dashboard-panel { padding: 12px 14px 14px; border-radius: var(--sh-radius); box-shadow: none; }
.app-shell--v2 .training-dashboard-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.app-shell--v2 .training-dashboard-heading strong { font-size: 15px; color: var(--ink); }
.app-shell--v2 .training-dashboard-filterbar { background: transparent; border: 0; padding: 0; margin-bottom: 10px; }
.app-shell--v2 .training-matrix-table thead th { padding: 8px 12px; font-size: 11.5px; letter-spacing: .03em; }
.app-shell--v2 .training-matrix-table tbody td { padding: 9px 12px; font-size: 14px; }
.app-shell--v2 .training-matrix-table .link-button { color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: none; }
.app-shell--v2 .training-matrix-table .link-button:hover { text-decoration: underline; }

/* Bảng tổng hợp đào tạo nội bộ: bỏ màu vàng/xanh chói kiểu Excel, giữ ý nghĩa (kế hoạch = xanh dương nhạt, thực hiện = xanh lá nhạt). */
.app-shell--v2 .internal-section-actionbar:not(:has(*)) { display: none !important; }
.app-shell--v2 .internal-summary-matrix { font-size: 13px; }
.app-shell--v2 .internal-summary-matrix th, .app-shell--v2 .internal-summary-matrix td { border-color: var(--border); }
.app-shell--v2 .internal-summary-matrix thead th, .app-shell--v2 .internal-summary-matrix thead .area { background: var(--surface-2); color: var(--ink-2); font-weight: 650; font-size: 12px; }
.app-shell--v2 .internal-summary-plan-row th, .app-shell--v2 .internal-summary-plan-row td, .app-shell--v2 .row-plan-total, .app-shell--v2 .internal-summary-plan-row .total-plan { background: #eaf3fc !important; color: #175cd3; font-weight: 650; }
.app-shell--v2 .internal-summary-plan-row .stt { background: #eaf3fc !important; color: #175cd3; font-size: 12px; }
.app-shell--v2 .internal-summary-done-row th, .app-shell--v2 .internal-summary-done-row td, .app-shell--v2 .row-done-total, .app-shell--v2 .done-total { background: var(--ok-bg) !important; color: var(--ok); font-weight: 650; }
.app-shell--v2 .internal-summary-cell { border-radius: 6px; }

/* ---------- Nhân sự (danh sách) ---------- */
#employee-table.loading-card:has(.employee-list-table-scroll) { padding: 0; text-align: left; color: inherit; }
.app-shell--v2 .header-actions .secondary-button { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.app-shell--v2 .header-actions .primary-button { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.app-shell--v2 .employee-list-table thead th { padding: 9px 12px; font-size: 11.5px; letter-spacing: .03em; }
.app-shell--v2 .employee-list-table tbody td { padding: 8px 12px; font-size: 14px; }
@media (min-width: 761px) {
  /* Ô lọc: một hàng gọn, tự xuống dòng khi hẹp (trước đây thành lưới 3 cột × 3 hàng rất cao). */
  .app-shell--v2 .filters-panel.excel-filter-grid, .app-shell--v2 .certificate-filter-panel.excel-filter-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 12px; }
  .app-shell--v2 .filters-panel.excel-filter-grid > input, .app-shell--v2 .certificate-filter-panel.excel-filter-grid > input { flex: 2 1 150px; min-width: 0; min-height: 40px; }
  .app-shell--v2 .filters-panel.excel-filter-grid > .excel-multiselect, .app-shell--v2 .filters-panel.excel-filter-grid > select, .app-shell--v2 .certificate-filter-panel.excel-filter-grid > select, .app-shell--v2 .certificate-filter-panel.excel-filter-grid > .excel-multiselect { flex: 1 1 130px; max-width: 200px; }
  .app-shell--v2 .filters-panel.excel-filter-grid .excel-multiselect-trigger, .app-shell--v2 .certificate-filter-panel.excel-filter-grid .excel-multiselect-trigger, .app-shell--v2 .filters-panel.excel-filter-grid > select, .app-shell--v2 .certificate-filter-panel.excel-filter-grid > select { min-height: 40px; }
  .app-shell--v2 .filters-panel.excel-filter-grid > button, .app-shell--v2 .certificate-filter-panel.excel-filter-grid > button { flex: 0 0 auto; min-height: 40px; padding: 0 16px; }
}

@media (max-width: 760px) {
  .app-shell--v2 .page-header.split { display: grid; gap: 10px; }
  .app-shell--v2 .page-header .header-actions { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)) !important; gap: 8px; overflow: visible; }
  .app-shell--v2 .page-header .header-actions .primary-button { grid-column: 1 / -1; order: -1; }
  .app-shell--v2 .page-header .header-actions button { width: 100%; min-height: 40px; }
  .app-shell--v2 .filters-panel.excel-filter-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px; padding: 10px; }
  .app-shell--v2 .filters-panel.excel-filter-grid > input, .app-shell--v2 .filters-panel.excel-filter-grid > .excel-multiselect:nth-of-type(5) { grid-column: 1 / -1; }
  .app-shell--v2 .filters-panel.excel-filter-grid > select { font-size: 14px; }
  .app-shell--v2 .filters-panel.excel-filter-grid > input, .app-shell--v2 .filters-panel.excel-filter-grid .excel-multiselect-trigger, .app-shell--v2 .filters-panel.excel-filter-grid > button { min-height: 40px; }
}

/* ---------- Chung cho các trang còn lại ---------- */
.app-shell--v2 .sh-content .loading-card:has(> *) { padding: 0; text-align: left; color: inherit; }
.app-shell--v2 .sh-content .table-panel table th { padding: 9px 12px; font-size: 11.5px; letter-spacing: .03em; }
.app-shell--v2 .sh-content .table-panel table td { padding: 9px 12px; font-size: 14px; }
.app-shell--v2 .sh-content .kpi-grid { gap: 12px; margin-bottom: 14px; }
.app-shell--v2 .sh-content .kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sh-radius); padding: 12px 16px; box-shadow: none; }
.app-shell--v2 .sh-content .kpi-card span { font-size: 12px; color: var(--ink-3); }
.app-shell--v2 .sh-content .kpi-card strong { font-size: 24px; letter-spacing: -.02em; color: var(--ink); }
.app-shell--v2 .sh-content .panel { border-radius: var(--sh-radius); box-shadow: none; }

/* Thẻ dung lượng R2: gọn lại, bỏ dòng mô tả dài. */
.app-shell--v2 .storage-usage-panel { padding: 12px 16px; margin-bottom: 12px; }
.app-shell--v2 .storage-usage-header small { display: none; }
.app-shell--v2 .storage-usage-header h2 { font-size: 14px; margin: 0; }
.app-shell--v2 .storage-usage-panel .loading-card { padding: 10px 0 0; }

@media (min-width: 761px) {
  .app-shell--v2 .sh-content .table-panel td button { min-height: 30px !important; height: auto !important; padding-top: 3px; padding-bottom: 3px; white-space: nowrap; }
  .app-shell--v2 .filters-panel.excel-filter-grid > .excel-multiselect, .app-shell--v2 .filters-panel.excel-filter-grid > select { flex-basis: 125px; max-width: 220px; }
}

/* Danh sách thiết bị: giữ các cột đầu trên một dòng, bảng rộng hơn thì cuộn ngang thay vì bóp chữ. */
.app-shell--v2 .asset-table { min-width: 1000px; }
.app-shell--v2 .asset-table td:nth-child(-n+5) { white-space: nowrap; }

/* Tổng quan thiết bị: danh sách phân loại gọn, không viền từng dòng. */
.app-shell--v2 .asset-breakdown-card { padding: 12px 16px; }
.app-shell--v2 .asset-breakdown-card .panel-header { margin-bottom: 6px; }
.app-shell--v2 .asset-breakdown-card .panel-header h2 { font-size: 14px; margin: 0; }
.app-shell--v2 .asset-breakdown-list { gap: 0; }
.app-shell--v2 .asset-breakdown-row { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 8px 2px; background: none; }
.app-shell--v2 .asset-breakdown-row:first-child { border-top: 0; }

/* ---------- Kiểm tra sau đào tạo (Kết quả + Đề thi & câu hỏi) ---------- */
.tc-tabs { margin-bottom: 12px; }
.tc-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 10px; }
.tc-filters > input[type=search] { flex: 2 1 200px; min-width: 0; }
.tc-filters > select { flex: 1 1 130px; min-width: 0; max-width: 200px; }
.tc-filters > input[type=date] { flex: 0 1 132px; min-width: 0; padding-left: 8px; padding-right: 6px; }
.tc-filters > button { flex: 0 0 auto; }
.tc-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 2px 10px; color: var(--ink-3); font-size: 13px; }
.tc-summary b { color: var(--ink); }
.tc-table td { vertical-align: middle; white-space: nowrap; }
.tc-detail-info { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.tc-detail-info small { display: block; color: var(--ink-3); font-size: 12px; }
.tc-detail-info b { font-weight: 600; word-break: break-word; }
.tc-declaration { margin: 0 0 12px; padding: 8px 10px; border-radius: var(--sh-radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.tc-answer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 55vh; overflow: auto; }
.tc-answer-list li { padding: 10px 12px; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--sh-radius-sm); display: grid; gap: 4px; }
.tc-answer-list li.ok { border-left-color: var(--ok); }
.tc-answer-list li.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.tc-answer-list .tc-q { font-weight: 600; }
.tc-answer-list .tc-a { font-size: 14px; color: var(--ink-2); }
.tc-answer-list .tc-a span { display: inline-block; min-width: 82px; margin-right: 8px; color: var(--ink-3); font-size: 12px; vertical-align: top; }
.tc-answer-list .tc-pts { font-size: 12px; color: var(--ink-3); }
.tc-exams { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; align-items: start; }
.tc-exam-list { padding: 10px; display: grid; gap: 6px; }
.tc-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 6px; }
.tc-list-head .primary-button { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.tc-exam-item { display: grid; gap: 2px; text-align: left; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--sh-radius-sm); background: none; color: var(--ink); cursor: pointer; font: inherit; width: 100%; min-height: 0 !important; }
.tc-exam-item:hover { background: var(--surface-2); }
.tc-exam-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.tc-exam-item .t { font-weight: 600; }
.tc-exam-item small { color: var(--ink-3); }
.tc-exam-detail { display: grid; gap: 10px; min-width: 0; }
.tc-exam-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tc-exam-head h2 { margin: 0 0 2px; font-size: 17px; }
.tc-exam-head p { margin: 0; color: var(--ink-3); font-size: 13px; }
.tc-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tc-questions { display: grid; gap: 8px; }
.tc-question { padding: 12px 14px; }
.tc-question.off { opacity: .6; }
.tc-q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tc-answers { list-style: none; margin: 8px 0 6px; padding: 0; display: grid; gap: 3px; font-size: 14px; }
.tc-answers li { display: flex; gap: 8px; color: var(--ink-2); }
.tc-answers li.correct { color: var(--ok); font-weight: 600; }
.tc-answers li span { width: 16px; flex: none; text-align: center; }
.tc-q-meta { color: var(--ink-3); }
.tc-question-form .tc-type { display: flex; gap: 18px; flex-wrap: wrap; }
.tc-answer-row { display: grid; grid-template-columns: 24px minmax(0, 2fr) minmax(0, 1.4fr) 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.tc-answer-row input[type=checkbox] { width: 18px; height: 18px; min-height: 0; }
.tc-answer-row .icon-button { font-size: 22px; line-height: 1; min-height: 0; }
.tc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Nhân sự nhà thầu: danh sách, cảnh báo đối chiếu */
.tc-count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.tc-pill { display: inline-block; padding: 1px 9px; margin: 1px 4px 1px 0; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tc-pill.ok { background: var(--ok-bg); color: var(--ok); }
.tc-pill.warn { background: var(--warn-bg); color: var(--warn); }
.tc-pill.bad { background: var(--bad-bg); color: var(--bad); }
.tc-pill.none { background: var(--neutral-bg); color: var(--neutral); }
.tc-red { color: var(--bad); }
.tc-table tr.tc-row-red > td { background: var(--bad-bg); }
.tc-table tr.tc-row-red > td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.tc-table tr.tc-row-amber > td { background: var(--warn-bg); }
.tc-table tr.tc-row-amber > td:first-child { box-shadow: inset 4px 0 0 #f79009; }
.tc-alerts { padding: 12px 14px; margin-bottom: 12px; border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.tc-alerts .tc-list-head small, .tc-verified summary small { color: var(--ink-3); font-weight: 400; }
.tc-warn-list { display: grid; gap: 8px; margin-top: 8px; max-height: 340px; overflow: auto; }
.tc-warn { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--sh-radius-sm); background: var(--surface); }
.tc-warn.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.tc-warn.warn { border-left-color: #f79009; background: var(--warn-bg); }
.tc-warn-main { display: grid; gap: 2px; min-width: 0; }
.tc-warn-main span, .tc-warn-main small { color: var(--ink-2); font-size: 13px; }
.tc-verified { padding: 10px 14px; margin-top: 12px; }
.tc-verified summary { cursor: pointer; list-style: none; }
.tc-chips { display: flex; flex-wrap: wrap; gap: 2px; }
.tc-hint { margin: 0; color: var(--ink-3); font-size: 13px; }
.tc-warn-text { margin: 0 0 8px; color: var(--warn); font-weight: 600; }
.tc-more { border: 1px solid var(--border); border-radius: var(--sh-radius-sm); padding: 8px 12px; }
.tc-more summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.tc-more .stack-form { margin-top: 10px; }
#rs-pick { display: grid; gap: 6px; }
#rs-worker { width: 100%; }
.tc-preview input { width: 100%; min-width: 0; min-height: 36px; padding: 4px 8px; }
.tc-preview td { padding: 4px 6px; }
.tc-preview .up-name { min-width: 170px; }
.tc-roster { grid-template-columns: 300px minmax(0, 1fr); }
.tc-roster .tc-list-head { flex-wrap: wrap; }
.tc-strip { display: inline-flex; gap: 2px; vertical-align: middle; }
.tc-strip i, .tc-legend i { display: inline-block; width: 12px; height: 16px; border-radius: 3px; background: var(--neutral-bg); }
.tc-strip i.d-P, .tc-legend i.d-P { background: #12b76a; }
.tc-strip i.d-F, .tc-legend i.d-F { background: #f79009; }
.tc-strip i.d-M, .tc-legend i.d-M { background: var(--bad); }
.tc-strip i.d-T, .tc-legend i.d-T { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); }
.tc-strip i.d-off, .tc-legend i.d-off { background: var(--neutral-bg); }
.tc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--ink-2); }
.tc-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tc-legend small { color: var(--ink-3); }
.tc-modebar { display: inline-flex; gap: 4px; padding: 3px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tc-modebar button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 0 !important; }
.tc-modebar button.active { background: var(--accent-soft); color: var(--accent); }
.tc-areabar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 2px; }
.tc-areabar .tc-actions { margin-left: auto; }
.tc-chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-2); min-height: 0 !important; }
.tc-chip.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); font-weight: 600; }
.tc-chip b { margin-left: 4px; }
.tc-monthbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tc-monthbar input[type=month] { min-height: 40px; }
.tc-month-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tc-month-card { display: grid; gap: 6px; text-align: left; padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; min-height: 0 !important; }
.tc-month-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.tc-month-card span { color: var(--ink-2); font-size: 13px; }
.tc-bar { display: block; height: 6px; border-radius: 99px; background: var(--neutral-bg); overflow: hidden; }
.tc-bar i { display: block; height: 100%; background: var(--ok); }
.tc-grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.tc-grid th, .tc-grid td { padding: 3px 2px; text-align: center; border-bottom: 1px solid var(--border); }
.tc-grid th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-3); font-weight: 600; min-width: 22px; }
.tc-grid th.sun { color: var(--bad); }
.tc-grid .tc-grid-name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; white-space: nowrap; padding: 4px 10px; min-width: 170px; border-right: 1px solid var(--border); }
.tc-grid thead .tc-grid-name { background: var(--surface-2); }
.tc-grid i { display: inline-block; width: 14px; height: 18px; border-radius: 3px; background: var(--neutral-bg); vertical-align: middle; }
.tc-grid i.d-P { background: #12b76a; } .tc-grid i.d-F { background: #f79009; } .tc-grid i.d-M { background: var(--bad); }
.tc-grid i.d-T { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); } .tc-grid i.d-off { background: var(--neutral-bg); }
.tc-grid-group td { background: var(--surface-2); text-align: left; font-weight: 600; padding: 5px 10px; color: var(--ink-2); }
.tc-grid-total { font-weight: 600; padding: 3px 10px !important; white-space: nowrap; }
.tc-grid-total.bad { color: var(--bad); }
/* Lưới ngày trong lưu trữ phải luôn là bảng thật (cuộn ngang), không bị luật "bảng thành thẻ" của điện thoại biến dạng. */
@media (max-width: 760px) {
  .app-shell--v2 .tc-grid { display: table !important; width: max-content; min-width: 100%; }
  .app-shell--v2 .tc-grid thead { display: table-header-group !important; }
  .app-shell--v2 .tc-grid tbody { display: table-row-group !important; }
  .app-shell--v2 .tc-grid tr { display: table-row !important; border: 0 !important; box-shadow: none !important; background: none !important; padding: 0 !important; margin: 0 !important; }
  .app-shell--v2 .tc-grid th, .app-shell--v2 .tc-grid td { display: table-cell !important; width: auto !important; padding: 3px 2px !important; border-bottom: 1px solid var(--border) !important; text-align: center; }
  .app-shell--v2 .tc-grid td::before { display: none !important; content: none !important; }
  .app-shell--v2 .tc-grid .tc-grid-name { text-align: left; min-width: 130px; }
  .app-shell--v2 .tc-grid .tc-grid-group td { text-align: left; padding: 5px 8px !important; }
}
/* Điện thoại: bảng đã đổi thành thẻ nằm trong .table-scroll (overflow + overscroll-behavior: contain + cuộn quán tính iOS).
   Vùng đó cao cả màn hình nên "nuốt" thao tác vuốt dọc và không chuyển cho trang -> không cuộn xuống được.
   Bỏ hai thuộc tính đó, và với thẻ thì không cần vùng cuộn riêng (lưới ngày .tc-grid vẫn cuộn ngang bình thường). */
@media (max-width: 760px) {
  .app-shell--v2 .table-scroll,
  .app-shell--v2 .training-matrix-scroll { overscroll-behavior: auto !important; -webkit-overflow-scrolling: auto !important; }
  .app-shell--v2 .panel .table-scroll:not(:has(.tc-grid)) { overflow: visible !important; margin-inline: 0; }
}
@media (max-width: 900px) { .tc-exams, .tc-roster { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app-shell--v2 .tc-filters { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px; padding: 10px; }
  .tc-filters > input[type=search], .tc-filters > select { grid-column: 1 / -1; max-width: none; }
  .tc-filters > input[type=date], .tc-filters > button { min-height: 40px; }
  .tc-filters > input[type=date], .tc-filters > select { max-width: none; }
  .tc-answer-row { grid-template-columns: 24px minmax(0, 1fr) 32px; }
  .tc-answer-row .a-sug { grid-column: 2 / 3; }
  .tc-row { grid-template-columns: 1fr 1fr; }
}

/* Khảo sát: mỗi mức điểm một màu riêng, đúng nghĩa (xanh lá = rất tốt, xanh dương = tốt, vàng cam = cần cải thiện, đỏ = kém). */
.app-shell--v2 {
  --tier-great: #067647;
  --tier-good: #175cd3;
  --tier-fair: #dc6803;
  --tier-poor: #b42318;
}
.app-shell--v2 .tier-great-text { color: var(--tier-great); }
.app-shell--v2 .tier-good-text { color: var(--tier-good); }
.app-shell--v2 .tier-fair-text { color: var(--tier-fair); }
.app-shell--v2 .tier-poor-text { color: var(--tier-poor); }
.app-shell--v2 .survey-bar-fill.tier-great, .app-shell--v2 .survey-trend-bar.tier-great, .app-shell--v2 .survey-legend-dot.tier-great { background: var(--tier-great); }
.app-shell--v2 .survey-bar-fill.tier-good, .app-shell--v2 .survey-trend-bar.tier-good, .app-shell--v2 .survey-legend-dot.tier-good { background: var(--tier-good); }
.app-shell--v2 .survey-bar-fill.tier-fair, .app-shell--v2 .survey-trend-bar.tier-fair, .app-shell--v2 .survey-legend-dot.tier-fair { background: var(--tier-fair); }
.app-shell--v2 .survey-bar-fill.tier-poor, .app-shell--v2 .survey-trend-bar.tier-poor, .app-shell--v2 .survey-legend-dot.tier-poor { background: var(--tier-poor); }
.app-shell--v2 .survey-card.tier-great-edge { border-left-color: var(--tier-great); }
.app-shell--v2 .survey-card.tier-good-edge { border-left-color: var(--tier-good); }
.app-shell--v2 .survey-card.tier-fair-edge { border-left-color: var(--tier-fair); }
.app-shell--v2 .survey-card.tier-poor-edge { border-left-color: var(--tier-poor); }
.app-shell--v2 .survey-trend-bar-value { color: var(--ink-2); }
.app-shell--v2 .survey-bar-value { color: var(--ink-2); }
.app-shell--v2 .survey-bar-track { display: block; }
.app-shell--v2 .survey-bar-fill { display: block; }
.survey-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--sh-radius-sm); background: var(--surface); font-size: 13px; color: var(--ink-2); }
.survey-legend-title { color: var(--ink-3); }
.survey-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.survey-legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
/* ---------- Tài khoản ---------- */
.accounts-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.accounts-toolbar input { flex: 1 1 240px; min-width: 0; }
.accounts-toolbar select { flex: 0 1 230px; min-width: 0; }
.accounts-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; color: var(--ink-3); font-size: 13px; }
.accounts-footer[hidden], .accounts-footer button[hidden] { display: none; }
.accounts-table .account-row-actions { white-space: normal; }
.accounts-table .account-row-actions .text-button { margin: 0 12px 0 0; }

/* Trên máy tính, mục con nằm trong menu bên trái nên dải tab phía trên nội dung chỉ dùng cho điện thoại. */
@media (min-width: 821px) { .sh-tabs { display: none; } }
@media (max-width: 1000px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-shell--v2 { grid-template-columns: 1fr; }
  .sh-side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30; flex-direction: row;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .sh-brand, .sh-me { display: none; }
  .sh-nav { flex-direction: row; justify-content: space-around; }
  .sh-group { flex: 1; display: flex; }
  .sh-group .sh-nav-item { flex: 1; }
  .sh-group .sh-sub, .sh-group.open .sh-sub { display: none; }
  .sh-nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; text-align: center; white-space: normal; line-height: 1.2; }
  .sh-badge { position: absolute; top: 0; left: 55%; margin: 0; }
  /* Chiều cao thanh trên = 56px; các thanh tab "dính" của trang cũ dùng --mobile-topbar-h nên phải khớp, và nằm dưới thanh này. */
  .app-shell--v2 { --mobile-topbar-h: 56px; }
  .sh-top { padding: 0 16px; height: 56px; z-index: 140; }
  .sh-top h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-top .sh-top-logout { display: grid; }
  .sh-tabs { padding: 0 12px; position: sticky; top: 56px; z-index: 130; }
  .sh-content { padding: 12px 12px 96px; }
  .accounts-toolbar { padding: 10px; }
  .accounts-toolbar select { flex: 1 1 100%; }
  .accounts-table .account-row-actions { display: flex !important; flex-wrap: wrap; gap: 2px 16px; padding-top: 6px !important; }
  .accounts-table .account-row-actions::before { display: none !important; }
  .accounts-table .account-row-actions .text-button { width: auto !important; min-height: 36px; padding: 0 !important; margin: 0; }
  .app-shell--v2 .training-dashboard-compact-actions { display: flex !important; flex-wrap: nowrap; gap: 8px; }
  .app-shell--v2 .training-dashboard-compact-actions > * { width: auto !important; }
  .app-shell--v2 .training-dashboard-compact-actions > :first-child { flex: 1 1 auto; }
  .app-shell--v2 .employee-tabs, .app-shell--v2 .training-dashboard-section-tabs, .app-shell--v2 .internal-dashboard-tabs { top: 56px; z-index: 120; }
  .ov-buckets { grid-template-columns: 1fr; }
  .ov-buckets > div + div { border-left: 0; border-top: 1px solid var(--border); }
}
/* Khung tải (.loading-card, padding 28px) vẫn bọc bảng sau khi tải xong nên làm bảng bị thụt vào hai bên. */
#training-dashboard-content.loading-card[data-rendered="1"] { padding: 0; text-align: left; color: inherit; }

/* Ô lọc của trang Đào tạo: cột cố định bị tràn khi vùng nội dung hẹp hơn (menu 276px) -> cho xuống dòng. */
@media (min-width: 761px) {
  .app-shell--v2 .training-dashboard-filterbar { display: flex; flex-wrap: wrap; }
  .app-shell--v2 .training-dashboard-filterbar > * { flex: 0 0 auto; min-width: 0; }
  .app-shell--v2 .training-dashboard-filterbar > .training-dashboard-main-search { flex: 1 1 260px; }
  .app-shell--v2 .training-dashboard-filterbar > select { flex: 1 1 170px; }
}

@media (prefers-reduced-motion: reduce) { .sh-nav-item, .sh-tab, .ov-row { transition: none; } }
