/* ============================================================
   CHI ĐỘI – ĐỘI KHOÁN, ĐỢT THANH TOÁN, IN HỒ SƠ 4 MẪU
   ============================================================ */

/* ---------------- Form đội ---------------- */
.crew-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.crew-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.crew-check input { width: 15px; height: 15px; accent-color: var(--brand); }

/* ---------------- Bảng khối lượng ---------------- */
.crew-volume-table { min-width: 1080px; }
.crew-volume-table th { white-space: nowrap; }
.crew-volume-table td { vertical-align: middle; }
.crew-volume-table .crew-row-system td { background: #eef4ff; color: #1e3a8a; font-size: 11.5px; letter-spacing: .02em; }
.crew-volume-table .crew-row-group td { background: #dbeafe; color: #1e3a8a; font-size: 12px; }
.crew-volume-table .crew-row-sub td { background: var(--surface-2); color: var(--ink-2); }
.crew-volume-table .crew-row-system .b,
.crew-volume-table .crew-row-group .b,
.crew-volume-table .crew-row-sub .b { font-weight: 700; }
.crew-cell-input {
  width: 100%;
  min-width: 62px;
  border: 1px solid transparent;
  background: #fffdf5;
  border-radius: 6px;
  padding: 5px 6px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.crew-cell-input:hover { border-color: #fde68a; }
.crew-cell-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); background: #fff; }
.crew-cell-input.note { text-align: left; min-width: 130px; background: transparent; }
.crew-cell-input.note:focus { background: #fff; }
.crew-total-row td { background: var(--brand-soft); border-top: 1.5px solid #fcd34d; }
.crew-grand-row td { background: var(--green-soft); border-top: 1.5px solid #a7f3d0; }
.crew-grand-row .num { color: #047857; font-size: 14px; }
.crew-volume-table .actions-col { width: 72px; }

/* ---------------- Lên bill ---------------- */
.bill-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bill-paste {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; font-family: inherit; resize: vertical; background: var(--surface-2);
}
.bill-paste:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); background: #fff; }
.bill-paste-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bill-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bill-table { min-width: 1080px; }
.bill-table .crew-cell-input { min-width: 74px; }
.bill-table .bill-row-group td { background: #dbeafe; color: #1e3a8a; font-weight: 700; font-size: 12px; }
.bill-table .bill-row-sub td { background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
.bill-table .bill-row-system td { background: #eef4ff; color: #1e3a8a; font-weight: 700; }
.bill-table th { position: sticky; top: 0; z-index: 1; }

/* ---------------- Cấu hình thanh toán ---------------- */
.crew-pay-editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-size: 12px; color: var(--ink-2);
}
.crew-pay-editor { width: 860px; min-width: 860px; table-layout: fixed; }
.crew-pay-editor th:nth-child(1) { width: 230px; }
.crew-pay-editor th:nth-child(2) { width: 150px; }
.crew-pay-editor th:nth-child(3) { width: 55px; }
.crew-pay-editor th:nth-child(4) { width: 120px; }
.crew-pay-editor th:nth-child(5) { width: 105px; }
.crew-pay-editor th:nth-child(6) { width: 52px; }
.crew-pay-editor th:nth-child(7) { width: 108px; }
.crew-pay-editor th:nth-child(8) { width: 40px; }
.crew-pay-editor input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; }
.crew-pay-editor input[readonly] { background: var(--surface-2); color: var(--muted); }
.crew-pay-editor select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font-size: 12px; background: #fff; }
.crew-pay-editor .icon-btn.danger { color: var(--red); }

/* ---------------- In hồ sơ: màn hình ---------------- */
.crew-print-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 14px; }
.crew-print-card-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.crew-print-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); }
.crew-print-meta b { color: var(--ink-2); }
.crew-print-card-body .btn { align-self: flex-start; }
.crew-print-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; }
.crew-print-flow span {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
  padding: 5px 11px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
}
.crew-print-flow i { color: var(--muted-2); font-style: normal; }

/* ---------------- Quét hồ sơ AI ---------------- */
.crew-scan-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; padding: 0 16px 16px; }
.crew-scan-drop {
  border: 1.5px dashed #cbd5e1; border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.crew-scan-drop img { width: 100%; max-height: 380px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.crew-scan-placeholder {
  min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; color: var(--muted); text-align: center; font-size: 12px;
}
.crew-scan-placeholder svg { width: 34px; height: 34px; color: var(--muted-2); }
.crew-scan-placeholder b { color: var(--ink-2); font-size: 13px; }
.crew-scan-actions { display: flex; gap: 8px; }
.crew-scan-actions .btn { flex: 1; justify-content: center; }
.crew-scan-guide h3 { font-size: 13px; margin: 0 0 8px; }
.crew-step-list { margin: 0 0 12px; padding-left: 20px; font-size: 12px; color: var(--ink-2); line-height: 1.7; }
.crew-step-list li { margin-bottom: 2px; }
.crew-scan-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; font-size: 12px; }
.crew-scan-info div { display: flex; gap: 6px; }
.crew-scan-info span { color: var(--muted); }
.crew-scan-thumb { width: 100%; max-height: 210px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.crew-scan-review { display: flex; flex-direction: column; gap: 12px; }
.crew-scan-table { min-width: 820px; }
.crew-scan-table input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font-size: 11.5px; }
.crew-scan-table input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); }

