/* =====================================================================
   Giao diện Actlife – bản 2026
   ---------------------------------------------------------------------
   Thiết kế gốc (canvas Claude Design): menu trái nền tối, dải trắng đầu
   trang chứa đường dẫn + tab mục, tab trang dạng nút phân đoạn, thẻ trắng
   viền mảnh không đổ bóng, bảng đầu cột xám nhạt, nút nhạt màu cho các
   thao tác phụ để hết cảnh "cầu vồng" nút.

   Nguyên tắc khi sửa file này:
   - Màu, cỡ chữ, bo góc chỉ lấy từ biến ở :root, không viết mã màu rời.
   - Ưu tiên chỉnh biến --bs-* của Bootstrap 5.3 thay vì đè từng thuộc
     tính, để các biến thể (.btn-sm, .table-sm, .form-control-sm...) vẫn
     hoạt động đúng.
   - Không thêm hiệu ứng nhấc thẻ/nút lên khi rê chuột: bảng dữ liệu dày,
     thứ gì cũng nhảy là rối mắt, và từng làm lệch bố cục khi mở hộp thoại.
   ===================================================================== */

:root {
  /* Nền & chữ */
  --ui-bg: #F4F5F7;
  --ui-surface: #FFFFFF;
  --ui-surface-2: #F8F9FA;
  --ui-surface-3: #EEF0F2;
  --ui-border: #E3E6EA;
  --ui-border-strong: #D0D5DB;
  --ui-text: #16181D;
  --ui-text-2: #4B5261;
  --ui-muted: #5B6270;
  --ui-faint: #8A909B;

  /* Menu trái */
  --ui-side-bg: #16191F;
  --ui-side-hover: #20242C;
  --ui-side-active: #262B34;
  --ui-side-text: #AEB4BF;
  --ui-side-muted: #7E8593;

  /* Màu nhấn */
  --ui-accent: #2F62E8;
  --ui-accent-hover: #2552CC;
  --ui-accent-text: #1F4FD1;
  --ui-accent-soft: #EAF0FD;
  --ui-accent-ring: rgba(47, 98, 232, .18);

  /* Trạng thái: [đậm, chữ trên nền nhạt, nền nhạt] */
  --ui-success: #1F8A4C;  --ui-success-text: #177245;  --ui-success-soft: #E7F5EC;
  --ui-warning: #C77A12;  --ui-warning-text: #95560B;  --ui-warning-soft: #FDF3E3;
  --ui-danger:  #D23B2F;  --ui-danger-text:  #B02A20;  --ui-danger-soft:  #FCEBEA;
  --ui-info:    #1A7FA8;  --ui-info-text:    #146685;  --ui-info-soft:    #E4F3F9;
  --ui-neutral-soft: #F1F2F4;

  /* Hình khối */
  --ui-radius-sm: 6px;
  --ui-radius: 8px;
  --ui-radius-lg: 12px;
  --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --ui-shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --ui-shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --ui-font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ui-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --app-sidebar-width: 248px;
  --page-pad-x: 32px;

  /* Bootstrap 5.3 đọc các biến này cho mọi thành phần */
  --bs-body-font-family: var(--ui-font);
  --bs-body-font-size: 14px;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--ui-text);
  --bs-body-bg: var(--ui-bg);
  --bs-emphasis-color: var(--ui-text);
  --bs-secondary-color: var(--ui-muted);
  --bs-tertiary-color: var(--ui-faint);
  --bs-secondary-bg: var(--ui-surface-3);
  --bs-tertiary-bg: var(--ui-surface-2);
  --bs-border-color: var(--ui-border);
  --bs-border-color-translucent: rgba(16, 24, 40, .1);
  --bs-border-radius: var(--ui-radius);
  --bs-border-radius-sm: var(--ui-radius-sm);
  --bs-border-radius-lg: var(--ui-radius-lg);
  --bs-link-color: var(--ui-accent-text);
  --bs-link-color-rgb: 31, 79, 209;
  --bs-link-hover-color: #173EA6;
  --bs-link-hover-color-rgb: 23, 62, 166;
  --bs-primary: var(--ui-accent);
  --bs-primary-rgb: 47, 98, 232;
  --bs-success: var(--ui-success);
  --bs-success-rgb: 31, 138, 76;
  --bs-warning: var(--ui-warning);
  --bs-warning-rgb: 199, 122, 18;
  --bs-danger: var(--ui-danger);
  --bs-danger-rgb: 210, 59, 47;
  --bs-info: var(--ui-info);
  --bs-info-rgb: 26, 127, 168;
  --bs-secondary: var(--ui-muted);
  --bs-secondary-rgb: 91, 98, 112;
  --bs-dark-rgb: 22, 25, 31;
  --bs-primary-text-emphasis: var(--ui-accent-text);
  --bs-primary-bg-subtle: var(--ui-accent-soft);
  --bs-success-text-emphasis: var(--ui-success-text);
  --bs-success-bg-subtle: var(--ui-success-soft);
  --bs-warning-text-emphasis: var(--ui-warning-text);
  --bs-warning-bg-subtle: var(--ui-warning-soft);
  --bs-danger-text-emphasis: var(--ui-danger-text);
  --bs-danger-bg-subtle: var(--ui-danger-soft);
  --bs-info-text-emphasis: var(--ui-info-text);
  --bs-info-bg-subtle: var(--ui-info-soft);
  --bs-focus-ring-color: var(--ui-accent-ring);

  /* Tên biến cũ – nhiều view còn dùng trong style riêng, giữ làm bí danh */
  --apple-blue: var(--ui-accent);
  --apple-blue-light: #6F93F0;
  --apple-blue-dark: var(--ui-accent-hover);
  --apple-blue-bg: var(--ui-accent-soft);
  --apple-gray: var(--ui-faint);
  --apple-gray-light: var(--ui-surface-3);
  --apple-gray-dark: var(--ui-text);
  --apple-gray-bg: var(--ui-surface-2);
  --apple-green: var(--ui-success);
  --apple-orange: var(--ui-warning);
  --apple-red: var(--ui-danger);
  --apple-purple: #7C4DDB;
  --apple-yellow: #E0A800;
  --apple-text-primary: var(--ui-text);
  --apple-text-secondary: var(--ui-muted);
  --apple-text-tertiary: var(--ui-faint);
  --apple-bg-primary: var(--ui-surface);
  --apple-bg-secondary: var(--ui-surface-2);
  --apple-bg-tertiary: var(--ui-surface);
  --apple-bg-card: var(--ui-surface);
  --apple-border: var(--ui-border-strong);
  --apple-border-light: var(--ui-border);
  --apple-border-dark: var(--ui-border-strong);
  --apple-shadow-sm: var(--ui-shadow-sm);
  --apple-shadow-md: var(--ui-shadow-md);
  --apple-shadow-lg: var(--ui-shadow-lg);
  --apple-shadow-xl: var(--ui-shadow-lg);
  --apple-radius: var(--ui-radius-lg);
  --apple-radius-sm: var(--ui-radius);
  --apple-radius-lg: var(--ui-radius-lg);
  --apple-radius-xl: 16px;
  --apple-font: var(--ui-font);
  --apple-font-mono: var(--ui-font-mono);
  --apple-space-xs: 4px;
  --apple-space-sm: 8px;
  --apple-space-md: 16px;
  --apple-space-lg: 24px;
  --apple-space-xl: 32px;
  --apple-space-2xl: 48px;
  --apple-transition: all .15s ease;
  --apple-transition-fast: all .12s ease;
  --bg-primary: var(--ui-surface);
  --bg-secondary: var(--ui-surface-2);
  --bg-tertiary: var(--ui-surface-3);
  --border-color: var(--ui-border);
  --border-color-light: var(--ui-surface-3);
  --text-primary: var(--ui-text);
  --text-secondary: var(--ui-text-2);
  --primary-blue: var(--ui-accent);
  --secondary-blue: var(--ui-accent-soft);
  --secondary-blue-light: #F5F8FF;
  --success-color: var(--ui-success);
  --warning-color: var(--ui-warning);
  --danger-color: var(--ui-danger);
  --info-color: var(--ui-info);
}

/* ===== Nền tảng ===== */
* { box-sizing: border-box; }

body {
  font-family: var(--ui-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ui-text);
  background: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 600;
  color: var(--ui-text);
  letter-spacing: -.01em;
  line-height: 1.3;
  margin-bottom: 12px;
}
h1, .h1 { font-size: 24px; }
h2, .h2 { font-size: 22px; }
h3, .h3 { font-size: 20px; }
h4, .h4 { font-size: 18px; }
h5, .h5 { font-size: 16px; }
h6, .h6 { font-size: 14.5px; }

