:root {
  --app-bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dbe3ef;
  --text: #122031;
  --muted: #5f6f84;
  --primary: #0a66c2;
  --primary-hover: #084f97;
  --success: #1f9d64;
  --success-hover: #187a4d;
  --warning: #dd9d23;
  --warning-hover: #b57d14;
  --danger: #d13f53;
  --danger-hover: #aa2e3f;
  --sidebar-width: 260px;
  --sidebar-bg: #1b2430;
  --sidebar-hover: #2b3544;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 6px 18px rgba(20, 35, 55, 0.08);
  --content-max: 1360px;
}

html,
body {
  height: 100%;
}

html {
  font-size: 15px;
}

body.app-body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--app-bg);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.app-shell {
  min-height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-width) !important;
  min-width: var(--sidebar-width) !important;
  max-width: var(--sidebar-width) !important;
  flex: 0 0 var(--sidebar-width);
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  transform: none !important;
  height: 100vh !important;
  overflow-y: auto;
  background: var(--sidebar-bg) !important;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
  z-index: 1031;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1f9d64, #0a66c2);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.app-brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f4f8fc;
}

.app-brand-subtitle {
  font-size: 0.75rem;
  color: #9fb0c5;
}

.app-sidebar .nav-link {
  color: #ecf2f8 !important;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: background-color 0.2s ease;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link:focus {
  background: var(--sidebar-hover);
}

.app-sidebar .nav-link.active {
  background: linear-gradient(120deg, rgba(10, 102, 194, 0.9), rgba(31, 157, 100, 0.88));
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(10, 102, 194, 0.28);
}

.app-sidebar .nav-item.small {
  letter-spacing: 0.06em;
  font-weight: 600;
}

.app-sidebar-backdrop {
  display: none;
}

.main-content.app-main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}

.app-topbar {
  height: 60px;
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
}

.app-topbar-title-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-topbar-title {
  font-weight: 700;
  font-size: 1rem;
  color: #1d2f45;
}

.app-topbar-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.app-page-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: var(--app-bg);
}

