/* TeamSync — dùng biến màu của home.css + apps.css. */

/* Màu dữ liệu cho biểu đồ (bảng màu đã kiểm định mù màu, xem TAILIEU_HE_THONG.md). */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }
}
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }

.ts-head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ts-head-actions .select { width: auto; max-width: 320px; }

/* Menu "⋯" */
.ts-menu { position: relative; }
.ts-menu > summary { list-style: none; }
.ts-menu > summary::-webkit-details-marker { display: none; }
.ts-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; padding: 6px; display: grid; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); box-shadow: var(--shadow); }
.ts-menu-item { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; font-size: .9rem; color: var(--fg-deep); cursor: pointer; }
.ts-menu-item:hover, .ts-menu-item:focus-visible { background: var(--badge); }
.ts-menu-item.btn-danger { color: var(--bad); }

/* Tóm tắt dự án */
.ts-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 16px 24px; margin-bottom: 18px; }
.app-body main .ts-project-name { margin: 0 0 4px; font-size: 1.6rem; }
.ts-meta { margin: 0 0 10px; }
.ts-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ts-chip-btn { border: 0; cursor: pointer; font: inherit; font-size: .8rem; }
.ts-summary-side { display: grid; gap: 6px; align-content: start; }
.ts-summary-side p { margin: 0; }
.ts-progress-label { display: flex; justify-content: space-between; font-size: .88rem; color: var(--fg-muted); }
.ts-meter { height: 3px; background: var(--border); overflow: hidden; }
.ts-meter span { display: block; height: 100%; background: var(--fg-deep); transition: width .4s var(--ease); }
.ts-avatars { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.ts-avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: hsl(var(--hue) 28% 92%); color: hsl(var(--hue) 40% 28%); font-size: .7rem; font-weight: 600; letter-spacing: .02em; font-family: var(--font-mono);
}
:root[data-theme="dark"] .ts-avatar { background: hsl(var(--hue) 18% 20%); color: hsl(var(--hue) 45% 82%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ts-avatar { background: hsl(var(--hue) 18% 20%); color: hsl(var(--hue) 45% 82%); } }
.ts-avatar-sm { width: 22px; height: 22px; font-size: .6rem; }
.ts-owner { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; min-width: 0; }

.ts-tabs { margin-bottom: 14px; }
.ts-panel { min-height: 200px; }
.ts-footnote { margin-top: 24px; }
.ts-h3 { margin: 0 0 10px; font-size: 1rem; color: var(--fg-deep); }

/* Kanban */
.ts-board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.ts-board-toolbar .input { width: 220px; }
.ts-board-toolbar .select { width: auto; }
.ts-hint { flex: 1; min-width: 180px; }
.ts-board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.ts-col { display: flex; flex-direction: column; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); scroll-snap-align: start; }
.ts-col-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px; }
.ts-col-head h3 { margin: 0; font-size: .82rem; font-weight: 600; flex: 1; display: flex; flex-direction: column; line-height: 1.25; letter-spacing: .01em; }
.ts-col-hint { font-size: .72rem; color: var(--fg-muted); font-weight: 400; }
.ts-col-count { font-size: .72rem; color: var(--fg-muted); white-space: nowrap; font-family: var(--font-mono); }
.ts-col-add { min-height: 26px; padding: 0 8px; }
.ts-col-list { flex: 1; display: grid; align-content: start; gap: 8px; padding: 6px 8px 10px; min-height: 120px; border-radius: 0 0 12px 12px; transition: background-color .15s, outline-color .15s; outline: 2px dashed transparent; outline-offset: -4px; }
.ts-col-list.ts-drop { background: color-mix(in srgb, var(--accent) 8%, transparent); outline-color: var(--accent); }
.ts-col-empty { margin: 8px 4px; text-align: center; }
.ts-card { background: var(--bg); border: 1px solid var(--border); border-top: 2px solid var(--border); border-radius: var(--radius); padding: 10px 11px; cursor: grab; display: grid; gap: 8px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.ts-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .07); transform: translateY(-1px); }
.ts-card.ts-dragging { opacity: .45; }
.ts-card.ts-prio-high { border-top-color: var(--warn); }
.ts-card.ts-prio-urgent { border-top-color: var(--bad); }
.ts-card.ts-prio-medium { border-top-color: var(--info); }
.ts-card-title { margin: 0; font-size: .88rem; font-weight: 500; line-height: 1.4; color: var(--fg-deep); }
.ts-card-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ts-card-chips .chip { font-size: .72rem; padding: 0 7px; }
.ts-card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; align-items: center; }
.ts-card-foot .muted-sm { font-size: .75rem; }