/* Tiêu đề của từng trang: đa số view mở đầu bằng một hàng flex chứa
   h3/h5 + các nút. Đồng bộ cỡ để trang nào cũng có tiêu đề như nhau. */
.main-content > .d-flex:first-child > :is(h1, h2, h3, h4, h5):first-child,
.main-content > .d-flex:first-child > div:first-child > :is(h1, h2, h3, h4, h5):first-child,
.main-content > .row:first-child > .col-12 > .d-flex:first-child > :is(h1, h2, h3, h4, h5):first-child {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* Icon đứng trước tiêu đề trang chỉ làm nặng thêm – làm nhạt đi */
.main-content > .d-flex:first-child > :is(h3, h5) > i.fas:first-child {
  color: var(--ui-faint);
  font-size: .85em;
  margin-right: 4px;
}

small, .small { font-size: 13px; }
.text-muted, .text-secondary { color: var(--ui-muted) !important; }
code, kbd, pre, .font-monospace { font-family: var(--ui-font-mono); }
code { color: var(--ui-text-2); background: var(--ui-surface-3); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
hr { border-color: var(--ui-border); opacity: 1; }
.page-subtitle { color: var(--ui-muted); font-size: 14px; font-weight: 400; margin-left: 10px; }

/* ===== Bố cục hai cột ===== */
.app-layout {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-body {
  flex: 1 1 auto;
  min-width: 0; /* cho bảng rộng tự cuộn thay vì đẩy giãn cả trang */
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1 0 auto;
  padding: 20px var(--page-pad-x) 32px;
}

.container { max-width: 1200px; }

/* ===== Menu trái ===== */
.app-sidebar {
  flex: 0 0 var(--app-sidebar-width);
  width: var(--app-sidebar-width);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--ui-side-bg);
  color: var(--ui-side-text);
  z-index: 1001;
}

/* Chỉ danh sách module mới cuộn: chân cột nằm ngoài vùng cuộn nên menu sổ ra
   của chuông và tài khoản không bị overflow cắt mất */
.app-sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #343A45 transparent;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 4px 40px 20px 8px; /* chừa chỗ nút thu gọn */
  text-decoration: none;
}

.app-sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ui-accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.app-sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; }
.app-sidebar-brand-name { color: #FFFFFF; font-weight: 600; font-size: 15px; line-height: 1.2; }
.app-sidebar-brand-sub { color: var(--ui-side-muted); font-size: 12px; line-height: 1.3; }

.app-sidebar-nav { gap: 2px; }

.app-sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--ui-radius);
  color: var(--ui-side-text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .12s ease, color .12s ease;
}

.app-sidebar-nav .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
  color: var(--ui-side-muted);
  transition: color .12s ease;
}

.app-sidebar-nav .nav-link:hover,
.app-sidebar-nav .nav-link:focus-visible {
  background: var(--ui-side-hover);
  color: #FFFFFF;
}

.app-sidebar-nav .nav-link:hover i { color: var(--ui-side-text); }

.app-sidebar-nav .nav-link.active {
  background: var(--ui-side-active);
  color: #FFFFFF;
  font-weight: 600;
}

