/* Fonts are loaded via <link> in index.html — no @import needed */

/* =========================================================================
   DESIGN SYSTEM — MEDIA FLOW (synced with FinFlow)
   ========================================================================= */

:root {
  /* FinFlow-aligned color palette */
  --bg-base:           hsl(222, 47%, 9%);
  --bg-surface:        hsla(223, 45%, 15%, 0.65);
  --bg-surface-solid:  hsl(223, 45%, 13%);
  --border-color:      rgba(255, 255, 255, 0.08);
  --border-hover:      rgba(255, 255, 255, 0.18);

  --text-primary:      hsl(210, 40%, 98%);
  --text-secondary:    hsl(215, 20%, 65%);
  --text-muted:        hsl(215, 15%, 45%);

  /* Primary accent — FinFlow blue */
  --primary:           hsl(217, 91%, 60%);
  --primary-hover:     hsl(217, 91%, 50%);
  --primary-glow:      hsla(217, 91%, 60%, 0.15);
  --primary-gradient:  linear-gradient(135deg, hsl(215, 96%, 62%), hsl(224, 82%, 46%));

  --success:           hsl(142, 72%, 45%);
  --success-glow:      hsla(142, 72%, 45%, 0.15);
  --success-gradient:  linear-gradient(135deg, hsl(142, 72%, 50%), hsl(152, 76%, 35%));

  --warning:           hsl(38, 92%, 50%);
  --warning-glow:      hsla(38, 92%, 50%, 0.15);

  --danger:            hsl(350, 89%, 60%);
  --danger-glow:       hsla(350, 89%, 60%, 0.15);

  --info:              hsl(190, 90%, 50%);
  --info-glow:         hsla(190, 90%, 50%, 0.15);

  --purple:            hsl(270, 85%, 60%);
  --purple-gradient:   linear-gradient(135deg, hsl(275, 90%, 65%), hsl(260, 80%, 48%));

  /* Media Flow category colours (preserved) */
  --cat-duan:          #10b981;
  --cat-duan-bg:       rgba(16, 185, 129, 0.12);
  --cat-duan-glow:     rgba(16, 185, 129, 0.2);

  --cat-event:         #f59e0b;
  --cat-event-bg:      rgba(245, 158, 11, 0.12);
  --cat-event-glow:    rgba(245, 158, 11, 0.2);

  --cat-zeng:          #f43f5e;
  --cat-zeng-bg:       rgba(244, 63, 94, 0.12);
  --cat-zeng-glow:     rgba(244, 63, 94, 0.2);

  /* Backward-compat aliases */
  --card-bg:           var(--bg-surface);
  --card-border:       var(--border-color);
  --card-hover-border: var(--border-hover);
  --bg-color:          var(--bg-base);

  /* Layout & glass */
  --sidebar-width:     280px;
  --radius-lg:         20px;
  --radius-md:         12px;
  --radius-sm:         8px;
  --border-radius-sm:  8px;
  --border-radius-md:  12px;
  --border-radius-lg:  20px;

  --glass-blur:        blur(20px);
  --glass-shadow:      0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-sm:         0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:         0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:         var(--glass-shadow);
  --shadow-glow:       0 0 24px var(--primary-glow);

  --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  --font-family:       'Plus Jakarta Sans', 'Outfit', system-ui, -apple-system, sans-serif;
}

/* =========================================================================
   LIGHT MODE
   ========================================================================= */
[data-theme="light"] {
  --bg-base:           hsl(210, 40%, 98%);
  --bg-surface:        hsla(210, 40%, 96%, 0.8);
  --bg-surface-solid:  hsl(210, 30%, 93%);
  --border-color:      rgba(0, 0, 0, 0.07);
  --border-hover:      rgba(0, 0, 0, 0.14);

  --text-primary:      hsl(222, 47%, 12%);
  --text-secondary:    hsl(217, 19%, 38%);
  --text-muted:        hsl(215, 16%, 57%);

  --primary:           hsl(222, 100%, 42%);
  --primary-hover:     hsl(222, 100%, 35%);
  --primary-glow:      hsla(222, 100%, 42%, 0.08);
  --primary-gradient:  linear-gradient(135deg, hsl(222, 100%, 50%), hsl(222, 100%, 38%));

  --success:           hsl(142, 76%, 33%);
  --success-glow:      hsla(142, 76%, 33%, 0.08);
  --success-gradient:  linear-gradient(135deg, hsl(142, 76%, 38%), hsl(152, 76%, 28%));

  --warning:           hsl(32, 95%, 38%);
  --warning-glow:      hsla(32, 95%, 38%, 0.08);

  --danger:            hsl(350, 89%, 46%);
  --danger-glow:       hsla(350, 89%, 46%, 0.08);

  --purple:            hsl(270, 85%, 45%);
  --purple-gradient:   linear-gradient(135deg, hsl(275, 90%, 50%), hsl(260, 80%, 38%));

  --cat-duan-bg:       rgba(16, 185, 129, 0.08);
  --cat-event-bg:      rgba(245, 158, 11, 0.08);
  --cat-zeng-bg:       rgba(244, 63, 94, 0.08);

  --card-bg:           var(--bg-surface);
  --card-border:       var(--border-color);
  --card-hover-border: var(--border-hover);
  --bg-color:          var(--bg-base);

  --glass-shadow:      0 8px 32px 0 rgba(15, 23, 42, 0.04);
  --shadow-lg:         var(--glass-shadow);
  --shadow-glow:       0 0 24px var(--primary-glow);
}

/* =========================================================================
   BASE RESET
   ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(at 10% 20%, hsla(217, 91%, 60%, 0.08) 0px, transparent 50%),
    radial-gradient(at 90% 10%, hsla(270, 85%, 60%, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 80%, hsla(142, 72%, 45%, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  scroll-behavior: smooth;
}

html[data-theme="light"],
html[data-theme="light"] body {
  background-image:
    radial-gradient(at 10% 20%, hsla(222, 100%, 50%, 0.03) 0px, transparent 50%),
    radial-gradient(at 90% 10%, hsla(38, 92%, 50%, 0.02) 0px, transparent 50%),
    radial-gradient(at 50% 80%, hsla(142, 72%, 45%, 0.02) 0px, transparent 50%);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

[data-theme="light"] ::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.22); }

/* =========================================================================
   APP LAYOUT
   ========================================================================= */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* =========================================================================
   SIDEBAR — FinFlow style
   ========================================================================= */
.sidebar {
  width: var(--sidebar-width);
  background: hsla(223, 45%, 12%, 0.4);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width 0.28s cubic-bezier(.4,0,.2,1);
  overflow: visible;
}

/* ── Sidebar toggle button ── */
.sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 72px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 101;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  line-height: 1;
}
.sidebar-toggle:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.1);
}

/* ── Collapsed state ── */
body.sidebar-collapsed .sidebar {
  width: 70px;
}
body.sidebar-collapsed .logo-text-area {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
body.sidebar-collapsed .nav-link span {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}
body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 11px 0;
}
body.sidebar-collapsed .user-info {
  display: none;
}
body.sidebar-collapsed .user-profile {
  justify-content: center;
  padding: 16px 0;
}
body.sidebar-collapsed .main-content {
  margin-left: 70px;
  max-width: calc(100vw - 70px);
}
body.sidebar-collapsed .sidebar-toggle {
  transform: rotate(180deg);
}
body.sidebar-collapsed .sidebar-toggle:hover {
  transform: rotate(180deg) scale(1.1);
}

