/* ===== Reset & base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f7f8fa;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --info: #0891b2;
  --info-light: #ecfeff;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
}

.muted { color: var(--gray-500); font-size: 13px; }
.strong { font-weight: 600; color: var(--gray-800); }
.center { text-align: center; }
.right { text-align: right; }
.money { font-variant-numeric: tabular-nums; }
.money-in { color: var(--success); font-variant-numeric: tabular-nums; }
.money-out { color: var(--danger); font-variant-numeric: tabular-nums; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; justify-content: center; padding: 6px 6px 16px; }
.brand-img { width: 100%; max-width: 168px; height: auto; display: block; }
.brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: white;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.brand-title { font-weight: 600; font-size: 14px; color: var(--gray-800); }
.brand-sub { font-size: 11px; color: var(--gray-500); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s;
  text-align: left;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-item.active svg { stroke: var(--primary); }
.nav-divider {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 12px 4px;
  margin-top: 2px;
}

.sidebar-footer {
  display: flex; gap: 4px; padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.btn-ghost {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 11.5px;
  color: var(--gray-600);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.main { flex: 1; overflow-y: auto; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 20px; font-weight: 600; color: var(--gray-800); }
.topbar p { margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; }
.view-container { padding: 24px 32px; }

.page-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }
.btn-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); font-size: 22px;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }

/* ===== Sync chip ===== */
.sync-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
  transition: all 0.15s;
  cursor: pointer;
}
.sync-chip:hover { background: var(--gray-200); }
.sync-chip.connected { background: var(--success-light); color: var(--success); }
.sync-chip.connected:hover { background: #dcfce7; }
.sync-chip.disconnected { background: var(--warning-light); color: var(--warning); }
.sync-chip.disconnected:hover { background: #fef3c7; }
.sync-chip.error { background: var(--danger-light); color: var(--danger); }
.sync-chip.syncing { background: var(--primary-light); color: var(--primary); }
.sync-chip.syncing #sync-icon { animation: spin 1s linear infinite; display: inline-flex; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Icon SVG trong chip/nút: canh giữa theo chữ */
#sync-icon, #lock-icon, .chip-ico { display: inline-flex; align-items: center; }

/* ===== Dashboard ===== */
.dashboard-date {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 14px;
  font-weight: 500;
}

/* ===== Stat cards ===== */
.stat-grid { display: grid; gap: 14px; margin-bottom: 20px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1400px) {
  .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1000px) {
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.1;
}
.stat-card .stat-value.money { font-size: 18px; }
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}
.stat-card.danger { background: linear-gradient(135deg, #fff, #fef2f2); border-color: #fecaca; }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.warning { background: linear-gradient(135deg, #fff, #fffbeb); border-color: #fde68a; }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success { background: linear-gradient(135deg, #fff, #f0fdf4); border-color: #bbf7d0; }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.primary { background: linear-gradient(135deg, #fff, #eff6ff); border-color: #bfdbfe; }
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.info { background: linear-gradient(135deg, #fff, #ecfeff); border-color: #a5f3fc; }
.stat-card.info .stat-value { color: var(--info); }

/* ===== Panel ===== */
.panel-grid { display: grid; gap: 14px; }
.panel-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1200px) {
  .panel-grid-3 { grid-template-columns: 1fr; }
}
.panel {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.panel-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.panel-title.danger { color: var(--danger); }
.panel-badge {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
}
.panel-badge.danger { background: var(--danger-light); color: var(--danger); }
.empty-mini {
  text-align: center;
  padding: 24px 12px;
  color: var(--gray-400);
  font-size: 13px;
}

/* ===== Task row mini ===== */
.task-row-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.1s;
}
.task-row-mini:hover { background: var(--gray-50); margin: 0 -8px; padding: 9px 8px; border-radius: 6px; }
.task-row-mini:last-child { border-bottom: none; }
.task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-dot.danger { background: var(--danger); }
.task-dot.warning { background: var(--warning); }
.task-dot.success { background: var(--success); }
.task-dot.primary { background: var(--primary); }
.task-row-mini .task-name {
  font-size: 13px; color: var(--gray-800); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-row-mini .task-meta {
  font-size: 11px; color: var(--gray-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-due {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.task-due.overdue { background: var(--danger-light); color: var(--danger); }
.task-due.soon { background: var(--warning-light); color: var(--warning); }
.task-due.normal { color: var(--gray-500); }

/* ===== Progress list ===== */
.progress-list { display: flex; flex-direction: column; gap: 10px; }
.progress-row {
  display: grid;
  grid-template-columns: 250px 1fr 120px;
  align-items: center;
  gap: 14px;
}
.progress-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--gray-700); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.progress-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-meta { font-size: 12px; color: var(--gray-500); text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Projects grid ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.project-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px 14px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.project-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card .accent-bar {
  position: absolute; top: 0; left: 18px; right: 18px; height: 3px;
  border-radius: 0 0 3px 3px;
}
.project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 6px; margin-bottom: 4px; }
.project-card .project-name { font-size: 15px; font-weight: 600; color: var(--gray-800); flex: 1; line-height: 1.3; }
.project-card .project-client { font-size: 12.5px; color: var(--gray-500); margin-bottom: 4px; }
.project-card .project-assignees { font-size: 12px; color: var(--gray-600); margin-bottom: 12px; }
.project-progress-bar {
  height: 6px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.project-progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.project-card .project-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--gray-500);
  margin-bottom: 10px;
}
.project-card .project-foot {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
}
.badge-mini {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 500;
}
.badge-mini.danger { background: var(--danger-light); color: var(--danger); }
.badge-mini.info { background: var(--info-light); color: var(--info); }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}
.search-input {
  flex: 1; min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.select-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-700);
  cursor: pointer;
}
.filter-summary {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* ===== Task table ===== */
.task-table, .gmc-table, .data-table-wrap {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.task-table table, .gmc-table table, table.data-table { width: 100%; border-collapse: collapse; }
.task-table th, .gmc-table th, .data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
/* th canh phải: .right (0,1,0) yếu hơn selector th ở trên -> phải nói rõ, không thì tiêu đề cột số bị lệch khỏi số. */
.task-table th.right, .gmc-table th.right, .data-table th.right { text-align: right; }
.task-table th.center, .gmc-table th.center, .data-table th.center { text-align: center; }
.task-table td, .gmc-table td, .data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
.task-table tr:last-child td, .gmc-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.task-table tbody tr, .gmc-table tbody tr { transition: background 0.1s; }
.task-table tbody tr { cursor: pointer; }
.task-table tbody tr:hover { background: var(--gray-50); }
.task-table td.task-check { width: 36px; text-align: center; padding: 0 0 0 12px; }
.task-table .check {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-300);
  border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.task-table .check:hover { border-color: var(--primary); }
.task-table .check.done {
  background: var(--success); border-color: var(--success);
  color: white;
}
.task-table .task-name-cell { font-weight: 500; color: var(--gray-800); }
.task-table tr.done .task-name-cell { text-decoration: line-through; color: var(--gray-400); }

table.data-table { font-size: 13px; }
.data-table tr.inactive-row { opacity: 0.5; }
.data-table tr.inactive-row td { color: var(--gray-400); }
.data-table tr.clickable, .gmc-table tr.clickable { cursor: pointer; transition: background 0.1s; }
.data-table tr.clickable:hover, .gmc-table tr.clickable:hover { background: var(--gray-50); }

/* ===== Badges & Pills ===== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
}
.badge.tag-bim       { background: #dbeafe; color: #1d4ed8; }
.badge.tag-drawing   { background: #ede9fe; color: #6d28d9; }
.badge.tag-report    { background: #fef3c7; color: #92400e; }
.badge.tag-survey    { background: #cffafe; color: #0e7490; }
.badge.tag-quote     { background: #d1fae5; color: #047857; }
.badge.tag-follow    { background: #fce7f3; color: #be185d; }
.badge.tag-meeting   { background: #e0e7ff; color: #4338ca; }
.badge.tag-other     { background: var(--gray-200); color: var(--gray-700); }

.badge.badge-in  { background: var(--success-light); color: var(--success); }
.badge.badge-out { background: var(--danger-light); color: var(--danger); }

.badge.type-villa      { background: #fef3c7; color: #92400e; }
.badge.type-townhouse  { background: #dbeafe; color: #1d4ed8; }
.badge.type-apartment  { background: #d1fae5; color: #047857; }
.badge.type-other      { background: var(--gray-200); color: var(--gray-700); }

.priority-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.priority-dot.high { background: var(--danger); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low { background: var(--gray-400); }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill.todo     { background: var(--gray-100); color: var(--gray-600); }
.status-pill.progress { background: var(--primary-light); color: var(--primary); }
.status-pill.done     { background: var(--success-light); color: var(--success); }
.status-pill.pending  { background: var(--warning-light); color: var(--warning); }
.status-pill.hold     { background: #fee2e2; color: var(--danger); }
.status-pill.quote    { background: #ede9fe; color: #7c3aed; }

/* ===== GMC section ===== */
.gmc-section { margin-bottom: 22px; }
.gmc-section-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.seg-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
}
.seg-pill.seg-nt  { background: #d1fae5; color: #047857; }
.seg-pill.seg-cdt { background: #fed7aa; color: #c2410c; }

/* ===== Highlight box ===== */
.highlight-box {
  background: linear-gradient(90deg, #fef3c7, #fffbeb);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--gray-800);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* ===== Timeline ===== */
.timeline-wrap {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.timeline-scroll { overflow-x: auto; }
.timeline-grid { display: grid; min-width: 100%; }
.timeline-header {
  display: flex;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 2;
}
.timeline-label-col {
  width: 240px; min-width: 240px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-right: 1px solid var(--gray-200);
  background: var(--gray-50);
  position: sticky; left: 0; z-index: 3;
}
.timeline-week-col {
  min-width: 80px;
  flex: 0 0 80px;
  padding: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  border-right: 1px solid var(--gray-100);
  text-align: center;
}
.timeline-week-col .wkd { font-size: 10px; color: var(--gray-400); margin-top: 2px; }
.timeline-row {
  display: flex;
  border-bottom: 1px solid var(--gray-100);
  min-height: 40px;
  position: relative;
}
.timeline-row:hover { background: var(--gray-50); }
.timeline-row .timeline-label-col {
  background: white;
  font-weight: 500;
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gray-800);
  display: flex; align-items: center;
}
.timeline-row:hover .timeline-label-col { background: var(--gray-50); }
.timeline-row.project-row .timeline-label-col {
  font-weight: 600;
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 12.5px;
}
.timeline-row[data-task-id] { cursor: pointer; }
.timeline-cells { display: flex; flex: 1; position: relative; }
.timeline-cell {
  min-width: 80px; flex: 0 0 80px;
  border-right: 1px solid var(--gray-100);
}
.timeline-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  background: var(--primary);
  border-radius: 5px;
  display: flex; align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: white;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.timeline-bar.done { background: var(--success) !important; opacity: 0.7; }
.timeline-bar.overdue { background: var(--danger) !important; }
.timeline-bar.soon { background: var(--warning) !important; }
.timeline-today {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--danger);
  pointer-events: none;
  z-index: 1;
}
.timeline-today::before {
  content: 'Hôm nay';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white;
  border-radius: 12px;
  width: 540px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}
.modal.wide { width: 920px; }

/* Students sub-table inside modal */
.students-section {
  margin-top: 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--gray-50);
}
.students-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.students-head strong { font-size: 13px; color: var(--gray-800); }
.students-table-wrap {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
}
.students-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.students-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 7px 6px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0;
  white-space: nowrap;
}
.students-table td {
  padding: 4px 4px;
  border-bottom: 1px solid var(--gray-100);
}
.students-table tr:last-child td { border-bottom: none; }
.students-table input {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12px;
  border-radius: 4px;
}
.students-table input:hover { background: var(--gray-50); }
.students-table input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
/* Cột: 1#, 2Tên, 3Học phí, 4Discount, 5RefH, 6RefT, 7RefL, 8Thuế8%, 9Ghi chú, 10× */
.students-table th:nth-child(1), .students-table td:nth-child(1) { width: 40px; }
.students-table th:nth-child(2), .students-table td:nth-child(2) { min-width: 160px; }
.students-table th:nth-child(3), .students-table td:nth-child(3),
.students-table th:nth-child(4), .students-table td:nth-child(4),
.students-table th:nth-child(5), .students-table td:nth-child(5),
.students-table th:nth-child(6), .students-table td:nth-child(6),
.students-table th:nth-child(7), .students-table td:nth-child(7) { width: 95px; }
.students-table th:nth-child(8), .students-table td:nth-child(8) { width: 56px; text-align: center; }
.students-table th:nth-child(9), .students-table td:nth-child(9) { min-width: 100px; }
.students-table th:nth-child(10), .students-table td:nth-child(10) { width: 30px; text-align: center; }

.s-remove {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: transparent;
  color: var(--gray-400);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.s-remove:hover { background: var(--danger-light); color: var(--danger); }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 22px; overflow-y: auto; }

.form-row { margin-bottom: 12px; }
.form-row.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row label { display: block; font-size: 12px; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-800);
  transition: border-color 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row textarea { resize: vertical; min-height: 60px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: space-between;
  padding: 14px 22px;
  margin: 16px -22px -18px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.modal-foot-left { display: flex; gap: 8px; }
.modal-foot-right { display: flex; gap: 8px; }

/* ===== Lock state: hide protected views' nav items & UI when locked ===== */
body.locked .nav-item[data-view="finance"],
body.locked .nav-item[data-view="lopRevit"],
/* Trang phát hành nhúng sẵn mộc công ty + chữ ký Giám đốc — không để lộ URL khi chưa mở khóa */
body.locked .nav-item.nav-issue {
  display: none !important;
}
/* Hide the "Chi tiết" divider if both items under it are hidden — only GMC remains, so divider still useful for it */
/* Note: we don't hide the divider because GMC still shows under it */

/* Lock indicator in sidebar footer */
.lock-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-50);
  width: 100%;
  justify-content: center;
}
.lock-indicator:hover { background: var(--gray-100); color: var(--gray-700); }
body:not(.locked) .lock-indicator { color: var(--success); }
body:not(.locked) .lock-indicator { background: var(--success-light); }

/* ===== Sort headers ===== */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: var(--gray-100) !important; color: var(--gray-700) !important; }
th.sortable.active-sort { color: var(--primary) !important; }

/* ===== Inline editing (task table) ===== */
.inline-cell { padding: 5px 8px !important; }
.inline-input {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.15s;
}
.inline-input:hover { border-color: var(--gray-200); background: white; }
.inline-input:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }

.inline-date {
  font-variant-numeric: tabular-nums;
  min-width: 130px;
  color: var(--gray-700);
}
.inline-date.overdue { color: var(--danger); font-weight: 500; background: var(--danger-light); }
.inline-date.soon { color: var(--warning); font-weight: 500; background: var(--warning-light); }

.pill-select {
  font-weight: 500;
  border-radius: 12px;
  padding-right: 22px;
  background-position: right 6px center;
  background-repeat: no-repeat;
  background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='%236b7280'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
}
.pill-select.todo     { background-color: var(--gray-100); color: var(--gray-600); }
.pill-select.progress { background-color: var(--primary-light); color: var(--primary); }
.pill-select.done     { background-color: var(--success-light); color: var(--success); }
.pill-select.hold     { background-color: #fee2e2; color: var(--danger); }
.pill-select.prio-high   { background-color: var(--danger-light); color: var(--danger); }
.pill-select.prio-medium { background-color: var(--warning-light); color: var(--warning); }
.pill-select.prio-low    { background-color: var(--gray-100); color: var(--gray-600); }

/* ===== Topbar layout (with hamburger) ===== */
.topbar-title { flex: 1; min-width: 0; }
.hamburger { display: none; padding: 8px; border-radius: 6px; color: var(--gray-700); }
.hamburger:hover { background: var(--gray-100); }

/* ===== Search trigger in topbar ===== */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 12.5px;
  transition: background 0.15s;
}
.search-trigger:hover { background: var(--gray-200); color: var(--gray-700); }
.search-trigger kbd {
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--gray-600);
}

/* ===== Search palette ===== */
.search-palette-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
  z-index: 200;
  animation: fadeIn 0.12s;
}
.search-palette-overlay[hidden] { display: none; }
.search-palette {
  width: 620px;
  max-width: 92vw;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.15s;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
}
.search-input-wrap svg { color: var(--gray-400); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  background: transparent;
}
.search-input-wrap kbd {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-family: inherit;
  color: var(--gray-500);
}
.search-results { max-height: 50vh; overflow-y: auto; padding: 6px 0; }
.search-hint { padding: 30px; text-align: center; color: var(--gray-400); font-size: 13px; }
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.08s;
}
.search-result.active { background: var(--primary-light); }
.search-result .sr-icon { width: 22px; text-align: center; font-size: 16px; flex-shrink: 0; }
.search-result .sr-text { flex: 1; min-width: 0; }
.search-result .sr-label { font-size: 13px; font-weight: 500; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .sr-sub { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .sr-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
  flex-shrink: 0;
}
.search-foot {
  display: flex; gap: 16px; padding: 8px 18px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 11px;
  color: var(--gray-500);
}
.search-foot kbd {
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  font-family: inherit;
  color: var(--gray-600);
  margin-right: 4px;
}

/* ===== Digest popup ===== */
.digest-popup {
  position: fixed; top: 80px; right: 32px;
  z-index: 90;
  animation: slideInRight 0.3s;
}
.digest-popup[hidden] { display: none; }
@keyframes slideInRight { from { transform: translateX(380px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.digest-card {
  width: 360px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  position: relative;
}
.digest-close {
  position: absolute; top: 10px; right: 12px;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--gray-400);
  font-size: 22px;
  line-height: 1;
}
.digest-close:hover { background: var(--gray-100); color: var(--gray-700); }
.digest-greeting {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  padding: 18px 20px 4px;
}
.digest-summary { padding: 0 20px 12px; color: var(--gray-500); font-size: 12.5px; }
.digest-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 20px 14px;
}
.digest-stat {
  text-align: center;
  padding: 10px 6px;
  background: var(--gray-50);
  border-radius: var(--radius);
  opacity: 0.4;
}
.digest-stat.has-data { opacity: 1; }
.digest-stat.has-data.danger { background: var(--danger-light); color: var(--danger); }
.digest-stat.has-data.warning { background: var(--warning-light); color: var(--warning); }
.digest-stat .ds-num { font-size: 24px; font-weight: 700; line-height: 1; }
.digest-stat .ds-lbl { font-size: 10.5px; margin-top: 4px; }

.digest-list { padding: 8px 20px; }
.dl-title { font-size: 11.5px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.dl-title.danger { color: var(--danger); }
.dl-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: 12.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.dl-item:last-child { border-bottom: none; }
.dl-item:hover { background: var(--gray-50); margin: 0 -10px; padding: 6px 10px; border-radius: 5px; }
.dl-name { flex: 1; color: var(--gray-800); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.digest-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--gray-100);
}

/* ===== Workload view ===== */
.workload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.workload-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.workload-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.wl-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.wl-toolbar-info { font-size: 13px; color: var(--gray-700, #374151); }
.wl-id { flex: 1; min-width: 0; }
/* Bấm thẳng vào ảnh để đổi ảnh / sửa hồ sơ */
.wl-avatar-btn, .crew-avatar {
  position: relative; flex: none; line-height: 0;
  border: none; background: none; padding: 0; cursor: pointer;
  border-radius: 50%;
}
.wl-avatar-btn:hover .avatar, .crew-avatar:hover .avatar { filter: brightness(.88); }
.wl-avatar-cam, .crew-cam {
  position: absolute; right: -2px; bottom: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 1px solid var(--gray-200);
  font-size: 9.5px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.workload-name { font-weight: 600; font-size: 14px; color: var(--gray-800); }
.workload-badge {
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.workload-badge.danger { background: var(--danger-light); color: var(--danger); }

.workload-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.ws { text-align: center; padding: 8px 4px; background: var(--gray-50); border-radius: var(--radius); }
.ws-num { font-size: 18px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.ws-lbl { font-size: 10.5px; color: var(--gray-500); margin-top: 3px; }

.workload-bar { height: 6px; background: var(--gray-100); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.workload-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.workload-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--gray-600); margin-bottom: 10px; }

.workload-open-tasks {
  border-top: 1px solid var(--gray-100);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.open-task {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
}
.open-task:hover { background: var(--gray-50); }
.open-task.danger { background: var(--danger-light); }
.open-task.warning { background: var(--warning-light); }
.open-task .ot-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-800); }
.open-task .ot-due { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.open-task.danger .ot-due { color: var(--danger); font-weight: 500; }
.open-task.warning .ot-due { color: var(--warning); font-weight: 500; }

/* ===== Customer view ===== */
.customer-list { display: flex; flex-direction: column; gap: 14px; }
.customer-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.customer-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.customer-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4338ca);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}
.customer-name { font-weight: 600; font-size: 15px; color: var(--gray-800); }
.customer-balance.pos { color: var(--success); text-align: right; }
.customer-balance.neg { color: var(--danger); text-align: right; }
.customer-status-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.customer-projects { border-top: 1px solid var(--gray-100); padding-top: 10px; }
.customer-project-row {
  display: grid;
  grid-template-columns: 10px 1fr auto 200px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.customer-project-row:hover { background: var(--gray-50); margin: 0 -8px; padding: 8px 8px; border-radius: 5px; }
.customer-project-row:last-child { border-bottom: none; }
.cp-name { font-size: 13px; font-weight: 500; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-progress { display: flex; align-items: center; gap: 8px; }
.cp-bar { flex: 1; height: 6px; background: var(--gray-100); border-radius: 4px; overflow: hidden; min-width: 100px; }
.cp-bar-fill { height: 100%; border-radius: 4px; }
.customer-finance {
  display: flex; gap: 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  font-size: 12.5px;
  color: var(--gray-600);
}

/* ===== Kanban toolbar (project pills) ===== */
.kb-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.project-pills {
  flex: 1;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
}
.project-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.project-pill:hover { background: var(--gray-50); border-color: var(--gray-300); }
.project-pill.active { font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.project-pill-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.project-pill.active .project-pill-dot { background: rgba(255,255,255,0.85) !important; }
.project-pills-sep {
  width: 1px; height: 20px;
  background: var(--gray-300);
  margin: 0 4px;
}
.kb-task-count {
  color: var(--gray-500);
  font-size: 13px;
  white-space: nowrap;
}

/* ===== Project filter bar ===== */
.project-filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}
.project-filter-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.project-filter-pill:hover { background: var(--gray-50); border-color: var(--gray-300); }
.project-filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.project-filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 600;
}
.project-filter-pill.active .project-filter-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  min-height: 500px;
}
.kanban-col {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 10px;
}
.kanban-col-title {
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}
.kanban-col-title.todo { background: white; color: var(--gray-600); border: 1px solid var(--gray-300); }
.kanban-col-title.progress { background: var(--primary-light); color: var(--primary); }
.kanban-col-title.done { background: var(--success-light); color: var(--success); }
.kanban-col-title.hold { background: #fee2e2; color: var(--danger); }
.kanban-col-body {
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 10px;
  overflow-y: auto;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.kanban-col-body.drag-over { background: rgba(37,99,235,0.07); outline: 2px dashed var(--primary); outline-offset: -4px; }
.kanban-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: grab;
  transition: all 0.1s;
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; }
.kanban-card .kc-project {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.kanban-card .kc-name { font-size: 13px; font-weight: 500; color: var(--gray-800); line-height: 1.3; margin-bottom: 8px; }
.kanban-card .kc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Time tracking ===== */
.task-timer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
}
.timer-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.5s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.timer-banner {
  position: fixed; bottom: 18px; right: 18px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: white;
  border: 2px solid var(--danger);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  font-size: 13px;
}
.timer-banner[hidden] { display: none; }
.timer-banner .timer-text { color: var(--gray-800); font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-banner .timer-elapsed { color: var(--danger); font-weight: 600; font-variant-numeric: tabular-nums; }

.task-logs-mini { margin-top: 8px; font-size: 11.5px; }
.log-mini-row {
  display: grid;
  grid-template-columns: 120px 80px 1fr;
  gap: 8px;
  padding: 4px 8px;
  background: var(--gray-50);
  border-radius: 4px;
  margin-bottom: 3px;
}

/* ===== P&L panel ===== */
.pnl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.pnl-block {
  padding: 12px 14px;
  background: var(--gray-50);
  border-radius: var(--radius);
}
.pnl-block.highlight {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
}
.pnl-label { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.pnl-value { font-size: 18px; font-weight: 700; line-height: 1.1; }
.pnl-breakdown { margin-top: 8px; font-size: 11.5px; color: var(--gray-600); display: flex; gap: 14px; flex-wrap: wrap; }
.pnl-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--gray-100); }
.pnl-bar-segment.income { background: var(--success); }
.pnl-bar-segment.expense { background: var(--danger); }
.pnl-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 11.5px; color: var(--gray-600); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.legend-swatch.income { background: var(--success); }
.legend-swatch.expense { background: var(--danger); }

/* ===== Mobile responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0; left: -240px;
    bottom: 0;
    z-index: 50;
    transition: left 0.25s;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { left: 0; }
  body.sidebar-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
  }
  .hamburger { display: inline-flex; }
  .topbar { padding: 16px 18px; gap: 12px; }
  .topbar h1 { font-size: 17px; }
  .topbar p { font-size: 12px; }
  .view-container { padding: 16px 18px; }

  .search-trigger span:not(:first-of-type) { display: none; }
  .search-trigger kbd { display: none; }
  .sync-chip #sync-text { display: none; }
  .btn-primary { padding: 8px 12px; }
  .btn-primary span { display: none; }

  .stat-grid-3, .stat-grid-4, .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }
  .panel-grid-3 { grid-template-columns: 1fr; }
  .pnl-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: 1fr; }
  .workload-grid { grid-template-columns: 1fr; }
  .customer-project-row { grid-template-columns: 8px 1fr; }
  .customer-project-row > :nth-child(3),
  .customer-project-row > :nth-child(4) { grid-column: 2; }

  .filter-bar { gap: 6px; }
  .filter-bar .search-input { min-width: 140px; }

  .task-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .task-table table { min-width: 920px; }
  .data-table-wrap, .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Form 2 cột -> xếp dọc cho dễ bấm trên điện thoại */
  .form-row.row-2 { grid-template-columns: 1fr; gap: 12px; }

  /* Tap target to hơn (chuẩn chạm ~44px) */
  .nav-item { padding: 12px 14px; }
  .form-row input, .form-row select, .form-row textarea { min-height: 44px; font-size: 16px; }
  .btn, .btn-primary, .btn-secondary, .btn-danger { min-height: 42px; }
  .pill-select, .inline-input { min-height: 38px; }
  .kanban-card { padding: 12px; }

  .modal { width: 100% !important; max-width: 100% !important; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal.wide { width: 100% !important; }
  .modal-foot { flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1; }

  .digest-popup { top: 70px; right: 12px; left: 12px; }
  .digest-card { width: 100%; }

  .timer-banner { bottom: 12px; right: 12px; left: 12px; justify-content: center; }
}

@media (max-width: 500px) {
  .stat-grid-3, .stat-grid-4, .stat-grid-6 { grid-template-columns: 1fr 1fr; }
  .topbar h1 { font-size: 15px; }
  .topbar p { display: none; }
}

/* ===== Assignee chip / ảnh đại diện dùng chung =====
   Cỡ ảnh truyền qua biến --av để một class dùng được ở mọi chỗ (bảng, kanban,
   thẻ nhân sự, bản đồ dự án). Chưa có ảnh -> chữ cái đầu trên nền màu riêng. */
.assignee-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.avatar {
  width: var(--av, 32px); height: var(--av, 32px); flex: 0 0 var(--av, 32px);
  border-radius: 50%; overflow: hidden;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(var(--av, 32px) * 0.4); font-weight: 700; line-height: 1;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kc-assignee { margin-left: auto; }

/* Ô chọn người phụ trách trong form task — kèm ảnh để nhìn là biết giao cho ai */
.assignee-pick { display: flex; align-items: center; gap: 10px; }
.assignee-pick select { flex: 1; min-width: 0; }

/* Form hồ sơ nhân sự */
.person-photo {
  display: flex; align-items: center; gap: 16px;
  padding: 4px 0 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--gray-100);
}
.person-photo-preview { flex: none; line-height: 0; }
.person-photo-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.person-photo-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person-photo-hint { font-size: 11.5px; line-height: 1.5; }

/* Số tiền không tách "11.000.000" / "₫" thành 2 dòng */
.stat-value.money { white-space: nowrap; }
.money-in, .money-out { white-space: nowrap; }

/* Lịch thi công — trạng thái việc */
.badge-doing { background: var(--warning-light); color: var(--warning); }
.badge-up { background: var(--gray-100); color: var(--gray-500); }
.badge-late { background: var(--danger-light); color: var(--danger); }
tr.sched-done td { background: rgba(16,185,129,0.06); }
tr.sched-doing td { background: rgba(245,158,11,0.10); }
tr.sched-late td { background: rgba(220,38,38,0.07); }
tr.sched-done td:nth-child(3) { color: var(--gray-500); text-decoration: line-through; }

/* Thanh tiến độ */
.sched-progress {
  position: relative; height: 22px; margin-top: 12px;
  background: var(--gray-100); border-radius: 999px; overflow: hidden;
}
.sched-progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--primary), #10b981);
  border-radius: 999px; transition: width .3s;
}
.sched-progress-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--gray-700);
}

/* Thanh công cụ: bộ lọc + nút về hôm nay */
.sched-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 14px; flex-wrap: wrap;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600); border: 1px solid transparent;
  cursor: pointer; transition: all .15s;
}
.chip:hover { background: var(--gray-200); }
.chip.active { background: var(--primary); color: #fff; }
.btn-sm {
  padding: 5px 12px; font-size: 12.5px;
  background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200);
  cursor: pointer;
}
.btn-sm:hover { background: var(--gray-200); }
.btn-sm:disabled { opacity: .45; cursor: default; }