.app-sidebar-nav .nav-link.active i { color: #8FB0FF; }

/* ===== Menu kiểu thư mục =====
   Mỗi khung (.side-panel) là một tầng: "root" là danh sách nhóm, mỗi nhóm một
   khung chứa các trang. Chỉ khung .is-active hiện; JS trong _sidebar.php đổi
   khung và gắn hướng trượt. */
.app-sidebar-scroll { position: relative; } /* mốc offsetTop khi cuộn tới trang đang mở */

.side-panel { display: none; }
.side-panel.is-active { display: block; }
.side-panel[data-panel="root"].is-active > .app-sidebar-nav { display: flex; }

.side-panel.slide-in-right { animation: side-in-right .18s ease-out; }
.side-panel.slide-in-left { animation: side-in-left .18s ease-out; }
@keyframes side-in-right { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes side-in-left { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .side-panel.slide-in-right, .side-panel.slide-in-left { animation: none; }
}

/* Mũi tên báo "bấm vào là mở thư mục" */
.app-sidebar-nav .nav-link .side-chevron {
  width: auto;
  margin-left: auto;
  font-size: 10px;
  color: #4B5261;
}
.app-sidebar-nav .nav-link:hover .side-chevron,
.app-sidebar-nav .nav-link.active .side-chevron { color: var(--ui-side-text); }

.side-back {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--ui-radius);
  background: transparent;
  color: var(--ui-side-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}
.side-back i { font-size: 11px; width: 18px; text-align: center; }
.side-back:hover, .side-back:focus-visible { background: var(--ui-side-hover); color: #FFFFFF; }

.side-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 6px;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
}
.side-group-title i { width: 18px; text-align: center; font-size: 15px; color: #8FB0FF; }

.side-section { display: flex; flex-direction: column; gap: 1px; padding-top: 12px; }

/* Tiêu đề cụm (tầng 2) to bằng link trang (tầng 3), có nền và màu riêng để
   mắt bắt được ngay khi dò trong nhóm dài; trang bên dưới thụt vào sau icon */
.side-section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 2px;
  padding: 6px 12px;
  border-radius: var(--ui-radius);
  background: rgba(143, 176, 255, .10);
  color: #C3D3FF;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.side-section-label i { width: 18px; text-align: center; font-size: 13px; color: #8FB0FF; flex-shrink: 0; }

.side-link {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px 6px 42px; /* thẳng hàng với chữ của tên nhóm, sau icon */
  border-radius: var(--ui-radius);
  color: var(--ui-side-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.side-link:hover, .side-link:focus-visible { background: var(--ui-side-hover); color: #FFFFFF; }
.side-link.active { background: var(--ui-side-active); color: #FFFFFF; font-weight: 600; box-shadow: inset 3px 0 0 #8FB0FF; }

/* Chân cột: chuông thông báo và tài khoản */
.app-sidebar-footer {
  flex-shrink: 0;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--ui-side-active);
}

.app-sidebar-tools .user-avatar,
.app-sidebar-tools .user-avatar-placeholder {
  width: 28px;
  height: 28px;
  font-size: 12px;
  flex-shrink: 0;
  border: 0;
}

.app-sidebar-tools .user-avatar-placeholder { background: #3A4150; }

.app-sidebar-tools .app-sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar .badge.bg-danger {
  background: var(--ui-danger) !important;
  color: #FFFFFF !important;
  font-size: 11px;
  padding: 2px 7px;
}

/* Bỏ mũi tên dropdown – ở đây chật, badge và tên đã kín hàng */
.app-sidebar-tools .dropdown-toggle::after { display: none; }

/* Menu sổ ra bám mép trái cột và mở LÊN TRÊN.
   Đặt rõ vị trí ở đây vì initNavbarEnhancements() trong app.js tự bật class
   .show rồi stopPropagation(), nên có lượt Popper của Bootstrap không chạy và
   menu sẽ rơi xuống dưới đáy màn hình. Khi Popper chạy thì style inline của nó
   đè lên mấy dòng này, vẫn đúng. */
.app-sidebar-tools .nav-item { position: relative; }

.app-sidebar-tools .dropdown-menu {
  position: absolute;
  top: auto;
  bottom: 100%;
  left: 0;
  right: auto;
  margin-bottom: 4px;
}

/* Nút ba gạch nổi ở góc trên bên trái (chỉ hiện ở màn hình nhỏ) */
.app-sidebar-toggle {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 1028;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--ui-radius);
  background: var(--ui-side-bg);
  color: #FFFFFF;
  font-size: 17px;
  line-height: 1;
  box-shadow: var(--ui-shadow-md);
}

/* Nút thu gọn ở góc trên cột menu - chỉ trên máy tính */
.app-sidebar-collapse {
  position: absolute;
  top: 18px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--ui-radius);
  background: transparent;
  color: var(--ui-side-muted);
  font-size: 13px;
}
.app-sidebar-collapse:hover, .app-sidebar-collapse:focus-visible { background: var(--ui-side-hover); color: #FFFFFF; }

@media (min-width: 992px) {
  .app-sidebar-toggle { display: none; }
  /* Đang thu gọn: bỏ hẳn cột menu, nội dung chiếm trọn cửa sổ, nút nổi để mở lại */
  .side-collapsed .app-sidebar { display: none; }
  .side-collapsed .app-sidebar-toggle { display: block; }
  .side-collapsed .main-content { padding-left: calc(var(--page-pad-x) + 52px); }
}

.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  z-index: 1029;
}

/* ===== Tab trong nội dung view (Bootstrap .nav-tabs / .nav-pills) ===== */
.main-content .nav-tabs {
  border-bottom: 1px solid var(--ui-border);
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-content .nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 0;
  margin-bottom: -1px;
  background: none;
  color: var(--ui-muted);
  font-weight: 500;
  white-space: nowrap;
}

.main-content .nav-tabs .nav-link:hover { color: var(--ui-text); border-bottom-color: var(--ui-border-strong); }

.main-content .nav-tabs .nav-link.active,
.main-content .nav-tabs .nav-item.show .nav-link {
  color: var(--ui-accent-text);
  font-weight: 600;
  background: none;
  border-bottom-color: var(--ui-accent);
}

.main-content .nav-pills {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #E9EBEE;
  border-radius: 10px;
  margin-bottom: 16px;
}

.main-content .nav-pills .nav-link {
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--ui-text-2);
  font-size: 13.5px;
  font-weight: 500;
}

.main-content .nav-pills .nav-link.active,
.main-content .nav-pills .show > .nav-link {
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}

/* ===== Thẻ ===== */
.card {
  --bs-card-border-color: var(--ui-border);
  --bs-card-border-radius: var(--ui-radius-lg);
  --bs-card-inner-border-radius: calc(var(--ui-radius-lg) - 1px);
  --bs-card-cap-bg: var(--ui-surface);
  --bs-card-cap-padding-y: 13px;
  --bs-card-cap-padding-x: 18px;
  --bs-card-spacer-y: 16px;
  --bs-card-spacer-x: 18px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: none;
}

.card-header {
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  font-weight: 600;
  font-size: 15px;
  color: var(--ui-text);
}

.card-header :is(h1, h2, h3, h4, h5, h6, .card-title) {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 0;
}

.card-header .text-muted, .card-header small { font-weight: 400; }

/* Header tô màu (bg-primary, bg-success...) -> đưa về trắng như mọi thẻ khác */
.card-header[class*="bg-"]:not(.bg-white):not(.bg-light):not(.bg-transparent) {
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
}

.card-header.bg-light { background: var(--ui-surface-2) !important; }

.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-footer { background: var(--ui-surface-2); border-top: 1px solid var(--ui-border); }

/* Thẻ chỉ chứa bảng thì bảng ăn sát mép thẻ */
.card-body.p-0 > .table-responsive > .table,
.card-body.p-0 > .table,
.card > .table-responsive > .table,
.card > .table { margin-bottom: 0; }

/* Thẻ viền màu (border-primary...) nhìn như cảnh báo – làm nhẹ lại */
.card[class*="border-"]:not(.border-0) { border-color: var(--ui-border) !important; }
.card.border-danger { border-color: #F2C5C1 !important; }
.card.border-warning { border-color: #F1D9B0 !important; }

/* Thẻ số liệu dạng .card.text-bg-* / .card.bg-* của Bootstrap -> thẻ trắng */
.card.text-white[class*="bg-"],
.card[class*="text-bg-"] {
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
}
.card.text-white[class*="bg-"] :is(.text-white, h1, h2, h3, h4, h5, h6, p, small, .card-title),
.card[class*="text-bg-"] :is(.text-white, h1, h2, h3, h4, h5, h6, p, small, .card-title) {
  color: inherit !important;
}

/* ===== Nút bấm =====
   Chỉ nút chính (.btn-primary) là đặc màu nhấn. Nút xanh lá/vàng/xanh nhạt
   trước đây dùng để trang trí (Nhập Excel, Cập nhật ngân hàng...) nay là nút
   nền nhạt, còn nút xóa (.btn-danger) vẫn đặc đỏ vì là thao tác nguy hiểm. */
.btn {
  --bs-btn-font-family: var(--ui-font);
  --bs-btn-font-size: 14px;
  --bs-btn-font-weight: 500;
  --bs-btn-padding-y: 7px;
  --bs-btn-padding-x: 14px;
  --bs-btn-border-radius: var(--ui-radius);
  --bs-btn-border-width: 1px;
  --bs-btn-box-shadow: none;
  --bs-btn-focus-box-shadow: 0 0 0 3px var(--ui-accent-ring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.btn:disabled, .btn.disabled { cursor: not-allowed; }

/* Khoảng cách icon - chữ đã có `gap` ở trên; view nào còn gắn me-1/me-2 lên
   icon thì thành cách gấp đôi */
.btn > :is(i, .fas, .far, .fab, .fa):is(.me-1, .me-2) { margin-right: 0 !important; }

.btn-sm {
  --bs-btn-font-size: 13px;
  --bs-btn-padding-y: 4px;
  --bs-btn-padding-x: 10px;
  --bs-btn-border-radius: var(--ui-radius-sm);
  gap: 4px;
}

.btn-lg {
  --bs-btn-font-size: 15px;
  --bs-btn-padding-y: 10px;
  --bs-btn-padding-x: 20px;
}

.btn-primary {
  --bs-btn-color: #FFFFFF;
  --bs-btn-bg: var(--ui-accent);
  --bs-btn-border-color: var(--ui-accent);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: var(--ui-accent-hover);
  --bs-btn-hover-border-color: var(--ui-accent-hover);
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: #1F47B3;
  --bs-btn-active-border-color: #1F47B3;
  --bs-btn-disabled-color: #FFFFFF;
  --bs-btn-disabled-bg: var(--ui-accent);
  --bs-btn-disabled-border-color: var(--ui-accent);
}

.btn-secondary,
.btn-light,
.btn-outline-secondary,
.btn-outline-dark,
.btn-outline-light {
  --bs-btn-color: var(--ui-text);
  --bs-btn-bg: var(--ui-surface);
  --bs-btn-border-color: var(--ui-border-strong);
  --bs-btn-hover-color: var(--ui-text);
  --bs-btn-hover-bg: var(--ui-surface-2);
  --bs-btn-hover-border-color: #B9C0C8;
  --bs-btn-active-color: var(--ui-text);
  --bs-btn-active-bg: var(--ui-surface-3);
  --bs-btn-active-border-color: #B9C0C8;
  --bs-btn-disabled-color: var(--ui-faint);
  --bs-btn-disabled-bg: var(--ui-surface);
  --bs-btn-disabled-border-color: var(--ui-border);
}

.btn-dark {
  --bs-btn-color: #FFFFFF;
  --bs-btn-bg: var(--ui-side-bg);
  --bs-btn-border-color: var(--ui-side-bg);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: #2A2F38;
  --bs-btn-hover-border-color: #2A2F38;
}

.btn-success {
  --bs-btn-color: var(--ui-success-text);
  --bs-btn-bg: var(--ui-success-soft);
  --bs-btn-border-color: var(--ui-success-soft);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: var(--ui-success);
  --bs-btn-hover-border-color: var(--ui-success);
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-success-text);
  --bs-btn-active-border-color: var(--ui-success-text);
  --bs-btn-disabled-color: var(--ui-success-text);
  --bs-btn-disabled-bg: var(--ui-success-soft);
  --bs-btn-disabled-border-color: var(--ui-success-soft);
}

.btn-warning {
  --bs-btn-color: var(--ui-warning-text);
  --bs-btn-bg: var(--ui-warning-soft);
  --bs-btn-border-color: var(--ui-warning-soft);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: var(--ui-warning);
  --bs-btn-hover-border-color: var(--ui-warning);
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-warning-text);
  --bs-btn-active-border-color: var(--ui-warning-text);
  --bs-btn-disabled-color: var(--ui-warning-text);
  --bs-btn-disabled-bg: var(--ui-warning-soft);
  --bs-btn-disabled-border-color: var(--ui-warning-soft);
}

.btn-info {
  --bs-btn-color: var(--ui-info-text);
  --bs-btn-bg: var(--ui-info-soft);
  --bs-btn-border-color: var(--ui-info-soft);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: var(--ui-info);
  --bs-btn-hover-border-color: var(--ui-info);
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-info-text);
  --bs-btn-active-border-color: var(--ui-info-text);
  --bs-btn-disabled-color: var(--ui-info-text);
  --bs-btn-disabled-bg: var(--ui-info-soft);
  --bs-btn-disabled-border-color: var(--ui-info-soft);
}

.btn-danger {
  --bs-btn-color: #FFFFFF;
  --bs-btn-bg: var(--ui-danger);
  --bs-btn-border-color: var(--ui-danger);
  --bs-btn-hover-color: #FFFFFF;
  --bs-btn-hover-bg: #B8322A;
  --bs-btn-hover-border-color: #B8322A;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: #9E2A23;
  --bs-btn-active-border-color: #9E2A23;
  --bs-btn-disabled-color: #FFFFFF;
  --bs-btn-disabled-bg: var(--ui-danger);
  --bs-btn-disabled-border-color: var(--ui-danger);
}

/* Nút viền: nền trắng, viền trung tính, chữ theo màu – để hàng nút trong
   bảng (sửa / xóa / xem) không thành một dải viền xanh đỏ vàng. */
.btn-outline-primary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-info {
  --bs-btn-bg: var(--ui-surface);
  --bs-btn-border-color: var(--ui-border-strong);
  --bs-btn-disabled-bg: var(--ui-surface);
  --bs-btn-disabled-border-color: var(--ui-border);
}

.btn-outline-primary {
  --bs-btn-color: var(--ui-accent-text);
  --bs-btn-hover-color: var(--ui-accent-text);
  --bs-btn-hover-bg: var(--ui-accent-soft);
  --bs-btn-hover-border-color: #B7C9F6;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-accent);
  --bs-btn-active-border-color: var(--ui-accent);
  --bs-btn-disabled-color: var(--ui-accent-text);
}

.btn-outline-success {
  --bs-btn-color: var(--ui-success-text);
  --bs-btn-hover-color: var(--ui-success-text);
  --bs-btn-hover-bg: var(--ui-success-soft);
  --bs-btn-hover-border-color: #A9D8BB;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-success);
  --bs-btn-active-border-color: var(--ui-success);
  --bs-btn-disabled-color: var(--ui-success-text);
}

.btn-outline-warning {
  --bs-btn-color: var(--ui-warning-text);
  --bs-btn-hover-color: var(--ui-warning-text);
  --bs-btn-hover-bg: var(--ui-warning-soft);
  --bs-btn-hover-border-color: #EBCB94;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-warning);
  --bs-btn-active-border-color: var(--ui-warning);
  --bs-btn-disabled-color: var(--ui-warning-text);
}

.btn-outline-danger {
  --bs-btn-color: var(--ui-danger-text);
  --bs-btn-hover-color: var(--ui-danger-text);
  --bs-btn-hover-bg: var(--ui-danger-soft);
  --bs-btn-hover-border-color: #F0B7B2;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-danger);
  --bs-btn-active-border-color: var(--ui-danger);
  --bs-btn-disabled-color: var(--ui-danger-text);
}

.btn-outline-info {
  --bs-btn-color: var(--ui-info-text);
  --bs-btn-hover-color: var(--ui-info-text);
  --bs-btn-hover-bg: var(--ui-info-soft);
  --bs-btn-hover-border-color: #A8D6E8;
  --bs-btn-active-color: #FFFFFF;
  --bs-btn-active-bg: var(--ui-info);
  --bs-btn-active-border-color: var(--ui-info);
  --bs-btn-disabled-color: var(--ui-info-text);
}

.btn-link {
  --bs-btn-color: var(--ui-accent-text);
  --bs-btn-hover-color: #173EA6;
  text-decoration: none;
}

/* Nhóm nút: dính liền, không nhảy lên khi rê chuột */
.btn-group > .btn { box-shadow: none; }
.btn-group > .btn:hover { z-index: 1; }

/* Nút trong bảng: chữ không được xuống dòng (cột thao tác hẹp sẽ bóp chữ
   thành 2-3 dòng tràn khỏi nút). Không ép bề ngang cố định cho nút "chỉ có
   icon": CSS không phân biệt được nút có chữ đi kèm (chữ là text node, không
   phải phần tử), ép 30px là cắt cụt nút "Phân quyền", "Đổi MK". */
.table .btn { white-space: nowrap; }
.table .btn-sm { min-height: 30px; }

/* Nút đang xử lý (app.js gắn .loading khi bấm) */
.loading { opacity: .6; pointer-events: none; }
.btn.loading { position: relative; }
.btn.loading::after {
  content: '';
  width: 12px;
  height: 12px;
  margin-left: 4px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ui-spin .8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ===== Nhãn ===== */
.badge {
  --bs-badge-font-size: 12px;
  --bs-badge-font-weight: 500;
  --bs-badge-padding-y: 3px;
  --bs-badge-padding-x: 8px;
  --bs-badge-border-radius: var(--ui-radius-sm);
  letter-spacing: 0;
  vertical-align: middle;
  line-height: 1.4;
}

.badge.rounded-pill { --bs-badge-border-radius: 999px; }

/* Nhãn đặc màu -> nền nhạt chữ đậm: bảng có hàng trăm nhãn, đặc màu thì
   trang nào cũng loang lổ. Nhãn đếm ở menu trái vẫn giữ đặc (xem trên). */
.badge.bg-primary, .badge.text-bg-primary { background: var(--ui-accent-soft) !important; color: var(--ui-accent-text) !important; }
.badge.bg-success, .badge.text-bg-success { background: var(--ui-success-soft) !important; color: var(--ui-success-text) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--ui-warning-soft) !important; color: var(--ui-warning-text) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--ui-danger-soft) !important; color: var(--ui-danger-text) !important; }
.badge.bg-info, .badge.text-bg-info { background: var(--ui-info-soft) !important; color: var(--ui-info-text) !important; }
.badge.bg-secondary, .badge.text-bg-secondary,
.badge.bg-light, .badge.text-bg-light { background: var(--ui-neutral-soft) !important; color: var(--ui-text-2) !important; }
.badge.bg-dark, .badge.text-bg-dark { background: var(--ui-side-bg) !important; color: #FFFFFF !important; }

.badge-primary { background: var(--ui-accent-soft); color: var(--ui-accent-text); }
.badge-success { background: var(--ui-success-soft); color: var(--ui-success-text); }
.badge-warning { background: var(--ui-warning-soft); color: var(--ui-warning-text); }
.badge-danger  { background: var(--ui-danger-soft);  color: var(--ui-danger-text); }

/* ===== Thông báo ===== */
.alert {
  --bs-alert-padding-y: 11px;
  --bs-alert-padding-x: 14px;
  --bs-alert-border-radius: 10px;
  font-size: 14px;
  font-weight: 400;
  border: 1px solid transparent;
}

.alert-success { background: var(--ui-success-soft); color: #145F3A; border-color: #CBE8D6; }
.alert-warning { background: var(--ui-warning-soft); color: #7D4808; border-color: #F3DDB4; }
.alert-danger  { background: var(--ui-danger-soft);  color: #8F2219; border-color: #F5CDC9; }
.alert-info,
.alert-primary { background: var(--ui-accent-soft);  color: #173EA6; border-color: #D3DFFB; }
.alert-secondary,
.alert-light   { background: var(--ui-surface-2);    color: var(--ui-text-2); border-color: var(--ui-border); }
.alert .alert-link { color: inherit; }

/* ===== Bảng =====
   --tbl-pad-y / --tbl-pad-x là chỗ duy nhất chỉnh mật độ ô cho toàn hệ
   thống; .table-sm (133 view) rút nhỏ lại qua chính hai biến này. */
.table {
  --tbl-pad-y: 10px;
  --tbl-pad-x: 12px;
  --bs-table-bg: var(--ui-surface);
  --bs-table-color: var(--ui-text);
  --bs-table-border-color: var(--ui-surface-3);
  --bs-table-striped-bg: #FAFBFC;
  --bs-table-striped-color: var(--ui-text);
  --bs-table-hover-bg: #F5F8FF;
  --bs-table-hover-color: var(--ui-text);
  --bs-table-active-bg: var(--ui-accent-soft);
  font-size: 14px;
  color: var(--ui-text);
  /* Không đặt overflow ở đây: overflow khác visible biến chính thẻ table thành
     một khung cuộn, khiến position:sticky của cột ghim tính theo table thay vì
     theo .table-responsive nên cột đứng im và bị nội dung trượt qua. */
}

.table-sm {
  --tbl-pad-y: 6px;
  --tbl-pad-x: 8px;
  font-size: 13.5px;
}

.table > :not(caption) > * > * {
  padding: var(--tbl-pad-y) var(--tbl-pad-x);
  border-bottom-color: var(--ui-surface-3);
}

.table > thead > tr > th,
.table > thead > tr > td {
  background: var(--ui-surface-2);
  color: var(--ui-muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  border-bottom: 1px solid var(--ui-border);
  vertical-align: middle;
  /* Không in hoa: tiêu đề tiếng Việt in hoa rộng hơn hẳn, lại khó đọc */
  text-transform: none;
  letter-spacing: 0;
}

.table > tbody > tr > td { vertical-align: middle; }
.table > tbody > tr:hover > * { --bs-table-bg-state: #F5F8FF; }

.table > tfoot > tr > * {
  background: var(--ui-surface-2);
  font-weight: 600;
  border-top: 1px solid var(--ui-border);
  border-bottom: 0;
}

/* Bảng trong thẻ: bỏ viền dòng cuối cho khỏi trùng viền thẻ */
.card .table > tbody > tr:last-child > * { border-bottom: 0; }

/* Bảng có kẻ ô (.table-bordered): viền nhạt đều */
.table-bordered > :not(caption) > * > * { border-color: var(--ui-border); }

/* Hàng tô màu (.table-success...) nhạt lại theo bảng màu mới */
.table-success { --bs-table-bg: var(--ui-success-soft); --bs-table-color: var(--ui-text); }
.table-warning { --bs-table-bg: var(--ui-warning-soft); --bs-table-color: var(--ui-text); }
.table-danger  { --bs-table-bg: var(--ui-danger-soft);  --bs-table-color: var(--ui-text); }
.table-info    { --bs-table-bg: var(--ui-info-soft);    --bs-table-color: var(--ui-text); }
.table-primary { --bs-table-bg: var(--ui-accent-soft);  --bs-table-color: var(--ui-text); }
.table-secondary, .table-light { --bs-table-bg: var(--ui-surface-2); --bs-table-color: var(--ui-text); }
.table-dark { --bs-table-bg: var(--ui-side-bg); --bs-table-color: #FFFFFF; }
.table > thead.table-dark > tr > *,
.table > thead > tr.table-dark > * { background: var(--ui-side-bg); color: #E6E8EC; border-color: #2A2F38; }
.table > thead.table-light > tr > * { background: var(--ui-surface-2); }

/* Chữ dài trong ô bảng (ghi chú, mô tả) không được kéo giãn bảng vô hạn */
.table td.text-wrap-cell {
  white-space: normal;
  min-width: 160px;
  max-width: 360px;
}

/* ===== Khung cuộn của bảng rộng =====
   Bảng nào thật sự không thể vừa khung thì phải cuộn TRONG thẻ card, không
   được đẩy giãn cả trang. Mọi view có bảng đều phải bọc .table-responsive. */
.table-responsive {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
/* Khung có giới hạn chiều cao (style="max-height:…") thì phải cuộn dọc được,
   không thì phần dưới bị cắt mất (Hợp đồng sắp hết hạn, 6/10/2026). */
.table-responsive[style*="max-height"] { overflow-y: auto; }

.table-responsive > .table { margin-bottom: 0; }

/* Thanh cuộn ngang mảnh, luôn thấy được để người dùng biết còn cột bên phải */
.table-responsive::-webkit-scrollbar { height: 10px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--ui-border-strong); border-radius: 5px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: var(--ui-faint); }

/* ===== Ghim cột đầu cho bảng quá rộng =====
   Bảng lương và báo cáo chấm công có 30-80 cột, không cách nào vừa màn hình.
   Kéo ngang tới cột thứ 30 thì không còn biết đang xem của ai, nên các cột
   nhận dạng (mã, họ tên) được ghim lại ở mép trái.

   Cách dùng: đặt `data-stick-cols="2"` trên thẻ <table>, bên trong một
   .table-responsive (bắt buộc - sticky tính theo khung cuộn gần nhất).

   Vị trí `left` do JS gán (xem setupStickyTableColumns trong assets/js/app.js)
   vì bề ngang cột phụ thuộc dữ liệu thật, và nhiều bảng có cột hiện theo điều
   kiện (bảng chấm công ẩn 2 cột chọn khi kỳ đã khóa) nên không thể đoán
   trước bằng CSS. JS đo bề ngang đã render rồi mới tính offset. */
.table[data-stick-cols] > thead > tr:first-child > .is-stuck,
.table[data-stick-cols] > tbody > tr > .is-stuck,
.table[data-stick-cols] > tfoot > tr > .is-stuck {
  position: sticky;
  z-index: 3;
}

/* Ô tiêu đề phải nổi trên ô thân khi cuộn cả hai chiều */
.table[data-stick-cols] > thead > tr:first-child > .is-stuck { z-index: 4; }

/* Ô ghim bắt buộc phải đục, nếu không chữ các cột đang trượt sẽ chồng xuyên qua */
.table[data-stick-cols] > tbody > tr > .is-stuck { background-color: var(--ui-surface); }

.table[data-stick-cols] > thead > tr:first-child > .is-stuck,
.table[data-stick-cols] > tfoot > tr > .is-stuck,
.table-striped[data-stick-cols] > tbody > tr:nth-of-type(odd) > .is-stuck {
  background-color: var(--ui-surface-2);
}

/* Vạch phân cách giữa phần ghim và phần đang trượt.
   Vẽ bằng ::after chứ không bằng box-shadow: Bootstrap dùng chính box-shadow
   inset để tô màu sọc của .table-striped, đặt box-shadow ở đây là xoá sọc của
   đúng ô đó. Ô ghim đã là position:sticky nên ::after định vị được ngay. */
.table[data-stick-cols] .is-stuck-last { position: sticky; }

.table[data-stick-cols] .is-stuck-last::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: var(--ui-border-strong);
  pointer-events: none;
}

/* Thẻ card chỉ chứa bảng thì thu hẹp đệm hai bên, trả bề ngang lại cho bảng */
.card-body:has(> .table-responsive),
.card-body:has(> .table) {
  padding-left: 12px;
  padding-right: 12px;
}

/* ===== Ô nhập ===== */
.form-control,
.form-select {
  font-family: var(--ui-font);
  font-size: 14px;
  padding: 7px 11px;
  color: var(--ui-text);
  background-color: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius);
  transition: border-color .12s ease, box-shadow .12s ease;
}

.form-select { padding-right: 2.25rem; } /* chừa chỗ cho mũi tên */

.form-control::placeholder { color: var(--ui-faint); }

.form-control:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) { border-color: #B9C0C8; }

.form-control:focus,
.form-select:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-ring);
  outline: none;
}

.form-control:disabled, .form-select:disabled,
.form-control[readonly] { background-color: var(--ui-surface-2); color: var(--ui-text-2); }

.form-control.form-control-sm,
.form-select.form-select-sm {
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 13.5px;
  min-height: 32px;
  border-radius: var(--ui-radius-sm);
}

.form-control.form-control-sm { padding-left: 9px; padding-right: 9px; }
.form-select.form-select-sm { padding-left: 9px; padding-right: 2rem; }

.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--ui-danger);
  box-shadow: 0 0 0 3px rgba(210, 59, 47, .15);
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ui-text);
  margin-bottom: 5px;
}

.form-text { font-size: 12.5px; color: var(--ui-muted); }

.form-check-input { border-color: var(--ui-border-strong); }
.form-check-input:checked { background-color: var(--ui-accent); border-color: var(--ui-accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--ui-accent-ring); border-color: var(--ui-accent); }

.input-group-text {
  background: var(--ui-surface-2);
  border-color: var(--ui-border-strong);
  color: var(--ui-muted);
  font-size: 14px;
}

/* ===== Thanh lọc / thêm nhanh trên MỘT hàng =====
   Đặt class form-bar lên thẻ <form> (hoặc khối bọc các ô). Mỗi ô con là một
   khối nhãn + input co giãn chia đều bề ngang; ô nào cần rộng hơn thêm
   .fb-wide, ô nhỏ (số lượng, năm) thêm .fb-sm, nút bấm thêm .fb-auto.
   Màn hẹp (< 992px) mới cho xuống hàng, để khỏi phải kéo ngang. */
.form-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
}

.form-bar > * {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  max-width: none;
  padding: 0;
  margin: 0;
}

.form-bar > .fb-wide { flex-grow: 2; }
.form-bar > .fb-sm { flex: 0 0 90px; }
.form-bar > .fb-auto,
.form-bar > .btn,
.form-bar > button,
.form-bar > a.btn { flex: 0 0 auto; }

.form-bar .form-label,
.form-bar label.small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--ui-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-bar .btn { white-space: nowrap; }

/* Nút cao bằng ô nhập đứng cạnh */
.form-bar .btn { min-height: 36px; }
.form-bar .btn-sm { min-height: 32px; }

/* Thanh lọc đứng riêng (không nằm trong thẻ) thì tự làm thành một dải trắng */
.main-content > form.form-bar,
.main-content > .row > .col-12 > form.form-bar {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  padding: 12px 14px;
}

/* ===== Menu sổ ===== */
.dropdown-menu {
  --bs-dropdown-font-size: 14px;
  --bs-dropdown-color: var(--ui-text);
  --bs-dropdown-border-color: var(--ui-border);
  --bs-dropdown-border-radius: 10px;
  --bs-dropdown-box-shadow: var(--ui-shadow-lg);
  --bs-dropdown-padding-y: 4px;
  --bs-dropdown-link-color: var(--ui-text);
  --bs-dropdown-link-hover-bg: var(--ui-surface-3);
  --bs-dropdown-link-hover-color: var(--ui-text);
  --bs-dropdown-link-active-bg: var(--ui-accent-soft);
  --bs-dropdown-link-active-color: var(--ui-accent-text);
  --bs-dropdown-item-padding-x: 12px;
  --bs-dropdown-item-padding-y: 7px;
  box-shadow: var(--ui-shadow-lg);
  z-index: 1050;
}

.dropdown-item {
  display: flex;
  align-items: center;
  border-radius: var(--ui-radius-sm);
  margin: 0 4px;
  width: calc(100% - 8px);
}

.dropdown-item i { width: 16px; text-align: center; color: var(--ui-faint); margin-right: 8px; }
.dropdown-item.me-2 i, .dropdown-item i.me-2 { margin-right: 8px !important; }
.dropdown-header { font-size: 12px; font-weight: 600; color: var(--ui-muted); }

/* Menu con nhiều tầng (initSubmenus trong app.js) */
.dropdown-submenu { position: relative; }
.dropdown-submenu .dropdown-menu { top: 0; left: 100%; margin-left: 2px; }

/* ===== Hộp thoại ===== */
.modal-content {
  border: 0;
  border-radius: 14px;
  box-shadow: var(--ui-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--ui-border);
  padding: 14px 20px;
}

.modal-header[class*="bg-"] { background: var(--ui-surface) !important; color: var(--ui-text) !important; }
.modal-header[class*="bg-"] .btn-close-white { filter: none; }

.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top: 1px solid var(--ui-border); padding: 12px 20px; background: var(--ui-surface-2); border-radius: 0 0 14px 14px; }
.modal-backdrop.show { opacity: .45; }

/* Popup dùng chung (app.js, link data-popup): trang form nằm gọn trong hộp */
.app-popup-body .form-bar { flex-wrap: wrap; }
.app-popup-body .form-bar > div { flex: 1 1 100%; }
.app-popup-body .form-bar > .btn,
.app-popup-body .form-bar > button,
.app-popup-body .form-bar > a.btn { flex: 0 0 auto; }
.app-popup-body > .card, .app-popup-body > form > .card { border: 0; box-shadow: none; }
.app-popup-body > .card > .card-body, .app-popup-body > form > .card > .card-body { padding: 0; }
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen-sm-down) { margin: 8px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .modal-footer > .btn { flex: 1 1 auto; }
}

/* ===== Linh tinh của Bootstrap ===== */
.list-group { --bs-list-group-border-color: var(--ui-border); --bs-list-group-action-hover-bg: var(--ui-surface-2); }
.list-group-item.active { background: var(--ui-accent-soft); color: var(--ui-accent-text); border-color: var(--ui-border); }

.pagination {
  --bs-pagination-color: var(--ui-text-2);
  --bs-pagination-border-color: var(--ui-border);
  --bs-pagination-hover-bg: var(--ui-surface-2);
  --bs-pagination-hover-color: var(--ui-text);
  --bs-pagination-active-bg: var(--ui-accent);
  --bs-pagination-active-border-color: var(--ui-accent);
  --bs-pagination-font-size: 14px;
}

.progress {
  --bs-progress-bg: var(--ui-surface-3);
  --bs-progress-border-radius: 999px;
  --bs-progress-bar-bg: var(--ui-accent);
}

.accordion {
  --bs-accordion-border-color: var(--ui-border);
  --bs-accordion-active-bg: var(--ui-surface-2);
  --bs-accordion-active-color: var(--ui-text);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 3px var(--ui-accent-ring);
}

.nav-link { color: var(--ui-accent-text); }

/* Nền màu tiện ích của Bootstrap dùng làm khối thông tin -> nhạt lại */
.bg-light { background-color: var(--ui-surface-2) !important; }

/* ===== Lịch & chấm công ===== */
.day-sun { background-color: var(--ui-surface-3); }
.day-holiday { background-color: var(--ui-danger-soft); }
.day-leave-approved { background-color: var(--ui-accent-soft); }
.day-leave-unapproved { background-color: var(--ui-warning-soft); }

.table td.day-sun, .table th.day-sun { background-color: var(--ui-surface-3) !important; }
.table td.day-holiday, .table th.day-holiday { background-color: var(--ui-danger-soft) !important; }
.table td.day-leave-approved, .table th.day-leave-approved { background-color: var(--ui-accent-soft) !important; }
.table td.day-leave-unapproved, .table th.day-leave-unapproved { background-color: var(--ui-warning-soft) !important; }

/* ===== Thông báo (chuông ở menu trái) ===== */
.notification-dropdown {
  min-width: 360px;
  max-width: 400px;
  border-radius: 12px;
  overflow: hidden;
}

.notification-dropdown .dropdown-header {
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ui-text);
}

.notification-dropdown .dropdown-footer {
  background: var(--ui-surface-2);
  border-top: 1px solid var(--ui-border);
}

#notificationList { max-height: 400px; overflow-y: auto; }

.notification-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ui-surface-3);
}

