/* ============================================================
   TANASU MarketHub — Bộ biến thiết kế trung tâm
   Màu chủ đạo: Xanh dương logo TANASU (#047CE4 / #0369C4 / #0256A3).
   Mọi cặp màu chữ / nền đã kiểm tra đạt chuẩn tương phản WCAG AA
   (≥ 4.5:1 cho chữ thường, ≥ 3:1 cho chữ lớn và viền ô nhập).
   ============================================================ */

:root {
  /* ── 1. Bảng màu Giao diện Tối (Dark Mode) ── */
  --bg-page: #0B1220;
  --bg-primary: #0B1220;
  --bg-darkest: #0B1220;
  --bg-dark: #0B1220;
  --bg-base: #111A2B;
  --bg-surface: #111A2B;
  --bg-secondary: #111A2B;
  --bg-card: #111A2B;
  --bg-elevated: #17223A;
  --bg-tertiary: #17223A;
  --bg-subtle: #1E2D4A;
  --bg-hover: #1E2D4A;

  --glass-bg: #111A2B;
  --glass-bg-hover: #17223A;

  --border-subtle: #243049;
  --border: #243049;
  --glass-border: #243049;
  --border-strong: #6B7C97;
  --glass-border-hover: #6B7C97;

  --text-primary: #E6EDF7;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-inverse: #0F172A;

  /* Nhận diện TANASU (Dark — chữ xanh sáng đạt ≥ 5.6:1 trên nền tối) */
  --brand-logo: #047CE4;
  --primary: #52A8FF;
  --primary-light: #7CC0FF;
  --primary-dark: #0369C4;
  --primary-hover: #7CC0FF;
  --primary-btn-bg: #0369C4;
  --primary-btn-hover: #047CE4;
  --primary-soft: #12304F;
  --primary-soft-text: #7CC0FF;
  --primary-soft-border: #1E4976;

  --secondary: #3B9CFF;
  --secondary-light: #7CC0FF;
  --accent: #FBBF24;
  --accent-light: #FCD34D;

  /* Trạng thái ngữ nghĩa (Dark — tương phản ≥ 6.1:1 trên #111A2B) */
  --success: #34D399;
  --success-color: #34D399;
  --success-bg: #063427;
  --success-border: #065F46;
  --success-text: #6EE7B7;

  --warning: #FBBF24;
  --warning-color: #FBBF24;
  --warning-bg: #3B2506;
  --warning-border: #78350F;
  --warning-text: #FCD34D;

  --danger: #F87171;
  --danger-color: #F87171;
  --danger-bg: #3F151B;
  --danger-border: #7F1D1D;
  --danger-text: #FCA5A5;

  --info: #7CC0FF;
  --info-color: #7CC0FF;
  --info-bg: #12304F;
  --info-border: #1E4976;
  --info-text: #7CC0FF;

  --neutral-bg: #1E293B;
  --neutral-border: #334155;
  --neutral-text: #CBD5E1;

  /* Dải chuyển sắc TANASU */
  --gradient-primary: linear-gradient(135deg, #0369C4 0%, #0256A3 100%);
  --primary-gradient: linear-gradient(135deg, #0369C4 0%, #0256A3 100%);
  --gradient-accent: linear-gradient(135deg, #047CE4 0%, #0369C4 100%);
  --gradient-warm: linear-gradient(135deg, #D97706 0%, #B45309 100%);
  --gradient-success: linear-gradient(135deg, #059669 0%, #047857 100%);
  --gradient-pink: linear-gradient(135deg, #047CE4 0%, #0256A3 100%);
  --gradient-card: linear-gradient(145deg, rgba(4, 124, 228, 0.08) 0%, rgba(2, 86, 163, 0.03) 100%);

  /* ── 2. Thang chữ (Typography) ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --text-xs: 0.75rem;     /* 12px — cỡ nhỏ nhất cho nhãn phụ / huy hiệu */
  --text-sm: 0.8125rem;   /* 13px — chữ phụ / chú thích */
  --text-base: 0.875rem;  /* 14px — nội dung chính */
  --text-md: 1rem;        /* 16px — tiêu đề thẻ / ô nhập trên điện thoại */
  --text-lg: 1.125rem;    /* 18px — tiêu đề mục */
  --text-xl: 1.375rem;    /* 22px — tiêu đề trang */
  --text-kpi: 1.625rem;   /* 26px — con số KPI lớn */

  /* ── 3. Thang khoảng cách (Spacing 4px base) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ── 4. Bo góc & Đổ bóng (Radius & Elevation) ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 4px 14px rgba(3, 105, 196, 0.32);
  --shadow-glow-primary: 0 4px 14px rgba(3, 105, 196, 0.32);
  --shadow-glow-accent: 0 4px 14px rgba(4, 124, 228, 0.32);

  /* ── 5. Khung bố cục & Chuyển động ── */
  --sidebar-width: 256px;
  --sidebar-collapsed: 68px;
  --header-height: 60px;
  --bottom-nav-height: 60px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── 6. Bảng màu đồ thị 8 màu đồng bộ (Chart Palette) ── */
  --chart-1: #3B9CFF;
  --chart-2: #F59E0B;
  --chart-3: #10B981;
  --chart-4: #EC4899;
  --chart-5: #06B6D4;
  --chart-6: #F97316;
  --chart-7: #84CC16;
  --chart-8: #94A3B8;
}

/* ── Bảng màu Giao diện Sáng (Light Mode) ── */
body.light-mode,
body.light-theme,
:root[data-theme="light"] {
  --bg-page: #F3F7FC;
  --bg-primary: #F3F7FC;
  --bg-darkest: #F3F7FC;
  --bg-dark: #EBF2FA;
  --bg-base: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-tertiary: #F3F7FC;
  --bg-subtle: #EBF2FA;
  --bg-hover: #EBF2FA;

  --glass-bg: #FFFFFF;
  --glass-bg-hover: #EBF2FA;

  --border-subtle: #DBE4EF;
  --border: #DBE4EF;
  --glass-border: #DBE4EF;
  --border-strong: #7C8DA6;
  --glass-border-hover: #7C8DA6;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-inverse: #FFFFFF;

  /* Nhận diện TANASU (Light — tương phản đạt ≥ 6.2:1 trên #FFFFFF & #E6F1FD) */
  --brand-logo: #047CE4;
  --primary: #0256A3;
  --primary-light: #0256A3;
  --primary-dark: #0256A3;
  --primary-hover: #0256A3;
  --primary-btn-bg: #0369C4;
  --primary-btn-hover: #0256A3;
  --primary-soft: #E6F1FD;
  --primary-soft-text: #0256A3;
  --primary-soft-border: #B6D8FA;

  --secondary: #0256A3;
  --secondary-light: #0256A3;
  --accent: #B45309;
  --accent-light: #92400E;

  /* Trạng thái ngữ nghĩa (Light — tương phản ≥ 5.5:1 trên #FFFFFF & nền nhạt) */
  --success: #047857;
  --success-color: #047857;
  --success-bg: #ECFDF5;
  --success-border: #A7F3D0;
  --success-text: #047857;

  --warning: #B45309;
  --warning-color: #B45309;
  --warning-bg: #FEF3C7;
  --warning-border: #FDE68A;
  --warning-text: #92400E;

  --danger: #B91C1C;
  --danger-color: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --danger-text: #B91C1C;

  --info: #0256A3;
  --info-color: #0256A3;
  --info-bg: #E6F1FD;
  --info-border: #B6D8FA;
  --info-text: #0256A3;

  --neutral-bg: #F1F5F9;
  --neutral-border: #CBD5E1;
  --neutral-text: #334155;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 2px 8px rgba(3, 105, 196, 0.22);

  --chart-1: #0369C4;
  --chart-2: #D97706;
  --chart-3: #059669;
  --chart-4: #DB2777;
  --chart-5: #0891B2;
  --chart-6: #EA580C;
  --chart-7: #65A30D;
  --chart-8: #475569;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    /* Tắt chuyển động theo cài đặt trợ năng của hệ điều hành dù thẻ con đặt animation/transition riêng */
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}

body.light-mode .sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 2px 0 12px rgba(0,0,0,0.04);
}
body.light-mode .sidebar-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
body.light-mode .sidebar-nav { padding: 8px 12px; }
body.light-mode .nav-section-title {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
body.light-mode .nav-item {
  color: var(--text-secondary);
  background: transparent;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 2px 0;
  font-size: var(--text-base);
  font-weight: 500;
}
body.light-mode .nav-item:hover { background: var(--bg-subtle); color: var(--text-primary); }
body.light-mode .nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-logo);
}
body.light-mode .nav-item .nav-icon svg { stroke: currentColor; }
body.light-mode .sidebar-footer { border-top: 1px solid var(--border-subtle); background: var(--bg-surface); }
body.light-mode .main-content { background: var(--bg-page); }
body.light-mode .page-header { background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
body.light-mode .page-title, body.light-mode .page-name { color: var(--text-primary); }
body.light-mode .stat-card, body.light-mode .card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}
body.light-mode .stat-card:hover, body.light-mode .card:hover {
  box-shadow: var(--shadow-md);
}
body.light-mode .stat-label { color: var(--text-secondary); }
body.light-mode .stat-value { color: var(--text-primary); }
body.light-mode .data-table th { background: var(--bg-subtle); color: var(--text-secondary); border-bottom: 1px solid var(--border-subtle); }
/* color không !important: màu riêng gắn trên ô (còn nợ, đã cọc, lỗi, hoa hồng...) phải thắng màu mặc định này */
body.light-mode .data-table td { color: var(--text-primary); border-bottom: 1px solid var(--border-subtle); }
body.light-mode .data-table tr:hover { background: var(--bg-subtle); }
body.light-mode .btn-primary { background: var(--primary-btn-bg); }
/* Thắng màu nền tối gắn inline trong một số trang cũ (.modal-content, .section-card, ô nhập readonly ở settings/marketing-ads) */
body.light-mode .modal-content { background: var(--bg-surface) !important; color: var(--text-primary) !important; border: 1px solid var(--border-subtle) !important; }
body.light-mode .section-card { background: var(--bg-card) !important; border: 1px solid var(--border-subtle) !important; }
body.light-mode input:not([type="checkbox"]):not([type="radio"]),
body.light-mode select,
body.light-mode textarea {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong);
}
body.light-mode .logo-text { color: var(--text-primary); }
body.light-mode .user-name { color: var(--text-primary); }
body.light-mode .user-role { color: var(--text-secondary); }

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Thuộc tính hidden phải luôn ẩn. Mặc định trình duyệt chỉ là display:none "yếu" — mọi class đặt display (.btn
   inline-flex, .myday-scope flex…) đều thắng, nên nút "Lưu chỉ tiêu" / tab "Cả công ty" đã đặt hidden với nhân viên
   vẫn hiện ra, bấm là lỗi 403. Ẩn nút theo quyền (data-can ở app.js) cũng dựa vào dòng này. */
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-darkest);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul, ol { list-style: none; }

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 1.875rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-darkest);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.login-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: orbFloat 12s ease-in-out infinite;
}