/* Giai đoạn có thể thu gọn */
.sched-phase-head { cursor: pointer; user-select: none; }
.sched-caret { display: inline-block; width: 14px; color: var(--gray-400); }
.sched-late-tag { color: var(--danger); font-weight: 600; }

/* Checkbox đánh dấu xong */
.sched-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* Bảng cuộn ngang trên màn nhỏ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sched-table { min-width: 640px; }

/* Hiệu ứng nhấp nháy khi "Về hôm nay" */
.sched-flash td { animation: schedFlash 1.6s ease; }
@keyframes schedFlash {
  0%, 100% { background: inherit; }
  20%, 60% { background: rgba(99,102,241,0.18); }
}

/* Ghi chú trong mục Tài chính */
.scratch-text {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 130px;
  padding: 12px; font-size: 13.5px; line-height: 1.55; font-family: inherit; color: var(--gray-800);
  background: #fffdf3; border: 1px solid #efe4bb; border-radius: 8px; outline: none;
}
.scratch-text:focus { border-color: var(--primary); }

/* ===== Bản đồ dự án — bong bóng + panel checklist ===== */
.pmap-layout { display: flex; gap: 16px; align-items: flex-start; margin-top: 14px; }
.pmap-canvas-panel { flex: 1; min-width: 0; }
.pmap-count {
  display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 4px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.pmap-canvas {
  position: relative; /* mốc định vị cho lớp mờ + thẻ dự án phóng to */
  display: flex; flex-wrap: wrap; gap: 18px;
  align-items: center; justify-content: center;
  padding: 26px 10px; min-height: 320px;
  background:
    radial-gradient(circle at 1px 1px, var(--gray-200) 1px, transparent 0) 0 0 / 22px 22px;
  border-radius: var(--radius-lg);
}
.pmap-bubble {
  position: relative; width: var(--bub); height: var(--bub);
  border: none; background: none; padding: 0; cursor: pointer;
  border-radius: 50%; transition: transform .18s ease;
}
.pmap-bubble:hover { transform: translateY(-3px) scale(1.03); }
.pmap-ring {
  position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .12);
}
.pmap-inner {
  position: absolute; inset: 7px; border-radius: 50%;
  background: white; border: 1px solid var(--gray-100);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px; text-align: center; overflow: hidden;
}
.pmap-name {
  font-size: 12px; font-weight: 600; color: var(--gray-800); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pmap-pct { font-size: 15px; font-weight: 700; color: var(--pc); line-height: 1; }
.pmap-sub { font-size: 10.5px; color: var(--gray-500); white-space: nowrap; }
.pmap-warn {
  position: absolute; top: 2px; right: 0;
  background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  box-shadow: 0 2px 6px rgba(220, 38, 38, .35);
}
.pmap-bubble.active .pmap-inner { border-color: var(--pc); }
/* Quầng sáng quanh bong bóng đang chọn — dòng đầu là bản dự phòng cho
   trình duyệt cũ chưa hỗ trợ color-mix(). */
.pmap-bubble.active .pmap-ring {
  box-shadow: 0 0 0 4px var(--gray-200), 0 8px 20px rgba(15, 23, 42, .18);
}
.pmap-bubble.active .pmap-ring {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 22%, transparent), 0 8px 20px rgba(15, 23, 42, .18);
}
/* Chỉ-xem: khoá luôn bảng ghi chú (đã có thuộc tính readonly, đây là phần nhìn) */
.note-board[readonly] { background: var(--gray-50, #f9fafb); cursor: default; }

.pmap-detail { width: 340px; flex: none; position: sticky; top: 12px; }
.pmap-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pmap-detail-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.pmap-detail-title { flex: 1; min-width: 0; }
.pmap-detail-name { font-size: 14.5px; font-weight: 600; color: var(--gray-800); word-break: break-word; }
.pmap-detail-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-bottom: 10px; text-align: center;
}
.pmap-deadline {
  margin: -4px 0 10px; padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  background: var(--gray-50, #f9fafb); color: var(--gray-600);
}
.pmap-deadline.warning { background: var(--warning-light); color: #b45309; }
.pmap-deadline.danger { background: var(--danger-light); color: var(--danger); }
.pmap-open-tasks { display: flex; flex-direction: column; gap: 4px; }
.pmap-open-tasks .open-task { cursor: pointer; }
.pmap-cl-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--gray-800);
}
.pmap-detail .pf-checklist { max-height: 44vh; }
.pmap-cl-add { display: flex; gap: 8px; margin-top: 10px; }
.pmap-cl-add input {
  flex: 1; min-width: 0; padding: 8px 11px; font-size: 13px;
  border: 1px solid var(--gray-200); border-radius: 8px; outline: none;
}
.pmap-cl-add input:focus { border-color: var(--primary); }
.pmap-open { width: 100%; margin-top: 12px; }
body.readonly .pmap-cl-add { display: none !important; }

/* ===== Bấm 1 dự án -> phóng to nó, mờ hết các dự án còn lại ===== */
.pmap-canvas.focus-mode { min-height: 420px; } /* JS nới thêm cho vừa thẻ */
.pmap-canvas.focus-mode .pmap-bubble { position: relative; z-index: 2; }
.pmap-canvas.focus-mode .pmap-bubble.dim {
  filter: blur(3px) grayscale(.4); opacity: .3; transform: scale(.92);
  transition: filter .18s ease, opacity .18s ease, transform .18s ease;
}
/* Vẫn bấm sang dự án khác được — rê chuột là nó rõ lại */
.pmap-canvas.focus-mode .pmap-bubble.dim:hover {
  filter: none; opacity: .8; transform: scale(.96);
}
.pmap-canvas.focus-mode .pmap-bubble.focused { visibility: hidden; }
.pmap-focus-backdrop {
  position: absolute; inset: 0; z-index: 1;
  background: rgba(248, 250, 252, .72);
  border-radius: var(--radius-lg);
  cursor: zoom-out;
}
.pmap-focus-card {
  position: absolute; z-index: 3; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(660px, calc(100% - 28px));
  max-height: calc(100% - 24px); overflow: auto;
  padding: 18px; box-sizing: border-box;
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 46px rgba(15, 23, 42, .18);
  animation: pmapPop .18s ease-out;
}
@keyframes pmapPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.88); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.pmap-focus-close {
  position: absolute; top: 8px; right: 10px;
  border: none; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--gray-500); padding: 2px 6px;
}
.pmap-focus-close:hover { color: var(--gray-800); }
.pmap-focus-top { display: flex; align-items: center; gap: 18px; }
.pmap-focus-bubble { position: relative; width: 118px; height: 118px; flex: none; }
.pmap-focus-bubble .pmap-inner { inset: 9px; }
.pmap-focus-bubble .pmap-pct { font-size: 27px; }
.pmap-focus-bubble .pmap-sub { font-size: 11.5px; }
.pmap-focus-info { flex: 1; min-width: 0; }
.pmap-focus-name { font-size: 17px; font-weight: 700; color: var(--gray-800); word-break: break-word; }
.pmap-focus-client {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 4px 0 8px; font-size: 12.5px; color: var(--gray-500);
}
.pmap-focus-info .pmap-detail-stats { margin-bottom: 0; }