.notification-item:hover { background: var(--ui-surface-2); }
.notification-item:last-child { border-bottom: 0; }
.notification-content { font-size: 14px; color: var(--ui-text); line-height: 1.45; }
.notification-time { font-size: 12px; color: var(--ui-muted); margin-top: 4px; }

/* ===== Ảnh đại diện ===== */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3A4150;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
}

.user-avatar-table {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--ui-border);
}

.user-avatar-placeholder-table {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin: 0 auto;
}

/* ===== Thẻ trạng thái công việc (trang chủ) ===== */
.status-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.status-card:hover { border-color: var(--ui-border-strong); }
.status-card.selected { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-ring); }
.status-card .status-count { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ui-text); }
.status-card .status-label { font-size: 13px; font-weight: 500; color: var(--ui-muted); }
.status-card .status-icon { font-size: 18px; }
.status-pending .status-icon { color: var(--ui-faint); }
.status-in-progress .status-icon { color: var(--ui-accent); }
.status-completed .status-icon { color: var(--ui-success); }
.status-cancelled .status-icon { color: var(--ui-danger); }

.task-card {
  border-radius: var(--ui-radius-lg);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
}

/* ===== Nhật ký nhập file ===== */
.import-log {
  max-height: 300px;
  overflow-y: auto;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 12px;
  font-family: var(--ui-font-mono);
  font-size: 12.5px;
}