[data-theme="light"] .sidebar {
  background: hsla(210, 40%, 96%, 0.4);
}

/* Brand / Logo */
.logo-container {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 15px var(--primary-glow);
  flex-shrink: 0;
}

.logo-text-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(120deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

[data-theme="light"] .logo-text {
  background: linear-gradient(120deg, var(--primary), var(--text-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Nav Menu */
.nav-menu {
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.nav-item { width: 100%; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
  cursor: pointer;
  border-left: 3px solid transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  background: transparent;
  width: 100%;
}

.nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* SVG icons in nav (FinFlow style) */
.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}
.nav-link.active svg {
  stroke: var(--primary);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .nav-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

.nav-link.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--primary);
  padding-left: 13px;
}

[data-theme="light"] .nav-link.active {
  background: rgba(0, 0, 0, 0.06);
}

/* User Profile Footer */
.user-profile {
  margin-top: auto;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Nút Đăng xuất */
.btn-logout {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all .2s ease;
}
.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-glow);
}
body.sidebar-collapsed .btn-logout { display: none; }

.username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* =========================================================================
   MAIN CONTENT
   ========================================================================= */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - var(--sidebar-width));
}

/* =========================================================================
   TOP HEADER — FinFlow style
   ========================================================================= */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 20px;
}

.header-title-section h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.header-title-section p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
  flex-shrink: 0;
}