/* Hộp thoại */
dialog.modal-wide { width: min(980px, calc(100vw - 24px)); }
.ts-form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.ts-form .modal-body { flex: 1; min-height: 0; }
.ts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ts-checks { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px 12px 10px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.ts-checks legend { padding: 0 4px; font-size: .9rem; color: var(--fg-muted); }
.ts-check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
.ts-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.ts-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ts-checklist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.ts-inline { display: flex; gap: 8px; }
.ts-range-row { display: flex; align-items: center; gap: 10px; }
.ts-range { flex: 1; accent-color: var(--accent); padding: 0; border: 0; min-height: 28px; background: none; }
.ts-weight-out { min-width: 2ch; font-weight: 600; font-size: 1.1rem; color: var(--fg-deep); text-align: right; }
.modal-foot .ts-left { margin-right: auto; }

/* Đóng góp */
.ts-alert { border-left: 3px solid var(--warn); background: var(--warn-bg); color: var(--fg-deep); padding: 12px 16px; margin-bottom: 18px; }
.ts-alert strong { color: var(--warn); }
.ts-alert ul { margin: 6px 0 0; padding-left: 1.2em; }
.ts-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; margin-bottom: 20px; }
.ts-chart { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; background: var(--bg); }
.ts-chart-title { margin-bottom: 14px; font-size: .9rem; }
.ts-chart-title strong { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; font-size: 1.15rem; }
.ts-bars { position: relative; display: grid; gap: 10px; --label-w: 120px; }
.ts-bar-row { display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); align-items: center; gap: 10px; border-radius: 6px; }
.ts-bar-row:focus-visible { outline-offset: 3px; }
.ts-bar-label { font-size: .85rem; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-bar-track { position: relative; display: flex; align-items: center; gap: 8px; min-height: 26px; }
.ts-bar { display: block; height: 16px; border-radius: 0 4px 4px 0; flex: none; }
.ts-bar-row:hover .ts-bar, .ts-bar-row:focus-visible .ts-bar { filter: brightness(1.12); }
.ts-bar-value { position: relative; z-index: 2; background: var(--bg); padding-right: 2px; font-size: .82rem; color: var(--fg-deep); font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.ts-flag { font-size: .72rem; padding: 0 6px; border-radius: 3px; border: 1px solid currentColor; }
.ts-flag-low { color: var(--bad); }
.ts-flag-watch { color: var(--warn); }
.ts-series-1 { background: var(--series-1); }
.ts-series-2 { background: var(--series-2); }
.ts-series-3 { background: var(--series-3); }
/* Vạch tham chiếu: nét liền mảnh, có nhãn. */
.ts-ref { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 1px solid var(--fg-muted); pointer-events: none; z-index: 1; }
.ts-ref span { position: absolute; top: -18px; transform: translateX(-50%); font-size: .7rem; color: var(--fg-muted); white-space: nowrap; background: var(--bg); padding: 0 3px; }
.ts-ref-fair { left: calc(var(--label-w) + 10px + (100% - var(--label-w) - 10px) * var(--fair-n, 0)); }
.ts-ref-threshold { left: calc(var(--label-w) + 10px + (100% - var(--label-w) - 10px) * var(--thr-n, 0)); border-left-color: var(--bad); opacity: .7; }
.ts-ref-threshold span { top: auto; bottom: -18px; color: var(--bad); }
.ts-bars:has(.ts-ref) { margin-top: 22px; margin-bottom: 20px; }
.ts-axis { display: grid; grid-template-columns: var(--label-w, 120px) minmax(0, 1fr); gap: 10px; margin-top: 4px; }
.ts-axis-track { position: relative; height: 16px; border-top: 1px solid var(--border); }
.ts-axis-track span { position: absolute; top: 2px; transform: translateX(-50%); font-size: .7rem; color: var(--fg-muted); }
.ts-stack { display: flex; gap: 2px; height: 16px; min-width: 4px; }
.ts-seg { display: block; height: 100%; min-width: 3px; cursor: default; }
.ts-seg:last-child { border-radius: 0 4px 4px 0; }
.ts-seg:hover, .ts-seg:focus-visible { filter: brightness(1.15); }
.ts-legend { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--fg); }
.ts-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ts-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.ts-table-view { margin-top: 12px; font-size: .85rem; }
.ts-table-view summary { cursor: pointer; color: var(--fg-muted); }
.ts-table-view .table-wrap { margin-top: 8px; }
.ts-tip { position: absolute; z-index: 60; pointer-events: none; min-width: 160px; max-width: 280px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); box-shadow: var(--shadow); font-size: .8rem; }
.ts-tip-title { color: var(--fg-muted); margin-bottom: 4px; }
.ts-tip-row { display: flex; gap: 8px; align-items: baseline; }
.ts-tip-row strong { color: var(--fg-deep); font-variant-numeric: tabular-nums; }
.ts-tip-row span { color: var(--fg-muted); }
.ts-method { margin-top: 20px; }
.ts-method ul { margin: 0 0 14px; padding-left: 1.2em; font-size: .92rem; }
.ts-method .select { max-width: 280px; }

