/* =====================================================================
 *  an-51.css — PHÂN TÍCH: gọn · sạch · khoa học (điện thoại + máy tính)
 *  Nạp SAU adv-51.css:
 *    <link rel="stylesheet" href="css/an-51.css?v=51a">
 *  Chỉ là CSS ghi đè (không đổi số liệu / logic). Gỡ file này là về như cũ.
 * ===================================================================== */
:root {
  --n5-or: #e7770e; --n5-or-d: #b85a06; --n5-tint: #fff6ea;
  --n5-line: #f0e6da; --n5-ink: #2b2a28; --n5-mute: #8b867d; --n5-green: #1a8f5b;
}

/* ---------- thẻ khung chung ---------- */
#summaryStats .card.border-0.shadow-sm {
  border: 1px solid var(--n5-line) !important; border-radius: 18px;
  box-shadow: 0 1px 2px rgba(60, 40, 10, .04), 0 12px 26px -20px rgba(60, 40, 10, .3) !important;
}
#summaryStats .an-h6 {
  display: flex; align-items: center; gap: 6px; margin: 0 0 10px;
  font-size: .92rem; font-weight: 800; letter-spacing: -.005em; color: var(--n5-ink);
}
#summaryStats .an-h6 > i.bi:first-child { color: var(--n5-or); font-size: 1.05rem; margin: 0 !important; }