.import-log .log-item { padding: 3px 0; border-bottom: 1px solid var(--ui-surface-3); }
.import-log .log-item:last-child { border-bottom: 0; }

/* ===== Hộp chốt sản lượng (production_balance/balance) ===== */
.pb-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 2000; }

.pb-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 90vw);
  max-height: 80vh;
  background: var(--ui-surface);
  border-radius: 14px;
  box-shadow: var(--ui-shadow-lg);
  display: flex;
  flex-direction: column;
}

.pb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ui-border);
}

.pb-close { background: transparent; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ui-muted); }
.pb-body { padding: 16px 20px; overflow: auto; }

/* ===== Thanh ngang cho khách chưa đăng nhập ===== */
.app-topbar {
  background: var(--ui-surface) !important;
  border-bottom: 1px solid var(--ui-border);
  padding: 12px 0;
}

.app-topbar .navbar-brand { font-weight: 600; font-size: 17px; color: var(--ui-text); }

/* ===== Thanh cuộn chung ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ui-border-strong); border-radius: 5px; border: 2px solid var(--ui-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ui-faint); }
.app-sidebar ::-webkit-scrollbar-thumb { background: #343A45; border-color: var(--ui-side-bg); }

/* ===== Màn hình hẹp ===== */
@media (max-width: 991.98px) {
  :root { --page-pad-x: 16px; }

  /* Cột trái trượt ra đè lên nội dung */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* Đặt thẳng 100vh chứ không dựa vào top/bottom: cột này là con định vị
       tuyệt đối của một flex container nên align-self chặn không cho nó giãn */
    height: 100vh;
    height: 100dvh;
    z-index: 1030;
    box-shadow: var(--ui-shadow-lg);
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

  .app-sidebar.show { transform: translateX(0); }
  .app-sidebar-backdrop.show { display: block; }
  .app-sidebar-collapse { display: none; }

  /* Chừa chỗ cho nút ba gạch nổi ở góc trái */
  .main-content { padding-top: calc(60px + env(safe-area-inset-top)); }
  .app-sidebar-toggle { top: calc(10px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); }
  .app-sidebar-footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  .form-bar { flex-wrap: wrap; }
  .form-bar > * { flex: 1 1 140px; }
  .form-bar > .fb-sm { flex: 0 0 90px; }
  .form-bar > .fb-auto,
  .form-bar > .btn,
  .form-bar > button,
  .form-bar > a.btn { flex: 0 0 auto; }
}

