/* Bang mau + kieu dang lay cam hung tu "Roster Assistant" (app noi bo khac
   tren cung VPS) de 2 app nhin "cung mot nha": font Inter, mau chu dao
   emerald (xanh la), bo goc rounded-xl, topbar trang mo (backdrop-blur),
   cac the/button bo tron + do do nhe (shadow-sm) thay cho kieu cu (navy +
   vang dong, bo goc vuong). KHONG doi ten bat ky class/id nao — toan bo
   cau truc HTML do app.js tu sinh ra dung nguyen class cu, chi doi GIA TRI
   style o day. */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #059669;
  --primary-dark: #047857;
  --primary-bg: #ecfdf5;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-bg: #eff6ff;
  --green: #059669;
  --green-bg: #d1fae5;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --gray: #64748b;
  --gray-bg: #f1f5f9;
  --orange: #c2410c;
  --blue: #2563eb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: var(--font); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.logo-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-title { font-weight: 700; font-size: 0.92rem; color: var(--text); }
.logo-sub { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; }
.logo img { height: 34px; width: auto; display: block; }

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .who-tag { margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--border); text-align: right; }

.layout { display: flex; align-items: flex-start; }
.app { max-width: 1080px; margin: 0 auto; padding: 24px; flex: 1 1 auto; min-width: 0; }
.layout.with-sidebar .app { max-width: none; margin: 0; }

.sidebar {
  flex: 0 0 230px;
  width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 57px);
  padding: 16px 12px;
  position: sticky;
  top: 57px;
}
.sidebar[hidden] { display: none; }
.sidebar-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  margin-bottom: 2px;
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar-item-icon { width: 18px; margin-right: 10px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.sidebar-item:hover { background: var(--bg); color: var(--text); }
.sidebar-item.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-weight: 700;
}
.sidebar-item.active .sidebar-item-icon { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-bg); color: var(--text); }
.btn-danger { background: transparent; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 6px 11px; font-size: 0.76rem; }
.btn-icon { background: transparent; border: none; cursor: pointer; font-size: 0.95rem; padding: 4px 8px; border-radius: var(--radius); color: var(--text-muted); }
.btn-icon:hover { background: var(--gray-bg); }

/* ---------- Màn hình đăng nhập (giao diện lấy cảm hứng từ Roster Assistant:
   chia 2 nửa, nửa trái thương hiệu + lưới tính năng, nửa phải form đăng
   nhập bằng Mã VAE ID — hiển thị TRỰC TIẾP ở trang chủ, không còn modal).
   Khi state.mode là null, render() gắn class "login-mode" vào <body> để
   ẩn topbar/sidebar và cho #app chiếm toàn bộ viewport (xem app.js). ---------- */
body.login-mode .topbar { display: none; }
body.login-mode .layout { display: block; }
body.login-mode .app { max-width: none; margin: 0; padding: 0; min-height: 100vh; }

.login-screen {
  display: flex;
  min-height: 100vh;
  font-family: var(--font);
}
.login-left {
  flex: 1 1 58%;
  position: relative;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: linear-gradient(160deg, #0b3a46 0%, #11505f 55%, #0e4452 100%);
  overflow: hidden;
  color: #fff;
}
.login-left::before {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.05) 0 2px, transparent 2px 26px);
  pointer-events: none;
}
.login-left > * { position: relative; z-index: 1; }

.login-logo-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.25);
}
.login-logo-card img { height: 64px; width: auto; max-width: 280px; object-fit: contain; display: block; }

