/* ============================================================
   ATVSLĐ – HỒ SƠ CÔNG NHÂN & BIỂU MẪU AN TOÀN
   ============================================================ */
.atv-thumb {
  width: 38px;
  height: 48px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
}
.atv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.atv-worker-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.atv-worker-cell .cell-title { font-weight: 650; }
.atv-worker-cell .cell-sub { font-size: 11px; color: var(--muted); }
.atv-muted { color: var(--muted); font-size: 11.5px; }
.atv-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 5px; vertical-align: 1px; }
.atv-dot.off { background: #cbd5e1; }

.atv-photo-grid { display: grid; grid-template-columns: 1.55fr 1.55fr 1fr; gap: 12px; margin-top: 4px; }
.atv-upload-card {
  border: 1px dashed #cbd5e1;
  border-radius: 11px;
  background: #fbfcff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.atv-upload-card.has-photo { border-style: solid; border-color: #bbf7d0; background: #f8fffb; }
.atv-upload-frame {
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f7;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 10.5px;
  text-align: center;
  padding: 6px;
}
.atv-upload-card[data-side="portrait"] .atv-upload-frame { width: 92px; aspect-ratio: 3 / 4; align-self: center; }
.atv-upload-card[data-side="front"] .atv-upload-frame,
.atv-upload-card[data-side="back"] .atv-upload-frame { aspect-ratio: 1.58 / 1; }
.atv-upload-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.atv-upload-card b { font-size: 11.5px; color: var(--ink-2); }
.atv-upload-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.atv-upload-card .btn { width: 100%; justify-content: center; }
.atv-upload-card .btn + .btn { margin-top: 6px; }
.atv-ai-state { font-size: 10.8px; line-height: 1.4; color: var(--muted); min-height: 15px; }
.atv-ai-state.ok { color: #047857; }
.atv-ai-state.err { color: #b91c1c; }
.atv-ai-state.busy { color: var(--blue); }
.atv-ai-banner {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 11.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.atv-ai-banner svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.atv-ai-banner .btn { margin-left: 6px; }
.atv-section-title {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--brand-dark);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
  margin: 18px 0 12px;
}
.atv-section-title:first-child { margin-top: 0; }

.atv-pick-box { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.atv-pick-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.atv-pick-head .filter-select { height: 30px; }
.atv-pick-head .search-box { flex: 1; min-width: 150px; }
.atv-pick-head .search-box input { padding: 5px 0; }
.atv-pick-list { max-height: 250px; overflow: auto; }
.atv-pick-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 12px;
}
.atv-pick-row:last-child { border-bottom: 0; }
.atv-pick-row:hover { background: #f8fbff; }
.atv-pick-row input { margin: 0; }
.atv-pick-row .name { font-weight: 600; flex: 1; min-width: 0; }
.atv-pick-row .cccd { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: var(--muted); white-space: nowrap; }
.atv-pick-row .team { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.atv-pick-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.atv-pick-foot .spacer { flex: 1; }
.atv-empty-pick { padding: 18px; text-align: center; font-size: 12px; color: var(--muted); }

.atv-time-rows { display: flex; flex-direction: column; gap: 8px; }
.atv-time-row { display: grid; grid-template-columns: 1.2fr .8fr .8fr 1.4fr 34px; gap: 8px; align-items: center; }
.atv-time-row input { width: 100%; }
.atv-time-row .icon-btn { justify-self: center; }

.atv-doc-list .tbl td { vertical-align: middle; }
.atv-doc-kind { display: flex; align-items: center; gap: 8px; }
.atv-doc-kind .ico {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand-dark);
}
.atv-doc-kind .ico svg { width: 16px; height: 16px; }
.atv-doc-kind small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 1px; }

.atv-profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.atv-profile-grid .dm-row b { max-width: 60%; }
.atv-profile-photos { display: grid; grid-template-columns: 1fr 1fr 110px; gap: 10px; margin-top: 14px; }
.atv-profile-photo { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #f8fafc; }
.atv-profile-photo img { width: 100%; display: block; }
.atv-profile-photo .cap { font-size: 10.5px; color: var(--muted); padding: 5px 7px; border-top: 1px solid var(--line); }
.atv-profile-photo.empty { display: grid; place-items: center; min-height: 110px; color: var(--muted-2); font-size: 11px; text-align: center; padding: 10px; }

.atv-summary-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

@media (max-width: 980px) {
  .atv-photo-grid { grid-template-columns: 1fr 1fr; }
  .atv-upload-card[data-side="portrait"] { grid-column: 1 / -1; }
  .atv-upload-card[data-side="portrait"] .atv-upload-frame { width: 120px; }
  .atv-time-row { grid-template-columns: 1fr 1fr; }
  .atv-time-row .icon-btn { grid-column: 2; justify-self: end; }
  .atv-profile-grid { grid-template-columns: 1fr; }
  .atv-profile-photos { grid-template-columns: 1fr 1fr; }
}

/* ---------------- Bản in A4 dọc ---------------- */
@media print {
  .print-page.atv-doc {
    position: relative;
    width: 210mm;
    height: 297mm;
    padding: 0;
    overflow: hidden;
    color: #000;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-page.atv-doc.atv-overtime { font-family: Arial, Helvetica, sans-serif; font-size: 12pt; line-height: 1; }
  .print-page.atv-doc.atv-guarantee { font-family: "Times New Roman", Times, serif; font-size: 12pt; line-height: 1; }

  .atv-watermark {
    position: absolute;
    left: calc(50% - 2mm);
    top: 50%;
    width: 70.5mm;
    height: 70.3mm;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
  }
  .atv-head, .atv-body, .atv-foot { position: relative; z-index: 1; }

  /* ----- Đầu trang: logo | tên mẫu | mã số ----- */
  .atv-head { position: absolute; border-collapse: collapse; table-layout: fixed; }
  .atv-head td { border: 0.8pt solid #000; padding: 0; vertical-align: middle; text-align: center; }
  .atv-logo img { display: block; margin: 0 auto; }
  .atv-title { font-weight: 700; }
  .atv-code-cell { font-weight: 700; }

  .atv-overtime .atv-head { left: 12mm; top: 6.4mm; width: 190.5mm; height: 30.4mm; }
  .atv-overtime .atv-head .atv-logo { width: 39.8mm; }
  .atv-overtime .atv-logo img { height: 25.4mm; width: 35.5mm; }
  .atv-overtime .atv-title { font-size: 14pt; line-height: 16pt; }
  .atv-overtime .atv-code-cell { width: 39.6mm; font-size: 12pt; }

  .atv-guarantee .atv-head { left: 14.7mm; top: 8.6mm; width: 187.3mm; height: 29.7mm; }
  .atv-guarantee .atv-head .atv-logo { width: 38.1mm; }
  .atv-guarantee .atv-logo img { height: 23.3mm; width: 34.4mm; }
  .atv-guarantee .atv-title { font-size: 16pt; }
  .atv-guarantee .atv-code-cell { width: 44.4mm; font-size: 12pt; }

  /* ----- Thân trang (tọa độ tuyệt đối theo mẫu) ----- */
  .atv-body { position: absolute; left: 0; top: 0; width: 210mm; height: 297mm; margin: 0; padding: 0; }
  .atv-block { position: absolute; left: 12.4mm; width: 185.6mm; margin: 0; padding: 0; }

  .atv-overtime .atv-b-info { top: 45.7mm; width: 191mm; }
  .atv-overtime .atv-b-sec1 { top: 75.3mm; }
  .atv-overtime .atv-b-sec2 { top: 97.2mm; }
  .atv-overtime .atv-b-sec3 { top: 144.8mm; }
  .atv-overtime .atv-b-sec4 { top: 185.9mm; }
  .atv-overtime .atv-b-end { top: 195.2mm; }

  .atv-overtime .atv-line {
    display: flex;
    align-items: baseline;
    margin: 0;
    font-size: 12pt;
    line-height: 7.3mm;
    white-space: nowrap;
    overflow: hidden;
  }
  .atv-dots {
    flex: 1 1 auto;
    min-width: 6mm;
    margin: 0 1.2mm 1mm;
    border-bottom: 1.2pt dotted #000;
  }
  .atv-dots-s { flex: 0 1 34mm; }
  .atv-overtime .atv-b-info .atv-dots-s { flex: 0 0 11.7mm; }
  .atv-overtime .atv-b-info .atv-dots-m { flex: 0 0 22.6mm; }

  .atv-overtime .atv-section { margin: 0; font-size: 12pt; line-height: 6.35mm; font-weight: 700; }
  .atv-overtime .atv-indent { margin: 1.1mm 0 0 6.9mm; font-size: 12pt; line-height: 6.35mm; min-height: 6.35mm; }
  .atv-dots-line { height: 0; border-bottom: 1.2pt dotted #000; margin-top: 4.9mm; }

  .atv-overtime .atv-table { width: 184.1mm; margin: 0 0 0 6.2mm; border: 0.75pt solid #000; border-collapse: collapse; table-layout: fixed; }
  .atv-overtime .atv-table th,
  .atv-overtime .atv-table td {
    border: 0;
    border-left: 0.5pt solid #7f7f7f;
    border-top: 0.5pt dotted #7f7f7f;
    padding: 0 1.4mm;
    font-size: 12pt;
    line-height: 1.05;
    vertical-align: middle;
    overflow-wrap: break-word;
  }
  .atv-overtime .atv-table tr > :first-child { border-left: 0; }
  .atv-overtime .atv-table thead tr:first-child > * { border-top: 0; }
  .atv-overtime .atv-table th { background: #d9d9d9; font-weight: 700; text-align: center; padding: 0 0.5mm; border-bottom: 0.5pt solid #7f7f7f; }
  .atv-overtime .atv-table .atv-center { text-align: center; }
  .atv-overtime .atv-time { margin-top: 1.65mm; }
  .atv-time thead tr:first-child th { height: 5.3mm; }
  .atv-time thead tr:last-child th { height: 6mm; }
  .atv-time tbody td { height: 9.06mm; }
  .atv-overtime .atv-sup { margin-top: 1.6mm; }
  .atv-sup thead th { height: 5.5mm; }
  .atv-sup tbody td { height: 9.06mm; }
  .atv-overtime .atv-worker { margin-top: 1.2mm; }
  .atv-worker thead th { height: 5.8mm; }
  .atv-worker tbody td { height: 7.56mm; }
  .atv-overtime .atv-worker-cont { position: absolute; left: 18.6mm; top: 46.7mm; margin: 0; }

  .atv-overtime .atv-pledge {
    margin: 0;
    padding-left: 12.2mm;
    text-indent: -12.2mm;
    font-size: 12pt;
    line-height: 4.95mm;
    text-align: justify;
  }
  .atv-num { display: inline-block; width: 12.2mm; text-indent: 0; }
  .atv-overtime .atv-date-line { margin: 4.65mm 27mm 0 0; text-align: right; font-size: 12pt; line-height: 4.95mm; }
  .atv-overtime .atv-sign3 { width: 190.5mm; margin: 0 0 0 9.8mm; border-collapse: collapse; table-layout: fixed; }
  .atv-overtime .atv-sign3 td { width: 63.5mm; border: 0; padding: 0; text-align: left; vertical-align: top; font-size: 12pt; }
  .atv-overtime .atv-sign3 td b { font-weight: 700; }

  /* ----- Giấy bảo lãnh ----- */
  .atv-guarantee .atv-b-info { top: 47.6mm; left: 15mm; width: 172.2mm; }
  .atv-guarantee .atv-line { margin: 0; font-size: 12pt; line-height: 7mm; display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; }
  .atv-guarantee .atv-gap-1 { margin-top: 0.3mm; }
  .atv-guarantee .atv-gap-2 { margin-top: 2.4mm; }
  .atv-guarantee .atv-b-table { top: 86mm; left: 12.5mm; width: 180.8mm; }
  .atv-guarantee.atv-cont .atv-b-table { top: 48.5mm; }

  .atv-guarantee .atv-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0; }
  .atv-guarantee .atv-table th,
  .atv-guarantee .atv-table td {
    border: 0.8pt solid #000;
    padding: 0 1.4mm;
    font-size: 12pt;
    line-height: 1;
    vertical-align: middle;
    text-align: center;
    overflow-wrap: break-word;
  }
  .atv-guarantee .atv-table th { background: #d9d9d9; font-weight: 700; }
  .atv-guarantee .atv-table th.atv-stt { font-style: italic; }
  .atv-guarantee .atv-table tbody td { height: 6.33mm; }
  .atv-guarantee .atv-table thead th { height: 8.1mm; }
  .atv-guarantee .atv-table tbody td:nth-child(2) { text-align: left; }
  .atv-guarantee .atv-table tbody td.atv-stt { font-style: italic; }
  .atv-guarantee .atv-table tbody td:nth-child(3) { padding: 0 1mm; }

  .atv-notes-block { top: 48.2mm; left: 14.6mm; width: 184.1mm; font-family: "Times New Roman", Times, serif; }
  .atv-guarantee .atv-note { margin: 0 0 1.4mm; font-size: 12pt; line-height: 13.9pt; text-align: justify; }
  .atv-guarantee .atv-note-title + .atv-note { margin-bottom: 0; }
  .atv-guarantee .atv-note-title { margin: 0 0 2.1mm; font-weight: 700; font-style: italic; }
  .atv-guarantee .atv-note-bold { font-weight: 700; margin-top: 3.2mm; }
  .atv-guarantee .atv-note-head { margin: 3.4mm 0 1.3mm; }
  .atv-guarantee .atv-note-list { margin: 0 0 1.3mm; }
  .atv-guarantee .atv-note-italic { margin-top: 3.2mm; font-style: italic; }
  .atv-guarantee .atv-sign3 { width: 100%; margin: 5.4mm 0 0; border-collapse: collapse; table-layout: fixed; }
  .atv-guarantee .atv-sign3 td { border: 0; padding: 0; text-align: left; vertical-align: top; font-size: 12pt; }
  .atv-guarantee .atv-sign3 td b { font-weight: 700; }
  .atv-guarantee .atv-sign3 td:nth-child(1) { width: 68.9mm; }
  .atv-guarantee .atv-sign3 td:nth-child(2) { width: 58.8mm; }
  .atv-sign-sub { font-size: 11pt; font-style: italic; line-height: 1.25; margin-top: 0.1mm; }

  /* ----- Chân trang ----- */
  .atv-foot {
    position: absolute;
    left: 12.4mm;
    right: 11.4mm;
    bottom: 5.8mm;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 4mm;
    border-top: 0.8pt solid #000;
    padding-top: 1.4mm;
    font-size: 10pt;
    line-height: 12pt;
    color: #000;
  }
  .atv-foot span:nth-child(2) { text-align: center; }
  .atv-foot span:nth-child(3) { text-align: right; }
  .atv-guarantee .atv-foot { left: 11.9mm; right: 10.5mm; bottom: 3.9mm; font-size: 12pt; line-height: 14pt; }
}