/* Laptop nhỏ và máy tính bảng nằm ngang: thu hẹp cột trái và lề, giữ nguyên
   nhãn - trả bề ngang cho thanh tab (Sản xuất, Quản trị cần 2 hàng ở 1280px) */
@media (min-width: 992px) and (max-width: 1365.98px) {
  :root { --app-sidebar-width: 216px; --page-pad-x: 20px; }
  .app-sidebar-nav .nav-link { gap: 10px; padding: 0 10px; }
}

@media (max-width: 767.98px) {
  .card-body { padding: 14px; }

  /* Trên điện thoại rút tiếp mật độ ô; đặt qua biến để .table-sm vẫn nhỏ hơn */
  .table { --tbl-pad-y: 8px; --tbl-pad-x: 8px; }
  .table-sm { --tbl-pad-y: 5px; --tbl-pad-x: 6px; }

  .card-body:has(> .table-responsive),
  .card-body:has(> .table) { padding-left: 8px; padding-right: 8px; }

  .notification-dropdown { min-width: 300px; max-width: 320px; }

  /* Hàng tiêu đề trang + nút: tiêu đề chiếm trọn hàng, nút xuống dưới */
  .main-content > .d-flex:first-child,
  .main-content > .row:first-child > .col-12 > .d-flex:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }
  .main-content > .d-flex:first-child > :first-child,
  .main-content > .row:first-child > .col-12 > .d-flex:first-child > :first-child {
    flex: 1 1 100%;
  }
  /* Cũng vậy với tiêu đề nằm sau khối <style> riêng của trang, trong
     .container(-fluid), và mọi hàng d-flex của card-header / thanh nút */
  .main-content > style + .d-flex,
  .main-content > :is(.container, .container-fluid) > .d-flex:first-child,
  .main-content > :is(.container, .container-fluid) > .row:first-child > .col-12 > .d-flex:first-child,
  .card-header.d-flex,
  .card-header > .d-flex,
  .main-content form.d-flex,
  .main-content .d-flex:not(.flex-nowrap):has(> .btn, > form, > select, > input, > .btn-group) {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .main-content > style + .d-flex > :first-child:is(h1, h2, h3, h4, h5, div),
  .main-content > :is(.container, .container-fluid) > .d-flex:first-child > :first-child,
  .main-content > :is(.container, .container-fluid) > .row:first-child > .col-12 > .d-flex:first-child > :first-child {
    flex: 1 1 100%;
  }
  .main-content :is(h1, h2, .h2):first-child { font-size: 1.25rem; }
  .main-content h3:first-child { font-size: 1.15rem; }

  /* Nút / huy hiệu cỡ chữ rất nhỏ của từng trang: đủ lớn để chạm */
  .main-content .btn.btn-sm { min-height: 32px; }
  .main-content .btn-group { flex-wrap: wrap; }

  /* Kế hoạch sản xuất: cột tên chuyền hẹp lại và đứng yên khi kéo ngang */
  .pb-line-col { width: 96px !important; flex: 0 0 96px !important; position: sticky; left: 0; z-index: 2; background: var(--ui-surface); }

  /* Ô chữ trong lưới nhập nhỏ: vẫn 16px để iOS khỏi phóng to */
  .main-content table input.form-control,
  .main-content table select.form-select { font-size: 16px; }

  /* iOS tự phóng to khi chạm vào ô chữ dưới 16px */
  .form-control, .form-select,
  .form-control.form-control-sm, .form-select.form-select-sm { font-size: 16px; }

  /* Nút đủ lớn để chạm */
  .btn { --bs-btn-padding-y: 9px; }
  .btn-sm { --bs-btn-padding-y: 6px; }
}