/* Thành viên & tài liệu */
.ts-row-actions { white-space: nowrap; text-align: right; }
.ts-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.ts-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.ts-card-head .ts-h3 { margin: 0; }
.ts-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.ts-dl dt { color: var(--fg-muted); }
.ts-dl dd { margin: 0; color: var(--fg-deep); }
.ts-desc { margin: 12px 0 0; font-size: .92rem; }
.ts-links { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.ts-links li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.ts-links a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-link-kind { font-size: .68rem; padding: 0 6px; border-radius: 3px; border: 1px solid var(--border); color: var(--fg-muted); white-space: nowrap; letter-spacing: .06em; text-transform: uppercase; }
.ts-link-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: end; }

/* Bản báo cáo A4 (xem trước + in) */
.ts-sheet-wrap { background: var(--badge); padding: 16px; border-radius: var(--radius-lg); overflow-x: auto; }
.ts-sheet {
  width: 210mm; max-width: 100%; margin: 0 auto; padding: 18mm 16mm; background: #fff; color: #111;
  font-family: "Times New Roman", Times, "Be Vietnam Pro", serif; font-size: 13px; line-height: 1.45; box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
}
.ts-sheet p { margin: 0 0 6px; }
.ts-sheet h2 { margin: 16px 0 6px; font-size: 14px; color: #111; }
.ts-sheet ul { margin: 0 0 8px; padding-left: 1.3em; }
.ts-sheet-top { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; margin-bottom: 16px; font-size: 12px; }
.ts-up { text-transform: uppercase; }
.ts-bold { font-weight: 700; }
.ts-center { text-align: center; }
.ts-rule { letter-spacing: .1em; }
.ts-sheet-title { margin: 10px 0 2px; font-size: 16px; text-align: center; color: #111; line-height: 1.35; }
.ts-sheet-info { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 10px 0; }
.ts-sheet-info dt { font-weight: 700; }
.ts-sheet-info dd { margin: 0; }
.ts-sheet-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 11.5px; }
.ts-sheet-table th, .ts-sheet-table td { border: 1px solid #555; padding: 3px 5px; text-align: left; vertical-align: top; }
.ts-sheet-table th { background: #eee; font-weight: 700; }
.ts-sheet-table .num { text-align: center; }
.ts-signs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; text-align: center; }
.ts-sign { min-height: 110px; display: flex; flex-direction: column; }
.ts-sign-name { margin-top: auto !important; font-weight: 700; }
.ts-muted-i { font-style: italic; font-size: 11px; color: #444; }
.ts-sheet-foot { margin-top: 18px !important; font-size: 10.5px; color: #555; font-style: italic; text-align: center; }

#ts-print-root { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  html.ts-print-mode body > *:not(#ts-print-root) { display: none !important; }
  html.ts-print-mode #ts-print-root { display: block; }
  html.ts-print-mode body { background: #fff; }
  html.ts-print-mode .ts-sheet { width: auto; padding: 0; box-shadow: none; }
  .ts-sheet-table tr, .ts-sign { break-inside: avoid; }
  .ts-sheet h2 { break-after: avoid; }
}

@media (max-width: 900px) {
  .ts-summary { grid-template-columns: 1fr; }
  .ts-board { grid-template-columns: repeat(5, minmax(240px, 82vw)); }
}
@media (max-width: 520px) {
  .ts-grid-2, .ts-link-form { grid-template-columns: 1fr; }
  .ts-board-toolbar .input { width: 100%; }
  .ts-hint { display: none; }
  .ts-bars { --label-w: 86px; }
  .ts-head-actions .select { max-width: 100%; flex: 1 1 100%; }
}

/* Tài khoản & dự án dùng chung */
.ts-welcome { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.ts-welcome .card p { margin: 0 0 12px; }
.ts-perm p { margin: 0 0 10px; }
.ts-username { font-size: 1.1rem; font-weight: 600; color: var(--fg-deep); background: var(--badge); border-radius: var(--radius); padding: 6px 12px; display: inline-block; user-select: all; }
.ts-invite-code { font-family: var(--font-mono); font-size: 1.6rem; letter-spacing: .12em; text-align: center; padding: 12px; background: var(--badge); border-radius: var(--radius-lg); color: var(--fg-deep); user-select: all; margin: 0; }
.ts-invite-link { font-size: .8rem; word-break: break-all; color: var(--fg-muted); margin: 0; user-select: all; }

/* =====================================================================
   Chủ đề màu riêng của TeamSync — thân thiện, nhiều màu nhưng có hệ thống:
   tím làm màu thương hiệu, mỗi cột Kanban một màu, avatar pastel, thanh tiến độ gradient.
   ===================================================================== */
.ts-theme {
  --ts-brand: #6c5ce7; --ts-brand-2: #f06595; --ts-brand-ink: #ffffff;
  --ts-brand-soft: #f1efff; --ts-brand-line: #d9d4ff;
  --ts-page: #fbfaff;
  --c-backlog: #8a94a6; --c-todo: #3b9eff; --c-in-progress: #ff9f1c; --c-review: #9b6bff; --c-done: #22c38e;
  --series-1: #6c5ce7; --series-2: #ff7a59; --series-3: #1fb8a2;
  --accent: var(--ts-brand); --focus: var(--ts-brand);
  --surface-2: #f6f4ff;
  background: var(--ts-page);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ts-theme {
    --ts-brand: #9a8cff; --ts-brand-2: #ff86b0; --ts-brand-ink: #14112b; --ts-brand-soft: #1f1b3a; --ts-brand-line: #3a3366;
    --ts-page: #0d0c14; --surface-2: #15131f;
    --c-backlog: #8f9ab0; --c-todo: #5cb0ff; --c-in-progress: #ffb347; --c-review: #b292ff; --c-done: #3fd6a2;
    --series-1: #9a8cff; --series-2: #ff8e70; --series-3: #34cdb6;
  }
}
:root[data-theme="dark"] .ts-theme {
  --ts-brand: #9a8cff; --ts-brand-2: #ff86b0; --ts-brand-ink: #14112b; --ts-brand-soft: #1f1b3a; --ts-brand-line: #3a3366;
  --ts-page: #0d0c14; --surface-2: #15131f;
  --c-backlog: #8f9ab0; --c-todo: #5cb0ff; --c-in-progress: #ffb347; --c-review: #b292ff; --c-done: #3fd6a2;
  --series-1: #9a8cff; --series-2: #ff8e70; --series-3: #34cdb6;
}
/* Nền có vệt màu nhẹ ở đầu trang */
.ts-theme::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 420px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(520px 260px at 12% -40px, color-mix(in srgb, var(--ts-brand) 16%, transparent), transparent 70%),
    radial-gradient(460px 240px at 88% -60px, color-mix(in srgb, var(--ts-brand-2) 13%, transparent), transparent 70%);
}
.ts-theme .appbar { background: color-mix(in srgb, var(--ts-page) 82%, transparent); }
.ts-theme .appbar-mark { background: linear-gradient(135deg, var(--ts-brand), var(--ts-brand-2)); color: #fff; }
.ts-theme .appbar-nav a[aria-current="page"]::after { background: var(--ts-brand); }
.ts-theme .appbar-user .userbar-avatar { background: linear-gradient(135deg, var(--ts-brand), var(--ts-brand-2)); color: #fff; }

/* Nút, tab, ô nhập */
.ts-theme .btn { border-radius: 10px; }
.ts-theme .btn-primary { background: var(--ts-brand); border-color: var(--ts-brand); color: var(--ts-brand-ink); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--ts-brand) 80%, transparent); }
.ts-theme .btn-primary:hover { opacity: 1; filter: brightness(1.08); }
.ts-theme .btn:not(.btn-primary):not(.btn-ghost):hover { border-color: var(--ts-brand); color: var(--ts-brand); }
.ts-theme #ts-report { background: linear-gradient(120deg, var(--ts-brand), var(--ts-brand-2)); border: 0; color: #fff; }
.ts-theme .tabs [role="tab"]::after { background: var(--ts-brand); height: 3px; border-radius: 3px 3px 0 0; }
.ts-theme .tabs [role="tab"][aria-selected="true"] { color: var(--ts-brand); }
.ts-theme .input:focus, .ts-theme .select:focus, .ts-theme textarea:focus { border-color: var(--ts-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ts-brand) 18%, transparent); }
.ts-theme .card { border-radius: 16px; border-color: color-mix(in srgb, var(--ts-brand-line) 60%, var(--border)); box-shadow: 0 1px 2px rgba(40, 30, 90, .04), 0 10px 30px -18px rgba(60, 40, 140, .25); }
.ts-theme .chip { border-radius: 999px; }
.ts-theme .ts-chips .chip-info { background: var(--ts-brand-soft); border-color: transparent; color: var(--ts-brand); }

/* Tóm tắt dự án */
.ts-theme .ts-meter { height: 8px; border-radius: 999px; background: var(--ts-brand-soft); }
.ts-theme .ts-meter span { border-radius: 999px; background: linear-gradient(90deg, var(--ts-brand), var(--ts-brand-2)); }
.ts-theme .ts-progress-label strong { color: var(--ts-brand); }
.ts-theme .ts-avatar { background: hsl(var(--hue) 90% 90%); color: hsl(var(--hue) 55% 30%); font-family: var(--font-ui); font-weight: 700; box-shadow: 0 0 0 2px var(--bg); }
:root[data-theme="dark"] .ts-theme .ts-avatar { background: hsl(var(--hue) 45% 26%); color: hsl(var(--hue) 90% 86%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ts-theme .ts-avatar { background: hsl(var(--hue) 45% 26%); color: hsl(var(--hue) 90% 86%); } }

/* Kanban: mỗi cột một màu */
.ts-theme .ts-col { --c: var(--c-backlog); border: 0; border-radius: 16px; background: color-mix(in srgb, var(--c) 9%, var(--bg)); }
.ts-theme .ts-col[data-status="todo"] { --c: var(--c-todo); }
.ts-theme .ts-col[data-status="in-progress"] { --c: var(--c-in-progress); }
.ts-theme .ts-col[data-status="review"] { --c: var(--c-review); }
.ts-theme .ts-col[data-status="done"] { --c: var(--c-done); }
.ts-col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--fg-muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, transparent) 25%, transparent); flex: none; align-self: flex-start; margin-top: 4px; }
.ts-theme .ts-col-head h3 { font-size: .86rem; font-weight: 700; }
.ts-theme .ts-col-count { background: color-mix(in srgb, var(--c) 18%, var(--bg)); color: color-mix(in srgb, var(--c) 70%, var(--fg-deep)); padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.ts-theme .ts-col-list.ts-drop { background: color-mix(in srgb, var(--c) 14%, transparent); outline-color: var(--c); }
.ts-theme .ts-card { border: 1px solid color-mix(in srgb, var(--c, var(--border)) 18%, var(--border)); border-radius: 12px; box-shadow: 0 1px 2px rgba(30, 20, 70, .05); position: relative; overflow: hidden; }
.ts-theme .ts-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c, var(--border)); }
.ts-theme .ts-card:hover { box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--c, #000) 55%, transparent); border-color: color-mix(in srgb, var(--c, var(--border)) 45%, var(--border)); }
.ts-theme .ts-card.ts-prio-high, .ts-theme .ts-card.ts-prio-urgent, .ts-theme .ts-card.ts-prio-medium { border-top-color: color-mix(in srgb, var(--c, var(--border)) 18%, var(--border)); }
.ts-theme .ts-card-title { font-weight: 600; }
.ts-theme .ts-card .chip-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: transparent; }
.ts-theme .ts-card .chip-bad { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: transparent; }
.ts-theme .ts-card .chip-info { background: color-mix(in srgb, var(--info) 10%, transparent); border-color: transparent; }