.login-bg .orb-1 {
  width: 500px; height: 500px;
  background: var(--primary);
  top: -15%; left: -10%;
  animation-delay: 0s;
}

.login-bg .orb-2 {
  width: 400px; height: 400px;
  background: var(--secondary);
  bottom: -10%; right: -5%;
  animation-delay: -4s;
}

.login-bg .orb-3 {
  width: 300px; height: 300px;
  background: var(--accent);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -8s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: cardEnter 0.6s var(--ease-out);
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-logo .logo-icon {
  width: 48px; height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-primary);
}

.login-logo .logo-icon svg {
  width: 28px; height: 28px;
  stroke: white;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 36px;
  font-size: 0.938rem;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.login-form .form-group { position: relative; }

.login-form .form-label {
  display: block;
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form .form-input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.938rem;
  transition: var(--transition-base);
  outline: none;
}

.login-form .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 124, 228, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

.login-form .form-input::placeholder { color: var(--text-muted); }

.login-form .input-icon {
  position: absolute;
  left: 14px;
  bottom: 13px;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.login-form .input-icon svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-extras {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.813rem;
}

.login-extras label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
}

.login-extras a { color: var(--primary-light); }
.login-extras a:hover { text-decoration: underline; }

.login-btn {
  width: 100%;
  height: 48px;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  box-shadow: var(--shadow-glow-primary);
  transform: translateY(-1px);
}

.login-btn:active { transform: translateY(0); }

.login-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.login-btn:hover::after { transform: translateX(100%); }

/* ============================================================
   LAYOUT — Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Sidebar header */
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  min-height: var(--header-height);
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Logo TANASU ở thanh bên: bản trắng (640×119) cho nền tối, bản đen (640×106) cho nền sáng; đổi bằng class của body.
   Khung .logo giữ min-height 32px để hai ảnh khác chiều cao không làm .sidebar-header nhảy chiều cao khi đổi giao diện.
   Khi thu gọn 72px (.sidebar.collapsed hoặc màn 769–1024px): cắt khung .logo (overflow:hidden) chỉ giữ biểu tượng chữ T đầu bên trái
   (ở rộng 168px biểu tượng kết thúc tại ~39px còn chữ "TANASU" bắt đầu từ ~43,6px; ở rộng 120px biểu tượng kết thúc tại ~27,9px còn chữ từ ~31,1px). */
.sidebar .logo { min-height: 32px; }
.sidebar .brand-logo {
  width: auto;
  height: auto;
  max-width: 168px;
  max-height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar .brand-logo-dark { display: block; }
.sidebar .brand-logo-light { display: none; }
body.light-mode .sidebar .brand-logo-dark,
body.light-theme .sidebar .brand-logo-dark { display: none; }
body.light-mode .sidebar .brand-logo-light,
body.light-theme .sidebar .brand-logo-light { display: block; }
@media (min-width: 1025px) {
  body .sidebar.collapsed .sidebar-header {
    justify-content: space-between !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
    gap: 4px;
  }
  body .sidebar.collapsed .logo {
    width: 28px;
    overflow: hidden;
    flex-shrink: 0;
    justify-content: flex-start !important;
  }
  body .sidebar.collapsed .brand-logo {
    width: 120px;
    max-width: none;
  }
}
@media (min-width: 769px) and (max-width: 1024px) {
  body .sidebar .sidebar-header {
    justify-content: center !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  body .sidebar .logo {
    width: 40px;
    overflow: hidden;
    flex-shrink: 0;
    justify-content: flex-start !important;
  }
  body .sidebar .brand-logo {
    width: 168px;
    max-width: none;
  }
}

.sidebar .logo-icon {
  width: 36px; height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar .logo-icon svg {
  width: 20px; height: 20px;
  stroke: white;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar .logo-text {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.sidebar-toggle {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--glass-bg-hover);
  color: var(--text-secondary);
}

.sidebar-toggle svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(4, 124, 228, 0.12);
  color: var(--primary-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text { white-space: nowrap; }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--danger);
  color: white;
  font-size: 0.688rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--glass-border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px; height: 36px;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.813rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.688rem; }
/* Ảnh đại diện thật (js/api.js avatarInnerHtml) phủ kín vòng tròn của .avatar / .avatar-lg / .settings-avatar / .activity-avatar... */
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
/* Khối "Ảnh đại diện" ở Cài đặt và hộp Sửa nhân viên (js/avatar-upload.js): ảnh tròn xem trước + nút Chọn / Xoá ảnh.
   Ô <input type=file> thật được ẩn bằng cách thu về 1 điểm ảnh (không display:none) và bỏ khỏi thứ tự Tab — nút "Chọn ảnh" là chỗ bàn phím tới. */
.avatar-edit { display: flex; align-items: center; gap: 16px; }
.avatar-edit-preview { width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--primary-gradient); color: #fff; font-size: 1.5rem; font-weight: 600; }
.avatar-edit-actions { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* Chữ 12px nên dùng --text-secondary (đủ tương phản ở cả 2 giao diện; --text-muted chỉ ~2,5:1 trên nền trắng). Giao diện sáng: đỏ đậm hơn --danger
   (#ef4444 chỉ ~3,8:1 trên nền trắng) cho câu báo lỗi và nút "Xoá ảnh"; giao diện tối giữ --danger (đã đủ tương phản trên nền tối). */
.avatar-edit-hint { flex-basis: 100%; font-size: 0.75rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.avatar-edit-hint.is-error { color: var(--danger); }
.avatar-edit .btn.avatar-remove-btn { color: var(--danger); }
body.light-mode .avatar-edit-hint.is-error,
body.light-mode .avatar-edit .btn.avatar-remove-btn { color: #b91c1c; }
.avatar-edit .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.avatar-edit .btn[hidden] { display: none; }
.avatar-file-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.user-info { overflow: hidden; }

.user-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-logout {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition-fast);
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-logout:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.sidebar-logout svg {
  width: 18px;
  height: 18px;
}

/* Sidebar collapsed */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-section-title {
  display: none;
}

.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 12px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer { padding: 16px 12px; justify-content: center; }
.sidebar.collapsed .user-profile { justify-content: center; }

/* ============================================================
   LAYOUT — Main Content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-base);
  background: var(--bg-darkest);
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed);
}

/* Page Header */
.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-height);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: rgba(5, 8, 16, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.mobile-menu-btn:hover { background: var(--glass-bg-hover); }

/* Một số trang (deliveries/warranty/activities) có <svg> hamburger không tự khai báo
   stroke="currentColor" như .sidebar-toggle svg — nút vẫn bấm được (đúng handler) nhưng icon
   render vô hình trên mobile vì stroke mặc định là none. Sửa 1 lần ở đây thay vì sửa từng trang. */
.mobile-menu-btn svg { stroke: currentColor; fill: none; stroke-width: 2; }

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.page-subtitle {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Header search */
.header-search {
  position: relative;
  width: 280px;
}

.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-base);
}

.header-search input:focus {
  background: var(--glass-bg-hover);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 124, 228, 0.1);
}

.header-search input::placeholder { color: var(--text-muted); }

.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}

.header-search .search-icon svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.global-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.search-result-item:hover {
  background: var(--glass-bg-hover);
}

/* Header icon buttons */
.header-icon-btn {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  position: relative;
}

.header-icon-btn:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.header-icon-btn svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-icon-btn .notification-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-darkest);
}

/* Page content */
.page-content {
  padding: 28px 32px 40px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition-base);
}

.card:hover {
  border-color: var(--glass-border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-heading);
}

.card-subtitle {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body { }

.card-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before { opacity: 1; }

.stat-card:nth-child(1)::before { background: var(--gradient-primary); }
.stat-card:nth-child(2)::before { background: var(--gradient-success); }
.stat-card:nth-child(3)::before { background: var(--gradient-warm); }
.stat-card:nth-child(4)::before { background: var(--gradient-accent); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px; height: 24px;
  stroke: white;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-icon.purple { background: var(--gradient-primary); }
.stat-icon.green { background: var(--gradient-success); }
.stat-icon.orange { background: var(--gradient-warm); }
.stat-icon.blue { background: var(--gradient-accent); }
.stat-icon.pink { background: var(--gradient-pink); }

.stat-info { flex: 1; min-width: 0; }

.stat-label {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-trend.up {
  color: var(--success);
  background: var(--success-bg);
}

.stat-trend.down {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 40px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  white-space: nowrap;
  border: none;
  cursor: pointer;
}

.btn svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-sm { height: 34px; padding: 0 14px; font-size: 0.813rem; }
.btn-lg { height: 48px; padding: 0 28px; font-size: 1rem; }

.btn-primary {
  background: var(--gradient-primary);
  color: white;
}
.btn-primary:hover {
  box-shadow: var(--shadow-glow-primary);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #059669; }

/* ============================================================
   FORM INPUTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-base);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 124, 228, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select option,
.form-select option,
.filter-select option,
.form-control option,
select.form-control option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Tiêu đề nhóm trong ô chọn (<optgroup>, VD "Theo menu website" / "Khác" ở ô Danh mục): <option> đã có nền + chữ theo giao diện, còn <optgroup>
   mà không đặt thì nền trong suốt → trình duyệt vẽ nền TRẮNG mặc định của danh sách thả xuống trong khi chữ vẫn là màu sáng của giao diện tối
   ⇒ chữ trắng trên nền trắng, không đọc được. Đặt nền + chữ theo cùng biến màu của giao diện sáng / tối (chữ phụ, đủ tương phản cả 2 giao diện). */
select optgroup,
.form-select optgroup,
.filter-select optgroup,
.form-control optgroup,
select.form-control optgroup {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-style: normal;
  font-weight: 700;
}

.form-textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 20px;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table-cell-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-cell-user .user-details {
  display: flex;
  flex-direction: column;
}

.table-cell-user .user-details .name {
  font-weight: 500;
  color: var(--text-primary);
}

.table-cell-user .user-details .email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   BADGES & TAGS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary { background: rgba(4, 124, 228, 0.15); color: var(--primary-light); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.688rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid;
}

.tag-vip { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.25); color: var(--warning); }
.tag-potential { background: rgba(4, 124, 228, 0.1); border-color: rgba(4, 124, 228, 0.25); color: var(--primary-light); }
.tag-new { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.25); color: var(--success); }
.tag-cold { background: rgba(100, 116, 139, 0.1); border-color: rgba(100, 116, 139, 0.25); color: var(--text-muted); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: var(--font-heading);
}

.modal-close {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 1.25rem;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--glass-border);
}

/* ============================================================
   DETAIL PANEL (Slide-in)
   ============================================================ */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-base);
  border-left: 1px solid var(--glass-border);
  z-index: 150;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.detail-panel.open { transform: translateX(0); }

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
}

.detail-panel-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.detail-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 149;
}