/* ── Chỉ báo trạng thái kết nối ───────────────────────────────── */
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
  transition: all .25s ease;
  white-space: nowrap;
  user-select: none;
}
.conn-status .conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background .25s ease;
}
/* Online */
.conn-status.conn-online {
  background: var(--success-glow, rgba(34,197,94,.12));
  color: var(--success, #22c55e);
  border-color: rgba(34,197,94,.25);
}
.conn-status.conn-online .conn-dot {
  background: var(--success, #22c55e);
  box-shadow: 0 0 0 0 rgba(34,197,94,.5);
  animation: conn-pulse 2s infinite;
}
/* Reconnecting */
.conn-status.conn-reconnecting {
  background: var(--warning-glow, rgba(245,158,11,.12));
  color: var(--warning, #f59e0b);
  border-color: rgba(245,158,11,.3);
}
.conn-status.conn-reconnecting .conn-dot {
  background: var(--warning, #f59e0b);
  animation: conn-blink .8s infinite;
}
/* Offline */
.conn-status.conn-offline {
  background: var(--danger-glow, rgba(239,68,68,.12));
  color: var(--danger, #ef4444);
  border-color: rgba(239,68,68,.3);
}
.conn-status.conn-offline .conn-dot { background: var(--danger, #ef4444); }

@keyframes conn-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.45); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
@keyframes conn-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .25; }
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn-primary {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

[data-theme="light"] .btn-secondary {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.15);
}

/* Theme Toggle — FinFlow square style */
.btn-theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 1.05rem;
  box-shadow: var(--glass-shadow);
  padding: 0;
}

.btn-theme-toggle:hover {
  border-color: var(--border-hover);
  transform: scale(1.05);
  background: var(--bg-surface-solid);
}

.btn-theme-toggle:active { transform: scale(0.95); }

/* SVG icons for theme toggle (if HTML updated) */
.btn-theme-toggle .sun-icon  { display: block;  color: var(--warning); }
.btn-theme-toggle .moon-icon { display: none;   color: var(--primary); }
[data-theme="light"] .btn-theme-toggle .sun-icon  { display: none; }
[data-theme="light"] .btn-theme-toggle .moon-icon { display: block; }

/* =========================================================================
   FILTER BAR
   ========================================================================= */
.filter-bar {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  box-shadow: var(--glass-shadow);
  transition: var(--transition-smooth);
}

.filter-bar:hover { border-color: var(--border-hover); }

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 150px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-input-wrapper {
  position: relative;
  flex: 1.5;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 14px 11px 40px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

[data-theme="light"] .search-input { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] .search-input:focus { background: rgba(0, 0, 0, 0.05); }

.select-filter {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 36px 11px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  transition: var(--transition-smooth);
}

.select-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

[data-theme="light"] .select-filter { background-color: rgba(0, 0, 0, 0.03); }

/* FinFlow alias — .form-select mirrors .select-filter */
.form-select { }
.form-select,
.select-filter {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 36px 9px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  transition: var(--transition-smooth);
}
.form-select:focus,
.select-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
[data-theme="light"] .form-select,
[data-theme="light"] .select-filter { background-color: rgba(0, 0, 0, 0.03); }

/* =========================================================================
   GLASS PANEL (shared base)
   ========================================================================= */
.dashboard-panel {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transition: var(--transition-smooth);
}

.dashboard-panel:hover {
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .dashboard-panel:hover {
  box-shadow: 0 12px 40px 0 rgba(15, 23, 42, 0.08);
}

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

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* =========================================================================
   DASHBOARD — Redesigned layout
   ========================================================================= */

/* KPI row */
.db-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) { .db-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .db-kpi-row { grid-template-columns: 1fr; } }

.db-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
  box-shadow: var(--glass-shadow);
}
.db-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.db-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.db-kpi-blue::before   { background: var(--primary); }
.db-kpi-green::before  { background: #22c55e; }
.db-kpi-purple::before { background: #a855f7; }
.db-kpi-orange::before { background: #f97316; }
.db-kpi-red::before    { background: var(--danger); }

.db-kpi-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.db-kpi-blue   .db-kpi-icon { background: var(--primary-glow);       color: var(--primary); }
.db-kpi-green  .db-kpi-icon { background: rgba(34,197,94,.12);       color: #22c55e; }
.db-kpi-purple .db-kpi-icon { background: rgba(168,85,247,.12);      color: #a855f7; }
.db-kpi-orange .db-kpi-icon { background: rgba(249,115,22,.12);      color: #f97316; }
.db-kpi-red    .db-kpi-icon { background: var(--danger-glow);        color: var(--danger); }
.db-kpi-icon svg { width: 20px; height: 20px; }
.db-kpi-body { display: flex; flex-direction: column; gap: 2px; }
.db-kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.db-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

/* Main row: upcoming + hk */
.db-main-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 18px;
  margin-bottom: 18px;
}
/* Bottom row: workload + conflicts */
.db-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) {
  .db-main-row, .db-bottom-row { grid-template-columns: 1fr; }
}

/* Panel header extras */
.db-panel-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  padding: 2px 10px;
}
.db-panel-link {
  font-size: 0.72rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}
.db-panel-link:hover { opacity: 0.7; }

/* ── Section dividers ────────────────────────────────────────── */
.db-section-divider {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 4px 0 4px 2px;
  margin: 6px 0 2px;
}
.db-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}
.db-section-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.db-section-today { color: var(--primary); }
.db-section-today .db-section-dot.db-dot-today { background: var(--primary); }
.db-section-today::after { background: rgba(59,130,246,.25); }

/* ── Upcoming items (redesigned) ─────────────────────────────── */
.db-upcoming-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.db-upcoming-item:hover { background: rgba(255,255,255,0.05); border-color: var(--border-hover); }
.db-upcoming-item.db-today {
  border-color: rgba(59,130,246,.3);
  background: rgba(59,130,246,.04);
}

.db-upcoming-date {
  min-width: 44px;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 5px 5px;
  flex-shrink: 0;
}
.db-upcoming-date.db-date-today { background: var(--primary-glow); }
.db-upcoming-dow   { font-size: 0.58rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing:.5px; }
.db-upcoming-day   { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.db-upcoming-month { font-size: 0.62rem; color: var(--text-muted); }
.db-date-today .db-upcoming-dow,
.db-date-today .db-upcoming-day,
.db-date-today .db-upcoming-month { color: var(--primary); }

.db-upcoming-meta  { flex: 1; min-width: 0; }
.db-upcoming-top-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.db-upcoming-loc   { font-size: 0.83rem; font-weight: 700; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-upcoming-detail { font-size: 0.68rem; color: var(--text-muted); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-cat-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.db-upcoming-team-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.db-team-chip {
  font-size: 0.62rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  padding: 1px 7px;
}

.db-upcoming-time-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  padding-top: 2px;
}
.db-upcoming-time     { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.db-upcoming-time-end { font-size: 0.62rem; color: var(--text-muted); white-space: nowrap; }
.db-upcoming-empty { font-size: 0.8rem; color: var(--text-muted); text-align: center; padding: 24px 0; }

/* ── Todo panel (Việc cần làm) ───────────────────────────────── */
.db-todo-section-hdr {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.db-todo-count {
  background: var(--primary-glow);
  color: var(--primary);
  border-radius: 99px;
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 700;
}

.db-todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.02);
  transition: background .15s;
}
.db-todo-item:hover { background: rgba(255,255,255,0.05); }
.db-todo-item.db-todo-overdue  { border-color: rgba(239,68,68,.25);  background: rgba(239,68,68,.05); }
.db-todo-item.db-todo-urgent   { border-color: rgba(249,115,22,.25); background: rgba(249,115,22,.05); }
.db-todo-item.db-todo-warn     { border-color: rgba(245,158,11,.2);  background: rgba(245,158,11,.04); }
.db-todo-item.db-todo-undelivered { border-color: rgba(245,158,11,.2); background: rgba(245,158,11,.04); }

.db-todo-badge {
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 54px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.db-todo-info  { flex: 1; min-width: 0; }
.db-todo-name  { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-todo-sub   { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }
.db-todo-action {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
  font-family: inherit;
}
.db-todo-action:hover { background: var(--primary-glow); color: var(--primary); border-color: var(--primary); }
.db-todo-loading, .db-todo-done, .db-todo-all-done {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0;
}

/* HK overview widget */
.db-hk-pipeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.db-hk-step {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  transition: background 0.15s;
  cursor: default;
}
.db-hk-step:hover { background: rgba(255,255,255,0.05); }
.db-hk-step-count { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.db-hk-step-label { font-size: 0.58rem; color: var(--text-muted); margin-top: 3px; line-height: 1.2; }
.db-hk-urgent-list { display: flex; flex-direction: column; gap: 6px; }
.db-hk-urgent-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.76rem; padding: 6px 10px;
  border-radius: 7px;
  background: rgba(239,68,68,0.05);
  border: 1px solid rgba(239,68,68,0.12);
}

/* Legacy — keep for other views that reference these */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  box-shadow: var(--glass-shadow);
}

/* Left accent strip */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--border-color);
}

/* Accent colour by icon type (uses modern :has()) */
.stat-card:has(.stat-icon.total)::before { background: var(--primary); }
.stat-card:has(.stat-icon.duan)::before  { background: var(--cat-duan); }
.stat-card:has(.stat-icon.event)::before { background: var(--cat-event); }
.stat-card:has(.stat-icon.zeng)::before  { background: var(--cat-zeng); }

/* Fallback via explicit class (JS can add these) */
.stat-card.accent-primary::before { background: var(--primary); }
.stat-card.accent-duan::before    { background: var(--cat-duan); }
.stat-card.accent-event::before   { background: var(--cat-event); }
.stat-card.accent-zeng::before    { background: var(--cat-zeng); }

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .stat-card:hover {
  box-shadow: 0 12px 40px 0 rgba(15, 23, 42, 0.08);
}

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

.stat-icon.total { background: hsla(217, 91%, 60%, 0.1); }
.stat-icon.duan  { background: var(--cat-duan-bg); }
.stat-icon.event { background: var(--cat-event-bg); }
.stat-icon.zeng  { background: var(--cat-zeng-bg); }

.stat-info { display: flex; flex-direction: column; }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* .row-layout kept for backward compatibility with other views */
.row-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* =========================================================================
   WORKLOAD DISTRIBUTION
   ========================================================================= */
.workload-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.workload-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workload-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}

.workload-name  { color: var(--text-primary); }
.workload-count { color: var(--text-secondary); }

.progress-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 99px;
  overflow: hidden;
}

[data-theme="light"] .progress-bar-bg { background: rgba(0, 0, 0, 0.05); }

.progress-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px var(--primary-glow);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: progressShine 1.5s infinite linear;
}

@keyframes progressShine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* =========================================================================
   VIEW PANELS (fade in)
   ========================================================================= */
.view-panel { display: none; }

.view-panel.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

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

/* =========================================================================
   CALENDAR VIEW
   ========================================================================= */
.calendar-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--glass-shadow);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-month-title {
  font-size: 1rem;
  font-weight: 700;
  min-width: 160px;
  text-align: center;
}

.btn-nav-cal {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-nav-cal:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

[data-theme="light"] .btn-nav-cal:hover { background: rgba(0, 0, 0, 0.05); }

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

.calendar-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 8px 0;
  letter-spacing: 0.5px;
}

.calendar-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 120px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

.calendar-cell:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.calendar-cell.other-month { opacity: 0.3; }

.calendar-cell.today {
  border-color: var(--primary);
  background: hsla(217, 91%, 60%, 0.04);
}

.calendar-date-number {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  align-self: flex-start;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.calendar-cell.today .calendar-date-number {
  background: var(--primary);
  color: white;
}

.calendar-events-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}

.calendar-event-item {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 7px;
  border-radius: 5px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.calendar-event-item:hover { transform: scale(1.02); }

.calendar-event-item.du-an { background: var(--cat-duan-bg); color: var(--cat-duan); border-left: 2px solid var(--cat-duan); }
.calendar-event-item.event { background: var(--cat-event-bg); color: var(--cat-event); border-left: 2px solid var(--cat-event); }
.calendar-event-item.zeng  { background: var(--cat-zeng-bg);  color: var(--cat-zeng);  border-left: 2px solid var(--cat-zeng); }

/* =========================================================================
   SMART DATA TABLE
   ========================================================================= */
.table-container {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 24px;
  box-shadow: var(--glass-shadow);
}

.data-table {
  width: 100%;
  min-width: 1480px;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: rgba(0, 0, 0, 0.15);
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 14px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

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

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

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

[data-theme="light"] .data-table tr:hover td { background: rgba(0, 0, 0, 0.015); }

.table-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table-badge.du-an { background: var(--cat-duan-bg); color: var(--cat-duan); }
.table-badge.event { background: var(--cat-event-bg); color: var(--cat-event); }
.table-badge.zeng  { background: var(--cat-zeng-bg);  color: var(--cat-zeng); }

.in-charge-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge-person {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-secondary);
}

.badge-person.highlight {
  border-color: var(--primary-glow);
  color: var(--text-primary);
  background: hsla(217, 91%, 60%, 0.1);
}

.checkbox-deliverable {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.checkbox-deliverable:checked {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}

.checkbox-deliverable:checked::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: 800;
}

.btn-details {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: var(--transition-smooth);
}

.btn-details:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

/* =========================================================================
   SLIDE-OVER DRAWER
   ========================================================================= */
.drawer-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.active { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: var(--bg-surface-solid);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--glass-shadow);
  z-index: 1001;
  padding: 32px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.active { right: 0; }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.btn-close-drawer {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-close-drawer:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.drawer-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.drawer-value {
  font-size: 14px;
  color: var(--text-primary);
}

.location-map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.location-map-link:hover { text-decoration: underline; }

/* =========================================================================
   MODAL FORM
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active { opacity: 1; pointer-events: auto; }

.modal-box {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

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

.btn-close-modal {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-close-modal:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .form-control { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] .form-control:focus { background: rgba(0, 0, 0, 0.05); }

.role-multiselect { min-height: 108px; }
.role-multiselect option, .inline-member-multiselect option { padding: 4px 6px; }

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

.checkbox-group-form {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* =========================================================================
   TOAST NOTIFICATION
   ========================================================================= */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface-solid);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2000;
}

.toast-notification.active { transform: translateY(0); opacity: 1; }
.toast-icon   { font-size: 1.1rem; }
.toast-message { font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* =========================================================================
   CONFLICT ALERT BADGE
   ========================================================================= */
.conflict-badge {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* =========================================================================
   LOADING OVERLAY
   ========================================================================= */
.loading-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(8, 13, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active { opacity: 1; pointer-events: auto; }

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   INLINE TABLE EDITING
   ========================================================================= */
.inline-select-container {
  position: relative;
  width: 100%;
  min-width: 105px;
}

.inline-table-input {
  width: 100%;
  min-width: 96px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  transition: var(--transition-smooth);
}

.inline-table-input:hover { background-color: rgba(255, 255, 255, 0.08); border-color: var(--border-hover); }
.inline-table-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.inline-time-group   { display: flex; flex-direction: column; gap: 6px; }
.inline-time-input   { min-width: 88px; }
.inline-location-input { min-width: 150px; }
.inline-detail-input { min-width: 130px; }

.inline-member-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 20px 6px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 11px;
  transition: var(--transition-smooth);
}

.inline-member-select:hover  { background-color: rgba(255, 255, 255, 0.08); border-color: var(--border-hover); }
.inline-member-select:focus  { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.inline-member-multiselect   { min-height: 84px; padding-right: 8px; background-image: none; }
.inline-category-select      { min-width: 96px; }

/* =========================================================================
   MEMBER COLOUR CODING (Media Flow)
   ========================================================================= */
.member-hoang    { background-color: rgba(59, 130, 246, 0.15) !important; color: #60a5fa !important; border-color: rgba(59, 130, 246, 0.35) !important; }
.member-haianh   { background-color: rgba(16, 185, 129, 0.15) !important; color: #34d399 !important; border-color: rgba(16, 185, 129, 0.35) !important; }
.member-thinh    { background-color: rgba(245, 158, 11, 0.15) !important; color: #fbbf24 !important; border-color: rgba(245, 158, 11, 0.35) !important; }
.member-phuongfly{ background-color: rgba(168, 85, 247, 0.15) !important; color: #c084fc !important; border-color: rgba(168, 85, 247, 0.35) !important; }
.member-tuan     { background-color: rgba(249, 115, 22, 0.15) !important; color: #ff9d5c !important; border-color: rgba(249, 115, 22, 0.35) !important; }
.member-dung     { background-color: rgba(244, 63, 94, 0.15)  !important; color: #fb7185 !important; border-color: rgba(244, 63, 94, 0.35)  !important; }

.assignee-dot.member-hoang    { background-color: #3b82f6 !important; color: white !important; border-color: var(--bg-base) !important; }
.assignee-dot.member-haianh   { background-color: #10b981 !important; color: white !important; border-color: var(--bg-base) !important; }
.assignee-dot.member-thinh    { background-color: #f59e0b !important; color: white !important; border-color: var(--bg-base) !important; }
.assignee-dot.member-phuongfly{ background-color: #a855f7 !important; color: white !important; border-color: var(--bg-base) !important; }
.assignee-dot.member-tuan     { background-color: #f97316 !important; color: white !important; border-color: var(--bg-base) !important; }
.assignee-dot.member-dung     { background-color: #f43f5e !important; color: white !important; border-color: var(--bg-base) !important; }

/* Light mode overrides */
[data-theme="light"] .member-hoang    { background-color: rgba(59, 130, 246, 0.1) !important; color: #2563eb !important; }
[data-theme="light"] .member-haianh   { background-color: rgba(16, 185, 129, 0.1) !important; color: #059669 !important; }
[data-theme="light"] .member-thinh    { background-color: rgba(245, 158, 11, 0.1) !important; color: #d97706 !important; }
[data-theme="light"] .member-phuongfly{ background-color: rgba(168, 85, 247, 0.1) !important; color: #7e22ce !important; }
[data-theme="light"] .member-tuan     { background-color: rgba(249, 115, 22, 0.1) !important; color: #ea580c !important; }
[data-theme="light"] .member-dung     { background-color: rgba(244, 63, 94, 0.1)  !important; color: #be123c !important; }

/* =========================================================================
   MEMBER PICKER — Custom multi-select thay thế native select trong bảng
   ========================================================================= */
.member-picker {
  position: relative;
  width: 100%;
}

.member-picker-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 34px;
  user-select: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.member-picker-trigger:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.07);
}

.member-picker.open .member-picker-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

[data-theme="light"] .member-picker-trigger { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] .member-picker-trigger:hover { background: rgba(0, 0, 0, 0.06); }

/* Avatar stack trong trigger */
.member-avatar-stack {
  display: flex;
  align-items: center;
  flex: 1;
}

.member-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: white !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: -5px;
  border: 2px solid var(--bg-surface-solid) !important;
  letter-spacing: -0.2px;
  background-color: unset;
}

.member-avatar:last-child { margin-right: 0; }

.member-avatar-extra {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
  font-size: 7px !important;
}

.picker-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.picker-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.member-picker.open .picker-chevron { transform: rotate(180deg); }

/* Dropdown — fixed position, set via JS để thoát overflow của table */
.member-picker-dropdown {
  position: fixed;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.2);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 600;
  display: none;
  overflow: hidden;
  padding: 4px;
}

[data-theme="light"] .member-picker-dropdown {
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
}

.member-picker.open .member-picker-dropdown {
  display: block;
  animation: pickerFadeIn 0.14s ease-out;
}

@keyframes pickerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Từng option trong dropdown */
.picker-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}

.picker-option:hover { background: rgba(255, 255, 255, 0.07); }
[data-theme="light"] .picker-option:hover { background: rgba(0, 0, 0, 0.04); }

.picker-option.selected { background: hsla(217, 91%, 60%, 0.08); }
[data-theme="light"] .picker-option.selected { background: hsla(222, 100%, 42%, 0.06); }

.picker-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.2px;
}

.picker-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  color: var(--text-primary);
}

.picker-check {
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}

.picker-option.selected .picker-check { opacity: 1; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1024px) {
  .row-layout { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
  .sidebar { width: 70px; overflow: hidden; }

  .logo-text-area, .username, .user-role { display: none; }

  .nav-link {
    padding: 12px;
    justify-content: center;
    border-left: 3px solid transparent;
  }

  .nav-link.active {
    padding-left: 12px;
    border-left: none;
    background: rgba(255, 255, 255, 0.12);
    color: var(--primary);
  }

  .user-profile { justify-content: center; padding: 16px 12px; }

  .main-content {
    margin-left: 70px;
    max-width: calc(100vw - 70px);
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .top-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .calendar-grid { font-size: 11px; }
  .calendar-cell { min-height: 80px; padding: 4px; }
  .drawer { width: 100%; right: -100%; }
}

/* =========================================================================
   SORT & FILTER ENHANCEMENTS
   ========================================================================= */

/* Sortable table header cells */
.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.sortable-th:hover {
  color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.07) !important;
}

.sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: 11px;
  opacity: 0.35;
  transition: opacity 0.18s, color 0.18s;
  vertical-align: middle;
  font-style: normal;
}

.sortable-th:hover .sort-icon { opacity: 0.75; }

.sortable-th.sort-asc  .sort-icon,
.sortable-th.sort-desc .sort-icon { opacity: 1; color: var(--primary); }

.sortable-th.sort-asc,
.sortable-th.sort-desc {
  color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.05) !important;
}

/* Reset filters button */
.btn-reset-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: rgba(239, 68, 68, 0.07);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: #fb7185;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  white-space: nowrap;
  align-self: flex-end;
  height: fit-content;
}

.btn-reset-filters:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f43f5e;
  transform: translateY(-1px);
}

[data-theme="light"] .btn-reset-filters { color: #dc2626; background: rgba(239, 68, 68, 0.05); }

/* Active filter count badge */
.filter-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Status badge in table */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge.status-created {
  background: rgba(34, 197, 94, 0.14);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.30);
}

.status-badge.status-updated,
.status-badge.status-update {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.status-badge.status-done {
  background: rgba(16, 185, 129, 0.14);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.status-badge.status-cancel {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-badge.status-default {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .status-badge.status-default {
  background: rgba(0, 0, 0, 0.04);
}

@media (max-width: 768px) {
  .btn-reset-filters { width: 100%; justify-content: center; }
}

/* =====================================================================
   SALARY VIEW
   ===================================================================== */

/* ── Header ── */
.salary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.salary-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.salary-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0;
}
.salary-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Month pills ── */
.salary-month-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.salary-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.salary-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.salary-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Person cards grid ── */
.salary-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.salary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
  transition: transform .15s, box-shadow .15s;
}
.salary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.salary-card-warn {
  border-color: rgba(245, 158, 11, .4);
  background: rgba(245, 158, 11, .05);
}
.salary-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.salary-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.salary-card-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.salary-card-sessions {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.salary-card-total {
  margin-bottom: 10px;
}
.salary-card-amount {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.salary-card-unknown {
  font-size: 0.82rem;
  color: var(--warning);
  font-weight: 600;
}
.salary-card-months {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.salary-card-month-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.salary-card-month-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Card selected state ── */
.salary-card-selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-glow), 0 8px 24px rgba(0,0,0,.2);
  transform: translateY(-2px);
}
.salary-card-check {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Person Mini Dashboard ── */
#person-mini-dashboard {
  margin-bottom: 16px;
}
.pmd-panel {
  background: var(--bg-surface);
  border: 1px solid var(--primary);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px var(--primary-glow), 0 12px 32px rgba(0,0,0,.2);
  animation: pmd-slide-in .18s ease;
}
@keyframes pmd-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pmd-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid var(--border-color);
}
.pmd-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.pmd-title-block {
  flex: 1;
}
.pmd-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}
.pmd-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
}
.pmd-total-block {
  text-align: right;
}
.pmd-total {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  display: block;
}
.pmd-total-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pmd-unknown {
  font-size: 0.85rem;
  color: var(--warning);
  font-weight: 600;
  display: block;
}
.pmd-close {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.85rem;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.pmd-close:hover {
  background: rgba(255,255,255,.12);
  color: var(--text-primary);
}
.pmd-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.pmd-section {
  padding: 20px 24px;
}
.pmd-section:first-child {
  border-right: 1px solid var(--border-color);
}
.pmd-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}
.pmd-role-bars, .pmd-month-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pmd-role-row, .pmd-month-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 10px;
}
.pmd-role-label, .pmd-month-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmd-role-bar-wrap, .pmd-month-bar-wrap {
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.pmd-role-bar, .pmd-month-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
  min-width: 4px;
}
.pmd-role-stat, .pmd-month-stat {
  font-size: 0.78rem;
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}
.pmd-role-pct {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72em;
}

@media (max-width: 768px) {
  .pmd-body { grid-template-columns: 1fr; }
  .pmd-section:first-child { border-right: none; border-bottom: 1px solid var(--border-color); }
}

/* ── Detail section ── */
.salary-detail-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(12px);
}
.salary-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.salary-detail-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.salary-detail-filters {
  display: flex;
  gap: 8px;
}
.salary-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
}
.salary-table-container {
  backdrop-filter: none !important;
  overflow-x: auto;
}
.salary-detail-table tbody tr:hover td {
  background: rgba(99, 102, 241, .05) !important;
}
.salary-row-alt td {
  background: var(--bg-surface-solid, rgba(255,255,255,.02)) !important;
}
.salary-total-row td {
  padding: 12px 16px;
  border-top: 2px solid var(--border-color);
  font-size: 0.9rem;
}
.salary-location-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.salary-role-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99,102,241,.12);
  color: var(--accent);
  white-space: nowrap;
}
.salary-person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}
.salary-person-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.salary-note-cell {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.salary-amount-cell {
  font-weight: 700;
  color: var(--success, #10b981);
  white-space: nowrap;
}
.salary-unknown-cell {
  color: var(--warning);
  font-weight: 600;
  font-size: 0.85rem;
}

/* ── Salary header action buttons ── */
.salary-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.btn-salary-export {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,.04);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-salary-export:hover {
  border-color: var(--success);
  color: var(--success);
  background: rgba(34,197,94,.08);
}
.btn-salary-settings {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,.04);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-salary-settings:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--primary-glow);
}

/* ── Rate config modal ── */
.rate-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 1100;
  animation: fade-in .15s ease;
}
.rate-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1101;
  width: min(860px, 96vw);
  max-height: 82vh;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  animation: modal-pop .18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translate(-50%, -48%) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.rate-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.rate-modal-icon {
  font-size: 1.4rem;
}
.rate-modal-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.rate-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.rate-modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.rate-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.rate-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all .15s;
  margin-left: 4px;
}
.rate-modal-close:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.rate-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 4px 8px;
}
.salary-sheet-link {
  color: var(--accent);
  text-decoration: underline dotted;
}
.salary-sheet-link {
  color: var(--accent);
  text-decoration: underline dotted;
}
.btn-salary-reload {
  padding: 3px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-salary-reload:hover { border-color: var(--accent); color: var(--accent); }
.salary-rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.salary-rate-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}
.salary-rate-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}
.salary-rate-amount {
  color: var(--accent);
}
.salary-type-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.73rem;
  font-weight: 600;
}
.salary-type-gio {
  background: rgba(59,130,246,.12);
  color: #3b82f6;
}
.salary-type-buoi {
  background: rgba(16,185,129,.12);
  color: #10b981;
}
/* ── Rate edit mode ── */
.salary-rate-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 14px;
  flex-wrap: wrap;
}
.salary-rate-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.salary-rate-toolbar-edit {
  background: rgba(99,102,241,.06);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
}
.salary-rate-edit-hint {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}
.btn-rate-edit {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-rate-edit:hover { background: var(--accent); color: #fff; }
.btn-rate-add {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid rgba(16,185,129,.5);
  background: rgba(16,185,129,.1);
  color: #10b981;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-rate-add:hover { background: rgba(16,185,129,.2); }
.btn-rate-cancel {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-rate-save {
  padding: 5px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-rate-save:disabled { opacity: .6; cursor: not-allowed; }
.btn-rate-save:hover:not(:disabled) { opacity: .85; }
.btn-rate-delete {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: .5;
  transition: opacity .15s, background .15s;
}
.btn-rate-delete:hover { opacity: 1; background: rgba(239,68,68,.12); }
.rate-edit-row td { padding: 5px 8px; vertical-align: middle; }
.rate-edit-row { background: rgba(99,102,241,.03); }
.rate-input {
  width: 100%;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-solid, rgba(255,255,255,.05));
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
}
.rate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
.rate-input-amount { text-align: right; width: 100px; }
.rate-input-cond { width: 90px; }
.rate-select-role, .rate-select-type {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
  cursor: pointer;
}

.salary-cond-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 0.73rem;
  font-weight: 600;
  background: rgba(99,102,241,.1);
  color: var(--accent);
}

/* =========================================================================
   HẬU KỲ VIEW
   ========================================================================= */

/* ── Header ── */
.hk-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.hk-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 4px; }
.hk-subtitle { font-size: 0.82rem; color: var(--text-secondary); margin: 0; }
.hk-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Stats */
.hk-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hk-stat-chip {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 14px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border-color);
  min-width: 60px;
}
.hk-stat-val { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.hk-stat-lbl { font-size: 0.65rem; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; }
.hk-stat-done { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.06); }
.hk-stat-done .hk-stat-val { color: #22c55e; }
.hk-stat-warn { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.06); }
.hk-stat-warn .hk-stat-val { color: #f59e0b; }
.hk-stat-danger { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.06); }
.hk-stat-danger .hk-stat-val { color: #ef4444; }

/* Add / Reload buttons */
.btn-hk-add {
  padding: 8px 18px; border-radius: 10px; border: none;
  background: var(--primary-gradient); color: #fff;
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.btn-hk-add:hover { opacity: .88; }
.btn-hk-reload {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border-color); background: transparent;
  color: var(--text-secondary); cursor: pointer; font-size: 1rem;
  transition: all .15s;
}
.btn-hk-reload:hover { border-color: var(--accent); color: var(--accent); }

/* ── Filters ── */
.hk-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.hk-select {
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: 0.82rem; cursor: pointer; outline: none;
  transition: border-color .15s;
}
.hk-select:focus { border-color: var(--accent); }

/* ── Kanban Board ── */
.hk-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(200px, 1fr));
  grid-auto-flow: column;
  gap: 12px;
  align-items: start;
  min-height: 400px;
  overflow-x: auto;
  padding-bottom: 12px;
  /* Always single horizontal row — scroll rather than wrap */
  grid-auto-rows: auto;
}

/* Profile-only columns */
.hk-col-profile { border-top: 2px solid rgba(139,92,246,.4); }
.hk-col-profile .hk-col-header { background: rgba(139,92,246,.06); border-radius: 8px 8px 0 0; }
.hk-col-profile-tag {
  font-size: .65rem; margin-right: 2px; opacity: .7;
}

/* ── Column ── */
.hk-col {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border-color);
  border-radius: 14px; padding: 12px;
  min-height: 200px;
  transition: background .15s;
}
.hk-col[data-status="da_giao"] { opacity: .75; }
.hk-col-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}
.hk-col-icon { font-size: 1rem; }
.hk-col-label { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); flex: 1; }
.hk-col-count {
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px; min-width: 22px; text-align: center;
}
.hk-cards { display: flex; flex-direction: column; gap: 10px; }