/* Đóng góp & cảnh báo */
.ts-theme .ts-chart { border-radius: 16px; border-color: color-mix(in srgb, var(--ts-brand-line) 60%, var(--border)); }
.ts-theme .ts-bar { border-radius: 0 8px 8px 0; height: 18px; }
.ts-theme .ts-alert { border: 0; border-radius: 14px; background: color-mix(in srgb, var(--warn) 12%, var(--bg)); box-shadow: inset 4px 0 0 var(--warn); }
.ts-theme dialog { border-radius: 18px; }
/* Đầu cột: chấm màu + tên + nút "+" trên một hàng, số thẻ xuống hàng dưới để tên cột không bị gãy chữ. */
.ts-theme .ts-col-head { flex-wrap: wrap; row-gap: 6px; }
.ts-theme .ts-col-head h3 { min-width: 0; }
.ts-theme .ts-col-add { order: 2; }
.ts-theme .ts-col-count { order: 3; margin-left: 16px; }
.ts-theme .ts-col-head::after { content: ""; order: 2; flex-basis: 100%; height: 0; }

/* =====================================================================
   Tính năng mới: thanh dự án gọn, mốc, Hôm nay, chuông thông báo, ngăn chi tiết,
   bình luận, danh sách, lịch, hoạt động, đánh giá chéo, bảng lệnh.
   ===================================================================== */
