/* Hiệu năng: không dùng backdrop-filter / filter: blur / background-attachment: fixed.
   Đo trên CPU chậm x4, 3 hiệu ứng này làm cuộn trang tụt từ ~47 xuống ~21 khung hình/giây. */
:root {
  --accent: #f43f5e;
  --accent-hover: #e11d48;
  --accent-soft: rgba(244, 63, 94, 0.14);
  --bg-base: #0f0514;
  --bg-gradient: radial-gradient(ellipse at 50% 0%, #3b1137 0%, #1f0b24 50%, #0f0514 100%);
  --card-bg: #1a1620;
  --card-bg-raised: #221c29;
  --card-border: rgba(255, 255, 255, 0.08);
  --subcard-bg: rgba(255, 255, 255, 0.04);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --c-todo: #94a3b8;
  --c-doing: #3b82f6;
  --c-done: #10b981;
  --c-danger: #f43f5e;
  --c-warn: #f59e0b;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html { background: var(--bg-base); }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Nền gradient nằm trên một lớp cố định riêng: trình duyệt không phải vẽ lại khi cuộn */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-gradient);
  pointer-events: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
body:not(.is-manager) .manager-only { display: none !important; }

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* --- Buttons --- */
.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(244, 63, 94, 0.3); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--card-border); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.14); }
.btn-danger { background: var(--accent-soft); color: #fda4af; margin-right: auto; }
.btn-danger:hover { background: rgba(244, 63, 94, 0.25); }
.btn-primary:active, .btn-secondary:active, .btn-danger:active { transform: scale(0.97); }
.btn-block { width: 100%; padding: 12px; margin-top: 6px; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; margin-left: 8px; }
.show-more-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.show-more-btn:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.2); }

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 380px; padding: 32px 28px; }
.login-card .brand-logo { margin-bottom: 18px; }
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-card p { font-size: 13.5px; margin: 4px 0 22px; }

/* --- Layout --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 0;
  gap: 24px;
  background: #0d0a11;
  border-right: 1px solid var(--card-border);
  z-index: 50;
}
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(244, 63, 94, 0.3);
}
.brand-logo svg { width: 22px; height: 22px; fill: #fff; }
.nav-items { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-btn {
  width: 64px;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}
.nav-btn svg { width: 21px; height: 21px; stroke-width: 2; }
.nav-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }
.nav-btn.active { color: #fff; background: rgba(255, 255, 255, 0.1); }
.nav-btn.active svg { color: var(--accent); }
.user-avatar-btn { border: none; background: none; border-radius: 50%; }
.user-avatar-btn .avatar { width: 42px; height: 42px; font-size: 14px; border: 2px solid rgba(255, 255, 255, 0.15); }

.account-menu {
  position: fixed;
  left: 98px;
  bottom: 20px;
  width: 230px;
  padding: 14px;
  z-index: 60;
  display: none;
  background: var(--card-bg-raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.account-menu.open { display: block; }
.account-name { font-weight: 800; }
.account-role { font-size: 12px; color: var(--text-muted); margin: 2px 0 10px; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.07); }
.menu-item.danger { color: #fda4af; }

.main-wrapper { flex: 1; margin-left: 88px; padding: 30px 36px 48px; min-width: 0; }
.top-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.welcome-meta h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.welcome-meta p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.view-container { display: none; }
.view-container.active { display: block; }
.section-heading { font-size: 15px; font-weight: 800; margin: 6px 0 12px; }

/* --- Stats & filters --- */
.stats-pills-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--subcard-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  white-space: nowrap;
}
.stat-pill .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-pill .val { font-size: 15px; font-weight: 800; }
.stat-pill.warn .val { color: var(--c-danger); }