/* ── Card ── */
.hk-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px; padding: 12px;
  cursor: grab; transition: transform .15s, box-shadow .15s, border-color .15s;
  user-select: none;
}
.hk-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.hk-card.hk-dragging { opacity: .5; cursor: grabbing; }
.hk-card.hk-overdue  { border-color: rgba(239,68,68,.6); background: rgba(239,68,68,.06); }
.hk-card.hk-urgent   { border-color: rgba(249,115,22,.5); background: rgba(249,115,22,.04); }
.hk-card.hk-soon     { border-color: rgba(245,158,11,.4); }

.hk-card-top {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
}
.hk-type-badge {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 8px; white-space: nowrap;
}
.hk-rev-badge {
  font-size: 0.65rem; padding: 2px 7px; border-radius: 8px;
  background: rgba(249,115,22,.15); color: #f97316; font-weight: 600;
}
.hk-card-actions { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.hk-card:hover .hk-card-actions { opacity: 1; }
.hk-btn-icon {
  background: transparent; border: none; cursor: pointer;
  font-size: 0.85rem; padding: 3px 5px; border-radius: 6px;
  transition: background .15s;
}
.hk-btn-icon:hover { background: rgba(255,255,255,.1); }
.hk-btn-del:hover  { background: rgba(239,68,68,.15) !important; }

.hk-card-name {
  font-size: 0.85rem; font-weight: 700; color: var(--text-primary);
  line-height: 1.35; margin-bottom: 8px;
}
.hk-card-editor {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 6px;
}
.hk-editor-dot {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; color: #fff;
}
.hk-deadline {
  font-size: 0.72rem; color: var(--text-muted);
  margin-bottom: 6px; font-weight: 500;
}
.hk-deadline.hk-overdue  { color: #ef4444; font-weight: 700; }
.hk-deadline.hk-critical { color: #ef4444; font-weight: 700; }
.hk-deadline.hk-urgent   { color: #f97316; font-weight: 700; }
.hk-deadline.hk-soon     { color: #f59e0b; font-weight: 600; }
.hk-link-badge {
  display: inline-block; font-size: 0.68rem; padding: 2px 7px;
  border-radius: 6px; background: rgba(99,102,241,.1); color: var(--accent);
  margin-bottom: 4px;
}
.hk-delivery-link {
  display: block; font-size: 0.72rem; color: #22c55e;
  text-decoration: none; word-break: break-all;
  margin-top: 4px;
}
.hk-delivery-link:hover { text-decoration: underline; }

/* ── Modal ── */
.hk-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  z-index: 1200; animation: fade-in .15s ease;
}
.hk-modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1201; width: min(640px, 96vw); max-height: 90vh;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color); border-radius: 20px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  animation: modal-pop .18s cubic-bezier(.34,1.56,.64,1);
}
.hk-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.hk-modal-title-text { font-size: 1rem; font-weight: 700; }
.hk-modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border-color); background: transparent;
  color: var(--text-secondary); cursor: pointer; font-size: .85rem;
  transition: all .15s;
}
.hk-modal-close:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.hk-modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }

.hk-form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hk-form-full { grid-column: 1 / -1; }
.hk-form-group { display: flex; flex-direction: column; gap: 5px; }
.hk-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.hk-required { color: #ef4444; }
.hk-input {
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,.04); color: var(--text-primary);
  font-size: 0.85rem; font-family: inherit; outline: none;
  transition: border-color .15s;
  width: 100%; box-sizing: border-box;
}
.hk-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--primary-glow); }
.hk-textarea { resize: vertical; min-height: 60px; }
.hk-form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 8px; border-top: 1px solid var(--border-color); margin-top: 4px;
}
.hk-btn-cancel {
  padding: 8px 18px; border-radius: 10px;
  border: 1px solid var(--border-color); background: transparent;
  color: var(--text-secondary); cursor: pointer; font-size: .85rem;
  transition: all .15s;
}
.hk-btn-cancel:hover { background: rgba(255,255,255,.06); }
.hk-btn-submit {
  padding: 8px 22px; border-radius: 10px; border: none;
  background: var(--primary-gradient); color: #fff;
  font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.hk-btn-submit:hover { opacity: .88; }

/* ── HK SLA & Deadline Enhancements ────────────────────────────────────────── */

/* Progress bar */
.hk-sla-progress {
  height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.08);
  margin: 6px 0 2px; overflow: hidden;
}
.hk-sla-bar {
  height: 100%; border-radius: 2px;
  transition: width .4s ease, background .4s ease;
}