.detail-panel-overlay.open {
  display: block;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 300px;
  max-width: 420px;
  transform: translateX(120%);
  transition: transform var(--transition-base);
}

.toast.show { transform: translateX(0); }

.toast-icon {
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
}

.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-error .toast-icon { background: var(--danger-bg); color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-bg); color: var(--warning); }
.toast-info .toast-icon { background: var(--info-bg); color: var(--info); }

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.toast-close {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px;
  transition: var(--transition-fast);
}

.toast-close:hover { color: var(--text-primary); }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 44px;
  bottom: 0;
  width: 1px;
  background: var(--glass-border);
}

.timeline-dot {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.timeline-dot.call { background: var(--info-bg); color: var(--info); }
.timeline-dot.email { background: var(--success-bg); color: var(--success); }
.timeline-dot.meeting { background: rgba(4, 124, 228, 0.12); color: var(--secondary); }
.timeline-dot.note { background: var(--warning-bg); color: var(--warning); }

.timeline-content { flex: 1; min-width: 0; }

.timeline-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.timeline-desc {
  font-size: 0.813rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   CALENDAR (Mini)
   ============================================================ */
.mini-calendar {
  width: 100%;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  gap: 4px;
}

.calendar-nav button {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  font-size: 1.25rem;
}

.calendar-nav button:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day-label {
  text-align: center;
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.813rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
  position: relative;
}

.calendar-day:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.calendar-day.today {
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
}

.calendar-day.other-month {
  color: var(--text-muted);
  opacity: 0.4;
}

.calendar-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.calendar-day.today.has-event::after {
  background: white;
}

/* ============================================================
   REMINDER CARDS
   ============================================================ */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  cursor: pointer;
}

.reminder-item:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
}