.ts-grow { flex: 1; }
.ts-projbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.ts-projbar .select { width: auto; max-width: 340px; font-weight: 600; }
.app-body main .ts-project-name { margin: 0 0 4px; font-size: clamp(1.4rem, 3vw, 1.8rem); letter-spacing: -.03em; outline: none; }
.ts-summary { padding: 16px 18px; margin-bottom: 12px; align-items: center; }
.ts-side-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ts-side-row .ts-avatars { margin: 0; }
.ts-meter-sm { height: 6px !important; }

/* Mốc */
.ts-milestones { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; flex-wrap: wrap; }
.ts-ms-label { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.ts-ms-list { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.ts-ms { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--fg-deep); font: inherit; font-size: .82rem; cursor: pointer; transition: border-color .15s, transform .15s; }
.ts-ms:hover { border-color: var(--accent); transform: translateY(-1px); }
.ts-ms-dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fg-muted); }
.ts-ms-dot .icon { width: 11px; height: 11px; }
.ts-ms-title { font-weight: 600; }
.ts-ms-date { color: var(--fg-muted); font-size: .76rem; }
.ts-ms-done { opacity: .75; }
.ts-ms-done .ts-ms-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.ts-ms-next { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.ts-ms-next .ts-ms-dot { border-color: var(--accent); }
.ts-ms-late .ts-ms-dot { border-color: var(--bad); }
.ts-ms-late .ts-ms-date { color: var(--bad); }

/* Kiểu xem (Bảng / Danh sách / Lịch) */
.ts-switch { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.ts-switch-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 10px; border-radius: 7px; font: inherit; font-size: .82rem; color: var(--fg-muted); cursor: pointer; }
.ts-switch-btn[aria-pressed="true"] { background: var(--bg); color: var(--fg-deep); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-weight: 600; }
.ts-switch-btn .icon { width: 14px; height: 14px; }

/* Thẻ: bình luận, kẹt, thêm nhanh */
.ts-card-icons { display: inline-flex; align-items: center; gap: 8px; }
.ts-card-comments { display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; color: var(--fg-muted); }
.ts-card-comments .icon { width: 13px; height: 13px; }
.ts-card.ts-stuck { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.ts-quick-wrap { padding: 0 8px 10px; }
.ts-quick { font-size: .8rem; min-height: 32px; background: color-mix(in srgb, var(--bg) 70%, transparent); border-style: dashed; }
.ts-quick:focus { border-style: solid; background: var(--bg); }

/* Danh sách */
.ts-sort { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; text-transform: inherit; letter-spacing: inherit; }
.ts-list-row { cursor: pointer; }
.ts-list-row:hover { background: var(--surface-2); }
.ts-list-title { font-weight: 600; color: var(--fg-deep); margin-right: 6px; }
.ts-status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--fg-muted); vertical-align: middle; }
.ts-st-backlog { --c: var(--c-backlog, #8a94a6); }
.ts-st-todo { --c: var(--c-todo, #3b9eff); }
.ts-st-in-progress { --c: var(--c-in-progress, #ff9f1c); }
.ts-st-review { --c: var(--c-review, #9b6bff); }
.ts-st-done { --c: var(--c-done, #22c38e); }
.ts-status-dot.ts-st-backlog, .ts-status-dot.ts-st-todo, .ts-status-dot.ts-st-in-progress, .ts-status-dot.ts-st-review, .ts-status-dot.ts-st-done { background: var(--c); }

/* Lịch */
.ts-cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ts-cal-title { font-family: var(--font-display); font-size: 1.1rem; min-width: 120px; text-align: center; }
.ts-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ts-cal-dow { font-size: .72rem; font-weight: 700; color: var(--fg-muted); text-align: center; padding: 4px 0; letter-spacing: .06em; }
.ts-cal-cell { min-height: 92px; padding: 6px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ts-cal-out { opacity: .45; }
.ts-cal-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ts-cal-today .ts-cal-date { background: var(--accent); color: #fff; }
.ts-cal-deadline { background: color-mix(in srgb, var(--bad) 7%, var(--bg)); }
.ts-cal-date { align-self: flex-start; font-size: .75rem; font-weight: 600; padding: 1px 6px; border-radius: 999px; color: var(--fg-muted); }
.ts-cal-task { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 12%, var(--bg)); border-radius: 5px; padding: 2px 6px; font: inherit; font-size: .74rem; color: var(--fg-deep); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-cal-task:hover { background: color-mix(in srgb, var(--c) 22%, var(--bg)); }
.ts-cal-ms { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 600; color: var(--accent); }
.ts-cal-ms .icon { width: 11px; height: 11px; }
.ts-cal-dl { color: var(--bad); }
@media (max-width: 640px) {
  .ts-cal-cell { min-height: 64px; padding: 3px; }
  .ts-cal-task { font-size: .66rem; padding: 1px 3px; }
}

/* Ngăn chi tiết công việc */
dialog.ts-drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: min(520px, 100vw);
  padding: 0; border: 0; border-left: 1px solid var(--border); background: var(--bg); color: var(--fg); box-shadow: -24px 0 60px rgba(20, 10, 60, .18);
  font-family: var(--font-ui); animation: drawer-in .22s var(--ease) both;
}
dialog.ts-drawer::backdrop { background: rgba(10, 8, 30, .28); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } }
.ts-drawer-inner { display: flex; flex-direction: column; height: 100%; }
.ts-drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }
.ts-drawer-head .ts-status-dot { margin-top: 9px; width: 11px; height: 11px; }
.ts-drawer-head h2 { flex: 1; margin: 0; font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; color: var(--fg-deep); }
.ts-drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 18px; display: grid; gap: 16px; align-content: start; }
.ts-drawer-body section .ts-h3 { margin-bottom: 8px; }
.ts-drawer-meta { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; font-size: .88rem; align-items: center; }
.ts-drawer-meta dt { color: var(--fg-muted); }
.ts-drawer-meta dd { margin: 0; color: var(--fg-deep); }
.ts-drawer-meta .select { max-width: 220px; }
.select-sm { min-height: 30px; padding-top: 2px; padding-bottom: 2px; font-size: .84rem; }
.ts-drawer-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.ts-approval { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: .86rem; display: grid; gap: 8px; }
.ts-approval p { margin: 0; }
.ts-approval-pending { background: color-mix(in srgb, var(--warn) 12%, var(--bg)); }
.ts-approval-approved, .ts-approval-auto { background: color-mix(in srgb, var(--ok) 10%, var(--bg)); }
.ts-desc { white-space: pre-wrap; }
.ts-comments { display: grid; gap: 12px; margin-bottom: 10px; }
.ts-comment { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.ts-comment-body { min-width: 0; }
.ts-comment-meta { margin: 0 0 2px; font-size: .82rem; display: flex; align-items: center; gap: 2px; }
.ts-comment-del { margin-left: auto; min-height: 22px; padding: 0 4px; opacity: .5; }
.ts-comment-del:hover { opacity: 1; }
.ts-comment-text { margin: 0; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); padding: 8px 10px; border-radius: 4px 12px 12px 12px; }
.ts-mention { color: var(--accent); }
.ts-comment-form { display: grid; gap: 6px; }
.ts-comment-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ts-mentions { display: flex; flex-wrap: wrap; gap: 4px; }
.ts-mentions .chip { font-size: .72rem; cursor: pointer; background: none; }
.ts-task-log summary { cursor: pointer; font-size: .86rem; color: var(--fg-muted); }
.ts-log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.ts-log li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: .86rem; }
.ts-task-activity .ts-log li { grid-template-columns: 1fr auto; }
.ts-link-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.ts-link-btn:hover { color: var(--accent); text-decoration: underline; }
.ts-log-text { min-width: 0; overflow-wrap: anywhere; }

/* Hoạt động */
.ts-activity { display: grid; gap: 16px; }
.ts-day-title { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); font-family: var(--font-ui); }
.ts-day .ts-log li { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* Hôm nay */
.ts-today-head { margin-bottom: 18px; }
.ts-today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; }
.ts-today-main, .ts-today-side { display: grid; gap: 12px; }
.ts-agenda .ts-h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.ts-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: .74rem; color: var(--fg-muted); }
.ts-agenda-bad .ts-count { background: color-mix(in srgb, var(--bad) 15%, var(--bg)); color: var(--bad); }
.ts-agenda-list, .ts-ms-upcoming, .ts-proj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ts-agenda p { margin: 0; }
.ts-agenda-item, .ts-proj-item { width: 100%; display: grid; gap: 4px; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 10px; font: inherit; color: inherit; cursor: pointer; }
.ts-agenda-item:hover, .ts-proj-item:hover { background: var(--surface-2); }
.ts-agenda-title { font-weight: 600; color: var(--fg-deep); display: inline-flex; align-items: center; gap: 6px; }
.ts-agenda-title .icon { width: 14px; height: 14px; color: var(--accent); }
.ts-agenda-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.ts-agenda-meta .chip { font-size: .72rem; }
@media (max-width: 860px) { .ts-today-grid { grid-template-columns: 1fr; } }

/* Chuông thông báo */
.ts-bell { position: relative; }
.ts-bell-badge { position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--ts-brand-2, #e5484d); color: #fff; font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center; }
.ts-bell-badge[hidden] { display: none; }
.ts-notif-panel {
  position: fixed; top: 60px; right: max(16px, calc((100vw - 1100px) / 2 + 24px)); z-index: 40; width: min(380px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); font-family: var(--font-ui); animation: menu-in .14s var(--ease) both;
}
.ts-notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 16px; position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.ts-notif-group { padding: 6px; }
.ts-notif-label { margin: 6px 10px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.ts-notif-item { width: 100%; display: grid; gap: 2px; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 10px; font: inherit; font-size: .86rem; color: var(--fg); cursor: pointer; border-left: 3px solid transparent; }
.ts-notif-item:hover { background: var(--surface-2); }
.ts-notif-item.ts-unread { background: color-mix(in srgb, var(--accent) 8%, var(--bg)); border-left-color: var(--accent); }
.ts-notif-text { color: var(--fg-deep); }
.ts-tone-bad { border-left-color: var(--bad); }
.ts-tone-warn { border-left-color: var(--warn); }
.ts-tone-info { border-left-color: var(--info); }
.ts-notif-empty { padding: 4px 10px 10px; margin: 0; }

/* Đóng góp: ghi chú, nhịp tuần, đánh giá chéo */
.ts-note { margin: 0 0 14px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 10%, var(--bg)); font-size: .88rem; }
.ts-heat { margin: 0 0 20px; }
.ts-heat-table { border-collapse: separate; border-spacing: 3px; font-size: .78rem; width: 100%; }
.ts-heat-table th { font-weight: 500; color: var(--fg-muted); text-align: left; white-space: nowrap; padding-right: 8px; }
.ts-heat-table thead th { text-align: center; font-size: .7rem; }
.ts-heat-cell { height: 26px; min-width: 34px; text-align: center; border-radius: 6px; color: var(--fg-deep); background: color-mix(in srgb, var(--series-1) calc(var(--heat) * 85%), var(--surface-2)); }
.ts-eval { margin-top: 20px; }
.ts-eval > p { margin: 0 0 12px; }
.ts-eval-round { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.ts-eval-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.ts-eval-table th { font-size: .72rem; }
.ts-shares { display: grid; gap: 6px; }
.ts-share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ts-share { width: 96px !important; text-align: right; }
.ts-share-total { margin: 8px 0 14px; font-size: .92rem; }
.ts-ok { color: var(--ok); }
.ts-bad { color: var(--bad); }
.ts-eval-form th[scope="row"] { font-weight: 500; white-space: nowrap; }
.ts-confirm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 12px; border-radius: 10px; background: var(--surface-2); font-size: .88rem; }
.ts-confirm-bar span { flex: 1; min-width: 200px; }

/* Bảng lệnh Ctrl + K */
dialog.ts-palette { width: min(560px, calc(100vw - 24px)); padding: 0; margin-top: 12vh; }
.ts-palette-inner { padding: 12px; display: grid; gap: 8px; }
.ts-palette-inner .input { font-size: 1rem; min-height: 44px; }
.ts-palette-inner > p { margin: 0 4px; }
.ts-palette-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.ts-palette-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: .9rem; color: var(--fg-deep); }
.ts-palette-item span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-palette-item span:last-child { flex: none; }
.ts-palette-item[aria-selected="true"], .ts-palette-item:hover { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }

@media (max-width: 520px) {
  .ts-projbar .select { max-width: 100%; flex: 1 1 100%; }
  dialog.ts-drawer { width: 100vw; }
  .ts-drawer-meta { grid-template-columns: 84px 1fr; }
}

/* Trang chỉ-xem cho giảng viên */
.ts-view-banner { margin: 0 0 16px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--bg)); font-size: .86rem; }
#teamsync-view h2 { margin: 28px 0 10px; }
.ts-view-log li { grid-template-columns: 1fr auto; padding: 6px 0; border-bottom: 1px solid var(--border); }
@media print {
  .appbar, .app-footer, .ts-view-banner, #teamsync-view .app-head .btn { display: none !important; }
}

@media (max-width: 640px) {
  .ts-ms-list { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .ts-milestones .btn { margin-left: auto; }
}
.ts-agenda .ts-count.ts-zero { background: var(--surface-2) !important; color: var(--fg-muted) !important; }