/* Card urgency states */
.hk-card.hk-critical {
  border-color: rgba(239,68,68,.7);
  background: rgba(239,68,68,.07);
  animation: hk-pulse 2s infinite;
}
.hk-card.hk-urgent  { border-color: rgba(249,115,22,.5); background: rgba(249,115,22,.05); }
.hk-card.hk-soon    { border-color: rgba(245,158,11,.4); }
.hk-card.hk-card-done { opacity: .65; }

@keyframes hk-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.3); }
  50%       { box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
}

/* Deadline label urgency colors */
.hk-deadline.hk-overdue  { color: #ef4444; font-weight: 700; }
.hk-deadline.hk-critical { color: #ef4444; font-weight: 700; }
.hk-deadline.hk-urgent   { color: #f97316; font-weight: 700; }
.hk-deadline.hk-soon     { color: #f59e0b; font-weight: 600; }

/* Stats chips new */
.hk-stat-critical { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.08); }
.hk-stat-critical .hk-stat-val { color: #ef4444; }

/* Notes on card */
.hk-card-notes {
  font-size: .72rem; color: var(--text-muted);
  margin-top: 4px; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Drag-over column highlight */
.hk-col-dragover { background: rgba(var(--accent-rgb),.06); border-radius: 12px; }

/* Form hints */
.hk-field-hint {
  font-size: .72rem; color: var(--text-muted);
  margin-top: 2px; line-height: 1.4;
}
.hk-sla-hint {
  display: block; font-size: .75rem; margin-top: 4px; line-height: 1.4;
}
.hk-sla-hint-info  { color: #3b82f6; }
.hk-sla-hint-muted { color: var(--text-muted); font-style: italic; }

/* Settings button */
.btn-hk-settings {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-secondary);
  font-size: 1rem; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-hk-settings:hover { border-color: var(--accent); color: var(--accent); }

/* SLA Modal */
.hk-sla-modal { max-width: 460px !important; }
.hk-sla-desc {
  font-size: .82rem; color: var(--text-secondary);
  margin: 0 0 16px; line-height: 1.6;
}
.hk-sla-table {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden;
}
.hk-sla-row {
  display: grid; grid-template-columns: 1fr 100px 90px;
  gap: 12px; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}
.hk-sla-row:last-child { border-bottom: none; }
.hk-sla-header {
  background: rgba(255,255,255,.03);
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.hk-sla-row-muted { opacity: .55; }
.hk-sla-type-label { font-size: .85rem; font-weight: 600; color: var(--text-primary); }
.hk-sla-input {
  padding: 6px 8px !important;
  font-size: .85rem !important;
  text-align: center;
}
.hk-sla-equiv {
  font-size: .78rem; color: var(--text-secondary);
  font-style: italic; text-align: right;
}
.hk-sla-manual {
  font-size: .78rem; color: var(--text-muted);
  font-style: italic;
}
.hk-sla-note {
  font-size: .78rem; color: var(--text-muted);
  background: rgba(59,130,246,.06); border: 1px solid rgba(59,130,246,.15);
  border-radius: 8px; padding: 10px 14px; margin-top: 14px;
  line-height: 1.6;
}

/* ── Pending từ Tiền kỳ ──────────────────────────────────────────────────── */
.hk-pending-section {
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.hk-pending-header {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; font-weight: 700; color: #f59e0b;
  margin-bottom: 10px;
}
.hk-pending-count {
  font-size: .72rem; font-weight: 600;
  background: rgba(245,158,11,.15);
  color: #f59e0b; border-radius: 20px; padding: 2px 8px;
}
.hk-btn-sync-all {
  margin-left: auto; flex-shrink: 0;
  background: rgba(245,158,11,.15); color: #f59e0b;
  border: 1px solid rgba(245,158,11,.35);
  border-radius: 6px; padding: 3px 10px; font-size: .75rem;
  font-weight: 700; cursor: pointer; transition: background .15s;
}
.hk-btn-sync-all:hover { background: rgba(245,158,11,.3); }
.hk-pending-list { display: flex; flex-direction: column; gap: 6px; }
.hk-pending-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px; padding: 8px 12px;
  font-size: .8rem;
}
.hk-pending-date { font-weight: 700; color: var(--text-primary); min-width: 60px; }
.hk-pending-loc  { flex: 1; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hk-pending-types { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.hk-btn-from-pending {
  margin-left: auto; flex-shrink: 0;
  background: rgba(99,102,241,.15); color: var(--accent);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 6px; padding: 4px 10px; font-size: .75rem;
  cursor: pointer; transition: background .15s;
}
.hk-btn-from-pending:hover { background: rgba(99,102,241,.28); }

/* Tiền kỳ reference trên card */
.hk-tienky-ref {
  font-size: .72rem; color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Nút tạo hậu kỳ trong Drawer */
.btn-hk-from-drawer {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 8px 14px; margin-bottom: 8px;
  background: rgba(99,102,241,.12); color: var(--accent);
  border: 1px solid rgba(99,102,241,.35);
  border-radius: 8px; font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-hk-from-drawer:hover { background: rgba(99,102,241,.25); }
.drawer-hk-linked {
  text-align: center; font-size: .75rem; color: #22c55e;
  padding: 5px 0 10px; font-weight: 600;
}

/* =========================================================================
   QUẢN LÝ NGƯỜI DÙNG (Admin)
   ========================================================================= */
.users-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.users-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.users-subtitle { font-size: 13.5px; color: var(--text-secondary); margin-top: 4px; }

.users-table-wrap {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--glass-shadow);
}
.users-table { width: 100%; border-collapse: collapse; }
.users-table thead th {
  text-align: left; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  padding: 14px 18px; border-bottom: 1px solid var(--border-color);
  background: rgba(255,255,255,.02);
}
.users-table tbody td {
  padding: 13px 18px; border-bottom: 1px solid var(--border-color);
  font-size: 13.5px; color: var(--text-primary); vertical-align: middle;
}
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover { background: rgba(255,255,255,.03); }
.users-empty { text-align: center; color: var(--text-muted); padding: 28px !important; }

.users-cell-name { display: flex; align-items: center; gap: 11px; }
.users-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.users-name { font-weight: 600; color: var(--text-primary); }
.users-display { font-size: 12px; color: var(--text-muted); }
.users-email { color: var(--text-secondary); font-size: 13px; }

.users-role-select {
  padding: 7px 11px; border-radius: var(--radius-sm, 8px);
  background: var(--bg-surface-solid); color: var(--text-primary);
  border: 1px solid var(--border-color); font-family: inherit; font-size: 13px;
  cursor: pointer; transition: border-color .2s ease;
}
.users-role-select:hover:not(:disabled) { border-color: var(--border-hover); }
.users-role-select:focus { outline: none; border-color: var(--primary); }
.users-role-select:disabled { opacity: .55; cursor: not-allowed; }

.users-toggle { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); }
.users-toggle:disabled { opacity: .5; cursor: not-allowed; }

.users-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.users-badge-ok   { background: var(--success-glow); color: var(--success); }
.users-badge-warn { background: var(--warning-glow); color: var(--warning); }

.users-note { margin-top: 16px; font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.users-note code {
  background: rgba(255,255,255,.06); padding: 2px 7px; border-radius: 5px;
  font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-secondary);
}

/* =========================================================================
   ẨN THAO TÁC SỬA KHI CHƯA ĐĂNG NHẬP QUYỀN (chế độ khách / xem)
   body.can-edit chỉ có khi đăng nhập admin/leader
   ========================================================================= */
body:not(.can-edit) #drawer-actions,
body:not(.can-edit) .btn-hk-add,
body:not(.can-edit) .btn-hk-settings,
body:not(.can-edit) .hk-btn-icon,
body:not(.can-edit) .btn-rate-edit { display: none !important; }

/* Thẻ hậu kỳ không hiện con trỏ kéo khi là khách */
body:not(.can-edit) .hk-card { cursor: default; }

/* =========================================================================
   THANH LỌC KHI ĐƯA XUỐNG DƯỚI LỊCH (view Lịch trực quan)
   ========================================================================= */
.filter-bar-bottom {
  margin-top: 20px;
  position: relative;
}
.filter-bar-bottom::before {
  content: "Bộ lọc & Tìm kiếm";
  position: absolute;
  top: -10px;
  left: 18px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-base);
  border-radius: 999px;
}

/* =========================================================================
   LỊCH TRỰC QUAN — vừa 1 màn hình, ô đồng đều & thẳng hàng
   (chỉ áp dụng khi đang ở view Lịch: body.view-calendar)
   ========================================================================= */
body.view-calendar .main-content { height: 100vh; min-height: 0; overflow: hidden; }
body.view-calendar #calendar-view {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
body.view-calendar .calendar-container {
  flex: 1; min-height: 0;
  gap: 10px;
}
body.view-calendar .calendar-header { padding: 10px 18px; }

/* Lưới ô ngày: chia đều chiều cao còn lại cho 6 hàng tuần */
body.view-calendar #calendar-grid-cells {
  flex: 1;
  min-height: 0;
  grid-auto-rows: 1fr;     /* mọi tuần cao bằng nhau → thẳng hàng */
  gap: 6px;
}
body.view-calendar .calendar-day-header { padding: 4px 0; }

/* Ô lịch: bỏ min-height cố định để chia đều, nội dung tràn thì cuộn trong ô */
body.view-calendar .calendar-cell {
  min-height: 0;
  padding: 6px;
  overflow: hidden;
}
body.view-calendar .calendar-date-number { margin-bottom: 4px; }
body.view-calendar .calendar-event-item { font-size: 10.5px; padding: 3px 6px; }

/* Thanh lọc dưới lịch — thu gọn */
.filter-bar-bottom { padding: 10px 16px 12px; gap: 8px 14px; margin-top: 12px; }
.filter-bar-bottom .filter-group { gap: 3px; min-width: 110px; }
.filter-bar-bottom .filter-group label { font-size: 10px; letter-spacing: .3px; }
.filter-bar-bottom .search-input,
.filter-bar-bottom .select-filter { padding: 7px 10px; font-size: 12px; }
.filter-bar-bottom .search-input-wrapper { min-width: 180px; }
.filter-bar-bottom .btn-reset-filters { padding: 7px 12px; font-size: 12px; }

/* =========================================================================
   LỊCH — TĂNG TƯƠNG PHẢN CHẾ ĐỘ SÁNG + NỔI BẬT NGÀY HÔM NAY
   ========================================================================= */
/* Chế độ sáng: ô lịch nền trắng, viền rõ, tách khỏi nền trang */
[data-theme="light"] .calendar-header { background: #fff; border-color: rgba(15,23,42,.08); }
[data-theme="light"] .calendar-cell {
  background: #fff;
  border-color: rgba(15,23,42,.11);
}
[data-theme="light"] .calendar-cell:hover {
  border-color: rgba(15,23,42,.22);
  box-shadow: 0 2px 10px rgba(15,23,42,.07);
}
[data-theme="light"] .calendar-day-header { color: var(--text-secondary); }
[data-theme="light"] .calendar-date-number { color: var(--text-primary); }
/* Ngày khác tháng: nền xám nhạt thay vì mờ tịt (dễ thấy lưới) */
[data-theme="light"] .calendar-cell.other-month {
  opacity: 1;
  background: rgba(15,23,42,.035);
  border-color: rgba(15,23,42,.06);
}
[data-theme="light"] .calendar-cell.other-month .calendar-date-number { color: var(--text-muted); }
/* Chip sự kiện rõ hơn trên nền sáng */
[data-theme="light"] .calendar-event-item.du-an { background: rgba(5,150,105,.13);  color:#047857; border-left-color:#059669; }
[data-theme="light"] .calendar-event-item.event { background: rgba(217,119,6,.14);  color:#b45309; border-left-color:#d97706; }
[data-theme="light"] .calendar-event-item.zeng  { background: rgba(225,29,72,.13);  color:#be123c; border-left-color:#e11d48; }
[data-theme="light"] .filter-bar-bottom { background: #fff; }

/* Ngày HÔM NAY nổi bật (cả 2 theme) — viền + nền + ring trong, không lệch layout */
.calendar-cell.today {
  border-color: var(--primary);
  background: var(--primary-glow);
  box-shadow: inset 0 0 0 2px var(--primary);
}
[data-theme="light"] .calendar-cell.today { background: hsla(222,100%,42%,.07); }