.reminder-item.overdue {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.04);
}

.reminder-status {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.reminder-status.pending { background: var(--warning); }
.reminder-status.done { background: var(--success); }
.reminder-status.overdue { background: var(--danger); animation: pulse 2s infinite; }

.reminder-info { flex: 1; min-width: 0; }

.reminder-customer {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.reminder-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px; height: 64px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 360px;
  margin: 0 auto;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.tab-item:hover { color: var(--text-secondary); }

.tab-item.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* ============================================================
   SOCIAL CARDS (Preview)
   ============================================================ */
.platform-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  transition: var(--transition-base);
}

.platform-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}

.platform-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.platform-icon.facebook { background: rgba(24, 119, 242, 0.15); color: #1877f2; }
.platform-icon.youtube { background: rgba(255, 0, 0, 0.12); color: #ff0000; }
.platform-icon.tiktok { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.platform-icon.instagram { background: linear-gradient(135deg, rgba(131, 58, 180, 0.15), rgba(253, 29, 29, 0.15)); color: #e1306c; }

.platform-info { flex: 1; }

.platform-name {
  font-weight: 600;
  font-size: 0.938rem;
}

.platform-stats {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.coming-soon-badge {
  padding: 4px 12px;
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar .search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.filter-bar .search-box input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-base);
}

.filter-bar .search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 124, 228, 0.1);
}

.filter-bar .search-box input::placeholder { color: var(--text-muted); }

.filter-bar .search-box .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-bar .search-box .icon svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.filter-select {
  height: 40px;
  padding: 0 32px 0 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.813rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: none;
  cursor: pointer;
}

.filter-select option {
  background: var(--bg-surface);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.pagination-info {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.813rem;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.pagination-btn:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--primary-btn-bg);
  color: white;
}

/* ============================================================
   GRID UTILITIES
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

/* ============================================================
   SPACING & TEXT UTILITIES
   ============================================================ */
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }

.text-sm { font-size: 0.813rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.ui-icon { flex-shrink: 0; vertical-align: middle; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fade { animation: fadeIn 0.4s var(--ease-out); }
.animate-slide-up { animation: slideUp 0.5s var(--ease-out); }

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .logo-text,
  .sidebar .nav-text,
  .sidebar .nav-badge,
  .sidebar .user-info,
  .sidebar .nav-section-title { display: none; }
  .sidebar .sidebar-header { justify-content: center; padding: 20px 12px; }
  .sidebar .nav-item { justify-content: center; padding: 10px; }
  .sidebar .sidebar-footer { padding: 16px 12px; }
  .sidebar .user-profile { justify-content: center; }
  .sidebar .sidebar-toggle { display: none; }

  .main-content { margin-left: var(--sidebar-collapsed); }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar .logo-text,
  .sidebar .nav-text,
  .sidebar .nav-badge,
  .sidebar .user-info,
  .sidebar .nav-section-title { display: block; }
  .sidebar .sidebar-header { justify-content: space-between; padding: 20px; }
  .sidebar .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar .sidebar-footer { padding: 16px 20px; }
  .sidebar .user-profile { justify-content: flex-start; }

  .main-content { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

  .page-header { padding: 16px; flex-direction: column; align-items: flex-start; }
  .page-content { padding: 20px 16px; }

  .header-search { display: none; }

  .stats-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .search-box { max-width: 100%; }
  .header-right { flex-wrap: wrap; }

  .form-row { grid-template-columns: 1fr; }

  .detail-panel { width: 100%; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.1rem; }
  .stat-value { font-size: 1.5rem; }
  .card { padding: 16px; }
  .stat-card { padding: 16px; }
}

/* ============================================================
   NOTIFICATION DROPDOWN
   ============================================================ */
.notification-btn-wrap {
  position: relative;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 480px;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-base);
  overflow: hidden;
}

.notification-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.notification-dropdown-header h3 {
  font-size: 0.938rem;
  font-weight: 600;
  font-family: var(--font-heading);
}

.notification-list {
  max-height: 340px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  transition: var(--transition-fast);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.notification-item:last-child { border-bottom: none; }

.notification-item:hover {
  background: var(--glass-bg-hover);
}

.notification-item.unread {
  background: rgba(4, 124, 228, 0.04);
}

.notification-item.unread::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.notification-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.notification-item-content {
  flex: 1;
  min-width: 0;
}

.notification-item-text {
  font-size: 0.813rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.notification-item-text strong {
  font-weight: 600;
  color: var(--primary-light);
}

.notification-item-time {
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.notification-dropdown-footer {
  padding: 12px 20px;
  text-align: center;
  border-top: 1px solid var(--glass-border);
}

.notification-dropdown-footer a {
  font-size: 0.813rem;
  color: var(--primary-light);
  font-weight: 500;
  transition: var(--transition-fast);
}

.notification-dropdown-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .notification-dropdown {
    width: calc(100vw - 32px);
    right: -60px;
  }
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: var(--transition-base);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-base);
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

/* Nút sáng / tối:
   - Trên máy tính (≥ 769px): nằm ở GÓC TRÊN BÊN PHẢI .page-header của MỌI trang (.theme-toggle-corner), .page-header chừa 84px bên phải để không đè lên nút đầu trang.
   - Trên điện thoại (≤ 768px): ẩn .theme-toggle-corner ở đầu trang và hiện nút .sidebar-theme-toggle ở chân thanh bên (.sidebar-footer) cạnh thông tin tài khoản. */
.page-header { padding-right: 84px; }
.page-header.has-theme-toggle { padding-right: 84px; }
.theme-toggle-corner { position: absolute; top: 14px; right: 24px; z-index: 2; flex: none; }
.sidebar-theme-toggle { display: none; }
@media (min-width: 769px) {
  /* Giữ khoảng chừa 84px bên phải trên máy tính kể cả khi trang có <style> riêng đặt padding cho .page-header (như dashboard.html) */
  .page-header.has-theme-toggle,
  body.light-mode .page-header.has-theme-toggle,
  body.report-page .page-header.has-theme-toggle {
    padding-right: 84px !important;
  }
}
@media (max-width: 768px) {
  /* Điện thoại: ẩn nút góc đầu trang để không đè lên nút chính / chuông thông báo; dùng nút trong chân thanh bên */
  .theme-toggle-corner { display: none !important; }
  .sidebar-theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    background-color: var(--bg-subtle);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    font-size: var(--text-base);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
  }
  .sidebar-theme-toggle:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-strong);
  }
  .sidebar-theme-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
  }
  .sidebar-theme-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .sidebar-theme-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ============================================================
   LIGHT THEME (biến màu sáng đã gộp ở khối body.light-mode, body.light-theme đầu file)
   ============================================================ */
body.light-theme .sidebar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
}