/* Ai đang phụ trách + ô giao việc cho từng người */
.pmap-crew-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--gray-800);
}
.crew-note {
  margin-bottom: 8px; padding: 6px 10px; border-radius: 8px;
  font-size: 12px; background: var(--warning-light); color: #b45309;
}
.pmap-crew { display: flex; flex-direction: column; gap: 10px; }
.crew-empty { font-size: 12.5px; }
.crew-row {
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  background: var(--gray-50, #f9fafb); padding: 10px;
}
.crew-head { display: flex; align-items: center; gap: 10px; }
.crew-id { flex: 1; min-width: 0; }
.crew-name { font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
.crew-meta { font-size: 11.5px; color: var(--gray-500); }
.crew-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.crew-badge.danger { background: var(--danger-light); color: var(--danger); }
.crew-badge.ok { background: var(--gray-100); color: var(--gray-500); }
.crew-del {
  border: none; background: none; cursor: pointer;
  font-size: 17px; line-height: 1; color: var(--gray-400, #9ca3af); padding: 0 2px;
}
.crew-del:hover { color: var(--danger); }
.crew-tasks { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.crew-tasks .open-task { background: #fff; }
.crew-more { font-size: 11px; text-align: center; padding: 2px; }
.crew-add { display: flex; gap: 6px; margin-top: 8px; }
.crew-input {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 12.5px;
  border: 1px solid var(--gray-200); border-radius: 8px; background: #fff; outline: none;
}
.crew-input:focus { border-color: var(--primary); }
.crew-date {
  width: 136px; padding: 6px 8px; font-size: 12px; color: var(--gray-600);
  border: 1px solid var(--gray-200); border-radius: 8px; background: #fff;
}
.crew-btn { padding: 6px 13px; font-weight: 700; }
.crew-more-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.crew-pick {
  flex: 1; min-width: 0; padding: 8px 10px; font-size: 12.5px;
  border: 1px solid var(--gray-200); border-radius: 8px; background: #fff;
}
/* Chỉ-xem: giấu mọi thứ tạo/sửa dữ liệu */
body.readonly .crew-add,
body.readonly .crew-more-row,
body.readonly .crew-del,
body.readonly .crew-cam,
body.readonly .wl-avatar-cam,
body.readonly #wl-add-person { display: none !important; }
body.readonly .crew-avatar,
body.readonly .wl-avatar-btn { cursor: default; }

@media (max-width: 1024px) {
  .pmap-layout { flex-direction: column; }
  .pmap-detail { width: 100%; position: static; }
  .pmap-canvas { padding: 18px 4px; gap: 14px; }
  .pmap-focus-card { width: calc(100% - 16px); padding: 16px 14px; }
  .pmap-focus-top { flex-direction: column; text-align: center; gap: 12px; }
  .pmap-focus-client { justify-content: center; }
  .crew-add { flex-wrap: wrap; }
  .crew-input { flex: 1 1 100%; }
  .crew-date { flex: 1; width: auto; }
}

/* ===== Ghi Chú — bảng trắng gõ nhanh ===== */
.note-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-status { font-size: 12px; white-space: nowrap; }
.note-danger { color: var(--danger); }
.note-board {
  width: 100%; box-sizing: border-box; resize: vertical;
  min-height: calc(100vh - 250px);
  padding: 16px 18px;
  font-size: 14.5px; line-height: 1.7; font-family: inherit; color: var(--gray-800);
  background: white; border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.note-board::placeholder { color: var(--gray-400); }
/* Nháy nhẹ khi nhảy tới 1 dòng từ ô tìm kiếm */
.note-board.note-flash { border-color: var(--warning); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.note-board:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.note-foot { display: flex; justify-content: flex-end; padding-top: 8px; font-size: 11.5px; color: var(--gray-500); }
@media (max-width: 640px) {
  .note-board { min-height: 60vh; padding: 12px 14px; font-size: 14px; }
  .panel .note-tools { gap: 6px; }
}

/* Thanh tiến độ % đã thu */
.prog-wrap { display: inline-block; width: 90px; height: 7px; background: var(--gray-200); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.prog-fill { display: block; height: 100%; border-radius: 4px; transition: width .3s; }
.prog-label { font-size: 11.5px; color: var(--gray-600); white-space: nowrap; }
/* Dòng "Tổng cộng" ở chân bảng */
.data-table tfoot .total-row td { border-top: 2px solid var(--gray-300); font-weight: 700; background: #f9fafb; }
/* Thẻ thống kê trong modal: gọn lại, nhãn + số trên 1 dòng */
.modal .stat-grid { gap: 8px; }
.modal .stat-card { padding: 10px 12px; min-width: 0; }
.modal .stat-card .stat-label { white-space: nowrap; font-size: 10.5px; }
.modal .stat-card .stat-value { font-size: 15px; white-space: nowrap; }

/* Link điều hướng mở tab ngoài (chứng nhận) — trông như nav-item */
a.nav-item.nav-ext { text-decoration: none; }
a.nav-item.nav-ext::after { content: "↗"; margin-left: auto; font-size: 11px; opacity: .5; }

/* ===== Khoá chỉnh sửa (cloud công khai: ai cũng xem, chỉ chủ mới sửa) ===== */
.edit-lock-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: var(--success-light);
  color: var(--success); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .15s;
}
.edit-lock-chip:hover { filter: brightness(0.97); }
.edit-lock-chip.locked { background: var(--warning-light); color: var(--warning); }

/* Chế độ chỉ xem: ẩn/khoá toàn bộ nút thao tác ghi */
body.readonly #btn-add-task,
body.readonly .btn-danger,
body.readonly #fin-add,
body.readonly #gmc-add,
body.readonly #lr-add,
body.readonly #empty-add-project,
body.readonly #btn-import,
body.readonly #btn-reset,
body.readonly #f-timer-start,
body.readonly #f-timer-person,
body.readonly .log-delete,
body.readonly .s-remove,
body.readonly #lf-add-student { display: none !important; }
body.readonly #pfin-staff-auto,
body.readonly .staff-table .sf-del,
body.readonly .staff-table .sf-sync { display: none !important; }
body.readonly .staff-table input { pointer-events: none; background: var(--gray-100); }
body.readonly .inline-input,
body.readonly [data-toggle] { pointer-events: none; }
body.readonly .inline-input { background: var(--gray-100); cursor: default; }
body.readonly .modal .btn-primary { opacity: .5; pointer-events: none; }

/* ===== Toast Hoàn tác (undo) ===== */
.undo-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 14px;
  background: var(--gray-900, #111827); color: #fff;
  padding: 12px 16px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 9999;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.undo-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.undo-toast .undo-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.4);
  color: #fff; font-weight: 600; font-size: 13px;
  padding: 5px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.undo-toast .undo-btn:hover { background: rgba(255,255,255,0.12); }

/* ===== Bộ lọc người phụ trách (Kanban / Tiến độ) ===== */
.kb-toolbar-right { display: flex; align-items: center; gap: 12px; }
.kb-assignee-filter, .tl-assignee-filter {
  height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--gray-200); background: #fff;
  font-size: 13px; color: var(--gray-700); cursor: pointer; max-width: 200px;
}
.tl-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================================
   TÍNH NĂNG MỞ RỘNG — checklist, quick-add, lặp, phụ thuộc,
   cảnh báo quá tải.
============================================================ */

/* ----- Chip chỉ báo trên task ----- */
.sub-badge, .block-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  vertical-align: middle; white-space: nowrap; line-height: 1.6;
}
.sub-badge { background: var(--gray-100); color: var(--gray-600); }
.sub-badge.done { background: var(--success-light); color: var(--success); }
.block-badge { background: var(--danger-light); color: var(--danger); }
.recur-mark { font-size: 11px; opacity: .8; margin-left: 2px; vertical-align: middle; }

/* ----- Checklist con trong modal ----- */
.sub-prog-label { font-weight: 400; font-size: 12px; color: var(--gray-500); }
.subtask-editor { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.subtask-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 7px; background: var(--gray-50);
}
.subtask-row.done .subtask-text { text-decoration: line-through; color: var(--gray-400); }
.subtask-check {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 5px;
  border: 1.5px solid var(--gray-300); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.subtask-check.done { background: var(--success); border-color: var(--success); }
.subtask-text { flex: 1; font-size: 13px; color: var(--gray-700); }
.subtask-del {
  border: none; background: transparent; color: var(--gray-400);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.subtask-del:hover { color: var(--danger); }
.subtask-add { display: flex; gap: 8px; }
.subtask-add input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--gray-200);
  border-radius: 7px; font-size: 13px; outline: none;
}
.subtask-add input:focus { border-color: var(--primary); }

/* ----- Thanh tiến độ checklist trên thẻ Kanban ----- */
.kc-subbar { height: 4px; background: var(--gray-200); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.kc-subbar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .3s; }

/* ----- Quick-add ----- */
.quick-add {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  background: var(--primary-light); border: 1px solid #dbeafe;
  border-radius: 10px; padding: 8px 10px;
}
.quick-add .qa-icon { font-size: 16px; }
.quick-add input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 14px; color: var(--gray-800);
}
.quick-add input::placeholder { color: var(--gray-400); }
.quick-add .qa-btn { padding: 7px 16px; flex: 0 0 auto; }
.qa-hint { font-size: 11.5px; color: var(--gray-500); margin: 0 2px 14px; }
.qa-hint code {
  background: var(--gray-100); padding: 1px 6px; border-radius: 5px;
  font-size: 11px; color: var(--gray-600);
}

/* ----- Cảnh báo quá tải (Workload) ----- */
.wl-warning {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--warning-light); border: 1px solid #fde68a;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 13px; color: var(--gray-700);
}
.wl-warning-icon { font-size: 18px; line-height: 1.2; }
.wl-warning-name { font-weight: 600; color: var(--danger); }
.workload-card.overloaded { border-color: #fca5a5; box-shadow: 0 0 0 1px #fecaca inset; }

/* ----- Đường nối phụ thuộc trên Gantt ----- */
.dep-overlay { pointer-events: none; }

/* ----- Mobile: quick-add gọn lại ----- */
@media (max-width: 900px) {
  .quick-add .qa-btn span { display: inline; }
  .qa-hint { display: none; }
}

/* ----- Tài chính: ẩn số tiền (blur, hiện lại khi rê chuột) ----- */
.fin-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.fin-toolbar .btn { display: inline-flex; align-items: center; gap: 6px; }
body.money-hidden .money,
body.money-hidden .money-in,
body.money-hidden .money-out,
body.money-hidden .stat-value.money {
  filter: blur(8px); transition: filter .12s; user-select: none;
}
body.money-hidden .money:hover,
body.money-hidden .money-in:hover,
body.money-hidden .money-out:hover,
body.money-hidden .stat-value.money:hover { filter: none; }

/* ----- Lớp Revit: biểu đồ học viên ----- */
.lr-chart-meta { font-size: 13px; color: var(--gray-600); margin-bottom: 10px; }
.lr-chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.lr-chart { display: block; height: auto; }
.lr-bar rect { transition: opacity .15s; }
.lr-bar:hover rect { opacity: .8; }

/* ----- Lớp Revit: ô checkbox thuế ----- */
.students-table .s-tax { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ===== Lịch tháng (Monthly calendar) ===== */
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-arrow { font-size: 18px; line-height: 1; padding: 6px 12px; font-weight: 700; }
.cal-title { font-size: 18px; font-weight: 700; color: var(--gray-800); margin: 0 0 0 6px; white-space: nowrap; }
.cal-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-filters .cal-select { padding: 6px 10px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 13px; background: #fff; cursor: pointer; }
.cal-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-600); cursor: pointer; user-select: none; }
.cal-toggle input { accent-color: var(--primary); cursor: pointer; }
.cal-hint {
  font-size: 12.5px; color: var(--gray-500); margin-bottom: 10px;
  position: relative; padding-right: 30px;
}
.cal-hint-close {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; line-height: 1;
  border: none; background: transparent; color: var(--gray-400);
  font-size: 15px; font-weight: 700; cursor: pointer; border-radius: 5px;
}
.cal-hint-close:hover { background: var(--gray-100); color: var(--gray-600); }

/* Dải tổng quan tháng: X việc · Y quá hạn (bấm để lọc) · Z xong */
.cal-stats {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--gray-500); margin-bottom: 8px;
}
.cal-stats b { color: var(--gray-800); font-weight: 700; }
.cal-sep { color: var(--gray-300); }
.cal-stat-overdue {
  border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: var(--danger);
  padding: 2px 9px; border-radius: 12px; transition: background .12s;
}
.cal-stat-overdue:hover { background: var(--danger-light); }
.cal-stat-overdue.active { background: var(--danger); color: #fff; }
.cal-stat-overdue.active:hover { background: #b91c1c; }
.cal-stat-overdue[disabled] { color: var(--gray-400); cursor: default; background: transparent; font-weight: 500; }
.cal-filter-note { color: var(--danger); font-weight: 600; }

/* Select có icon SVG đứng trước (thay emoji trong option) */
.cal-select-wrap { position: relative; display: inline-flex; align-items: center; }
.cal-select-wrap > svg {
  position: absolute; left: 9px; pointer-events: none; color: var(--gray-500);
}
.cal-select-wrap .cal-select { padding-left: 28px; }

/* Nút "?" mở bảng phím tắt */
.cal-help {
  width: 26px; height: 26px; flex: none;
  border: 1px solid var(--gray-200); border-radius: 50%;
  background: #fff; color: var(--gray-500);
  font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1;
}
.cal-help:hover { color: var(--primary); border-color: var(--primary); }

/* Bảng phím tắt (modal "?") */
.shortcut-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.shortcut-table td { padding: 8px 6px; border-bottom: 1px solid var(--gray-100); }
.shortcut-table td:first-child { width: 46%; color: var(--gray-600); }
.shortcut-table kbd {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  font-size: 12px; font-family: inherit; font-weight: 600; color: var(--gray-700);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--gray-200);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-dow {
  background: var(--gray-50);
  text-align: center;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  color: var(--gray-500);
  padding: 8px 0;
}
.cal-dow.cal-weekend { color: var(--danger); }

.cal-cell {
  background: #fff;
  min-height: 116px;
  padding: 5px 6px 7px;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: background .12s;
}
.cal-cell:hover { background: var(--gray-50); }
.cal-cell.cal-out { background: var(--gray-50); }
.cal-cell.cal-out .cal-daynum { color: var(--gray-400); }
.cal-cell.cal-weekend:not(.cal-out) { background: #f6f7f9; }
.cal-cell:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell.cal-today { background: var(--primary-light); box-shadow: inset 0 0 0 2px var(--primary); }

.cal-cell-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; min-height: 20px; }
.cal-daynum { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.cal-cell.cal-today .cal-daynum { color: var(--primary-dark); font-weight: 800; }
.cal-count {
  font-size: 10.5px; font-weight: 700; color: var(--gray-500);
  background: var(--gray-100); border-radius: 10px; padding: 1px 6px;
}
.cal-add {
  margin-left: auto; width: 20px; height: 20px; line-height: 1;
  border: none; background: transparent; color: var(--gray-400);
  font-size: 17px; font-weight: 700; cursor: pointer; border-radius: 5px;
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--primary); color: #fff; }

.cal-cell-body { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-task {
  display: flex; align-items: center; gap: 5px;
  width: 100%; text-align: left;
  border: none; cursor: pointer;
  background: color-mix(in srgb, var(--cal-clr) 12%, #fff);
  color: var(--gray-800);
  border-left: 3px solid var(--cal-clr);
  border-radius: 4px;
  padding: 3px 6px; font-size: 12px; line-height: 1.25;
  transition: filter .12s;
}
.cal-task:hover { filter: brightness(.95); }
/* Chấm màu = nút tick nhanh: hover chip -> nở thành ô check, click để hoàn thành */
.cal-task-dot {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; line-height: 1;
  background: var(--cal-clr); color: transparent;
  transform: scale(.45);
  transition: transform .12s, background .12s, color .12s, box-shadow .12s;
}
.cal-task-dot::after { content: '✓'; }
.cal-task:hover .cal-task-dot {
  transform: none; background: #fff; color: var(--cal-clr);
  box-shadow: inset 0 0 0 1.5px var(--cal-clr);
}
.cal-task:hover .cal-task-dot:hover { background: var(--cal-clr); color: #fff; }
.cal-task.done .cal-task-dot { transform: none; color: #fff; }
.cal-task-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-task.done { opacity: .55; }
.cal-task.done .cal-task-name { text-decoration: line-through; }
.cal-task.overdue:not(.done) { background: var(--danger-light); border-left-color: var(--danger); color: var(--danger); font-weight: 600; }
.cal-task.overdue:not(.done) .cal-task-dot { background: var(--danger); }
.cal-task.overdue:not(.done):hover .cal-task-dot { background: #fff; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }

/* Avatar chữ cái người phụ trách ở mép phải chip */
.cal-task-ava {
  margin-left: auto; width: 15px; height: 15px; flex: none;
  border-radius: 50%; background: var(--cal-clr); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8.5px; font-weight: 700; opacity: .9;
}
.cal-task.overdue:not(.done) .cal-task-ava { background: var(--danger); }

/* ===== Bar việc nhiều ngày: kéo dài liên tục từ ngày bắt đầu đến deadline =====
   Mỗi đoạn nằm trong 1 ô; đoạn giữa kéo âm margin để phủ padding ô + khe lưới,
   nhìn thành một thanh liền. Lane cố định theo tuần nên các đoạn thẳng hàng. */
.cal-spans { display: flex; flex-direction: column; gap: 2px; margin-bottom: 3px; }
.cal-span {
  display: block; height: 16px; border: none; cursor: pointer; padding: 0 5px;
  background: color-mix(in srgb, var(--cal-clr) 80%, #fff);
  color: #fff; font-size: 10.5px; font-weight: 600; text-align: left;
  margin-left: -7px; margin-right: -6px; border-radius: 0;
  position: relative; z-index: 2; overflow: hidden;
}
.cal-span:hover { filter: brightness(.92); }
.cal-span.span-start { margin-left: 0; border-top-left-radius: 5px; border-bottom-left-radius: 5px; }
.cal-span.span-end { margin-right: 0; border-top-right-radius: 5px; border-bottom-right-radius: 5px; }
.cal-span.done { opacity: .45; }
.cal-span.done .cal-span-label { text-decoration: line-through; }
.cal-span.overdue { box-shadow: inset 0 0 0 1.5px var(--danger); }
.cal-span-label {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 16px;
}
.cal-span-gap { height: 16px; visibility: hidden; }

/* ===== Skeleton khi đang tải dữ liệu cloud lần đầu ===== */
.cal-skel {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: calSkel 1.2s ease-in-out infinite;
}
@keyframes calSkel { to { background-position: -200% 0; } }
.cal-skel-num { display: inline-block; width: 18px; height: 11px; border-radius: 3px; }
.cal-skel-bar { height: 14px; border-radius: 4px; margin-bottom: 3px; }

/* Cảnh báo Caps Lock trong dialog nhập mật khẩu */
.ad-caps { font-size: 12px; color: var(--warning); margin: -4px 0 8px; }

/* "+N việc khác" khi 1 ngày có nhiều việc hơn số chip hiển thị */
.cal-more {
  border: none; background: transparent; text-align: left;
  font-size: 11.5px; font-weight: 600; color: var(--gray-500);
  padding: 2px 6px; border-radius: 4px; cursor: pointer;
}
.cal-more:hover { background: var(--gray-100); color: var(--primary); }

/* ===== Layout lịch + panel chi tiết ngày ===== */
.cal-layout { display: flex; gap: 14px; align-items: flex-start; }
.cal-main { flex: 1 1 auto; min-width: 0; }

/* Ô đang chọn + ô đang kéo-thả vào */
.cal-cell.cal-selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell.cal-today.cal-selected { box-shadow: inset 0 0 0 3px var(--primary); }
.cal-cell.cal-drag-over { background: var(--primary-light); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-task[draggable="true"] { cursor: grab; }
.cal-task.dragging { opacity: .4; }

/* Panel chi tiết ngày (trượt bên phải) */
.cal-day-panel {
  flex: 0 0 340px; width: 340px; align-self: stretch;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  position: sticky; top: 0; max-height: calc(100vh - 120px);
}
/* Chỉ animate lần ĐẦU mở panel — re-render (tick việc, đổi ngày) không nháy lại */
.cal-day-panel.anim { animation: calPanelIn .16s ease; }
@keyframes calPanelIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.cal-dp-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--gray-100);
}
.cal-dp-date { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.cal-dp-sub { font-size: 12px; margin-top: 2px; }
.cal-dp-body { flex: 1 1 auto; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cal-dp-empty { text-align: center; color: var(--gray-400); font-size: 13px; padding: 28px 10px; }
.cal-dp-item {
  display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid var(--gray-100); border-left: 3px solid var(--cal-clr);
  border-radius: 8px; padding: 9px 10px; background: #fff; transition: background .12s;
}
.cal-dp-item:hover { background: var(--gray-50); }
.cal-dp-item.overdue { border-color: var(--danger-light); border-left-color: var(--danger); }
.cal-dp-item.done { opacity: .6; }
.cal-dp-item.done .cal-dp-name { text-decoration: line-through; }
.cal-dp-check {
  flex: none; width: 20px; height: 20px; margin-top: 1px;
  border: 1.5px solid var(--gray-300); border-radius: 50%;
  background: #fff; color: var(--success); font-size: 12px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1;
}
.cal-dp-item.done .cal-dp-check { background: var(--success); border-color: var(--success); color: #fff; }
.cal-dp-main { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.cal-dp-name { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.cal-dp-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--gray-500); }
.cal-dp-proj { background: var(--gray-100); border-radius: 5px; padding: 1px 6px; color: var(--gray-600); }
.cal-dp-foot { padding: 10px; border-top: 1px solid var(--gray-100); }
.cal-dp-foot .btn { width: 100%; justify-content: center; }

.cal-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--gray-500); flex-wrap: wrap; }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.cal-legend-dot:first-child { margin-left: 0; }

/* Trạng thái / giờ / xoá trong panel ngày worklog */
.cal-dp-status {
  flex: none; align-self: flex-start; cursor: pointer; border: none;
  border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 700;
  color: #fff; background: var(--cal-clr);
}
.cal-dp-del {
  flex: none; align-self: flex-start; width: 22px; height: 22px; line-height: 1;
  border: none; background: transparent; color: var(--gray-400); cursor: pointer;
  border-radius: 5px; font-size: 13px;
}
.cal-dp-del:hover { background: var(--danger-light); color: var(--danger); }

/* Mục "Bắt đầu trong ngày này" trong panel ngày */
.cal-dp-starts { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--gray-200); }
.cal-dp-starts-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--gray-400); margin-bottom: 6px;
}
.cal-dp-item.cal-dp-ghost { opacity: .85; }
.cal-dp-ghost-mark { flex: none; color: var(--cal-clr); font-weight: 700; font-size: 12px; padding-top: 2px; }
@media (max-width: 900px) {
  .cal-cell { min-height: 84px; }
  .cal-task-name { font-size: 11px; }
  .cal-title { font-size: 16px; }
  /* Trên mobile: panel phủ toàn chiều rộng dưới lịch */
  .cal-layout { flex-direction: column; }
  .cal-day-panel { width: 100%; flex-basis: auto; position: static; max-height: none; }
}

/* ===== Checklist cong viec trong modal du an ===== */
.pf-checklist {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
}
.pf-cl-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; background: var(--gray-50, #f9fafb);
  border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px;
  cursor: pointer; font-size: 13.5px;
}
.pf-cl-item input[type=checkbox] {
  width: 16px; height: 16px; flex: none; cursor: pointer;
  accent-color: var(--primary, #2563eb);
}
.pf-cl-item span { flex: 1; word-break: break-word; }
.pf-cl-item.done span { text-decoration: line-through; color: var(--gray-400, #9ca3af); }
.pf-cl-del {
  flex: none; border: none; background: transparent; cursor: pointer;
  color: var(--gray-400, #9ca3af); font-size: 16px; line-height: 1;
  padding: 2px 6px; border-radius: 5px;
}
.pf-cl-del:hover { background: var(--danger-light, #fee2e2); color: var(--danger, #dc2626); }

/* Che do chi-xem: khoa luon checklist trong modal du an */
body.readonly .pf-cl-item input[type=checkbox] { pointer-events: none; }
body.readonly .pf-cl-del,
body.readonly #pf-cl-add { display: none !important; }
body.readonly #pf-cl-input { pointer-events: none; background: var(--gray-100); }

/* ===== Modal du an 2 cot (desktop) ===== */
.pm-cols { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
@media (min-width: 900px) {
  .pm-cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .pm-col-side { border-left: 1px solid var(--gray-200, #e5e7eb); padding-left: 24px; border-radius: 0; }
  .pm-col-side .pf-checklist { max-height: 340px; }
}

/* Goi y ngay dd/mm/yyyy duoi input date */
.date-hint { margin-top: 3px; font-size: 11.5px; min-height: 14px; }

/* ===== Hop thoai xac nhan cua app ===== */
.app-dialog-overlay {
  position: fixed; inset: 0; z-index: 99000;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.app-dialog {
  width: 100%; max-width: 440px; background: #fff;
  border-radius: 14px; padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.app-dialog h3 { margin: 0 0 8px; font-size: 16px; }
.app-dialog-msg { font-size: 13.5px; color: var(--gray-600, #4b5563); line-height: 1.55; margin-bottom: 14px; }
.app-dialog input {
  width: 100%; box-sizing: border-box; padding: 9px 12px;
  border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px;
  margin-bottom: 12px; font-size: 14px; outline: none;
}
.app-dialog-btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Keo-tha sap xep checklist du an */
.pf-cl-grip {
  flex: none; cursor: grab; color: var(--gray-400, #9ca3af);
  font-size: 13px; line-height: 1; padding: 2px 2px 2px 0; user-select: none;
}
.pf-cl-item.dragging { opacity: .45; }
.pf-cl-item.drag-over { border-color: var(--primary, #2563eb); box-shadow: 0 -2px 0 0 var(--primary, #2563eb); }
body.readonly .pf-cl-grip { display: none !important; }

/* ===== Tin tuc BIM/AI ===== */
.news-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.news-head-info { font-size: 13px; }
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: #fff;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.news-card:hover {
  border-color: var(--primary); box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.news-rank {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: var(--primary-light); color: var(--primary);
}
.news-main { flex: 1; min-width: 0; }
.news-title {
  font-size: 15px; font-weight: 600; color: var(--gray-800);
  line-height: 1.4; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news-card:hover .news-title { color: var(--primary); }
.news-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--gray-500); flex-wrap: wrap;
}
.news-fav { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.news-source { font-weight: 500; color: var(--gray-600); }
.news-dot { color: var(--gray-300); }
.news-time { color: var(--gray-500); }
.news-arrow { flex: none; color: var(--gray-300); }
.news-card:hover .news-arrow { color: var(--primary); }

/* Skeleton khi dang tai */
.news-skeleton { pointer-events: none; }
.news-skeleton .sk-line {
  height: 12px; border-radius: 6px; margin: 3px 0;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
  background-size: 400% 100%; animation: sk-shimmer 1.4s ease infinite;
}
.news-skeleton .sk-title { width: 70%; height: 15px; }
.news-skeleton .sk-meta { width: 35%; }
@keyframes sk-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (max-width: 640px) {
  .news-card { padding: 12px; gap: 10px; }
  .news-arrow { display: none; }
}

/* ===== Tài chính: bảng gọn, số tiền dồn về phải & dễ dò theo dòng ===== */
/* Màn hình rất rộng: chặn bề ngang để số tiền không "trôi" xa tên dự án. */
.fin-view { max-width: 1500px; }
.fin-view .panel { padding: 14px 0 0; overflow: hidden; }
.fin-view .panel > .panel-head { padding: 0 18px; }
.fin-view .panel > .empty-mini,
.fin-view .panel > .scratch-text { margin: 0 18px 16px; }
.fin-view .panel > .table-scroll { margin-bottom: -1px; }
.fin-view .panel > .scratch-text { width: calc(100% - 36px); }
.panel-head-right { display: flex; align-items: center; gap: 12px; }
.panel-head-right .muted { font-size: 12px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Cột: tên co giãn, số tiền cố định hẹp -> nhìn ngang không bị "trôi" mất dòng. */
.fin-table { min-width: 720px; }
.fin-table .col-money { width: 148px; white-space: nowrap; }
.fin-table .col-num   { width: 96px;  white-space: nowrap; }
.fin-table .col-date  { width: 96px; }
.fin-table .col-type  { width: 120px; white-space: nowrap; }
.fin-table .col-kind  { width: 76px; }
.fin-table .col-note  { min-width: 110px; }
/* Tiêu đề cột không xuống dòng: "PHƯƠNG THỨC"/"GHI CHÚ" bị gãy 2 dòng trông rất rối. */
.fin-table th { white-space: nowrap; }
.fin-table .col-person{ width: 160px; }
.fin-table .col-staff { width: 252px; }
/* Tên dự án giữ 1 dòng: cột nhân sự có số tiền nên hay bóp tên gãy làm đôi. */
.fin-table .col-name  { min-width: 150px; white-space: nowrap; }
.fin-table td, .fin-table th { padding: 9px 12px; }
.fin-table th.col-money, .fin-table th.col-num { padding-right: 14px; }
.fin-table td.col-money, .fin-table td.col-num { padding-right: 14px; font-variant-numeric: tabular-nums; }
/* Kẻ nhẹ ngăn khối chữ với khối số */
.fin-table td.col-money:first-of-type, .fin-table th.col-money:first-of-type { border-left: 1px solid var(--gray-100); }
/* Sọc ngựa vằn — dò dòng trên màn hình rộng */
.fin-table tbody tr:nth-child(even) { background: #fbfcfd; }
.fin-table tbody tr.clickable:hover { background: var(--primary-light); }
.fin-table tbody td { border-bottom: 1px solid var(--gray-100); }

/* Hàng ngang: bảng nhân viên + bảng trả theo tháng, lấp chỗ trống bên phải. */
.fin-row { display: flex; gap: 16px; align-items: flex-start; margin-top: 16px; }
.fin-row > .panel { margin-top: 0; min-width: 0; flex: 1 1 auto; }
.fin-month-panel { flex: 0 0 420px; }
/* Hai bảng nằm ngang cần ~1330px chỗ trống; hẹp hơn thì xếp dọc, chứ để
   ngang là cả hai cùng đẻ thanh cuộn và cột "Đã trả" bị cắt mất. */
@media (max-width: 1600px) {
  .fin-row { flex-direction: column; }
  .fin-row > .panel { width: 100%; max-width: none; flex: 1 1 auto; }
}

/* Bảng "Trả nhân viên theo tháng" */
.month-table { min-width: 0; }
.fin-month-panel .col-month { min-width: 128px; }
.fin-month-panel .col-num { width: 62px; }
.fin-month-panel .col-money { width: 132px; }
.mon-name { display: block; font-weight: 600; color: var(--gray-800); }
.mon-sub { display: block; margin-top: 2px; font-size: 11px; color: var(--gray-400); }
.month-table .cell-bar .prog-wrap { width: 100%; }
.month-note { padding: 8px 14px 12px; font-size: 11.5px; }

/* Bảng nhân viên ít cột hơn -> hẹp lại, không thì số trôi ra tận rìa phải. */
.fin-emp-panel { max-width: 1040px; }
.fin-emp-panel.narrow { max-width: 720px; }
/* Bảng ít cột -> hạ min-width, không thì panel hẹp lại đẻ ra thanh cuộn ngang thừa. */
.fin-emp-panel .fin-table { min-width: 520px; }

/* Số 0 / ô trống: lùi về sau, đừng đỏ-xanh chói như số thật. */
.zero { color: var(--gray-300); font-variant-numeric: tabular-nums; }

.fin-proj-name { font-weight: 600; color: var(--gray-800); }
.fin-edit-hint { color: var(--gray-300); font-size: 11px; margin-left: 6px; }
.fin-table tr:hover .fin-edit-hint { color: var(--primary); }
.muted-hint { color: var(--gray-400); font-size: 12px; }
.cell-bar { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px; }
.cell-bar .prog-wrap { width: 58px; height: 5px; margin: 0; }
.cell-bar .prog-label { font-size: 10.5px; }

.fin-person { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.fin-person > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staff-cell { display: flex; align-items: center; gap: 8px; }
.av-stack { display: inline-flex; align-items: center; }
.av-stack .avatar { margin-right: -7px; border: 2px solid #fff; }
.av-stack .avatar:last-child { margin-right: 0; }
.av-more {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px; margin-left: 4px;
  border-radius: 11px; background: var(--gray-200); color: var(--gray-600);
  font-size: 10.5px; font-weight: 600;
}
.staff-meta { font-size: 11.5px; color: var(--gray-500); white-space: nowrap; }
.staff-meta b { font-weight: 600; }

/* ===== Bảng nhập nhân sự & báo giá (dialog tài chính dự án) ===== */
.pfin-staff-panel { overflow: hidden; }
.pfin-staff-panel > #pfin-staff-wrap { margin: 0 -18px -16px; }
.pfin-staff-panel > #pfin-staff-wrap > .empty-mini { padding: 18px 12px; }
.staff-table { min-width: 520px; }
.staff-table td { padding: 7px 10px; vertical-align: middle; }
.staff-table th { padding: 8px 10px; }
.staff-table input {
  width: 100%; padding: 6px 9px; font-size: 13px;
  border: 1px solid var(--gray-200); border-radius: 6px; background: #fff;
  font-family: inherit; color: var(--gray-800);
}
.staff-table input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.staff-table input.right { text-align: right; font-variant-numeric: tabular-nums; }
.staff-table .sf-person { display: flex; align-items: center; gap: 7px; }
.staff-table .sf-person .avatar { flex: 0 0 auto; }
.staff-table .sf-left { font-variant-numeric: tabular-nums; white-space: nowrap; }
.staff-table .sf-sync {
  display: block; width: 100%; margin-top: 4px; padding: 2px 6px;
  border: 1px dashed var(--gray-300); border-radius: 5px; background: var(--gray-50);
  color: var(--gray-600); font-size: 10.5px; font-family: inherit; cursor: pointer;
  text-align: right; white-space: nowrap;
}
.staff-table .sf-sync:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.staff-table .sf-del { width: 26px; height: 26px; font-size: 12px; line-height: 1; }

@media (max-width: 1100px) { .hide-sm { display: none; } }
@media (max-width: 900px) {
  .fin-view .panel > .panel-head { padding: 0 14px; }
  .fin-view .panel > .empty-mini, .fin-view .panel > .scratch-text { margin: 0 14px 14px; }
  .fin-view .panel > .scratch-text { width: calc(100% - 28px); }
}