/* ===== In ===== */
@media print {
  .app-sidebar,
  .app-sidebar-backdrop,
  .app-sidebar-toggle,
  .btn,
  .dropdown-menu { display: none !important; }

  body { background: #FFFFFF; }
  .main-content { padding: 0; }
  .card { border: 1px solid #DDD; }
}

/* ---- Ô chọn có tìm kiếm (attachCombo trong app.js) ---- */
.ui-combo { position: relative; }
.ui-combo.d-inline-block { min-width: 200px; vertical-align: middle; }
.ui-combo-native {
  position: absolute !important; left: 0; bottom: 0; width: 100% !important;
  height: 1px !important; min-height: 0 !important; opacity: 0; pointer-events: none;
  padding: 0 !important; border: 0 !important;
}
.ui-combo-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  cursor: text; height: auto; line-height: 1.5;
}
.ui-combo-input { height: 1.5em; }
.ui-combo-multi .ui-combo-box { padding-top: 5px; padding-bottom: 5px; min-height: calc(1.5em + 16px); }
.ui-combo-multi .form-select-sm.ui-combo-box { padding-top: 3px; padding-bottom: 3px; min-height: 32px; }
.ui-combo.is-open .ui-combo-box {
  border-color: var(--ui-accent); box-shadow: 0 0 0 .2rem var(--ui-accent-ring);
}
.ui-combo.is-disabled .ui-combo-box { background-color: var(--ui-surface-3); cursor: default; }
.ui-combo-chips { display: contents; }
.ui-combo-input {
  flex: 1 1 60px; min-width: 60px; border: 0; outline: 0; padding: 0;
  background: transparent; color: inherit; font: inherit;
}
.ui-combo-input::placeholder { color: var(--ui-faint); }
.ui-combo-chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 1px 4px 1px 8px; border-radius: var(--ui-radius-sm);
  background: var(--ui-accent-soft); color: var(--ui-accent-text);
  font-size: .85em; line-height: 1.4; white-space: nowrap;
}
.ui-combo-chip-x {
  border: 0; background: transparent; color: inherit; padding: 0 4px;
  font-size: 1.1em; line-height: 1; cursor: pointer; opacity: .7;
}
.ui-combo-chip-x:hover { opacity: 1; }
.ui-combo-menu {
  display: none; position: fixed; z-index: 1090; overflow-y: auto;
  max-width: min(520px, calc(100vw - 8px));
  background: var(--ui-surface); border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius); box-shadow: var(--ui-shadow-lg); padding: 4px;
}
.ui-combo.is-open .ui-combo-menu { display: block; }
.ui-combo-opt {
  padding: 6px 10px; border-radius: var(--ui-radius-sm); cursor: pointer;
  color: var(--ui-text); font-size: .925rem;
}
.ui-combo-opt.is-active { background: var(--ui-surface-3); }
.ui-combo-opt.is-selected { color: var(--ui-accent-text); font-weight: 600; }
.ui-combo-multi .ui-combo-opt { padding-left: 30px; position: relative; }
.ui-combo-multi .ui-combo-opt::before {
  content: ''; position: absolute; left: 9px; top: 50%; width: 14px; height: 14px;
  margin-top: -7px; border: 1.5px solid var(--ui-border-strong); border-radius: 3px;
}
.ui-combo-multi .ui-combo-opt.is-selected::before {
  background: var(--ui-accent); border-color: var(--ui-accent);
  box-shadow: inset 0 0 0 2px var(--ui-surface);
}
.ui-combo-opt.is-disabled { color: var(--ui-faint); cursor: not-allowed; }
.ui-combo-group {
  padding: 8px 10px 2px; font-size: .75rem; font-weight: 600;
  color: var(--ui-muted); text-transform: uppercase; letter-spacing: .02em;
}
.ui-combo-empty { padding: 8px 10px; color: var(--ui-muted); font-size: .9rem; }
.ui-suggest-menu .ui-combo-opt { display: flex; gap: 10px; align-items: baseline; }
.ui-suggest-menu .ui-combo-opt > span:first-child { font-weight: 600; white-space: nowrap; }
.ui-suggest-desc { color: var(--ui-muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.input-group > .ui-combo { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .ui-combo:not(:last-child) .ui-combo-box { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .ui-combo:not(:first-child) .ui-combo-box { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

/* ===== Khu Group (quản trị tổng công ty) =====
   Menu trái riêng (_group_sidebar.php): logo chữ G màu tím để nhìn là biết
   đang ở Group chứ không phải trong một công ty. */
.app-sidebar--group .app-sidebar-logo { background: #6D4AE0; }
.app-sidebar-section-title {
  padding: 16px 12px 6px;
  color: var(--ui-side-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.app-sidebar-company-btn {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}
.app-sidebar-company-btn .side-go { margin-left: auto; opacity: .5; font-size: 11px; }
.app-sidebar-company-btn:hover .side-go { opacity: 1; }

/* Trong công ty, quản trị tổng công ty có lối về Group ngay dưới tên công ty */
.app-sidebar-group-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -8px 0 10px;
  flex-shrink: 0;
}
.app-sidebar-group-bar .side-back-top { width: auto; flex: 1 1 auto; }
.app-sidebar-group-bar .side-back-top[hidden] { display: none; }

/* Hàng icon đổi nhanh Group / công ty ở chân menu, ngay trên Thông báo (_company_switch.php) */
.app-sidebar-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 8px 10px;
}
.app-sidebar-switch-item {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  opacity: .6;
  transition: opacity .12s ease, transform .12s ease;
}
.app-sidebar-switch-item:hover, .app-sidebar-switch-item:focus-visible { opacity: 1; color: #FFFFFF; transform: translateY(-1px); }
.app-sidebar-switch-item.is-current { opacity: 1; box-shadow: 0 0 0 2px var(--ui-side-bg), 0 0 0 4px #FFFFFF; cursor: default; }

/* Chuông thông báo ở góc trên menu, bên trái nút thu gọn */
.app-sidebar-bell { position: absolute; top: 18px; right: 44px; z-index: 2; }
.app-sidebar-bell > .dropdown-toggle {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: var(--ui-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-side-text);
  font-size: 15px;
  text-decoration: none;
}
.app-sidebar-bell > .dropdown-toggle::after { display: none; }
.app-sidebar-bell > .dropdown-toggle:hover, .app-sidebar-bell > .dropdown-toggle:focus-visible { background: var(--ui-side-hover); color: #FFFFFF; }
.app-sidebar-bell .badge { position: absolute; top: -4px; right: -6px; }
.app-sidebar-bell .dropdown-menu { top: 100%; left: 0; margin-top: 6px; }
.app-sidebar:has(.app-sidebar-bell) .app-sidebar-brand { padding-right: 80px; }
@media (max-width: 991.98px) {
  .app-sidebar-bell { right: 10px; }
  .app-sidebar:has(.app-sidebar-bell) .app-sidebar-brand { padding-right: 46px; }
  /* Điện thoại: cột menu chỉ 248px, danh sách thông báo trải hết bề ngang cột */
  .app-sidebar-bell .dropdown-menu { position: fixed !important; top: 58px !important; left: 8px !important; right: 8px !important; min-width: 0; max-width: none; transform: none !important; }
  .app-sidebar-bell #notificationList { min-width: 0 !important; }
}

/* Nút báo lỗi / đề xuất sửa góc dưới bên phải mọi trang (layouts/_feedback.php) */
.fb-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 1040;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ui-border-strong);
  background: var(--ui-surface); color: var(--ui-text-2); box-shadow: 0 2px 8px rgba(16, 24, 40, .15);
  opacity: .75; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.fb-fab:hover, .fb-fab:focus-visible { opacity: 1; color: var(--ui-accent-text); border-color: var(--ui-accent); }
@media print { .fb-fab { display: none !important; } }
/* Nút Hỏi AI (G11, layouts/_ask_ai.php) — trên nút báo lỗi */
.ask-fab {
  position: fixed; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); z-index: 1040;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ui-border-strong);
  background: var(--ui-surface); color: var(--ui-accent-text); box-shadow: 0 2px 8px rgba(16, 24, 40, .15);
  opacity: .85; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.ask-fab:hover, .ask-fab:focus-visible, .ask-fab[aria-expanded="true"] { opacity: 1; border-color: var(--ui-accent); }
.ask-panel {
  position: fixed; right: 16px; bottom: calc(112px + env(safe-area-inset-bottom, 0px)); z-index: 1045;
  width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 560px); display: flex; flex-direction: column;
  background: var(--ui-surface); border: 1px solid var(--ui-border-strong); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .2);
}
.ask-panel[hidden] { display: none; }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--ui-border); }
.ask-head strong { flex: 1; font-size: 14px; }
.ask-log { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 13px; min-height: 60px; }
.ask-msg { margin-bottom: 8px; }
.ask-who { font-size: 11px; color: var(--ui-text-2); }
.ask-user .ask-body { background: var(--ui-surface-2, rgba(0,0,0,.04)); border-radius: 8px; padding: 6px 8px; white-space: pre-wrap; }
.ask-system .ask-body { color: var(--ui-text-2); font-style: italic; }
.ask-agent .ask-body table { font-size: 12px; }
.ask-form { padding: 8px 10px; border-top: 1px solid var(--ui-border); }
@media print { .ask-fab, .ask-panel { display: none !important; } }
/* Bong bóng Trợ lý AI cho Ban Giám đốc (layouts/_ai_widget.php) — góc dưới cùng; có bong bóng thì nút báo lỗi / Hỏi AI lên trên */
.aiw-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 1041;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--ui-accent); color: #fff; box-shadow: var(--ui-shadow-lg);
  display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.aiw-fab:hover, .aiw-fab:focus-visible { background: var(--ui-accent-hover); }
.aiw-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--ui-danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 20px; text-align: center;
  border: 2px solid var(--ui-surface);
}
.aiw-badge[hidden] { display: none; }
.aiw-on .fb-fab { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
.aiw-on .ask-fab { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }
.aiw-on .ask-panel { bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
.aiw-panel {
  position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 1046;
  width: min(400px, calc(100vw - 32px)); height: min(75vh, 620px); display: flex; flex-direction: column;
  background: var(--ui-surface); border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-lg); overflow: hidden;
}
.aiw-panel[hidden] { display: none; }
.aiw-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--ui-accent); color: #fff; }
.aiw-head strong { flex: 1; font-size: 14px; }
.aiw-head .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.aiw-tabs { display: flex; border-bottom: 1px solid var(--ui-border); background: var(--ui-surface-2); }
.aiw-tab {
  flex: 1; border: 0; background: transparent; padding: 8px 4px; font-size: 13px; color: var(--ui-text-2);
  border-bottom: 2px solid transparent;
}
.aiw-tab.active { color: var(--ui-accent-text); border-bottom-color: var(--ui-accent); font-weight: 600; }
.aiw-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--ui-danger); color: #fff; font-size: 11px; }
.aiw-count[hidden] { display: none; }
.aiw-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.aiw-pane[hidden] { display: none; }
.aiw-log { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 13px; }
.aiw-hint { color: var(--ui-muted); font-size: 12px; text-align: center; padding: 16px 8px; }
.aiw-hint[hidden] { display: none; }
.aiw-msg { display: flex; margin-bottom: 8px; }
.aiw-msg .aiw-body { max-width: 85%; padding: 7px 10px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.aiw-user { justify-content: flex-end; }
.aiw-user .aiw-body { background: var(--ui-accent); color: #fff; border-bottom-right-radius: 4px; }
.aiw-bot .aiw-body { background: var(--ui-surface-3); color: var(--ui-text); border-bottom-left-radius: 4px; }
.aiw-typing .aiw-body { color: var(--ui-muted); font-style: italic; }
.aiw-typing .aiw-body::after { content: '…'; }
.aiw-form { padding: 8px 12px; border-top: 1px solid var(--ui-border); }
.aiw-list { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 13px; }
.aiw-empty { color: var(--ui-muted); text-align: center; padding: 24px 8px; }
.aiw-item { border: 1px solid var(--ui-border); border-radius: var(--ui-radius); margin-bottom: 6px; background: var(--ui-surface); }
.aiw-item.aiw-new { border-left: 3px solid var(--ui-accent); }
.aiw-item-head {
  display: flex; align-items: flex-start; gap: 6px; width: 100%; border: 0; background: transparent; padding: 7px 9px;
  text-align: left; color: var(--ui-text);
}
.aiw-item-title { flex: 1; font-weight: 500; }
.aiw-item-age { color: var(--ui-faint); font-size: 11px; white-space: nowrap; }
.aiw-item-body { padding: 0 9px 8px; }
.aiw-item-body[hidden] { display: none; }
.aiw-pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ui-text-2); }
.aiw-item-meta { color: var(--ui-faint); font-size: 11px; margin-top: 4px; }
.aiw-quality { padding: 6px 10px 0; font-size: 12px; }
.aiw-rate { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.aiw-rate .btn { padding: 1px 8px; font-size: 12px; }
.aiw-rate-form { display: flex; gap: 6px; width: 100%; }
.aiw-rate-form input { flex: 1; min-width: 0; }
.aiw-rate-form[hidden] { display: none; }
.aiw-md table { font-size: 12px; }
.aiw-md { overflow-x: auto; }
@media (max-width: 767.98px) {
  .aiw-panel { inset: 0; right: 0; bottom: 0; width: 100vw; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 1060; }
  .aiw-open .aiw-fab, .aiw-open .fb-fab, .aiw-open .ask-fab { display: none; }
}
@media print { .aiw-fab, .aiw-panel { display: none !important; } }