/* ---------- kỳ báo cáo ---------- */
.an-period {
  background: #fff; border: 1px solid var(--n5-line); border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(60, 40, 10, .04), 0 12px 26px -20px rgba(60, 40, 10, .3);
}
.an-period-t { display: flex; align-items: center; gap: 6px; font-size: .68rem !important; font-weight: 800 !important; letter-spacing: .06em; text-transform: uppercase; color: var(--n5-mute); }
.an-period-t > i { color: var(--n5-or); font-size: .95rem; }
.an-period-row .form-select { font-weight: 700; color: var(--n5-ink); border-radius: 12px; border-color: #f1e3d2; background-color: #fffaf3; }
.an-period-info { font-size: .76rem !important; color: var(--n5-mute) !important; }
.an-period-info b { color: var(--n5-ink); font-weight: 800; }
.an-export { background: #f2fbf6 !important; border-color: #bfe5cf !important; color: var(--n5-green) !important; font-weight: 700; }

/* ---------- thẻ chỉ số (KPI) ---------- */
.an-kpi {
  --c: #adb5bd;
  position: relative; cursor: default;
  border: 1px solid var(--n5-line) !important; border-left-width: 1px !important; border-radius: 14px !important;
  background: #fff; box-shadow: 0 1px 2px rgba(60, 40, 10, .04) !important;
  padding: 10px 12px 9px !important; overflow: hidden; min-width: 0;
}
.an-kpi::before { content: ''; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.an-green { --c: #2e9d5b; } .an-blue { --c: #2f7cf6; } .an-red { --c: #d4533a; } .an-teal { --c: #0f9d8c; }
.an-orange { --c: #e7770e; } .an-purple { --c: #7a5af8; } .an-gray { --c: #8a95a3; }
.an-kpi-label {
  display: flex; align-items: center; gap: 4px; font-size: .66rem !important; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--n5-mute) !important; line-height: 1.3; padding-left: 2px;
}
.an-kpi-label .lb-i { margin-left: auto; flex: none; }
.an-kpi-value { font-size: 1.6rem !important; font-weight: 800 !important; letter-spacing: -.02em; line-height: 1.15 !important; margin: 4px 0 2px 2px; color: var(--n5-ink); }
.an-kpi-sub { font-size: .72rem !important; color: var(--n5-mute) !important; line-height: 1.35; margin-left: 2px; }
.an-kpi-sub a { color: var(--n5-or-d); font-weight: 700; }

/* ---------- bảng theo công ty / người giới thiệu ---------- */
#summaryStats .an-table-wrap { border: 1px solid var(--n5-line); border-radius: 12px; max-height: 360px; }
.an-table { --bs-table-hover-bg: #fff6ea; }
.an-table th {
  background: #faf5ee !important; color: #7a6f60; font-size: .64rem !important; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 8px 8px !important; border-bottom: 1px solid #ead9c4 !important;
}
.an-table td { font-size: .8rem !important; padding: 7px 8px !important; border-color: #f6efe6 !important; font-variant-numeric: tabular-nums; }
.an-table tbody tr:nth-child(even) > td { background: #fffcf8; }
.an-table th:first-child, .an-table td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: 6px 0 8px -8px rgba(60, 40, 10, .25); font-weight: 600; }
.an-table th:first-child { z-index: 3; background: #faf5ee !important; }
.an-table tbody tr:nth-child(even) > td:first-child { background: #fffcf8; }

/* ---------- phân bố lao động ---------- */
#summaryStats .an-dhead { margin-top: 4px; }
.an-dnote { display: block; font-size: .74rem; color: var(--n5-mute); margin-top: 2px; }
#summaryStats .an-dcard .card-body { padding: 12px 14px 12px !important; }
.an-dcard .an-h6 { font-size: .86rem; margin-bottom: 8px; }
.an-li { font-size: .85rem !important; padding: 5px 4px !important; margin: 0 -4px; }
.an-li > div:first-child { align-items: baseline; }
.an-li .fw-semibold { font-weight: 800 !important; font-variant-numeric: tabular-nums; }
.an-bar { height: 7px !important; background: #f3ede4 !important; border-radius: 4px !important; margin-top: 4px !important; }
.an-bar span { background: linear-gradient(90deg, #f5b06e, #e7770e) !important; border-radius: 4px !important; }
.an-morebtn {
  display: block; width: 100%; margin-top: 6px; padding: 7px 10px !important; border-radius: 10px; background: #faf5ee !important;
  color: var(--n5-or-d) !important; font-weight: 700; font-size: .76rem !important; text-align: center;
}

/* =====================================================================
 * ĐIỆN THOẠI (≤576px)
 * ===================================================================== */
@media (max-width: 576px) {
  /* kỳ báo cáo: nhãn → ô chọn full → 2 nút cạnh nhau */
  .an-period { padding: 12px; }
  .an-period-row { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .an-period-t { grid-column: 1 / -1; }
  .an-period-row .form-select { grid-column: 1 / -1; height: 46px; font-size: .95rem; padding-right: 32px; }
  .an-period-row > .btn { height: 42px; border-radius: 12px; font-size: .82rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 4px; margin: 0; }
  .an-period-row > .an-export { grid-column: auto !important; width: auto !important; margin: 0 !important; }
  .an-period-line { margin-top: 2px; }

  /* KPI: "Đang làm" là thẻ lớn nổi bật, còn lại 2 cột đều */
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .an-kpis > .an-kpi:first-child {
    grid-column: 1 / -1; padding: 12px 14px !important;
    background: linear-gradient(135deg, #f1faf4, #fff 72%); border-color: #cfe9d9 !important;
  }
  .an-kpis > .an-kpi:first-child .an-kpi-value { font-size: 2.3rem !important; color: #167a4b; }
  .an-kpis > .an-kpi:last-child:nth-child(even) { grid-column: 1 / -1; }          /* thẻ cuối đứng một mình → trải hết hàng */
  .an-kpi-value { font-size: 1.45rem !important; }

  /* phân bố: mỗi thẻ một hàng đầy đủ → tiêu đề không bị gãy dòng, không còn khoảng trống */
  #summaryStats > .col-6.d-flex { flex: 0 0 100%; max-width: 100%; }
  #summaryStats .an-dhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  #summaryStats .an-dhead .an-dhead-l { flex: 1 1 100%; }
  #summaryStats .an-listsw { margin: 0; font-size: .78rem; }
}