/* ---------------- Màn hình nhỏ ---------------- */
@media (max-width: 1280px) {
  .crew-print-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .crew-scan-grid, .crew-print-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   IN HỒ SƠ THANH TOÁN
   ============================================================ */
@page crew-landscape { size: A4 landscape; margin: 7mm 8mm; }

@media print {
  .crew-print { font-family: "Times New Roman", Times, serif; color: #000; }
  .crew-print .print-page {
    width: auto;
    max-width: none;
    padding: 0;
    box-sizing: border-box;
    page-break-after: always;
    font-family: "Times New Roman", Times, serif;
    font-size: 10.5pt;
    line-height: 1.3;
    color: #000;
  }
  .crew-print .print-page:last-child { page-break-after: auto; }
  .crew-print .crew-cover,
  .crew-print .crew-portrait,
  .crew-print .crew-wide,
  .crew-print .crew-payment { page: crew-landscape; }
  .crew-print .crew-wide { font-size: 8pt; }

  .crew-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .crew-table thead { display: table-header-group; }
  .crew-table tr { page-break-inside: avoid; }
  .crew-table th, .crew-table td {
    border: 1px solid #000;
    padding: 2px 2px;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .crew-table th { background: #ccffff; font-weight: 700; text-align: center; font-size: 7.6pt; line-height: 1.2; }
  .crew-table td { font-size: 7.8pt; }
  .crew-table .c { text-align: center; }
  .crew-table .r { text-align: right; white-space: nowrap; }
  .crew-table .b { font-weight: 700; }
  .crew-table .note { font-size: 7.4pt; }
  .crew-table .muted { color: #555; font-style: italic; }
  .crew-formula th { background: #fff; font-weight: 400; font-size: 6.8pt; padding: 1px 0; }

  .crew-gt-table td, .crew-gt-table th { font-size: 7.4pt; }
  .crew-kl-table td, .crew-kl-table th { font-size: 8pt; }

  .crew-system td { background: #fde9d9; font-weight: 700; text-align: center; }
  .crew-group td, .crew-block td { background: #b8cce4; font-weight: 700; text-align: center; }
  .crew-area td { background: #fff2cc; font-weight: 700; text-align: center; }
  .crew-floor td { background: #fff2cc; font-weight: 700; font-style: italic; text-align: center; }
  .crew-total td { background: #d9d9d9; font-weight: 700; }
  .crew-grand td { background: #fde9d9; font-weight: 700; }
  .crew-pay-line td { background: #fde9d9; }
  .crew-inwords td { font-style: italic; }
  .crew-inwords-line { font-size: 9.5pt; font-style: italic; margin: 4px 2px 0; }

  /* Bìa hồ sơ */
  .crew-cover { padding: 0; }
  .crew-cover-frame {
    position: relative;
    height: 195mm;
    padding: 8mm 12mm;
    border: 1.5px solid #000;
    box-sizing: border-box;
  }
  .crew-cover-head { position: relative; min-height: 28mm; text-align: center; }
  .crew-cover-logo { position: absolute; left: 0; top: 0; width: 32mm; height: auto; }
  .crew-cover-nation { font-size: 12pt; line-height: 1.38; }
  .crew-cover-nation b { font-size: 13pt; }
  .crew-cover-title { text-align: center; text-transform: uppercase; font-size: 24pt; letter-spacing: .01em; margin: 26mm 0 22mm; }
  .crew-cover-info { width: 74%; margin: 0 auto; border-collapse: collapse; }
  .crew-cover-info th, .crew-cover-info td { border: 0; padding: 3.6px 0; font-size: 12pt; vertical-align: top; text-align: left; }
  .crew-cover-info th { width: 34%; font-weight: 700; }
  .crew-cover-info td { font-weight: 700; }
  .crew-cover-date { position: absolute; right: 12mm; bottom: 9mm; font-size: 11pt; font-style: italic; }

  /* Bảng tổng hợp thanh toán */
  .crew-payment { font-size: 9.6pt; }
  .crew-pay-title { text-align: center; text-transform: uppercase; color: #c00000; font-size: 15pt; margin: 0 0 1px; line-height: 1.2; }
  .crew-pay-period { text-align: center; text-transform: uppercase; color: #c00000; font-size: 13pt; font-weight: 700; margin: 0 0 3px; }
  .crew-pay-project { color: #c00000; font-weight: 700; font-size: 9.6pt; line-height: 1.35; margin-bottom: 6px; text-align: left; }
  .crew-pay-table th { font-size: 7.6pt; padding: 3px 2px; }
  .crew-pay-table td { font-size: 8.6pt; padding: 2.6px 2px; }
  .crew-pay-table .crew-total td { background: #fff; }

  /* Bảng chi tiết / xác nhận khối lượng */
  .crew-wide-title { text-align: center; font-size: 15pt; font-weight: 700; margin: 0 0 6px; line-height: 1.2; }
  .crew-wide-sub { font-size: 9.6pt; font-weight: 700; line-height: 1.4; margin: 0 0 6px; }
  .crew-wide-sub b { font-weight: 700; }
  .crew-gt-table, .crew-kl-table { font-size: 7.4pt; }

  /* Bảng theo dõi khối lượng theo tầng */
  .crew-floor-table { line-height: 1.05; }
  .crew-floor-table th { font-size: 6pt; padding: 1px 1px; }
  .crew-floor-table td { font-size: 6pt; padding: 0.6px 1px; }
  .crew-floor-cell { font-weight: 700; }

  /* Chữ ký */
  .crew-sign-date { text-align: right; font-size: 10pt; font-style: italic; margin: 9px 4px 0 0; page-break-inside: avoid; }
  .crew-sign { display: flex; justify-content: space-between; gap: 8px; text-align: center; font-size: 9.6pt; margin-top: 2px; page-break-inside: avoid; }
  .crew-sign > div { flex: 1; font-weight: 700; line-height: 1.3; }
  .crew-sign > div span { display: block; height: 54px; }
  .crew-sign > div small { display: block; font-weight: 700; font-size: 9pt; }
  .crew-sign-3 > div { max-width: 33%; }
  .crew-sign-4 > div { font-size: 9pt; }
  .crew-sign-5 > div { font-size: 8.8pt; }
  .crew-sign-5 > div span { height: 50px; }
  .crew-sign-kl > div:nth-child(1) { max-width: 34%; }
  .crew-sign-kl > div:nth-child(2), .crew-sign-kl > div:nth-child(3) { max-width: 30%; }
}
