/* ===== 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; gap: 12px; padding: 4px 8px 18px; }
.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-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-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 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: 11.5px;
  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: 11.5px;
  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);
}
.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); }

/* ===== 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);
}
.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) { min-width: 100px; }
.students-table th:nth-child(9), .students-table td:nth-child(9) { 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"] {
  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; }
.workload-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px;
  flex-shrink: 0;
}
.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;
}

/* ===== Kanban ===== */
.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 / avatar ===== */
.assignee-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.assignee-avatar {
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.kc-assignee { margin-left: auto; }

/* ===== Login overlay ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.login-card {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 18px;
  padding: 32px 26px 26px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: #2563eb; color: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800;
}
.login-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; color: var(--gray-900); }
.login-sub { font-size: 13.5px; color: var(--gray-500); margin: 0 0 22px; }
.login-input-wrap { position: relative; margin-bottom: 10px; }
.login-input-wrap input {
  width: 100%; height: 50px;
  padding: 0 46px 0 16px;
  font-size: 16px; /* >=16px để iOS không tự zoom */
  border: 1.5px solid var(--gray-200); border-radius: 12px;
  outline: none; transition: border-color .15s;
}
.login-input-wrap input:focus { border-color: var(--primary); }
.login-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: none; background: transparent;
  font-size: 18px; cursor: pointer; border-radius: 8px;
}
.login-toggle:active { background: var(--gray-100); }
.login-err { min-height: 18px; font-size: 13px; margin-bottom: 8px; }
.login-err.error { color: var(--danger); }
.login-err.checking { color: var(--gray-500); }
.login-remember {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13.5px; color: var(--gray-600); margin-bottom: 18px; cursor: pointer;
}
.login-remember input { width: 18px; height: 18px; }
.login-submit { width: 100%; height: 50px; font-size: 16px; border-radius: 12px; }
.login-clearcache {
  display: none; width: 100%; margin-top: 12px;
  background: none; border: none; color: var(--gray-500);
  font-size: 13px; text-decoration: underline; cursor: pointer; padding: 8px;
}
body.login-active { overflow: hidden; }

/* ===== 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); }