.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filter-search-box {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 40px;
  background: var(--subcard-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--text-dim);
}
.filter-search-box input { flex: 1; min-width: 0; background: none; border: none; outline: none; font-size: 13.5px; color: var(--text-main); }
.filter-select {
  height: 40px;
  padding: 0 14px;
  background: var(--subcard-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 13.5px;
  outline: none;
}
.filter-select option, .form-input option { background: #1a1d26; }

.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 999px;
}
.segmented-btn {
  border: none;
  background: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.segmented-btn.active { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* --- Badges & avatars --- */
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.type-team { background: rgba(168, 85, 247, 0.16); color: #d8b4fe; }
.type-personal { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
.priority-urgent { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.priority-high { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.due { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.due.soon { color: var(--c-warn); font-weight: 600; }
.due.overdue { color: var(--c-danger); font-weight: 700; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--card-bg); margin-left: -7px; }

.status-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-todo { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.status-doing { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.status-done { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }

/* --- Kanban --- */
.kanban-tabs { display: none; }
.kanban-board-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kanban-column {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 200px;
  transition: border-color 0.15s;
}
.kanban-column.drop-target { border-color: var(--accent); }
.kanban-col-header { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; margin-bottom: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.todo { border: 2px solid var(--c-todo); }
.dot.doing { background: var(--c-doing); }
.dot.done { background: var(--c-done); }
.col-count-pill { font-size: 11px; color: var(--text-muted); background: rgba(255, 255, 255, 0.07); padding: 1px 8px; border-radius: 999px; }
.kanban-col-body { display: flex; flex-direction: column; gap: 10px; }
.empty-col { color: var(--text-dim); font-size: 13px; text-align: center; padding: 24px 8px; }

.kanban-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.kanban-card.dragging { opacity: 0.4; }
.kanban-card.is-done .card-task-name { text-decoration: line-through; color: var(--text-muted); }
.card-task-name { font-size: 14px; font-weight: 700; line-height: 1.4; margin: 8px 0 10px; word-break: break-word; }
.card-meta-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-footer-left { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-next-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-next-btn:hover { background: var(--accent); }

@media (hover: hover) {
  .kanban-card:hover { border-color: rgba(255, 255, 255, 0.2); }
  .kanban-card:hover .card-next-btn { opacity: 1; }
}

/* --- Workload --- */
.workload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 26px; }
.workload-card { padding: 16px; cursor: pointer; transition: border-color 0.15s; }
.workload-card:hover { border-color: rgba(255, 255, 255, 0.2); }
.workload-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.workload-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-width: 0; }
.workload-name { font-weight: 800; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workload-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.workload-stats .num { display: block; font-size: 20px; font-weight: 800; }
.workload-stats .lbl { font-size: 11px; color: var(--text-muted); }
.workload-stats .is-overdue .num { color: var(--c-danger); }
.workload-stats .is-done .num { color: var(--c-done); }

/* --- Lists --- */
.list-table { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}
.row-title { font-weight: 700; font-size: 14px; word-break: break-word; }
.row-title.is-done { text-decoration: line-through; color: var(--text-muted); }

.team-row { grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) 120px; cursor: pointer; transition: border-color 0.15s; }
.team-row:hover { border-color: rgba(255, 255, 255, 0.18); }
.team-row-main .badge-row { margin-top: 6px; }
.assignee-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 2px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.progress-text { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; text-align: right; }
.progress-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress-fill { height: 100%; background: var(--c-done); border-radius: 999px; }

.user-row { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.user-row.inactive { opacity: 0.55; }

/* --- Modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s, visibility 0s linear 0.18s;
}
.modal-backdrop.open { visibility: visible; opacity: 1; transition: opacity 0.18s; }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card-bg-raised);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-sm { max-width: 420px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-header h2 { font-size: 18px; font-weight: 800; }
.modal-close-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.modal-close-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.form-group { margin-bottom: 14px; }
.form-group > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-input:disabled { opacity: 0.6; }
textarea.form-input { resize: vertical; min-height: 70px; }
input[type="date"].form-input { color-scheme: dark; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: #fda4af; font-size: 13px; min-height: 18px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 10px; }
#taskTypeToggle { display: flex; }
#taskTypeToggle .segmented-btn { flex: 1; }

.assignee-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
}
.assignee-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.assignee-option:hover { background: rgba(255, 255, 255, 0.05); }
.assignee-option input { accent-color: var(--accent); width: 16px; height: 16px; }

.detail-title { font-size: 20px; font-weight: 800; line-height: 1.35; word-break: break-word; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 14px; }
.detail-desc {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.6;
  color: #cbd5e1;
  background: var(--subcard-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.detail-section-title { font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: 0.4px; }
.status-control { display: flex; }
.status-control .segmented-btn { flex: 1; padding: 9px 10px; }
.detail-assignees { display: flex; flex-direction: column; gap: 6px; }
.detail-assignee {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--subcard-bg);
  border-radius: var(--radius-sm);
}
.detail-assignee .name { font-size: 13.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-select { border: none; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; outline: none; }

/* --- Comments --- */
.comment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.comment-badge.has-unread {
  color: #fff;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment .avatar { margin-top: 2px; }
.comment-content {
  flex: 1;
  min-width: 0;
  background: var(--subcard-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 8px 12px;
}
.comment.is-mine .comment-content { background: rgba(244, 63, 94, 0.08); border-color: rgba(244, 63, 94, 0.18); }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.comment-author { font-size: 13px; font-weight: 700; }
.comment-body { font-size: 13.5px; line-height: 1.55; color: #e2e8f0; white-space: pre-wrap; word-break: break-word; }
.comment-delete {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 11.5px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.15s;
}
.comment-delete:hover { color: #fda4af; }
.comment-delete[data-armed] { color: #fda4af; opacity: 1; }
.comment:hover .comment-delete { opacity: 1; }
.empty-comments { font-size: 13px; color: var(--text-dim); padding: 4px 0; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.comment-form textarea { min-height: 44px; resize: vertical; font-size: 13.5px; }
.comment-form .btn-primary { padding: 11px 18px; }
.comment-form .btn-primary:disabled { opacity: 0.6; }
#taskDetailActions { border-top: 1px solid var(--card-border); padding-top: 16px; }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 11px 20px;
  background: #0d1a12;
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #1f0b10; border-color: rgba(244, 63, 94, 0.5); }

/* --- Máy tính bảng --- */
@media (max-width: 1000px) {
  .main-wrapper { padding: 24px 22px 40px; }
  .kanban-board-grid { grid-template-columns: 1fr; }
  .team-row { grid-template-columns: 1fr; gap: 10px; }
  .progress-text { text-align: left; }
}

/* --- Điện thoại --- */
@media (max-width: 700px) {
  /* Thanh điều hướng dưới đáy, chừa vùng an toàn của iPhone */
  .sidebar {
    top: auto;
    width: 100%;
    height: calc(var(--nav-h) + var(--safe-b));
    padding: 0 8px var(--safe-b);
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    border-right: none;
    border-top: 1px solid var(--card-border);
  }
  .sidebar .brand-logo { display: none; }
  .nav-items { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .nav-btn { width: auto; flex: 1; padding: 8px 2px; font-size: 11px; }
  .nav-btn.active { background: none; }
  .user-avatar-btn { padding: 0 8px; }
  .user-avatar-btn .avatar { width: 36px; height: 36px; font-size: 12px; }
  .account-menu { left: auto; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); width: min(260px, calc(100vw - 24px)); }

  .main-wrapper { margin-left: 0; padding: calc(16px + var(--safe-t)) 16px calc(var(--nav-h) + var(--safe-b) + 88px); }
  .top-header { margin-bottom: 14px; }
  .welcome-meta h1 { font-size: 21px; }
  .welcome-meta p { font-size: 13px; }

  /* Nút thêm việc nổi phía trên thanh điều hướng */
  #headerNewBtn {
    position: fixed;
    right: 16px;
    bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
    z-index: 40;
    padding: 14px 20px;
    font-size: 14.5px;
    box-shadow: 0 10px 28px rgba(244, 63, 94, 0.45);
  }

  /* Dòng thống kê cuộn ngang, không chiếm nhiều chiều cao */
  .stats-pills-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    margin: 0 -16px 14px;
    padding: 0 16px;
    scrollbar-width: none;
  }
  .stats-pills-row::-webkit-scrollbar { display: none; }
  .stat-pill { padding: 7px 13px; gap: 8px; }

  .filters-row { gap: 8px; margin-bottom: 14px; }
  .filters-row .segmented-control { width: 100%; }
  .filters-row .segmented-control .segmented-btn { flex: 1; }
  .filter-search-box { flex-basis: 100%; min-width: 0; height: 44px; }
  .filter-select { flex: 1; min-width: 0; height: 44px; }

  /* Bảng việc: xem từng cột theo tab */
  .kanban-tabs { display: flex; width: 100%; margin-bottom: 12px; }
  .kanban-tabs .segmented-btn { flex: 1; padding: 10px 6px; font-size: 13px; }
  .tab-count {
    display: inline-block;
    min-width: 20px;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 11px;
  }
  .kanban-board-grid { display: block; }
  .kanban-column { display: none; padding: 0; border: none; background: none; min-height: 0; }
  .kanban-board-grid[data-mobile-col="todo"] .kanban-column[data-status="todo"],
  .kanban-board-grid[data-mobile-col="doing"] .kanban-column[data-status="doing"],
  .kanban-board-grid[data-mobile-col="done"] .kanban-column[data-status="done"] { display: block; }
  .kanban-col-header { display: none; }
  .kanban-card { padding: 14px; }
  .card-task-name { font-size: 15px; margin-right: 0; }
  .card-next-btn { opacity: 1; position: static; margin-top: 12px; width: 100%; padding: 10px; font-size: 13px; }

  /* Khối lượng việc: vuốt ngang */
  .workload-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    gap: 10px;
    margin: 0 -16px 22px;
    padding: 0 16px 4px;
    scrollbar-width: none;
  }
  .workload-grid::-webkit-scrollbar { display: none; }
  .workload-card { flex: 0 0 72%; max-width: 260px; scroll-snap-align: start; padding: 14px; }
  .workload-stats .num { font-size: 18px; }

  .list-row { padding: 14px; }
  .user-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .user-row .badge, .user-row .status-pill { display: none; }

  /* Cửa sổ chi tiết thành bảng trượt từ dưới lên */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-sm {
    max-width: none;
    max-height: calc(100dvh - 24px - var(--safe-t));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: 20px 18px calc(18px + var(--safe-b));
    transform: translateY(24px);
    transition: transform 0.22s ease-out;
  }
  .modal-backdrop.open .modal { transform: none; }
  .modal-header { position: sticky; top: -20px; margin: -20px -18px 14px; padding: 16px 18px 10px; background: var(--card-bg-raised); z-index: 1; }
  .form-row-2 { grid-template-columns: 1fr; }
  .modal-actions { position: sticky; bottom: calc(-18px - var(--safe-b)); margin: 18px -18px calc(-18px - var(--safe-b)); padding: 12px 18px calc(12px + var(--safe-b)); background: var(--card-bg-raised); border-top: 1px solid var(--card-border); }
  .modal-actions .btn-primary, .modal-actions .btn-secondary { flex: 1; padding: 12px; }
  .detail-assignee { grid-template-columns: auto 1fr auto; }
  .detail-assignee .muted { display: none; }
  .comment-list { max-height: none; }
  .comment-delete { opacity: 1; }
  .assignee-picker { grid-template-columns: 1fr; max-height: 40vh; }

  /* iPhone tự phóng to khi ô nhập nhỏ hơn 16px */
  .form-input, .filter-search-box input, .filter-select { font-size: 16px; }

  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 84px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