.app-content-wrap {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Keep all feature pages on one visual scale, regardless of container/container-fluid usage. */
.app-content-wrap > .container,
.app-content-wrap > .container-fluid,
.app-content-wrap > .container-sm,
.app-content-wrap > .container-md,
.app-content-wrap > .container-lg,
.app-content-wrap > .container-xl,
.app-content-wrap > .container-xxl {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.app-content-wrap > .container.mt-3,
.app-content-wrap > .container.mt-4,
.app-content-wrap > .container-fluid.mt-3,
.app-content-wrap > .container-fluid.mt-4 {
  margin-top: 0 !important;
}

.app-content-wrap .card {
  margin-bottom: 1rem;
}

.app-content-wrap h1,
.app-content-wrap h2,
.app-content-wrap h3,
.app-content-wrap h4,
.app-content-wrap h5 {
  margin-top: 0;
}

.card,
.modal-content,
.dropdown-menu {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.table {
  margin-bottom: 0;
}

.table thead th {
  background: var(--surface-2);
  border-bottom-color: var(--border);
  color: #2a3b51;
  font-weight: 600;
}

.table td,
.table th {
  border-color: #e8edf5;
  vertical-align: middle;
}

.btn {
  border-radius: 10px;
}

.btn:not(.btn-sm):not(.btn-lg) {
  min-height: 42px;
  padding: 0.5rem 1rem;
  font-weight: 600;
}

.btn-sm {
  min-height: 32px;
}

.btn-primary,
.btn-add-group {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(10, 102, 194, 0.24);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-add-group:hover,
.btn-add-group:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--success);
  border-color: var(--success);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(31, 157, 100, 0.24);
}

.btn-success:hover,
.btn-success:focus {
  background-color: var(--success-hover);
  border-color: var(--success-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-warning {
  background-color: var(--warning);
  border-color: var(--warning);
  color: #1f2b3b;
  box-shadow: 0 6px 16px rgba(221, 157, 35, 0.26);
}

.btn-warning:hover,
.btn-warning:focus {
  background-color: var(--warning-hover);
  border-color: var(--warning-hover);
  color: #1f2b3b;
  transform: translateY(-1px);
}

.btn-danger {
  background-color: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(209, 63, 83, 0.26);
}

.btn-danger:hover,
.btn-danger:focus {
  background-color: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #5f6f84;
  border-color: #5f6f84;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(95, 111, 132, 0.24);
}

.btn-secondary:hover,
.btn-secondary:focus {
  background-color: #4f5e73;
  border-color: #4f5e73;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-info {
  background-color: #1b9bb7;
  border-color: #1b9bb7;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(27, 155, 183, 0.24);
}

.btn-info:hover,
.btn-info:focus {
  background-color: #157d94;
  border-color: #157d94;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-light {
  background-color: #f3f6fb;
  border-color: #d7e0ee;
  color: #2a3b51;
  box-shadow: none;
}

.btn-light:hover,
.btn-light:focus {
  background-color: #e7edf7;
  border-color: #cad7ea;
  color: #1f2f44;
  transform: translateY(-1px);
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-info,
.btn-outline-secondary {
  background-color: transparent;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-outline-success {
  color: var(--success);
  border-color: var(--success);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
  background-color: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.btn-outline-warning {
  color: #a87110;
  border-color: #c8921b;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
  background-color: var(--warning);
  border-color: var(--warning);
  color: #1f2b3b;
}

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
  background-color: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-outline-info {
  color: #1b9bb7;
  border-color: #1b9bb7;
}

.btn-outline-info:hover,
.btn-outline-info:focus {
  background-color: #1b9bb7;
  border-color: #1b9bb7;
  color: #ffffff;
}

.btn-outline-secondary {
  color: #5f6f84;
  border-color: #5f6f84;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background-color: #5f6f84;
  border-color: #5f6f84;
  color: #ffffff;
}

.btn-add-group {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1;
  text-decoration: none;
}

.btn-add-group-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
}

.form-control,
.form-select {
  border-radius: 10px;
  border-color: #ccd7e6;
}

.app-content-wrap .form-control,
.app-content-wrap .form-select,
.app-content-wrap .input-group-text {
  min-height: 42px;
}

.app-content-wrap .form-control-sm,
.app-content-wrap .form-select-sm {
  min-height: 34px;
}

.badge.bg-success {
  background-color: var(--success) !important;
}

.badge.bg-warning {
  background-color: var(--warning) !important;
}

.badge.bg-danger {
  background-color: var(--danger) !important;
}

.form-control:focus,
.form-select:focus,
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(10, 102, 194, 0.2);
  border-color: #7eb7f1;
}

.alert {
  border-radius: 10px;
}

@media (max-width: 992px) {
  .app-sidebar {
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    max-width: var(--sidebar-width) !important;
    flex-basis: var(--sidebar-width);
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    top: 0;
    transition: left 0.25s ease;
  }

  .main-content.app-main {
    margin-left: 0;
    width: 100%;
  }

  body.sidebar-open .app-sidebar {
    left: 0;
  }

  .app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1030;
  }

  body.sidebar-open .app-sidebar-backdrop {
    display: block;
  }

  .app-page-content {
    padding: 14px;
  }

  .app-topbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .app-topbar-meta {
    display: none;
  }

  .btn-add-group {
    padding: 0.4rem 0.8rem;
    font-size: 0.88rem;
  }
}

/* ---------- AI page ---------- */
.ai-page .summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e9ecef;
  border-radius: 0.6rem;
  background: #fafafa;
}

.ai-page .table-search {
  width: 240px;
  max-width: 100%;
}

.ai-page .ai-progress {
  height: 1rem;
}

/* ---------- Thong ke ---------- */
.app-content-wrap > .container-fluid.thongke-page {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.thongke-page {
  overflow-x: clip;
}

.thongke-page .row {
  margin-left: 0;
  margin-right: 0;
}

.thongke-page .row > * {
  min-width: 0;
}

.thongke-page .card {
  border-radius: 12px;
  border: 1px solid #eef1f4;
}

.thongke-page .chart-card .chart-body {
  position: relative;
  overflow: hidden;
}

.thongke-page .chart-card .chart-body canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.thongke-page .chart-h-280 {
  height: 280px;
  min-height: 280px;
  max-height: 280px;
}

.thongke-page .chart-h-300 {
  height: 300px;
  min-height: 300px;
  max-height: 300px;
}

.thongke-page .chart-h-320 {
  height: 320px;
  min-height: 320px;
  max-height: 320px;
}

.thongke-page .chart-h-260 {
  height: 260px;
  min-height: 260px;
  max-height: 260px;
}

.thongke-page .chart-h-340 {
  height: 340px;
  min-height: 340px;
  max-height: 340px;
}

.thongke-page .metric-card {
  border-radius: 12px;
  padding: 16px;
  color: #fff;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(32, 40, 52, 0.12);
}

.thongke-page .metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.thongke-page .metric-label {
  font-size: 0.95rem;
  opacity: 0.95;
}

.thongke-page .metric-blue { background: linear-gradient(135deg, #2d7ff9, #1b5ec8); }
.thongke-page .metric-green { background: linear-gradient(135deg, #28b87a, #1f8f60); }
.thongke-page .metric-yellow { background: linear-gradient(135deg, #f4b942, #d4941e); }
.thongke-page .metric-red { background: linear-gradient(135deg, #e65a6f, #bd3650); }
.thongke-page .metric-purple { background: linear-gradient(135deg, #5561ff, #3c45bf); }

.thongke-page .metric-ai {
  min-height: 108px;
}

.thongke-page .report-metric {
  border-radius: 10px;
  color: #fff;
  padding: 12px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.thongke-page .report-metric-label {
  font-size: 0.84rem;
  opacity: 0.92;
}

.thongke-page .report-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
}

.thongke-page .report-slate { background: linear-gradient(120deg, #4a5568, #2d3748); }
.thongke-page .report-teal { background: linear-gradient(120deg, #0d9488, #0f766e); }
.thongke-page .report-amber { background: linear-gradient(120deg, #d97706, #b45309); }
.thongke-page .report-rose { background: linear-gradient(120deg, #e11d48, #be123c); }

/* ---------- Nhan vien ---------- */
.nhanvien-page {
  overflow-x: hidden;
  min-width: 0;
}

.nhanvien-page #resultTable {
  max-width: 100%;
  overflow: hidden;
}

.nhanvien-page .employee-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  width: 100%;
  max-width: 100%;
}

.nhanvien-page .employee-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.nhanvien-page .employee-table-wrap.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.nhanvien-page .employee-table-wrap::-webkit-scrollbar {
  height: 10px;
}

.nhanvien-page .employee-table-wrap::-webkit-scrollbar-thumb {
  background: #b8c6da;
  border-radius: 999px;
}

.nhanvien-page .employee-table-wrap::-webkit-scrollbar-track {
  background: #edf2f8;
}

.nhanvien-page .employee-table {
  min-width: 1100px;
  width: max-content;
  table-layout: fixed;
}

.nhanvien-page .employee-table th,
.nhanvien-page .employee-table td {
  white-space: nowrap;
}

.nhanvien-page .employee-table .col-name,
.nhanvien-page .employee-table .col-email,
.nhanvien-page .employee-table .col-department {
  white-space: normal;
}

.nhanvien-page .employee-table .col-name {
  min-width: 140px;
}

.nhanvien-page .employee-table .col-email {
  min-width: 180px;
}

.nhanvien-page .employee-table .col-department {
  min-width: 150px;
}

.nhanvien-page .text-truncate-inline {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.nhanvien-page .employee-table td:last-child {
  min-width: 120px;
}

.nhanvien-page .employee-table .col-actions {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -8px 0 10px -10px rgba(20, 35, 55, 0.55);
  z-index: 1;
}

.nhanvien-page .employee-table thead .col-actions {
  z-index: 2;
  background: var(--surface-2);
}

@media (max-width: 1200px) {
  .nhanvien-page .employee-table {
    min-width: 820px;
  }
}

@media (max-width: 768px) {
  .nhanvien-page .employee-table-wrap {
    max-height: calc(100vh - 280px);
    margin-bottom: 2px;
  }
}

/* ---------- Auth pages ---------- */
.auth-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  border-radius: 15px;
}

/* ---------- Assign work ---------- */
.list-box {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 5px;
}

@media (max-width: 768px) {
  .app-content-wrap > .container-fluid.thongke-page {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .thongke-page .chart-h-340 {
    height: 280px;
    min-height: 280px;
    max-height: 280px;
  }

  .thongke-page .chart-h-320 {
    height: 260px;
    min-height: 260px;
    max-height: 260px;
  }

  .thongke-page .chart-h-300,
  .thongke-page .chart-h-280,
  .thongke-page .chart-h-260 {
    height: 240px;
    min-height: 240px;
    max-height: 240px;
  }
}


/* HEADER FIXED */
.nhanvien-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* SEARCH FIXED */
.nhanvien-search {
    position: sticky;
    top: 90px;
    z-index: 900;
}

/* TABLE SCROLL */
.employee-table-wrap {
    max-height: 70vh;
    overflow-y: auto;
}

/* TABLE STYLE */
.employee-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

/* TEXT TRUNCATE */
.text-truncate-inline {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}