.login-caption {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.76rem; font-weight: 700;
  color: #e0b464; text-align: center; margin: 0;
}
.login-title { font-size: 2rem; font-weight: 800; text-align: center; margin: 0; max-width: 560px; }
.login-subtitle { font-size: 0.95rem; color: #bcd4da; text-align: center; margin: -14px 0 0; max-width: 460px; }

.login-feature-grid {
  display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 14px;
  width: 100%; max-width: 640px; margin-top: 6px;
}
.login-feature-card {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px; padding: 16px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.login-feature-icon { font-size: 1.1rem; color: #e0b464; }
.login-feature-title { font-size: 0.86rem; font-weight: 700; color: #fff; }
.login-feature-sub { font-size: 0.72rem; color: #a9c4cb; line-height: 1.35; }

.login-right {
  flex: 1 1 42%;
  background: #0f1c27;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.login-right-inner { width: 100%; max-width: 380px; }
.login-right-inner h2 { color: #fff; font-size: 1.5rem; font-weight: 800; margin: 0 0 6px; }
.login-right-inner > p#vaeAuthHint { color: #8ea2ad; font-size: 0.88rem; margin: 0 0 28px; line-height: 1.5; }
.login-right-inner .form-error { color: #f87171; font-size: 0.82rem; margin: -10px 0 16px; }

.login-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.login-field[hidden] { display: none; } /* ".login-field{display:flex}" o tren se de len quy tac [hidden] mac dinh cua trinh duyet neu khong co dong nay */
.login-field label { font-size: 0.82rem; font-weight: 700; color: #cfdee3; }
.login-input-wrap { position: relative; display: flex; align-items: center; }
.login-input-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: #6b8793; font-size: 0.86rem; pointer-events: none;
}
.login-input-wrap input {
  width: 100%; box-sizing: border-box; padding: 11px 38px 11px 38px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(148,163,184,0.25);
  border-radius: 9px; color: #fff; font-size: 0.92rem;
}
.login-input-wrap input::placeholder { color: #5c7984; }
.login-input-wrap input:focus { outline: none; border-color: #2c7a8c; box-shadow: 0 0 0 3px rgba(44,122,140,0.25); }
.login-password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: #6b8793; font-size: 0.86rem; padding: 6px;
}
.login-password-toggle:hover { color: #cfdee3; }

.login-remember-row { display: flex; align-items: center; gap: 8px; margin: -4px 0 20px; }
.login-remember-row input[type=checkbox] { accent-color: #2c7a8c; }
.login-remember-row label { font-size: 0.82rem; color: #9fb4bd; cursor: pointer; }

.login-submit-btn {
  width: 100%; padding: 12px; border: none; border-radius: 9px; cursor: pointer;
  font-family: var(--font); font-size: 0.95rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #1b5c6f, #2c7a8c);
  box-shadow: 0 10px 22px rgba(27,92,111,0.35);
  transition: filter .15s;
}
.login-submit-btn:hover { filter: brightness(1.08); }

.login-footer { margin-top: 28px; text-align: center; font-size: 0.74rem; color: #5c7984; line-height: 1.6; }

@media (max-width: 860px) {
  .login-screen { flex-direction: column; }
  .login-left, .login-right { flex: 1 1 auto; }
  .login-left { padding: 40px 24px; }
  .login-right { padding: 36px 24px; }
  .login-feature-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Member grid ---------- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.member-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.member-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.member-card h3 { margin: 0 0 2px; font-size: 1rem; color: var(--text); font-weight: 700; }
.member-card .position { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px; }
.member-card .delete-btn {
  position: absolute; top: 10px; right: 10px;
}
.team-group-header {
  font-size: 0.78rem; font-weight: 700; color: var(--primary-dark); margin: 22px 0 10px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.team-group-header:first-of-type { margin-top: 2px; }
.leader-badge {
  display: inline-block; font-size: 0.66rem; font-weight: 700; color: var(--accent-dark);
  background: var(--accent-bg); padding: 2px 8px; border-radius: 999px; vertical-align: middle;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.team-move-select {
  margin-top: 10px; width: 100%; font-size: 0.78rem; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); background: var(--surface);
}
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.badge-green { background: var(--green-bg); color: #047857; }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Member detail ---------- */
.back-link { background: none; border: none; color: var(--primary-dark); font-weight: 700; cursor: pointer; padding: 0; margin-bottom: 14px; font-size: 0.86rem; }
.member-detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.member-detail-header h2 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 800; }
.member-detail-header .position { color: var(--text-muted); }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; background: var(--gray-bg); border-radius: var(--radius); padding: 4px; width: fit-content; }
.tab-btn {
  background: none; border: none; padding: 8px 16px; font-weight: 600; font-size: 0.84rem;
  color: var(--text-muted); cursor: pointer; border-radius: 6px; transition: background .12s, color .12s;
}
.tab-btn.active { color: var(--primary-dark); background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }

/* ---------- Work item cards ---------- */
.work-list { display: flex; flex-direction: column; gap: 14px; }
.work-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
}
.work-card.status-red { border-left: 4px solid var(--red); }
.work-card.status-amber { border-left: 4px solid var(--amber); }
.work-card.status-green { border-left: 4px solid var(--green); }
.work-card.status-completed { border-left: 4px solid var(--gray); opacity: 0.85; }

.work-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.work-title { font-weight: 700; font-size: 0.98rem; margin: 0 0 4px; }
.work-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.work-note { margin-top: 10px; font-size: 0.87rem; background: var(--bg); padding: 10px 12px; border-radius: var(--radius); white-space: pre-wrap; }
.work-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.progress-bar-outer { background: var(--gray-bg); border-radius: 999px; height: 6px; margin-top: 12px; overflow: hidden; }
.progress-bar-inner { background: var(--primary); height: 100%; border-radius: 999px; transition: width .2s; }
.progress-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.progress-note-text { font-size: 0.86rem; margin-top: 6px; font-style: italic; color: var(--text); }

.progress-edit-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.progress-edit-row input[type=range] { flex: 1; min-width: 120px; accent-color: var(--primary); }
.progress-edit-row input[type=text] { flex: 2; min-width: 160px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); }

.comments-toggle { margin-top: 10px; }
.comments-box { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment { padding: 8px 10px; background: var(--bg); border-radius: var(--radius); margin-bottom: 6px; font-size: 0.84rem; }
.comment .author { font-weight: 700; margin-right: 6px; }
.comment.author-manager .author { color: var(--primary-dark); }
.comment.author-member .author { color: var(--accent-dark); }
.comment .time { color: var(--text-muted); font-size: 0.76rem; margin-left: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Trainings ---------- */
.training-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.training-table th, .training-table td { padding: 10px 12px; text-align: left; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.training-table th { background: var(--bg); color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.04em; }
.training-table tr:last-child td { border-bottom: none; }

/* ---------- Tiến độ tuần ---------- */
.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.week-range-label { font-weight: 800; font-size: 0.92rem; }
.weekly-warning {
  background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); padding: 10px 14px;
  font-size: 0.84rem; margin-bottom: 16px; border-left: 3px solid var(--amber);
}
.weekly-table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow-x: auto;
}
.weekly-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.weekly-table th, .weekly-table td {
  padding: 10px 10px; text-align: center; font-size: 0.84rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.weekly-table th { background: var(--bg); color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.04em; }
.weekly-table tr:last-child td { border-bottom: none; }
.weekly-table .weekly-name { text-align: left; font-weight: 600; white-space: normal; min-width: 160px; }
.weekly-table th:nth-last-child(1), .weekly-table th:nth-last-child(2),
.weekly-table td:nth-last-child(1), .weekly-table td:nth-last-child(2) { min-width: 140px; text-align: left; }

.att-cell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; font-size: 0.7rem; font-weight: 700;
}
.att-on { background: var(--green-bg); color: #047857; }
.att-off { background: var(--red-bg); color: var(--red); }
.att-unknown { background: var(--gray-bg); color: var(--gray); }

/* ---------- Lịch trực (bảng xem trực tiếp từ Google Sheet) ---------- */
.roster-table th, .roster-table td { padding: 8px 8px; }
.att-on-text { color: #047857; font-weight: 700; }
.att-off-text { color: var(--red); font-weight: 700; }
.att-unknown-text { color: var(--text-muted); }

/* Thanh công cụ (tìm theo tên + nhảy đến hôm nay) + chú giải màu */
.month-tab-banner {
  background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); padding: 10px 14px;
  font-size: 0.84rem; margin-bottom: 14px; border-left: 3px solid var(--amber);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.month-tab-banner span { flex: 1; min-width: 220px; }
.roster-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.roster-search-input {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.84rem;
  min-width: 200px; color: var(--text); background: var(--surface);
}
.roster-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.roster-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-muted); margin: -2px 0 14px; }
.roster-legend span { display: inline-flex; align-items: center; gap: 5px; }
.roster-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.roster-legend .dot.on { background: var(--green); }
.roster-legend .dot.off { background: var(--red); }
.roster-legend .dot.unknown { background: var(--gray); }
.roster-legend .dot.today { background: var(--primary); }
.roster-legend .dot.weekend { background: var(--amber); }
.roster-group-summary { font-size: 0.82rem; color: var(--text-muted); margin: -4px 0 10px; font-weight: 600; }

/* The "Tổng hợp đào tạo" import card (upload file KHDT + báo cáo kết quả) */
.training-import-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.training-import-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.training-import-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.training-import-report {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.training-import-summary { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text); }
.training-import-unmatched-list {
  margin: 0; padding-left: 20px; font-size: 0.85rem; color: var(--text-muted);
  max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}

/* Bang "Ket noi Google" o dau trang Lich truc */
.google-connect-panel {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  padding: 10px 14px; margin-bottom: 12px; font-size: 0.85rem; box-shadow: var(--shadow);
}
.google-connected-tag { color: #047857; font-weight: 600; }

/* O lich truc co the bam de sua (sau khi da ket noi Google) */
.roster-cell-editable { cursor: pointer; }
.roster-cell-editable:hover { background: var(--primary-bg); outline: 1px dashed var(--primary); }
.roster-cell-edit-wrap { display: flex; align-items: center; gap: 3px; }
.roster-cell-input {
  flex: 1 1 auto; min-width: 40px; box-sizing: border-box; padding: 2px 4px;
  border: 1px solid var(--primary); border-radius: 4px; font-size: 0.82rem;
  text-align: center; color: var(--text); background: var(--surface);
}
.roster-cell-input:focus { outline: none; }
.roster-cell-btn {
  flex: 0 0 auto; width: 20px; height: 20px; line-height: 1; padding: 0;
  border: none; border-radius: 4px; font-size: 0.75rem; font-weight: 700;
  cursor: pointer; color: #fff;
}
.roster-cell-btn:disabled { opacity: 0.5; cursor: default; }
.roster-cell-save { background: var(--green); }
.roster-cell-cancel { background: var(--red); }

/* Cuộn trong khung cố định chiều cao — cần thiết để dòng tiêu đề "đông cứng"
   (sticky top:0) có một khung cuộn để bám vào, không phải cuộn cả trang. */
.roster-scroll { overflow: auto; max-height: 70vh; border-radius: var(--radius-lg); }
.roster-table { min-width: unset; }
.roster-table thead th { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.roster-table .weekday-label { display: block; font-size: 0.66rem; font-weight: 500; color: var(--text-muted); }

/* Đông cứng (freeze) 5 cột thông tin thành viên khi cuộn ngang. */
.roster-table .freeze-col { position: sticky; z-index: 1; background: var(--surface); }
.roster-table thead th.freeze-col { z-index: 3; background: var(--bg); }
.roster-table .freeze-col.freeze-last { border-right: 2px solid var(--border); }

/* Tô cột hôm nay / cột cuối tuần để dễ định hướng khi nhìn bảng dài. */
.roster-table th.col-today, .roster-table td.col-today { background: var(--primary-bg); }
.roster-table thead th.col-today { background: #d4f3e6; }
.roster-table th.col-weekend, .roster-table td.col-weekend { background: var(--amber-bg); }
.roster-table thead th.col-weekend { background: #fde8b8; }

/* Tô sáng dòng đang trỏ chuột vào — độ đặc hiệu cao hơn .freeze-col ở trên
   (nhiều phần tử/tag hơn) nên luôn thắng, kể cả trên các cột đã freeze. */
.roster-table tbody tr:hover td { background: var(--gray-bg) !important; }

/* Chế độ toàn màn hình: phủ kín màn hình, tự cuộn riêng, nằm trên thanh
   trên cùng (topbar) nhưng dưới các modal/toast. */
.roster-fullscreen-overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  padding: 20px 24px; overflow-y: auto;
}
.roster-fullscreen-overlay .roster-scroll { max-height: calc(100vh - 230px); }

/* ---------- Tổng hợp công việc (mới) ---------- */
.overview-row { cursor: pointer; }
.overview-row:hover td { background: var(--bg); }
.overview-progress { display: flex; align-items: center; gap: 6px; justify-content: center; }
.overview-progress-bar { width: 70px; height: 6px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.overview-progress-bar-inner { height: 100%; border-radius: 999px; background: var(--primary); }
.overview-progress-bar-inner.status-red { background: var(--red); }
.overview-progress-bar-inner.status-amber { background: var(--amber); }
.overview-progress-bar-inner.status-green { background: var(--green); }
.overview-progress-bar-inner.status-completed { background: var(--gray); }

/* Biểu đồ tròn (donut) tiến độ công việc theo tổ, trên trang "Tổng hợp
   công việc" — bấm vào 1 lát cắt/mục chú giải để lọc bảng bên dưới. */
.donut-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 2px 0 18px; }
.donut-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column;
  align-items: center; gap: 10px; min-width: 190px;
}
.donut-card-title { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.donut-svg-wrap { position: relative; width: 128px; height: 128px; }
.donut-svg-wrap svg { width: 100%; height: 100%; display: block; }
.donut-seg { cursor: pointer; transition: opacity .12s; }
.donut-seg:hover { opacity: 0.8; }
.donut-center-label {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; pointer-events: none; line-height: 1.1;
}
.donut-center-label strong { font-size: 1.15rem; color: var(--text); }
.donut-center-label span { font-size: 0.7rem; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.donut-legend-item {
  display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text);
  cursor: pointer; padding: 4px 8px; border-radius: 6px; border: 1px solid transparent;
  background: none; width: 100%; text-align: left; font-family: var(--font);
}
.donut-legend-item:hover { background: var(--bg); }
.donut-legend-item.active { border-color: var(--border); background: var(--bg); font-weight: 700; }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.donut-legend-count { margin-left: auto; font-weight: 700; }
.donut-filter-badge {
  display: flex; align-items: center; gap: 10px; background: var(--primary-bg); border: 1px solid #a7f3d0;
  border-radius: var(--radius); padding: 8px 14px; font-size: 0.85rem; margin: -2px 0 16px; color: var(--primary-dark);
}

.mini-bar-row { display: flex; align-items: center; gap: 8px; }
.mini-bar-outer { flex: 1; min-width: 70px; background: var(--gray-bg); border-radius: 999px; height: 8px; overflow: hidden; }
.mini-bar-inner { height: 100%; border-radius: 999px; }
.mini-bar-progress { background: var(--orange); }
.mini-bar-completed { background: var(--blue); }
.mini-bar-label { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); min-width: 34px; }

/* ---------- Notifications ---------- */
.notif-wrap { position: relative; }
.notif-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; cursor: pointer; font-size: 0.85rem; position: relative; font-weight: 600; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.notif-btn:hover { background: var(--gray-bg); }
.notif-btn svg { display: block; width: 18px; height: 18px; }
.notif-count {
  position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff;
  font-size: 0.7rem; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.notif-dropdown {
  position: absolute; right: 0; top: 44px; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  z-index: 30; padding: 8px;
}
.notif-item { padding: 10px; border-radius: var(--radius); cursor: pointer; font-size: 0.84rem; }
.notif-item:hover { background: var(--bg); }
.notif-item .name { font-weight: 700; }
.notif-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
/* Quan trong: attribute selector [hidden] co do dac hieu bang .modal-overlay,
   nen neu khong co dong nay thi "display: flex" o tren se thang va modal van
   hien ra du da co thuoc tinh "hidden". */
.modal-overlay[hidden] {
  display: none;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); padding: 26px; width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md);
}
.modal h2 { margin: 0 0 18px; font-size: 1.1rem; font-weight: 800; }
.modal form { display: flex; flex-direction: column; gap: 14px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.modal input, .modal select, .modal textarea {
  font-size: 0.9rem; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 400;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form-error { color: var(--red); font-size: 0.85rem; margin: 0; }

/* ---------- Hướng dẫn sử dụng (help modal) ---------- */
.modal-help { max-width: 680px; }
.help-body { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.help-section {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden;
}
.help-section summary {
  cursor: pointer; padding: 12px 16px; font-weight: 700; font-size: 0.95rem; list-style: none;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.help-section summary::-webkit-details-marker { display: none; }
.help-section summary::before { content: "▸"; color: var(--text-muted); font-size: 0.8rem; transition: transform 0.15s; }
.help-section[open] summary::before { transform: rotate(90deg); color: var(--primary); }
.help-section summary em { font-weight: 500; font-size: 0.78rem; color: var(--text-muted); font-style: normal; }
.help-content { padding: 0 16px 16px 16px; font-size: 0.89rem; line-height: 1.55; color: var(--text); }
.help-content p { margin: 0 0 10px; }
.help-content p:last-child { margin-bottom: 0; }
.help-content ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.help-content em { color: var(--text-muted); font-style: normal; font-size: 0.85rem; }

/* ---------- Dọn dẹp & đồng bộ lại (sync-cleanup) ---------- */
.cleanup-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 300px; overflow-y: auto; }
.cleanup-row { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 0.9rem; cursor: pointer; }
.cleanup-row input[type=checkbox] { margin-top: 3px; accent-color: var(--primary); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: var(--radius); font-size: 0.86rem; z-index: 100;
  box-shadow: var(--shadow-md);
}
.who-tag { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.small-muted { color: var(--text-muted); font-size: 0.82rem; }
.small-muted a { color: var(--primary-dark); font-weight: 600; text-decoration: none; }
.small-muted a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .form-row { flex-direction: column; }
  .app { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .logo-sub { display: none; }
}