:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e5ea;
  --accent: #2563eb;
  --accent-soft: #e6eefc;
  --danger: #c2410c;
  --ok: #15803d;
  --warn: #b45309;
  --side: #17202f;
  --side-text: #cfd6e3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #1a1e24;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --border: #2b313a;
    --accent: #6b9cff;
    --accent-soft: #1f2a3f;
    --danger: #f08a5d;
    --ok: #4ade80;
    --warn: #fbbf24;
    --side: #0b0e12;
    --side-text: #b8c0cc;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; }

/* Đăng nhập */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px; width: min(360px, 100%); display: grid; gap: 12px; }

/* Khung */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; font-size: 13px; }
.me-box { display: flex; gap: 10px; align-items: center; padding: 14px 14px 10px; color: #fff; }
.me-name { font-weight: 600; line-height: 1.2; }
.me-pos { color: #8a93a3; font-size: 12px; }
.side-search { margin: 0 12px 10px; width: auto; background: rgba(255, 255, 255, .08); border: 0; color: #fff; border-radius: 16px; padding: 6px 12px; }
.side-search::placeholder { color: #8a93a3; }
.side-scroll { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.navhead { display: flex; justify-content: space-between; width: 100%; background: none; border: 0; color: #7d8696; font: inherit; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; padding: 12px 16px 4px; cursor: pointer; text-align: left; }
.navhead.static { cursor: default; }
#nav { display: flex; flex-direction: column; }
#nav a, #proj-nav a { color: var(--side-text); padding: 6px 16px; display: flex; gap: 10px; align-items: center; border-left: 3px solid transparent; }
#nav a i { font-style: normal; width: 16px; text-align: center; opacity: .8; }
#proj-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav a:hover, #proj-nav a:hover { background: rgba(255, 255, 255, .05); }
#nav a.active, #proj-nav a.active { background: rgba(255, 255, 255, .1); border-left-color: var(--accent); color: #fff; }
/* Kết quả tìm nhanh công việc (ô tìm ở menu trái, routers/search.py) */
#search-res { border-bottom: 1px solid rgba(255, 255, 255, .08); padding-bottom: 6px; }
#search-res a { color: var(--side-text); padding: 5px 16px; display: block; border-left: 3px solid transparent; }
#search-res a:hover { background: rgba(255, 255, 255, .05); }
#search-res a b, #search-res a small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: normal; }
#search-res a small { color: #8a93a3; font-size: 11px; }
#search-res a.is-done b { text-decoration: line-through; opacity: .6; }
#search-res p { color: #8a93a3; font-size: 12px; padding: 0 16px; margin: 4px 0; }
#nav .badge { margin-left: auto; }
#nav .short { display: none; } /* tên ngắn cho menu dưới trên điện thoại */
.me { padding: 10px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.me a { color: #8a93a3; }
.view { padding: 0; min-width: 0; }
.view > .toolbar, .view > .grid, .view > .tabs, .view > .table-wrap, .view > .card, .view > div:not(.pwrap):not(.tlist):not(.ptabs):not(.pbar):not(.phead) { margin-left: 24px; margin-right: 24px; }
.view > .toolbar:first-child { margin-top: 20px; }

/* Thành phần */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin: 0; margin-right: auto; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat .num { font-size: 26px; font-weight: 600; }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.btn { border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--border); }
.btn.small { padding: 3px 9px; font-size: 13px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a.tview { padding-right: 4px; }
.tabs a.tview .iconbtn { font-size: 13px; padding: 0 4px; margin-left: 2px; opacity: 0; }
.tabs a.tview:hover .iconbtn, .tabs a.tview.active .iconbtn { opacity: 1; }
@media (hover: none) { .tabs a.tview .iconbtn { opacity: 1; } }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.gray { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--accent); }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: color-mix(in srgb, var(--border) 45%, transparent); border-radius: 8px; padding: 10px; min-height: 200px; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.task { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.task.overdue { border-left: 3px solid var(--danger); }

/* Modal */
dialog { border: 1px solid var(--border); border-radius: 10px; padding: 0; background: var(--panel); color: var(--text); width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
#modal-body { padding: 20px; max-height: 85vh; overflow: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.comment { border-top: 1px solid var(--border); padding: 8px 0; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 360px; }
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 8px 0; }
  .brand { padding: 0 16px 8px; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a { white-space: nowrap; padding: 8px 12px; border-left: 0; border-bottom: 2px solid transparent; }
  #nav a.active { border-bottom-color: var(--accent); }
  .view { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 240px); }
}

/* ===== Giao diện kiểu Base: trang dự án, danh sách việc, chi tiết việc ===== */
.av { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 13px; font-weight: 600; flex: none; }
.av.sm { width: 22px; height: 22px; font-size: 11px; }
.av.xs { width: 18px; height: 18px; font-size: 10px; }
.av.sq { border-radius: 4px; }
.av.lg { width: 34px; height: 34px; font-size: 16px; }
.av.more { background: #94a3b8; }
.blue { color: var(--accent); }
.up { text-transform: uppercase; letter-spacing: .3px; font-size: 13px; }
.pre { white-space: pre-wrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 4px 6px; }
.linkbtn.danger { color: var(--danger); }
.iconbtn { background: none; border: 0; cursor: pointer; font-size: 15px; color: var(--muted); padding: 4px 6px; border-radius: 4px; }
.iconbtn:hover { background: var(--bg); }

.pwrap { display: grid; grid-template-columns: 1fr 300px; min-height: 100vh; }
.pcol { min-width: 0; background: var(--panel); border-right: 1px solid var(--border); }
.view > .phead, .view > .ptabs, .view > .pbar, .view > .tlist { background: var(--panel); }
.phead { display: flex; align-items: center; gap: 10px; padding: 14px 20px 4px; }
.phead h1 { margin: 0; font-size: 18px; }
.picon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; }
.ptabs { display: flex; gap: 22px; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.ptabs a { color: var(--muted); padding: 8px 0; border-bottom: 2px solid transparent; }
.ptabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.vswitch { display: flex; gap: 10px; text-transform: none; letter-spacing: 0; }
.vswitch a { padding: 8px 0; }
.pbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pbar .search { width: 220px; border-radius: 16px; padding: 5px 12px; }
.pbar .spacer { flex: 1; }
.mini { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.mini select { width: auto; border: 0; background: none; font-weight: 600; color: var(--text); padding: 2px; }

.tlist { padding: 4px 16px 40px; min-height: 60vh; }
.tgroup { margin-top: 6px; }
.tgroup > header { display: flex; align-items: center; gap: 8px; padding: 12px 4px 8px; border-bottom: 1px solid var(--border); }
.tgroup > header h3 { margin: 0; font-size: 15px; }
.tgroup > header .gcount { margin-left: auto; color: var(--muted); }
.tgroup > header .gcount b { color: var(--text); }
.caret { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 11px; width: 18px; transition: transform .12s; padding: 0; }
.caret.open { transform: rotate(90deg); }

.trow, .prow { display: grid; grid-template-columns: 18px 26px 1fr 90px 110px; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--border); cursor: pointer; }
.prow { grid-template-columns: 34px 1fr 160px; }
.trow:hover, .prow:hover { background: var(--accent-soft); }
.trow.lvl1 { padding-left: 26px; } .trow.lvl2 { padding-left: 48px; } .trow.lvl3 { padding-left: 70px; }
.trow .exp { display: flex; justify-content: center; }
.chk { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #cbd5e1; background: var(--panel); color: transparent; cursor: pointer; display: grid; place-items: center; font-size: 13px; padding: 0; }
.chk:hover { border-color: #22c55e; color: #22c55e; }
.chk.on { background: #22c55e; border-color: #22c55e; color: #fff; }
.chk.wait { border-color: #eab308; border-style: dashed; color: #ca8a04; }
.badge.rv { background: #facc15; color: #713f12; }
.rvbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: color-mix(in srgb, #facc15 16%, transparent); border: 1px solid color-mix(in srgb, #eab308 55%, transparent); border-radius: 4px; padding: 8px 12px; margin: 4px 0 8px; }
.rvact { margin-left: auto; display: flex; gap: 6px; }
.chk.sm, .lvl1 .chk, .lvl2 .chk, .lvl3 .chk { width: 20px; height: 20px; font-size: 11px; }
.tmain { min-width: 0; }
.ttitle { overflow: hidden; text-overflow: ellipsis; }
.is-done > .tmain .ttitle { color: #16a34a; }
.cmt { color: var(--muted); font-size: 12px; }
.tmeta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; margin-top: 3px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.st-done { background: #22c55e; color: #fff; }
.st-doing { background: #dbeafe; color: #1d4ed8; }
.st-todo { background: #e5e7eb; color: #4b5563; }
/* Chờ duyệt: vàng nhấp nháy như nhãn "Đánh giá" của Base */
.st-review { background: #facc15; color: #713f12; animation: blink-rv 1.2s ease-in-out infinite; }
@keyframes blink-rv { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .st-review { animation: none; } }
.st-today { background: rgba(66, 184, 20, .9); color: #fff; font-weight: 500; }
.st-late { background: #facc15; color: #713f12; font-weight: 500; }
.st-over { background: #fecaca; color: #b91c1c; font-weight: 500; }
.st-date, .st-sub { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 400; }
.tdue { text-align: right; color: var(--muted); font-size: 12px; }
.tdue.late { color: #dc2626; font-weight: 600; }
.tass { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.tass span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pprog { display: flex; align-items: center; gap: 8px; }
.pprog .progress { flex: 1; }

.pside { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.scard { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; }
.scard h2 { font-size: 17px; margin: 0 0 4px; }
.scard h4 { margin: 0 0 10px; }
.sline { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.progress.big { height: 5px; margin: 0 0 6px; }
.progress.big > div { background: #22c55e; }
.avs { display: flex; gap: 3px; flex-wrap: wrap; padding: 4px 0 8px; }
.mystats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.mystats b { display: block; font-size: 20px; }
.mystats span { font-size: 11px; color: var(--muted); }
.donutbox { display: flex; gap: 12px; align-items: center; }
.donut { width: 100px; height: 100px; flex: none; }
.donutbox ul { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.donutbox li { display: flex; gap: 6px; align-items: center; padding: 2px 0; }
.donutbox i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Khung chi tiết công việc bên phải */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; left: 600px; background: var(--bg); box-shadow: -6px 0 24px rgba(0, 0, 0, .15); z-index: 50; display: grid; grid-template-columns: 1fr 240px; gap: 10px; padding: 10px; overflow-y: auto; align-items: start; }
.dmain, .dside { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dcard { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 14px 18px; }
.dcard h3 { margin: 0 0 8px; }
.dcard .toolbar { margin-bottom: 6px; }
.dhead { display: flex; align-items: center; }
.dact { margin-left: auto; display: flex; gap: 2px; }
.dtitle { font-size: 19px; margin: 6px 0 12px; }
.drow { display: grid; grid-template-columns: 180px 1fr; padding: 4px 0; font-size: 13px; }
.dstatus { display: flex; gap: 16px; align-items: center; border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; flex-wrap: wrap; }
.stsel { width: auto; font-weight: 600; color: #fff; border: 0; border-radius: 3px; padding: 9px 12px; cursor: pointer; }
.stsel.st-done { background: #22c55e; } .stsel.st-doing { background: #3b82f6; } .stsel.st-todo { background: #64748b; } .stsel.st-review { background: #7c3aed; }
.stsel option { color: var(--text); background: var(--panel); }
.dassign { display: flex; align-items: center; gap: 8px; }
.dassign select { width: auto; border: 0; font-weight: 600; background: none; }
.dcard textarea { min-height: 60px; border-color: transparent; background: var(--bg); }
.dcard textarea:focus { border-color: var(--accent); background: var(--panel); }
.dcard .actions { margin-top: 6px; }
.srow { display: grid; grid-template-columns: 26px 1fr 90px 110px; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); cursor: pointer; font-size: 13px; }
.srow.is-done .stitle { text-decoration: line-through; color: #16a34a; }
.subadd { display: flex; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; margin-top: 8px; }
.subadd input { border: 0; padding: 4px; }
.comment { display: block; padding: 8px 0; border-top: 1px solid var(--border); }
.ctext { white-space: pre-wrap; margin: 2px 0 0 28px; }
.person { display: flex; gap: 8px; align-items: center; }
.small-lines div { padding: 3px 0; font-size: 13px; }

@media (max-width: 1100px) {
  .pwrap { grid-template-columns: 1fr; }
  .pside { order: -1; }
  .drawer { left: 0; grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .side-scroll, .side-search, .me-box { display: none; }
  .sidebar { height: auto; }
  .trow { grid-template-columns: 14px 24px 1fr 70px; }
  .trow .tass { display: none; }
  .pbar .search { width: 100%; }
}

/* ===== Trang Công việc (việc của tôi theo tuần) ===== */
.trow.home { grid-template-columns: 26px 1fr 90px 110px; }
.wk { padding: 16px 4px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--border); }
.st-proj { background: transparent; border: 1px solid #93c5fd; color: #2563eb; font-weight: 500; }
.st-proj:hover { background: #eff6ff; }
.addbig { display: flex; align-items: center; gap: 8px; }
.addbig span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; }
.flt { width: auto; border: 0; background: none; color: var(--text); font-size: 13px; padding: 4px; cursor: pointer; }
.ucard { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.ucard h2 { margin: 0; }
.slink { color: var(--text); }
.slink:hover { background: var(--accent-soft); }
.notice { background: #fffbeb; font-size: 13px; }
.more { text-align: center; padding: 16px; }

/* ===== Ảnh đại diện ===== */
img.av { object-fit: cover; background: var(--border); }
.av.xl { width: 64px; height: 64px; font-size: 26px; }

/* ===== Thông báo ===== */
.me-row { display: flex; align-items: center; }
.me-row .me-box { flex: 1; min-width: 0; }
.bell { position: relative; background: none; border: 0; cursor: pointer; font-size: 18px; padding: 6px 12px 6px 4px; filter: grayscale(1) brightness(1.6); }
.bell:hover { filter: none; }
.bell-n { position: absolute; top: 0; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; filter: none; }
.notif { position: fixed; top: 52px; left: 12px; width: 380px; max-height: 70vh; overflow-y: auto; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); z-index: 80; }
.nhead { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); }
.nhead .spacer { flex: 1; }
.nhint { padding: 8px 14px; font-size: 12px; border-bottom: 1px solid var(--border); }
.nitem { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.nitem:hover { background: var(--accent-soft); }
.nitem.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.nitem.unread .ntitle { font-weight: 600; }
.nicon { width: 22px; text-align: center; flex: none; }
.nbody { color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.small { font-size: 11px; }
.mention-host { position: relative; }
.mention { position: absolute; bottom: 100%; left: 0; width: 320px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .15); z-index: 90; margin-bottom: 4px; }
.mi { display: flex; gap: 8px; align-items: center; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.mi.on, .mi:hover { background: var(--accent-soft); }
.zcode { font-size: 18px; letter-spacing: 1px; user-select: all; }
@media (max-width: 760px) { .notif { width: calc(100vw - 24px); } }

/* ===== Thành viên ===== */
.mfind { max-width: 260px; margin-left: auto; border-radius: 16px; padding: 5px 12px; }
.mtable td { vertical-align: middle; }
.mtable td:first-child { min-width: 170px; }
.mtable .btn { white-space: nowrap; }
.mtable th:nth-child(n+3):not(:last-child), .mtable td:nth-child(n+3):not(:last-child) { text-align: center; width: 84px; }
.ok-txt { color: #16a34a; }
.rv-txt { color: #ca8a04; }
.mgroup { font-weight: 600; font-size: 15px; padding: 16px 4px 6px; border-bottom: 1px solid var(--border); }
.mbig { padding: 10px 0 6px; } .mbig b { font-size: 28px; color: var(--accent); margin-right: 4px; }
.sbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--border); }
.sbar i { display: block; height: 100%; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 760px) {
  .hide-sm { display: none; }
  .mfind { max-width: none; margin-left: 0; }
  .mtable th:nth-child(n+3):not(:last-child), .mtable td:nth-child(n+3):not(:last-child) { width: 48px; padding: 8px 4px; }
  .mtable th { font-size: 10px; white-space: normal; }
}

/* ===== Nhân viên của tôi – Tổng quan ===== */
.tfilters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tfilters input[type=date] { width: auto; padding: 4px 6px; }
.tproj { position: relative; }
.tpop { position: absolute; top: 100%; left: 0; z-index: 30; width: 300px; max-width: calc(100vw - 24px); margin-top: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .15); padding: 8px; }
.tpop-head { display: flex; gap: 10px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.tpop-head .muted { margin-right: auto; }
.tpop-list { max-height: 260px; overflow-y: auto; margin: 6px 0; }
.tpop-list label { display: flex; gap: 6px; align-items: center; padding: 3px 2px; font-size: 13px; cursor: pointer; }
.tpop-list label .ell { flex: 1; }
.tpop-list input { width: auto; }
.tpop-foot { text-align: right; }
.tcharts { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin-bottom: 16px; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 28px; gap: 8px; align-items: center; font-size: 13px; }
.hbar div { height: 14px; background: var(--accent-soft); border-radius: 3px; }
.hbar i { display: block; height: 100%; background: #7fb2f0; border-radius: 3px; }
.hbar b { text-align: right; }
.donutbox.big .donut { width: 150px; height: 150px; }
.donutbox.big ul { font-size: 13px; }
.donutc { position: relative; flex: none; }
.donutc > b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.tteam .toolbar { margin-bottom: 10px; }
.tt th.click { cursor: pointer; }
.tt th:nth-child(2), .tt td:nth-child(2) { min-width: 120px; text-align: left !important; }
.tt .sbar { margin-bottom: 2px; }
tr.click { cursor: pointer; }
.tsub { margin-top: -6px; }
.tsub .spacer { flex: 1; }
/* Danh sách việc theo người */
.tlist2 td { vertical-align: middle; white-space: nowrap; font-size: 13px; }
.tlist2 .tname { max-width: 420px; white-space: nowrap; }
.tlist2 .tproj-n { max-width: 200px; }
tr.tgrp td { background: var(--bg); padding: 6px 10px; }
tr.tgrp .person, .tlgrp .person { gap: 6px; }
tr.tgrp .linkbtn { margin-left: 12px; }
tr.click:hover td, .tlrow.click:hover .tlleft, .tlrow.click:hover .tlchart { background: var(--accent-soft); }
/* Timeline (Gantt): cột trái dính khi cuộn ngang, thanh theo ngày */
.tl { --tll: 330px; position: relative; width: calc(var(--tll) + var(--tlw)); }
.tlwrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.tlrow { display: grid; grid-template-columns: var(--tll) var(--tlw); min-height: 30px; border-bottom: 1px solid var(--border); }
.tlleft { position: sticky; left: 0; z-index: 2; background: var(--panel); display: grid; grid-template-columns: minmax(0, 1fr) 54px 54px; gap: 6px; align-items: center; padding: 4px 10px; font-size: 13px; border-right: 1px solid var(--border); white-space: nowrap; }
.tlgrp .tlleft { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
.tlgrp .tlchart { background: var(--bg); }
.tlchart { position: relative; }
.tlbody .tlchart { background: var(--tlbg); }
.tlhead { position: sticky; top: 0; z-index: 3; min-height: 44px; }
.tlhead .tlleft, .tlhead .tlchart { background: var(--panel); }
.tlmonths, .tlticks { position: relative; height: 20px; font-size: 11px; color: var(--muted); }
.tlmonths span { position: absolute; top: 3px; padding-left: 4px; border-left: 1px solid var(--border); font-weight: 600; color: var(--text); white-space: nowrap; }
.tlticks span { position: absolute; top: 2px; white-space: nowrap; }
.tlticks.week span { text-align: center; }
.tlticks.month span { padding-left: 2px; border-left: 1px solid var(--border); }
.tlticks .now { color: #fff; background: #ef4444; border-radius: 3px; }
.tlbar { position: absolute; top: 7px; height: 16px; border-radius: 3px; color: #fff; font-size: 11px; font-style: normal; line-height: 16px; padding: 0 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tldot { position: absolute; top: 10px; width: 10px; height: 10px; border-radius: 50%; }
.tlnow { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #ef4444; z-index: 1; pointer-events: none; }
/* ===== Tệp đính kèm ===== */
.files { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.file { display: grid; grid-template-columns: 44px minmax(0, 1fr) 28px; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; }
.file img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; display: block; }
.fext { width: 44px; height: 44px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 4px; font-size: 11px; font-weight: 700; }
.fmeta { display: flex; flex-direction: column; min-width: 0; }
.fmeta a { color: var(--text); }
.file .iconbtn { text-align: center; }

/* ===== Báo cáo ===== */
.rsec { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .3px; margin: 22px 0 10px; }
.rstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.rstats .card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.rstats h4 { margin: 0; font-weight: 600; }
.rstats b { font-size: 30px; line-height: 1.2; }
.rgrid { display: grid; gap: 12px; margin-bottom: 12px; align-items: start; }
.rgrid.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rgrid.r2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.rgrid.r3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
.rgrid.r2w { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.rgrid .card { min-width: 0; }
.rgrid h3 { margin: 0 0 10px; }
.rgrid .toolbar { margin-bottom: 8px; }
.rgrid .toolbar h3 { margin: 0; margin-right: auto; }
.rcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rtable { max-height: 420px; overflow: auto; }
.rtop-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.rtop-list .person { color: var(--text); align-items: flex-start; }
.donutbox.col { flex-direction: column; }
.rrow { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ring { --p: 0; --c: #ef4444; width: 64px; height: 64px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--border) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-size: 12px; }
b.big { font-size: 26px; } b.huge { font-size: 38px; line-height: 1.1; }
.eis { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-bottom: 6px; }
.eis div { background: #ecfdf5; padding: 8px; display: flex; flex-direction: column; align-items: center; }
.eis div.red { background: #fef2f2; color: #dc2626; }
.eis div.wide { grid-column: span 2; background: var(--bg); }
.eis b { font-size: 22px; } .eis span { font-size: 11px; color: var(--muted); }
.rpair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
.rpair > div { display: flex; flex-direction: column; gap: 2px; }
.gchart { width: 100%; height: auto; display: block; }
.gchart .gl { stroke: var(--border); stroke-width: 1; }
.gchart .gt { fill: var(--muted); font-size: 10px; }
.glegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-top: 4px; }
.glegend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
@media (prefers-color-scheme: dark) { .eis div { background: #12261f; } .eis div.red { background: #2a1515; } }
@media (max-width: 1100px) {
  .rgrid.r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rgrid.r3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rgrid.r3 > :first-child { grid-column: span 2; }
}
@media (max-width: 760px) {
  .rstats, .rgrid.r4, .rgrid.r2, .rgrid.r3, .rgrid.r2w { grid-template-columns: minmax(0, 1fr); }
  .rstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rgrid.r3 > :first-child { grid-column: auto; }
}
:root { --tl-weekend: rgba(0, 0, 0, .035); }
@media (prefers-color-scheme: dark) { :root { --tl-weekend: rgba(255, 255, 255, .04); } }
@media (max-width: 760px) {
  #nav a.desk-only { display: none; }
  .tl { --tll: 170px; }
  .tlleft { grid-template-columns: minmax(0, 1fr); }
  .tlleft > span:not(.ell):not(.person) { display: none; }
  .tlist2 .tname { max-width: 220px; }
  .tcharts { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: 110px minmax(0, 1fr) 24px; }
  .donutbox.big .donut { width: 120px; height: 120px; }
}

/* ===== Điện thoại: thanh trên (tên, chuông) + thanh menu dưới, nội dung tràn ngang ===== */
@media (max-width: 760px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* iOS không tự phóng to khi gõ */
  .sidebar { position: sticky; top: 0; z-index: 40; flex-direction: row; align-items: center; padding: 0 4px 0 0; padding-top: env(safe-area-inset-top); }
  .me-row { flex: 1; min-width: 0; }
  .me-box { display: flex; padding: 8px 12px; gap: 8px; }
  .me-box .me-pos { display: none; }
  .me-box .me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .me { border-top: 0; padding: 8px; white-space: nowrap; }
  .side-scroll { display: block; flex: none; overflow: visible; padding: 0; }
  .side-scroll > .navhead, #proj-nav, #search-res { display: none; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; flex-direction: row; overflow: visible; background: var(--side); border-top: 1px solid rgba(255, 255, 255, .08); padding-bottom: env(safe-area-inset-bottom); }
  #nav a { flex: 1; flex-direction: column; gap: 0; padding: 7px 2px 6px; border-left: 0; border-bottom: 0; border-top: 2px solid transparent; font-size: 11px; white-space: nowrap; position: relative; }
  #nav a i { font-size: 19px; width: auto; line-height: 1.2; }
  #nav a.active { border-top-color: var(--accent); background: none; }
  #nav a .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; padding: 0 5px; font-size: 10px; }
  #nav .long { display: none; }
  #nav .short { display: inline; }
  .view { padding: 0 0 calc(64px + env(safe-area-inset-bottom)); }
  .view > .toolbar, .view > .grid, .view > .tabs, .view > .table-wrap, .view > .card, .view > div:not(.pwrap):not(.tlist):not(.ptabs):not(.pbar):not(.phead) { margin-left: 12px; margin-right: 12px; }
  .view > .toolbar:first-child { margin-top: 14px; }
  .pside { padding: 8px; }
  .phead { padding: 12px 12px 4px; }
  .ptabs { gap: 16px; padding: 0 12px; overflow-x: auto; white-space: nowrap; }
  .pbar { padding: 8px 12px; gap: 8px; }
  .tlist { padding: 4px 8px 24px; }
  .trow, .trow.home { grid-template-columns: 26px minmax(0, 1fr) 52px; gap: 8px; }
  .trow .exp { display: none; }
  .trow.lvl1 { padding-left: 14px; } .trow.lvl2 { padding-left: 24px; } .trow.lvl3 { padding-left: 34px; }
  .ttitle { overflow: visible; }
  .tmeta .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tdue { font-size: 11px; }
  .prow { grid-template-columns: 34px minmax(0, 1fr) 104px; }
  .pprog { gap: 6px; }
  .pprog .progress { min-width: 30px; }
  .drawer { left: 0; z-index: 60; padding: 0; gap: 0; padding-bottom: env(safe-area-inset-bottom); }
  .dcard { border-radius: 0; border-left: 0; border-right: 0; padding: 12px 14px; }
  .drow { grid-template-columns: 110px minmax(0, 1fr); }
  .srow { grid-template-columns: 26px minmax(0, 1fr) 60px; }
  .srow > :nth-child(4) { display: none; }
  .mention { width: min(320px, calc(100vw - 40px)); }
  .toast { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }
  .notif { top: calc(52px + env(safe-area-inset-top)); max-height: calc(100vh - 140px); }
  .dl { grid-template-columns: 110px 1fr; }
}

/* ===== Checklist, người theo dõi, lịch sử, tải tệp, tìm kiếm, hạn nhanh ===== */
.cl { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 8px; }
.cl .toolbar { margin-bottom: 4px; }
.clrow { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.clrow input[type="checkbox"] { width: 16px; height: 16px; flex: none; accent-color: #22c55e; }
.cltext { flex: 1; min-width: 0; }
.clrow.is-done .cltext { text-decoration: line-through; color: var(--muted); }
.person.fl { padding: 2px 0; }
.person.fl .iconbtn { margin-left: auto; font-size: 12px; }
.hist summary { cursor: pointer; font-size: 12px; font-weight: 600; }
.hist[open] summary { margin-bottom: 8px; }
.hrow { font-size: 12.5px; padding: 5px 0; border-top: 1px dashed var(--border); }
.drawer.dropping { outline: 3px dashed var(--accent); outline-offset: -6px; }
.ptabs .hsearch { margin-left: auto; width: 230px; border-radius: 16px; padding: 4px 12px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.qd { display: flex; gap: 6px; margin-top: 4px; }
@media (max-width: 760px) {
  .ptabs .hsearch { width: 140px; }
}

/* ===== Nhóm 2: nhãn, dấu sao, bộ lọc, lịch biểu, việc lặp lại ===== */
.st-label { background: #eef2ff; color: #4338ca; font-weight: 500; }
.trow.home { grid-template-columns: 26px 1fr 90px 110px 24px; }
.star { background: none; border: 0; cursor: pointer; font-size: 16px; color: #cbd5e1; padding: 2px; line-height: 1; }
.star:hover { color: #f59e0b; }
.star.on { color: #f59e0b; }
.dact .star { font-size: 17px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chipf { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 14px; padding: 3px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.chipf.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.hx { min-height: 100vh; }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; } .seg .btn:first-child { border-radius: 6px 0 0 6px; } .seg .btn:last-child { border-radius: 0 6px 6px 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); margin: 0 12px 24px; background: var(--panel); }
.calh { padding: 6px; text-align: center; font-size: 11px; color: var(--muted); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calc { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; min-height: 110px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal.week .calc { min-height: 60vh; }
.calc.other { background: color-mix(in srgb, var(--border) 25%, transparent); }
.calc.today .cald b { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; }
.cald { font-size: 13px; padding: 2px; }
.calt { font-size: 12px; padding: 2px 6px; border-radius: 3px; background: #dbeafe; color: #1e3a8a; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calt.done { background: #dcfce7; color: #166534; text-decoration: line-through; }
.calt.late { background: #fee2e2; color: #991b1b; }
.calt.rv { background: #fef3c7; color: #713f12; }
.calc .linkbtn { margin-top: auto; font-size: 11px; opacity: 0; text-align: left; }
.calc:hover .linkbtn { opacity: 1; }
.rtable .rgroup td { background: color-mix(in srgb, var(--border) 35%, transparent); font-size: 12px; }
.xlprev { max-height: 180px; overflow: auto; font-size: 13px; margin-top: 6px; }
/* Mục tiêu */
.ggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.gcard { color: var(--text); display: block; }
.gcard:hover { border-color: var(--accent); }
.gline { gap: 8px; }
.gline .progress { height: 5px; min-width: 0; }
.gstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.gstats .card { display: grid; gap: 4px; padding: 12px 14px; }
.gstats b { font-size: 22px; }
.gtree, .gkrs { padding: 4px 12px; }
.grow, .gkr { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px 90px 140px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.gkr { grid-template-columns: minmax(0, 1fr) 150px 150px 140px 56px; }
.grow:last-child, .gkr:last-child { border-bottom: 0; }
.ghead { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 6px 0; }
.gname { display: flex; align-items: center; gap: 6px; min-width: 0; padding-left: calc(var(--gd, 0) * 22px); }
.gname a { color: var(--text); min-width: 0; }
.grow .pprog .progress, .gkr .pprog .progress { min-width: 0; }
.gci { padding: 10px 0; border-bottom: 1px dashed var(--border); display: grid; gap: 4px; }
.gci:last-child { border-bottom: 0; }
@media (max-width: 760px) {
  .grow, .gkr { grid-template-columns: minmax(0, 1fr) 96px; }
  .grow > :nth-child(2), .grow > :nth-child(3), .grow > :nth-child(4), .ghead > :nth-child(n+2):not(:last-child) { display: none; }
  .gkr > :nth-child(2) { display: none; }
  .gkr > :nth-child(3) { grid-column: 1; }
}
.xlprev div { padding: 2px 0; border-bottom: 1px dashed var(--border); }
.optrow { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.optrow input { width: auto; }
.siprev .table-wrap { max-height: 280px; overflow: auto; }
.siprev th, .siprev td { padding: 5px 8px; }
@media (max-width: 760px) {
  .trow, .trow.home { grid-template-columns: 26px minmax(0, 1fr) 52px 22px; }
  .cal.week { grid-template-columns: 1fr; }
  .cal.week .calc { min-height: 0; }
  .cal.month { overflow-x: auto; grid-template-columns: repeat(7, 90px); }
  .calc .linkbtn { opacity: 1; }
}

/* Đợt 1: Kanban theo nhóm công việc, tab Tổng quan dự án */
.kanban.bygroup { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 260px; }
.kanban .col > .linkbtn { display: block; margin: 0 0 8px; }
.kanban .addcol { display: flex; align-items: flex-start; justify-content: center; background: transparent; border: 1px dashed var(--border); }
.tgroup header .iconbtn { margin-left: 4px; }
.ovgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
.ovgrid .card { min-width: 0; }
.ovgrid .person { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.ovmem { max-height: 260px; overflow-y: auto; }
.stlog { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.stlog li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
@media (max-width: 760px) {
  .ovgrid { grid-template-columns: 1fr; padding: 8px 0; }
  .kanban.bygroup { grid-auto-columns: 240px; }
}
