* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: #f1f5f9; color: #1e293b; line-height: 1.5; }
h1,h2,h3 { font-weight: 700; }
a { color: inherit; }

/* ---------- Auth ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0050E2, #00A3E0); padding: 16px; }
.auth-box { background: #fff; padding: 32px; border-radius: 14px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.auth-box h1 { font-size: 22px; margin-bottom: 16px; text-align: center; }
.auth-logo-lg { display: block; width: 78%; max-width: 320px; margin: 4px auto 14px; }
.slogan { text-align: center; font-size: 15px; color: #0050E2; line-height: 1.5; margin: 0 auto 22px; max-width: 360px; font-style: italic; }
.slogan b { color: #0A2472; background: #F3F112; padding: 0 5px; border-radius: 4px; font-style: normal; font-weight: 800; }
.auth-box label { display: block; font-size: 14px; margin: 12px 0 4px; font-weight: 600; }
.auth-box input { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px; }
.auth-box button { width: 100%; margin-top: 20px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-link a { color: #0050E2; text-decoration: none; font-weight: 600; }
.alert { background: #fee2e2; color: #b91c1c; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---------- Topbar & nav ---------- */
.topbar { background: #fff; padding: 10px 24px; display: flex; align-items: center; gap: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.06); flex-wrap: wrap; }
.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: 8px 14px; border-radius: 8px; text-decoration: none; font-size: 14px; color: #475569; font-weight: 500; }
.mainnav a:hover { background: #f1f5f9; }
.mainnav a.active { background: #0050E2; color: #fff; }
.user-area { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-area .who { text-align: right; line-height: 1.25; }
.user-area small { color: #64748b; }

/* ---------- Layout ---------- */
.container { max-width: 860px; margin: 22px auto; padding: 0 16px; }
.container-wide { max-width: 1180px; }
.card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 20px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.hint { font-size: 13px; color: #64748b; margin: 6px 0; }
.lbl { display:block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color:#334155; }

/* ---------- Forms ---------- */
.task-form .row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.task-form .field { flex: 1 1 180px; }
.task-form input, .task-form textarea, .task-form select,
.edit-form input, .edit-form textarea, .edit-form select,
.mini-form input, .mini-form textarea, select {
    padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; font-family: inherit; width: 100%; background:#fff;
}
.task-form textarea { width: 100%; }
.perm-row { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; font-size: 14px; }
.perm-row label { display: flex; align-items: center; gap: 8px; }
.perm-row input { width: auto; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 4px; }
@media (max-width: 800px){ .stat-grid { grid-template-columns: repeat(3,1fr); } }

/* ---------- WIP grid ---------- */
.wip-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
@media (max-width: 900px){ .wip-grid { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #475569; margin-top: 10px; }
.legend .dot, .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ---------- Occupancy table ---------- */
.occ-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.occ-table th, .occ-table td { text-align: left; padding: 8px 6px; border-top: 1px solid #eef2f7; vertical-align: top; }
.occ-table th { color: #64748b; font-weight: 600; border-top: none; }
.occ-table small { color: #94a3b8; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-free { background: #d1fae5; color: #047857; }
.pill-busy { background: #fef3c7; color: #b45309; }

/* ---------- Task cards ---------- */
.task-list { display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; color: #94a3b8; padding: 30px 0; }
.task { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); border-left: 4px solid #cbd5e1; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card .task { box-shadow: none; border: 1px solid #eef2f7; }
.status-wo-dang_lam { border-left-color: #0050E2; }
.status-wo-cho_duyet { border-left-color: #f59e0b; }
.status-wo-chua_duyet { border-left-color: #dc2626; }
.status-wo-hoan_thanh { border-left-color: #10b981; }
.status-wo-hoan_thanh h3 { text-decoration: line-through; color: #94a3b8; }
.status-wo-thu_hoi { border-left-color: #94a3b8; opacity: .8; }
.status-wo-thu_hoi h3 { text-decoration: line-through; color: #94a3b8; }
.badge-thu_hoi { background: #e2e8f0; color: #475569; }
.status-wo-tam_dung { border-left-color: #f59e0b; }
.badge-tam_dung { background: #fef3c7; color: #b45309; }
.task-main { flex: 1 1 340px; }
.task-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.task-head h3 { font-size: 16px; }
.task-desc { font-size: 14px; color: #475569; margin: 6px 0; }
.task-meta { font-size: 13px; color: #64748b; margin-top: 4px; }
.task-actions { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.task-side { flex: 0 0 260px; }
@media (max-width: 700px){ .task-side { flex-basis: 100%; } }

/* ---------- Badges ---------- */
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.badge-plain { background: #e2e8f0; color: #475569; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-super_admin { background: #ede9fe; color: #6d28d9; }
.badge-quan_ly { background: #dbeafe; color: #1e40af; }
.badge-nhan_su { background: #e2e8f0; color: #475569; }
.badge-dang_lam { background: #DCE8FD; color: #0041BE; }
.badge-cho_duyet { background: #fef3c7; color: #b45309; }
.badge-chua_duyet { background: #fee2e2; color: #b91c1c; }
.badge-hoan_thanh { background: #d1fae5; color: #047857; }
.badge-uu-cham { background: #f1f5f9; color: #64748b; }
.badge-uu-binh_thuong { background: #e0f2fe; color: #0369a1; }
.badge-uu-nhanh { background: #ffedd5; color: #c2410c; }
.badge-uu-gap { background: #fee2e2; color: #b91c1c; }
.badge-du-an { background: #F3F112; color: #0A2472; }

/* ---------- Files & reviews ---------- */
.files { margin-top: 8px; font-size: 13px; }
.file-link { display: inline-block; margin: 2px 8px 2px 0; color: #0041BE; text-decoration: none; }
.submit-item { padding: 4px 0; border-top: 1px dashed #eef2f7; }
.submit-item .note { color: #475569; }
.submit-item .by { color: #94a3b8; margin-left: 6px; }
.reviews { margin-top: 8px; }
.review-item { font-size: 13px; padding: 6px 10px; border-radius: 8px; margin-top: 6px; }
.review-item.ok { background: #ecfdf5; color: #065f46; }
.review-item.no { background: #fef2f2; color: #991b1b; }
.review-item .note { font-style: italic; }

/* ---------- Countdown ---------- */
.cd { font-weight: 600; color: #b45309; }
.cd.late { color: #dc2626; }
.cu { font-weight: 600; }
.ns-name { color: #0050E2; text-decoration: none; font-weight: 600; cursor: pointer; }
.ns-name:hover { text-decoration: underline; }
.ns-detail td { background: #f8fafc; border-top: none; }
.ns-detail ul { list-style: disc; }

/* ---------- Mini form (nộp/duyệt) ---------- */
.mini-form { background: #f8fafc; border: 1px solid #eef2f7; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mini-form b { font-size: 13px; }
.mini-form hr { border: none; border-top: 1px dashed #cbd5e1; margin: 4px 0; }
.mini-form .lbl { margin: 0; }

/* ---------- Edit forms (admin) ---------- */
.inline { display: inline; }
.edit-form { flex-basis: 100%; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.edit-form .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { padding: 9px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; display: inline-block; }
.btn-primary { background: #0050E2; color: #fff; }
.btn-primary:hover { background: #0041BE; }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

/* ---------- Chuông thông báo ---------- */
.bell { position: relative; text-decoration: none; font-size: 20px; line-height: 1; padding: 4px; }
.bell-badge { position: absolute; top: -4px; right: -6px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.tb-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tb-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid #eef2f7; border-radius: 10px; background: #fff; }
.tb-item.chua-xem { background: #eff4ff; border-color: #c7dbff; }
.tb-ic { font-size: 20px; line-height: 1.2; flex: 0 0 auto; }
.tb-main { flex: 1; }
.tb-noi { font-size: 14px; }
.tb-item.chua-xem .tb-noi { font-weight: 600; }
.tb-meta { font-size: 12px; color: #94a3b8; margin-top: 3px; }
.tb-meta a { color: #0050E2; }
.tb-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 800px){ .chat-wrap { grid-template-columns: 1fr; } }
.chat-side { background:#fff; border-radius:12px; box-shadow:0 1px 4px rgba(0,0,0,.06); overflow:hidden; align-self:start; }
.chat-new { padding: 12px; border-bottom: 1px solid #eef2f7; }
.chat-new summary { cursor: pointer; list-style: none; }
.chat-new summary::-webkit-details-marker { display:none; }
.chat-list { max-height: 60vh; overflow-y: auto; }
.chat-item { display:flex; gap:10px; align-items:center; padding:10px 12px; text-decoration:none; color:#1e293b; border-bottom:1px solid #f4f6fa; }
.chat-item:hover { background:#f8fafc; }
.chat-item.active { background:#e8f0ff; }
.chat-ava { width:38px; height:38px; border-radius:50%; background:#0050E2; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; text-transform:uppercase; flex:0 0 auto; }
.chat-item-name { font-weight:600; font-size:14px; }
.chat-item-last { font-size:12px; color:#94a3b8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:210px; }
.chat-main { background:#fff; border-radius:12px; box-shadow:0 1px 4px rgba(0,0,0,.06); display:flex; flex-direction:column; min-height:560px; }
.chat-empty { margin:auto; color:#94a3b8; padding:40px; text-align:center; }
.chat-head { padding:14px 16px; border-bottom:1px solid #eef2f7; display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.chat-sub { font-size:12px; color:#64748b; margin-top:2px; }
.chat-add summary { list-style:none; }
.ghim-box { background:#fffbea; border-bottom:1px solid #fde68a; padding:8px 14px; font-size:13px; }
.ghim-tit { font-weight:700; color:#b45309; margin-bottom:4px; }
.ghim-item { padding:2px 0; color:#475569; }
.tin-box { flex:1; overflow-y:auto; padding:14px 16px; max-height:52vh; display:flex; flex-direction:column; gap:8px; }
.tin { display:flex; }
.tin-me { justify-content:flex-end; }
.tin-bubble { max-width:78%; background:#f1f5f9; border-radius:12px; padding:8px 12px; }
.tin-me .tin-bubble { background:#dbeafe; }
.tin-ai { font-size:12px; font-weight:700; color:#0050E2; margin-bottom:2px; }
.tin-noi { font-size:14px; word-break:break-word; }
.tin-noi a { color:#0041BE; }
.tin-gio { font-size:11px; color:#94a3b8; margin-top:3px; text-align:right; }
.pin-btn { background:none; border:none; cursor:pointer; font-size:12px; color:#94a3b8; padding:0 2px; }
.pin-btn:hover { color:#b45309; }
.chat-send { display:flex; gap:8px; padding:12px 16px; border-top:1px solid #eef2f7; }
.chat-send textarea { flex:1; resize:none; padding:9px 11px; border:1px solid #cbd5e1; border-radius:10px; font-family:inherit; font-size:14px; }

/* FullCalendar tinh chỉnh nhỏ */
.fc { font-size: 13px; }
.fc .fc-toolbar-title { font-size: 16px; }

/* ============ TỐI ƯU MOBILE ============ */
@media (max-width: 640px) {
    .topbar { padding: 10px 14px; gap: 8px; }
    .brand { order: 1; }
    .brand img { height: 28px; }
    .user-area { order: 2; margin-left: auto; font-size: 12px; gap: 8px; }
    .mainnav { order: 3; width: 100%; gap: 3px; }
    .mainnav a { font-size: 13px; padding: 7px 10px; }
    .container { margin: 14px auto; }
    .card { padding: 16px; overflow-x: auto; }
    .card h2 { font-size: 15px; }
    /* Ô thống kê: 2 cột cho gọn màn nhỏ */
    .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .stat-num { font-size: 22px; }
    /* Bảng rộng: cho cuộn ngang trong thẻ thay vì vỡ layout */
    .rank-table, .occ-table { min-width: 480px; }
    /* Thẻ công việc: xếp dọc, ô nộp/duyệt full chiều ngang */
    .task { flex-direction: column; }
    .task-side { flex: 1 1 100%; width: 100%; }
    .task-actions { width: 100%; }
    .report-form .field { flex: 1 1 45%; }
    .fc .fc-toolbar { flex-direction: column; gap: 6px; }
    .fc .fc-toolbar-title { font-size: 15px; }
    /* Chat: khung tin cao hơn cho dễ đọc */
    .tin-box { max-height: 46vh; }
    .chat-list { max-height: 38vh; }
    .tin-bubble { max-width: 88%; }
    /* Đăng nhập */
    .auth-box { padding: 24px; }
    .slogan { font-size: 14px; }
}
@media (max-width: 380px) {
    .stat-grid { grid-template-columns: 1fr 1fr !important; }
    .mainnav a { font-size: 12px; padding: 6px 8px; }
}
.fc .fc-button-primary { background: #0050E2; border-color: #0050E2; }
.fc .fc-button-primary:hover { background: #0041BE; border-color: #0041BE; }

/* ---------- Logo thương hiệu ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 34px; width: auto; display: block; }
.topbar { border-top: 3px solid #F3F112; }
.auth-logo { display: block; max-width: 210px; margin: 0 auto 16px; }

/* ---------- Báo cáo & Thành tích ---------- */
.report-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.report-form .field { flex: 1 1 180px; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank-table th, .rank-table td { padding: 9px 8px; border-top: 1px solid #eef2f7; text-align: left; }
.rank-table th { color: #64748b; font-weight: 600; border-top: none; }
.rank-num { font-weight: 700; color: #0050E2; width: 42px; }
.rank-bar { height: 8px; background: #DCE8FD; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.rank-bar > i { display: block; height: 100%; background: #0050E2; }
.rank-top1 .rank-num { color: #B7950B; }
.dept-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 18px 0 8px; }
.dept-title .chip-count { background: #F3F112; color: #0A2472; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
