:root {
  --pbkt-green: #1e6b32;
  --pbkt-green-dark: #154d24;
  --pbkt-red: #8c2a23;
  --pbkt-yellow: #f2b92b;
}

body {
  background: #f4f6f5;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.navbar-pbkt {
  background: var(--pbkt-green);
}
.navbar-pbkt .navbar-brand, .navbar-pbkt .nav-link {
  color: #fff !important;
}
.navbar-pbkt .nav-link.active {
  font-weight: 700;
  text-decoration: underline;
}
.navbar-pbkt img.logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  margin-right: 8px;
}

.btn-pbkt {
  background: var(--pbkt-green);
  border-color: var(--pbkt-green);
  color: #fff;
}
.btn-pbkt:hover {
  background: var(--pbkt-green-dark);
  border-color: var(--pbkt-green-dark);
  color: #fff;
}

.card-stat {
  border: none;
  border-left: 5px solid var(--pbkt-green);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.card-stat .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--pbkt-green-dark);
}

.badge-role-admin { background: var(--pbkt-red); }
.badge-role-sales_admin { background: var(--pbkt-yellow); color: #333; }
.badge-role-accountant { background: #2a6f97; }
.badge-role-sales { background: var(--pbkt-green); }

.badge-type-dai_ly { background: #2a6f97; }
.badge-type-nong_ho { background: var(--pbkt-green); }
.badge-type-npp_oem { background: var(--pbkt-red); }

.table thead th {
  background: #eef4ee;
  white-space: nowrap;
}

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* tránh bị che bởi thanh địa chỉ trình duyệt mobile */
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--pbkt-green) 0%, var(--pbkt-green-dark) 100%);
  padding: 16px;
}
.login-card {
  max-width: 400px;
  width: 100%;
  border-radius: 12px;
}
.login-card img.logo {
  height: 80px;
}

@media (max-width: 576px) {
  .card-stat .stat-value { font-size: 1.3rem; }
}

.required::after {
  content: " *";
  color: var(--pbkt-red);
}

.bg-pbkt-progress {
  background: var(--pbkt-green) !important;
}
.kpi-progress {
  height: 18px;
  border-radius: 9px;
  background: #e7ebe8;
}
.kpi-progress .progress-bar {
  font-size: .75rem;
  font-weight: 600;
}
.kpi-card {
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.announcement-pinned {
  border-left: 5px solid var(--pbkt-yellow);
}

/* Chữ ở các mục thông tin chi tiết (mục đích/kết quả cuộc thăm, ghi chú xác minh,
   khó khăn/đề xuất, đánh giá nhân viên...): cỡ nhỏ hơn & màu nhạt hơn để không
   "đua" độ nổi bật với tên khách hàng, tiêu đề hay các điểm nhấn khác. */
.detail-text {
  font-size: .85rem;
  color: #76827a;
  line-height: 1.45;
}
.detail-text .text-muted {
  color: #8b968f !important;
}

/* ============================================================
   TỐI ƯU HIỂN THỊ TRÊN ĐIỆN THOẠI (MOBILE)
   ============================================================ */

/* Tránh Safari/iOS tự zoom khi bấm vào input (yêu cầu font-size >= 16px) */
@media (max-width: 767.98px) {
  input.form-control,
  select.form-select,
  textarea.form-control {
    font-size: 16px;
  }
}

/* Tap target rộng rãi hơn cho ngón tay */
@media (max-width: 767.98px) {
  .btn {
    padding-top: .5rem;
    padding-bottom: .5rem;
  }
  .btn-sm {
    padding: .4rem .65rem;
    font-size: .8rem;
  }
  .table td a.btn,
  .table td .btn {
    margin-bottom: .25rem;
  }
  /* Các cụm nút (sửa/khoá/xoá...) tự xuống dòng gọn gàng thay vì tràn ngang */
  td .btn + .btn,
  .btn-group-mobile-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .35rem;
  }
}

/* Container đỡ bị sát mép màn hình nhỏ */
@media (max-width: 575.98px) {
  .container-fluid {
    padding-left: 12px;
    padding-right: 12px;
  }
  h4 { font-size: 1.15rem; }
}

/* Navbar trên mobile: xếp các mục menu theo dạng "chip" nhiều hàng ngang
   thay vì liệt kê dọc từng dòng dài xuống dưới (mặc định của Bootstrap). */