body.light-theme .page-header {
  background: rgba(248, 250, 252, 0.85);
}

body.light-theme .data-table th {
  background: rgba(0, 0, 0, 0.02);
}

body.light-theme .data-table td {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}

body.light-theme .data-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

body.light-theme .notification-item {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}

body.light-theme .notification-item.unread {
  background: rgba(4, 124, 228, 0.04);
}

body.light-theme .login-card {
  background: rgba(255, 255, 255, 0.8);
}

body.light-theme .form-input,
body.light-theme .form-select,
body.light-theme .form-textarea {
  background: rgba(0, 0, 0, 0.03);
}

body.light-theme .form-input:focus,
body.light-theme .form-select:focus,
body.light-theme .form-textarea:focus {
  background: rgba(0, 0, 0, 0.02);
}

body.light-theme .login-form .form-input {
  background: rgba(0, 0, 0, 0.04);
}

body.light-theme .reminder-item {
  background: rgba(0, 0, 0, 0.01);
}

body.light-theme .toast {
  background: var(--bg-base);
}

body.light-theme ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

/* ============================================================
   RESPONSIVE — MOBILE ENHANCEMENTS
   ============================================================ */

/* Table horizontal scroll */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-container .data-table {
  min-width: 700px;
}

@media (max-width: 768px) {
  /* Header buttons wrap */
  .header-actions { flex-wrap: wrap; gap: 8px; }
  .header-actions .btn { font-size: 0.75rem; padding: 6px 10px; }
  .header-actions .btn svg { width: 14px; height: 14px; }

  /* Stats grid 2-col on tablet */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Modal full width */
  .modal { width: 95vw; max-width: 95vw; max-height: 90vh; }

  /* Tabs scroll */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; flex-shrink: 0; }

  /* Pagination compact */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .pagination .btn { min-width: 32px; padding: 4px 8px; font-size: 0.75rem; }

  /* Notification dropdown */
  .notification-dropdown { width: 300px; right: 0; }

  /* Platform cards */
  .grid-3 { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* Stats single column */
  .stats-grid { grid-template-columns: 1fr; }

  /* Smaller fonts */
  .page-subtitle { font-size: 0.75rem; }
  .stat-label { font-size: 0.7rem; }

  /* Header actions stack */
  .header-actions { justify-content: flex-start; }

  /* Notification dropdown full width */
  .notification-dropdown { width: calc(100vw - 32px); right: -16px; }

  /* Quote items table compact */
  .quote-items-table th, .quote-items-table td { padding: 6px 8px; font-size: 0.75rem; }
}

/* Điện thoại: hộp chuông thông báo neo theo MÀN HÌNH, không theo chuông. Trên điện thoại chuông không nằm sát mép phải (đứng
   cạnh nút ☰ / các nút khác) nên hộp rộng 343px neo `right` theo chuông bị đẩy ra ngoài bên trái (đo ở 375px: left -219 → ~64%
   nằm ngoài màn hình, 11/12 trang). `top` do initNotifications() (js/app.js) đặt lúc mở theo vị trí chuông; 64px chỉ là mặc định. */
@media (max-width: 600px) {
  .notification-dropdown { position: fixed; top: 64px; left: 8px; right: 8px; width: auto; max-width: none; max-height: min(480px, calc(100vh - 88px));
    transition: opacity var(--transition-base), transform var(--transition-base), visibility var(--transition-base); } /* không animate `top`: hộp trượt từ 64px xuống chỗ chuông */
}

/* Dark Custom Scrollbar for Kanban and Tables */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(4, 124, 228, 0.6);
}

/* Sticky columns for wide Ads Table */
.ads-table th:first-child, .ads-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 2;
  border-right: 1px solid var(--glass-border);
}

.ads-table th:nth-child(2), .ads-table td:nth-child(2) {
  position: sticky;
  left: 180px;
  background: var(--bg-surface);
  z-index: 2;
  border-right: 1px solid var(--glass-border);
}