@media (max-width: 991.98px) {
  .navbar-pbkt .navbar-collapse {
    padding: .6rem 0 .3rem;
    border-top: 1px solid rgba(255,255,255,.2);
    margin-top: .4rem;
  }
  .navbar-pbkt .navbar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .4rem;
  }
  .navbar-pbkt .navbar-nav + .navbar-nav {
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid rgba(255,255,255,.2);
  }
  .navbar-pbkt .nav-item {
    flex: 0 0 auto;
  }
  .navbar-pbkt .nav-link {
    padding: .4rem .75rem;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    white-space: nowrap;
  }
  .navbar-pbkt .nav-link.active {
    background: #fff;
    color: var(--pbkt-green-dark) !important;
    text-decoration: none;
  }
  .navbar-pbkt .dropdown-menu {
    position: static;
    width: auto;
    margin-top: .35rem;
    background: rgba(0,0,0,.12);
    border: none;
    box-shadow: none;
  }
  .navbar-pbkt .dropdown-item {
    color: #fff;
  }
  .navbar-pbkt .dropdown-item:hover,
  .navbar-pbkt .dropdown-item:focus {
    background: rgba(255,255,255,.15);
    color: #fff;
  }
  .navbar-pbkt .dropdown-divider {
    border-color: rgba(255,255,255,.25);
  }
}

/* ---- Bảng dạng "card" trên mobile: dùng cho các bảng chỉ hiển thị dữ liệu
   (danh sách khách hàng, nhân viên, tài khoản, KPI, thông báo...).
   Mỗi <td> cần thuộc tính data-label="Tên cột" để hiện nhãn trước giá trị. ---- */
@media (max-width: 767.98px) {
  .table-mobile-cards thead {
    display: none;
  }
  .table-mobile-cards,
  .table-mobile-cards tbody,
  .table-mobile-cards tr,
  .table-mobile-cards td {
    display: block;
    width: 100%;
  }
  .table-mobile-cards {
    border: none;
  }
  .table-mobile-cards tr {
    margin-bottom: .85rem;
    border: 1px solid #e0e6e1;
    border-radius: 10px;
    padding: .6rem .8rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  .table-mobile-cards tr:hover {
    background: #fff;
  }
  .table-mobile-cards td {
    border: none !important;
    padding: .3rem 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    text-align: right;
  }
  .table-mobile-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #5d6b61;
    text-align: left;
    flex-shrink: 0;
    font-size: .8rem;
  }
  .table-mobile-cards td:not([data-label])::before {
    content: none;
  }
  .table-mobile-cards td:not([data-label]) {
    justify-content: flex-end;
  }
  .table-mobile-cards td[data-full] {
    display: block;
    text-align: left;
  }
  .table-mobile-cards td[data-full]::before {
    display: block;
    margin-bottom: .2rem;
  }
  .table-mobile-cards td[colspan] {
    display: block;
    text-align: center;
  }
  .table-mobile-cards td[colspan]::before {
    content: none;
  }
}

/* ---- Bảng nhập liệu (form) trên mobile: mỗi dòng (khách hàng/visit) thành
   1 khối card riêng, nhãn hiện phía trên ô nhập để dễ bấm & dễ đọc. Dùng cho
   bảng nhập báo cáo ngày (nhiều khách/nhiều cột). ---- */
@media (max-width: 767.98px) {
  .table-stack-form thead {
    display: none;
  }
  .table-stack-form,
  .table-stack-form tbody,
  .table-stack-form tr,
  .table-stack-form td {
    display: block;
    width: 100%;
  }
  .table-stack-form tr {
    position: relative;
    margin-bottom: .85rem;
    border: 1px solid #e0e6e1;
    border-radius: 10px;
    padding: .75rem .8rem .5rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  .table-stack-form td {
    border: none !important;
    padding: 0 0 .5rem !important;
  }
  .table-stack-form td::before {
    content: attr(data-label);
    display: block;
    font-size: .68rem;
    font-weight: 600;
    color: #97a29b;
    margin-bottom: .15rem;
    text-transform: uppercase;
    letter-spacing: .03em;
  }
  .table-stack-form td input.form-control,
  .table-stack-form td select.form-select,
  .table-stack-form td textarea.form-control {
    color: #1c2420;
    padding-top: .4rem;
    padding-bottom: .4rem;
  }
  .table-stack-form td.col-remove {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: auto;
    padding: 0 !important;
  }
  .table-stack-form td.col-remove::before {
    content: none;
  }
}