/* Drag and Drop Zone */
.dropzone {
  border: 2px dashed var(--glass-border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover {
  border-color: var(--primary);
  background: rgba(4, 124, 228, 0.05);
}

/* ============================================================
   TAB CON của mục menu "Hỗ trợ tư vấn": Tra cứu tư vấn · Kho đào tạo · Quy trình phòng ban (consult.html, training.html).
   Dùng lại .tabs / .tab-item; ở đây chỉ chỉnh cho thẻ <a> và cho điện thoại (3 tab chia đều bề rộng, chữ dài tự xuống dòng
   thay vì cuộn ngang — tránh tab thứ 3 bị giấu ngoài màn hình mà người dùng không biết).
   ============================================================ */
.consult-tabs { margin-bottom: 16px; }
.consult-tabs .tab-item { display: inline-block; text-decoration: none; }
/* Chữ tab đủ rõ (tương phản ≥ 4,5:1) ở cả giao diện tối và sáng: .tab-item mặc định dùng --text-muted / --primary-light, trên nền sáng chỉ khoảng 2,3:1 */
.consult-tabs .tab-item { color: var(--text-secondary); }
.consult-tabs .tab-item:hover { color: var(--text-primary); }
.consult-tabs .tab-item.active { color: #FFFFFF; }
body.light-mode .consult-tabs .tab-item { color: #4b5563; }
body.light-mode .consult-tabs .tab-item:hover { color: var(--text-primary); }
body.light-mode .consult-tabs .tab-item.active { color: #FFFFFF; }
@media (max-width: 600px) {
  .consult-tabs { overflow-x: visible; }
  .consult-tabs .tab-item { flex: 1 1 0; min-width: 0; padding: 10px 6px; text-align: center; font-size: 0.8rem; line-height: 1.25; white-space: normal; }
}




/* ============================================================
   TANASU MarketHub — Bộ thành phần dùng chung
   Đồng bộ nút bấm, ô nhập, thẻ, KPI, huy hiệu, bảng, hộp thoại,
   thanh đầu trang gọn và thanh điều hướng đáy trên điện thoại.
   ============================================================ */

/* ── 1. Nút bấm (Buttons) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  min-width: 38px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand-logo);
  outline-offset: 2px;
}

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

.btn-primary,
body.light-mode .btn-primary,
body.light-theme .btn-primary {
  background: var(--primary-btn-bg);
  background-color: var(--primary-btn-bg);
  color: #FFFFFF;
  border-color: var(--primary-btn-bg);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled),
body.light-mode .btn-primary:hover:not(:disabled),
body.light-theme .btn-primary:hover:not(:disabled) {
  background: var(--primary-btn-hover);
  background-color: var(--primary-btn-hover);
  border-color: var(--primary-btn-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary,
body.light-mode .btn-secondary,
body.light-theme .btn-secondary {
  background: var(--bg-surface);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled),
body.light-mode .btn-secondary:hover:not(:disabled),
body.light-theme .btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  background-color: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost,
body.light-mode .btn-ghost,
body.light-theme .btn-ghost {
  background: transparent;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover:not(:disabled),
body.light-mode .btn-ghost:hover:not(:disabled),
body.light-theme .btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost.text-danger,
body.light-mode .btn-ghost.text-danger {
  color: var(--danger);
}

.btn-danger,
body.light-mode .btn-danger {
  background: #DC2626;
  background-color: #DC2626;
  color: #FFFFFF;
  border-color: #DC2626;
}

.btn-danger:hover:not(:disabled) {
  background: #B91C1C;
  background-color: #B91C1C;
}

.btn-success,
body.light-mode .btn-success {
  background: #047857;
  background-color: #047857;
  color: #FFFFFF;
  border-color: #047857;
}

.btn-sm {
  min-height: 32px;
  min-width: 32px;
  padding: 5px 10px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 44px;
  padding: 10px 22px;
  font-size: var(--text-md);
}

.btn-icon,
.header-icon-btn,
.sidebar-toggle {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover,
.header-icon-btn:hover,
.sidebar-toggle:hover {
  background-color: var(--bg-subtle);
  color: var(--primary);
  border-color: var(--border-strong);
}

/* ── 2. Ô nhập liệu, Chọn, Tick (Inputs, Selects, Checkboxes) ── */
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea,
.form-control,
select.form-control,
input.form-control,
textarea.form-control,
.filter-select,
body.light-mode .form-input,
body.light-mode .form-select,
body.light-mode .form-textarea,
body.light-mode .form-control,
body.light-mode .filter-select {
  min-height: 38px;
  padding: 7px 12px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.4;
  /* Thắng các luật .form-control đặt nền tối / viền mờ trong thẻ <style> riêng của một số trang (marketing-ads, settings, content-calendar...) */
  color: var(--text-primary) !important;
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select,
select.form-control,
.filter-select,
body.light-mode .form-select,
body.light-mode select.form-control,
body.light-mode .filter-select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2356657A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder,
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
.filter-select:focus {
  /* Thắng viền focus màu tím cũ khai báo trong <style> riêng của một số trang */
  border-color: var(--brand-logo) !important;
  box-shadow: 0 0 0 3px rgba(4, 124, 228, 0.2) !important;
  outline: none;
}

/* Ô tick (Checkbox / Radio) có vùng bấm ≥ 32x32px trên máy tính và ≥ 44x44px trên điện thoại (trừ .lg-checkbox của trang đăng nhập dùng kiểu riêng trong css/login.css) */
input[type="checkbox"]:not(.lg-checkbox),
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  /* Khung ngoài 32x32 chỉ là vùng chạm trong suốt, hình hộp kiểm thật vẽ bằng ::before 18x18 ở giữa */
  background: transparent;
  border: none;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
}

input[type="checkbox"]:not(.lg-checkbox)::before,
input[type="radio"]::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--bg-surface);
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

input[type="checkbox"]:not(.lg-checkbox)::before {
  border-radius: 5px;
}

input[type="radio"]::before {
  border-radius: 50%;
}

input[type="checkbox"]:not(.lg-checkbox):hover::before,
input[type="radio"]:hover::before {
  border-color: var(--brand-logo);
}

input[type="checkbox"]:not(.lg-checkbox):checked::before {
  background-color: var(--primary-btn-bg);
  border-color: var(--primary-btn-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

input[type="radio"]:checked::before {
  border-color: var(--primary-btn-bg);
  border-width: 5px;
  background-color: #FFFFFF;
}

/* ── 3. Thẻ & Thẻ chỉ số KPI (Cards & Stat Cards) ── */
.card,
body.light-mode .card,
body.light-theme .card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card,
body.light-mode .stat-card,
body.light-theme .stat-card {
  background: var(--bg-card);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-card::before {
  display: none;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.stat-icon.blue,
.stat-icon.purple {
  background: var(--info-bg);
  color: var(--info-text);
}

.stat-icon.green {
  background: var(--success-bg);
  color: var(--success-text);
}

.stat-icon.orange {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.stat-icon.pink,
.stat-icon.red {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.3;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ── 4. Huy hiệu & Nhãn trạng thái (Badges, Tags, Care Chips — Tương phản ≥ 5.1:1) ── */
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  /* Đảm bảo huy hiệu không nhỏ hơn 12px (chuẩn M3) kể cả khi trang có <style> đặt 0.688rem */
  font-size: var(--text-xs) !important;
  font-weight: 600;
  line-height: 1.35;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary,
.badge-info,
.tag-new,
body.light-mode .badge-primary,
body.light-mode .badge-info,
body.light-mode .tag-new {
  background-color: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.badge-success,
.tag-potential,
body.light-mode .badge-success,
body.light-mode .tag-potential {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge-warning,
.tag-vip,
body.light-mode .badge-warning,
body.light-mode .tag-vip {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.badge-danger,
body.light-mode .badge-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.badge-secondary,
.tag-cold,
body.light-mode .badge-secondary,
body.light-mode .tag-cold {
  background-color: var(--neutral-bg);
  color: var(--neutral-text);
  border: 1px solid var(--neutral-border);
}

/* ── 5. Bảng dữ liệu gọn & chuẩn (Data Tables) ── */
.table-container,
body.light-mode .table-container,
body.light-theme .table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
body.light-mode .data-table th,
body.light-theme .data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td,
body.light-mode .data-table td,
body.light-theme .data-table td {
  padding: 8px 12px;
  font-size: var(--text-base);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover,
body.light-mode .data-table tbody tr:hover {
  background-color: var(--bg-subtle);
}

.table-cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  background: var(--gradient-accent);
  background-color: #0256A3;
  color: #FFFFFF;
}

.table-cell-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-primary);
  background-color: #0256A3;
  color: #FFFFFF;
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.calendar-day-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.calendar-day.today {
  background: var(--gradient-primary);
  background-color: #0256A3;
  color: #FFFFFF;
}

.main-content,
.page-content,
.card,
.card-body,
.table-container,
.chart-container {
  min-width: 0;
  max-width: 100%;
}

.grid-2 > *,
.grid-3 > *,
.grid-sidebar > *,
.stats-grid > * {
  min-width: 0;
}

/* ── 6. Thanh bên (Sidebar) & Phần đầu trang (Page Header) ── */
.sidebar,
body.light-mode .sidebar,
body.light-theme .sidebar {
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.nav-section-title,
body.light-mode .nav-section-title,
body.light-theme .nav-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}

.nav-section-title svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar.collapsed .nav-section-title,
body.light-mode .sidebar.collapsed .nav-section-title,
body.light-theme .sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-item,
body.light-mode .nav-item,
body.light-theme .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
  margin-bottom: 2px;
}

.nav-item:hover,
body.light-mode .nav-item:hover,
body.light-theme .nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-item.active,
body.light-mode .nav-item.active,
body.light-theme .nav-item.active {
  background: var(--primary-soft);
  background-color: var(--primary-soft);
  color: var(--primary-soft-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-logo);
}

.nav-item.active::before {
  display: none;
}

.nav-badge {
  margin-left: auto;
  background-color: #DC2626;
  color: #FFFFFF;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 22px;
  text-align: center;
  line-height: 1.2;
}

.page-header,
body.light-mode .page-header,
body.light-theme .page-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 84px 12px 24px;
  min-height: var(--header-height);
}

.header-left,
.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title,
.page-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin: 0;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 2px 0 0;
}

/* ── 7. Tab chuyển trang (Tabs) ── */
.tabs {
  display: flex;
  gap: 4px;
  background-color: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-item {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  background-color: var(--primary-btn-bg);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

/* Tab gạch chân (như Danh sách | Thống kê ở trang Khách hàng) */
.cs-tabs {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 0;
  gap: 16px;
}

.cs-tabs .tab-item {
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  padding: 8px 4px;
  box-shadow: none;
}

.cs-tabs .tab-item.active {
  background: transparent;
  color: var(--primary);
  border-bottom-color: var(--brand-logo);
}

/* ── 8. Hộp thoại & Khung trượt (Modals & Detail Panels) ── */
.modal-overlay {
  visibility: hidden;
}

.modal-overlay.active {
  visibility: visible;
}

.modal,
body.light-mode .modal,
body.light-theme .modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
}

.modal-close:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.detail-panel-overlay {
  visibility: hidden;
}

.detail-panel-overlay.open,
.detail-panel-overlay.active {
  visibility: visible;
}

.detail-panel {
  visibility: hidden;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
}

.detail-panel.open,
.detail-panel.active {
  visibility: visible;
}

/* ── 9. Phân trang (Pagination) ── */
.pagination-btn,
.pagination > button {
  min-width: 34px;
  min-height: 34px;
  padding: 4px 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pagination-btn.active {
  background-color: var(--primary-btn-bg);
  border-color: var(--primary-btn-bg);
  color: #FFFFFF;
}

/* ── 10. Thanh điều hướng đáy trên điện thoại (Mobile Bottom Nav) ── */
.mobile-bottom-nav {
  display: none;
}

/* ── 11. Chuẩn Điện thoại & Màn hình cảm ứng (≤ 768px / pointer: coarse) ── */
@media (max-width: 768px), (pointer: coarse) {
  .btn,
  .btn-sm,
  .btn-icon,
  .header-icon-btn,
  .mobile-menu-btn,
  .sidebar-toggle,
  .sidebar-logout,
  .sidebar-theme-toggle,
  .modal-close,
  .pagination-btn,
  .pagination > button,
  .tab-item,
  .nav-item,
  a[href^="tel:"],
  details > summary {
    /* Đảm bảo vùng chạm ≥ 44x44px trên màn hình cảm ứng (chuẩn M2) kể cả khi trang có <style> đặt nút nhỏ hơn */
    min-height: 44px !important;
    min-width: 44px !important;
  }

  .form-input,
  .form-select,
  .form-textarea,
  .form-control,
  select.form-control,
  input.form-control,
  textarea.form-control,
  .filter-select,
  .filter-bar .search-box input {
    /* Chiều cao ≥ 44px và cỡ chữ 16px để iPhone không tự phóng to khi chạm vào ô nhập */
    min-height: 44px !important;
    font-size: 16px !important;
  }

  input[type="checkbox"]:not(.lg-checkbox),
  input[type="radio"] {
    /* Vùng chạm ô tick ≥ 44x44px trên điện thoại (chuẩn M2) */
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar .nav-item { justify-content: center; padding: 10px; }
  .sidebar .nav-text,
  .sidebar .nav-badge,
  .sidebar .user-info,
  .sidebar .nav-section-title,
  body.light-mode .sidebar .nav-section-title,
  body.light-theme .sidebar .nav-section-title { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    height: 100vh;
    height: 100dvh;
  }
  /* Thanh bên ẩn khỏi luồng tab khi đang đóng trên điện thoại; mở bằng class .open (js/app.js) */
  .sidebar:not(.open) {
    visibility: hidden;
    pointer-events: none;
  }
  .sidebar.open {
    visibility: visible;
    pointer-events: auto;
  }
  .sidebar .nav-section-title {
    display: flex;
  }

  /* Phần đầu trang trên điện thoại: gọn khi ít nút, tự xuống hàng khi trang có nhiều nút (Sản phẩm, Hợp đồng, Kho đào tạo) để không nút nào bị cắt */
  .page-header,
  body.light-mode .page-header,
  body.report-page .page-header {
    padding: 8px 12px !important;
    min-height: 52px;
    gap: 6px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .header-left,
  .header-title {
    flex: 1 1 140px;
    min-width: 0;
    gap: 8px;
  }

  .header-left > div,
  .header-title > div {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .page-title,
  .page-name {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .page-subtitle {
    display: none;
  }

  .header-right {
    width: auto;
    max-width: 100%;
    flex: 0 1 auto;
    gap: 6px;
    flex-wrap: wrap;
  }

  .header-right > * {
    max-width: 100%;
  }

  .page-header .header-right .btn-primary {
    padding: 0 10px;
    font-size: 0.8125rem;
  }

  .header-search {
    display: none;
  }

  .page-content {
    /* Chừa 76px đáy cho thanh điều hướng 5 mục cố định ở đáy màn hình điện thoại */
    padding: 12px 12px calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.report-page .main-content {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  /* Trang có nút trợ lý AI nổi (nằm ở bottom 74px, cao ~52px): chừa 136px đáy để cuộn kịch trang không bị nút nổi che */
  body.aia-has-fab .main-content,
  body:has(.ai-fab) .page-content,
  body:has(.aia-fab) .page-content {
    padding-bottom: calc(136px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Thẻ KPI 2 cột gọn trên điện thoại */
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  .stat-card,
  body.light-mode .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .card,
  body.light-mode .card {
    padding: 14px;
  }

  /* Hộp thoại dạng ngăn kéo đáy (Bottom Sheet) trên điện thoại */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  body.light-mode .modal {
    /* Thắng style="max-width:..." gắn trực tiếp trên thẻ .modal ở nhiều trang để hộp thoại bung khít chiều ngang điện thoại */
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    margin: 0;
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
  }

  .modal-header {
    padding: 14px 16px;
    flex-shrink: 0;
  }

  .modal-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
  }

  .modal-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    background-color: var(--bg-surface);
  }

  /* Thanh điều hướng đáy 5 mục (Mobile Bottom Navigation) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 98;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 4px 4px env(safe-area-inset-bottom, 0px);
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }

  .mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    min-width: 48px;
    padding: 4px 1px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
  }

  .mobile-bottom-nav-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    stroke-width: 2;
  }

  .mobile-bottom-nav-item.active {
    color: var(--primary);
  }

  .mobile-bottom-nav-item.active::after {
    content: "";
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background-color: var(--brand-logo);
  }

  .mobile-bottom-nav-label {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
  }

  /* Đẩy nút chat / phân tích AI nổi lên trên thanh đáy để không đè nhau */
  #aiChatFab,
  .ai-fab,
  .aia-fab {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── 12. Thanh cảnh báo hệ thống & Công cụ dùng chung (Đợt 3) ── */
.view-only-notice {
  margin: 12px clamp(12px, 3vw, 32px) 0;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--info);
  background: var(--info-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sys-save-alert {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: #b91c1c;
  color: #ffffff;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 0.875rem;
  line-height: 1.45;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.sys-save-alert-link {
  color: #ffffff;
  text-decoration: underline;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 8px;
}

.sys-problems-bar {
  margin: 4px clamp(12px, 3vw, 32px) 0;
  padding: 3px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--warning-border, var(--warning));
  border-left-width: 4px;
  background: var(--warning-bg);
  color: var(--text-primary);
  font-size: 0.8125rem;
  line-height: 1.35;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}

.sys-problems-bar.is-danger {
  border-color: var(--danger-border, var(--danger));
  background: var(--danger-bg);
}

.sys-alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.45;
}

.sys-alert-danger {
  border-color: var(--danger-border, var(--danger));
  background: var(--danger-bg);
  color: var(--danger-text, var(--danger));
}

.sys-alert-text {
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sys-alert-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.sys-alert-link {
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
}

.sys-alert-link:hover {
  text-decoration: underline;
  background: var(--glass-bg-hover);
}

.sys-alert-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
}

.sys-alert-close:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

/* Menu gộp nút phụ ở đầu trang (Công cụ ▾) */
.toolbar-dropdown {
  position: relative;
  display: inline-flex;
}

.toolbar-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-dropdown-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border-subtle, var(--glass-border));
}

.toolbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 260;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.toolbar-dropdown.open .toolbar-dropdown-menu {
  display: flex;
}

/* Menu bị khung cuộn cắt / tràn mép màn hình: js/app.js placeDropdownMenu() đặt theo màn hình (top / left tính từ nút mở) */
.toolbar-dropdown-menu.is-fixed {
  position: fixed;
  right: auto;
  bottom: auto;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  z-index: 1000;
}

@media (max-width: 480px) {
  .toolbar-dropdown-menu {
    max-width: calc(100vw - 16px);
  }
  /* Khi bên phải nút "Công cụ" còn nút hành động hiển thị (VD: "+ Thêm sản phẩm" ở Quản trị viên / Giám đốc / Quản lý KD),
     nút "Công cụ" dịch sang trái nên căn theo mép trái nút để không tràn mép trái màn hình hẹp 320–375px;
     khi nút bên phải ẩn (Sale Admin KD / Nhân viên KD / CSKH / Marketing) thì giữ right: 0 để không tràn mép phải */
  .toolbar-dropdown:has(+ :not([hidden]):not([style*="display: none"])) .toolbar-dropdown-menu {
    right: auto;
    left: 0;
  }
}

.toolbar-dropdown-item {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.toolbar-dropdown-item:hover,
.toolbar-dropdown-item:focus-visible {
  background: var(--bg-subtle);
  color: var(--primary);
  outline: none;
}

.toolbar-dropdown-item[hidden] {
  display: none !important;
}

/* Mục nguy hiểm trong menu (Xoá hợp đồng, Huỷ đơn, Từ chối…) giữ màu ĐỎ ở sáng + tối — .toolbar-dropdown-item đặt màu chữ sau .text-danger nên thắng (rà Đợt 5) */
.toolbar-dropdown-item.text-danger,
.toolbar-dropdown-item.text-danger:hover,
.toolbar-dropdown-item.text-danger:focus-visible {
  color: var(--danger-text);
}
.toolbar-dropdown-item.text-danger:hover,
.toolbar-dropdown-item.text-danger:focus-visible {
  background: var(--danger-bg);
}

/* Tiêu đề nhóm trong hộp thoại nhiều ô nhập */
.modal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-section-title:first-child {
  margin-top: 0;
}

/* Giữ tiêu đề trang trên 1 dòng ở máy tính */
.main-content,
.page-content {
  min-width: 0;
  max-width: 100%;
}

.notification-item-link {
  text-decoration: none;
  color: inherit;
}

.notification-icon-info {
  background: var(--info-bg);
  color: var(--primary);
}

@media (min-width: 769px) {
  .page-title,
  .page-name {
    white-space: nowrap;
  }
}

@media (max-width: 768px), (pointer: coarse) {
  .sys-problems-bar {
    margin: 4px 12px 0;
    padding: 2px 6px 2px 10px;
    gap: 4px;
    font-size: 0.75rem;
  }

  .sys-alert-actions {
    gap: 2px;
  }

  .sys-alert-link {
    padding: 0 6px;
    font-size: 0.75rem;
  }

  .sys-alert-link,
  .sys-alert-close,
  .sys-save-alert-link,
  .toolbar-dropdown-item {
    min-height: 44px !important;
    min-width: 44px !important;
  }
}
