/* ===== Hệ thống điều hành công việc — giao diện ===== */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2433; --muted: #667085; --line: #e4e7ec; --soft: #f8f9fb;
  --brand: #1e4f8f; --brand-ink: #ffffff; --brand-soft: #e8f0fb;
  --done: #16a34a; --doing: #2563eb; --due: #ca8a04; --due-bg: #fef3c7; --over: #dc2626; --todo: #8a94a6; --review: #7c3aed;
  --done-bg: #dcfce7; --doing-bg: #dbeafe; --over-bg: #fee2e2; --todo-bg: #eef0f3; --review-bg: #ede9fe;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --sidebar: 228px;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Bố cục */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: #12233d; color: #c9d4e5; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 20; }
.sidebar .brand { padding: 16px; font-weight: 700; color: #fff; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand small { display: block; font-weight: 400; color: #9fb0c9; font-size: 12px; margin-top: 2px; }
.sidebar nav { padding: 8px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; color: #c9d4e5; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .who { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.sidebar .who b { color: #fff; display: block; font-size: 13px; }
.main { margin-left: var(--sidebar); flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; gap: 12px; align-items: center; }
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { width: 100%; }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.search-results a { display: block; padding: 8px 12px; color: var(--ink); border-bottom: 1px solid var(--soft); }
.search-results a:hover { background: var(--soft); text-decoration: none; }
.bell { position: relative; font-size: 18px; }
.bell .dot { position: absolute; top: -4px; right: -8px; background: var(--over); color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 5px; }
.content { padding: 20px; max-width: 1400px; }
.bottomnav { display: none; }
.show-sm { display: none; }

/* Thẻ, bảng */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card > h3:first-child, .card > .row:first-child h3 { margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; cursor: default; }
.kpi.click { cursor: pointer; } .kpi.click:hover { box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.done { border-left-color: var(--done); } .kpi.done .v { color: var(--done); }
.kpi.doing { border-left-color: var(--doing); } .kpi.doing .v { color: var(--doing); }
.kpi.due_soon { border-left-color: var(--due); } .kpi.due_soon .v { color: var(--due); }
.kpi.overdue { border-left-color: var(--over); } .kpi.overdue .v { color: var(--over); }
.kpi.todo { border-left-color: var(--todo); } .kpi.todo .v { color: var(--todo); }
.kpi.review { border-left-color: var(--review); } .kpi.review .v { color: var(--review); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f5f8fd; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; }

/* Nhãn trạng thái — đúng quy ước màu */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-done { background: var(--done-bg); color: #166534; }
.s-doing { background: var(--doing-bg); color: #1e40af; }
.s-due_soon { background: var(--due-bg); color: #854d0e; }
.s-overdue { background: var(--over-bg); color: #991b1b; }
.s-todo { background: var(--todo-bg); color: #4b5563; }
.s-review { background: var(--review-bg); color: #5b21b6; }
.s-cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.dot-s { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; background: #eef2f7; color: #475467; }
.tag.sample { background: #fff4e5; color: #b54708; border: 1px dashed #f79009; font-weight: 600; }
.tag.slow { background: var(--over-bg); color: #991b1b; font-weight: 600; }
.prio-urgent { color: var(--over); font-weight: 700; } .prio-high { color: #c2410c; font-weight: 600; }

/* Thanh tiến độ */
.bar { height: 8px; background: #edf0f4; border-radius: 99px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: var(--doing); border-radius: 99px; }
.bar.done > span { background: var(--done); } .bar.over > span { background: var(--over); } .bar.warn > span { background: var(--due); }
.bar .plan { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #111827; opacity: .55; }

/* Nút & form */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: #173f73; }
.btn.success { background: var(--done); border-color: var(--done); color: #fff; }
.btn.danger { background: #fff; border-color: #fca5a5; color: var(--over); }
.btn.warn { background: #fff; border-color: #facc15; color: #854d0e; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { border: 1px solid #d0d5dd; border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3f5; border-color: var(--brand); }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
label.f input, label.f select, label.f textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: none; background: none; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.multi { border: 1px solid #d0d5dd; border-radius: 8px; max-height: 150px; overflow: auto; padding: 6px; background: #fff; }
.multi label { display: flex; gap: 6px; align-items: center; padding: 2px 4px; }

/* Hộp thoại */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal.wide { max-width: 900px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2433; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: #b42318; } .toast.ok { background: #067647; }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--brand-soft); border: 1px solid #c7d7ee; }
.alert.warn { background: #fffaeb; border-color: #fedf89; } .alert.err { background: #fef3f2; border-color: #fecdca; }

/* Dòng thời gian */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 14px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.k-progress::before { background: var(--doing); } .timeline li.k-submit::before { background: var(--review); }
.timeline li.k-approve::before { background: var(--done); } .timeline li.k-return::before { background: var(--over); }
.timeline li.k-comment::before { background: #98a2b3; }
.timeline .meta { font-size: 12px; color: var(--muted); }
.blocker { background: #fffaeb; border-left: 3px solid var(--due); padding: 4px 8px; margin-top: 4px; font-size: 13px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.files .f { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--soft); font-size: 12px; }
.files .f img { width: 100%; height: 100px; object-fit: cover; display: block; }
.files .f .n { padding: 6px; word-break: break-all; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 16px; }
.info-grid > div > span { display: block; font-size: 12px; color: var(--muted); }
.stars button { border: none; background: none; font-size: 26px; cursor: pointer; color: #d0d5dd; padding: 0 2px; }
.stars button.on { color: #f59e0b; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.list-item { padding: 8px 0; border-bottom: 1px solid var(--soft); display: flex; gap: 8px; align-items: flex-start; }
.list-item:last-child { border-bottom: none; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.kanban .col { background: #eef1f5; border-radius: 10px; padding: 10px; min-height: 200px; }
.kanban .col h4 { display: flex; justify-content: space-between; }
.kanban .tcard { background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid var(--todo); }
.tcard.st-done { border-left-color: var(--done); } .tcard.st-doing { border-left-color: var(--doing); }
.tcard.st-due_soon { border-left-color: var(--due); } .tcard.st-overdue { border-left-color: var(--over); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(135deg, #12233d, #1e4f8f); }
.login { background: #fff; padding: 28px; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login h1 { font-size: 20px; }
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #f0f6ff; font-size: 13px; }
.fc .fc-event { cursor: pointer; }
.fc-ev { overflow: hidden; line-height: 1.3; padding: 1px 2px; }
.fc-ev .t { font-weight: 600; }
.daygroup { margin-bottom: 14px; }
.daygroup > h4 { background: var(--soft); padding: 6px 10px; border-radius: 6px; }
pre.tg { white-space: pre-wrap; background: #f6f8fa; padding: 12px; border-radius: 8px; font-family: inherit; font-size: 13px; max-height: 420px; overflow: auto; }

@media (max-width: 1250px) { .g2.lg { grid-template-columns: minmax(0, 1fr); } .g3 > [style*="span 2"] { grid-column: auto !important; } }
@media (max-width: 1250px) and (min-width: 901px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Điện thoại */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: 64px; }
  .content { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; }
  .bottomnav a { flex: 1; text-align: center; padding: 8px 2px 6px; font-size: 11px; color: var(--muted); }
  .bottomnav a b { display: block; font-size: 18px; font-weight: 400; }
  .bottomnav a.active { color: var(--brand); }
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  table.cards thead { display: none; }
  table.cards tr { display: block; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
  table.cards td { display: flex; justify-content: space-between; gap: 10px; border: none; padding: 5px 10px; }
  table.cards td::before { content: attr(data-l); color: var(--muted); font-size: 12px; flex-shrink: 0; }
  .kanban { grid-template-columns: repeat(4, 80vw); }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
@media print {
  .sidebar, .topbar, .bottomnav, .no-print { display: none !important; }
  .main { margin: 0; }
}
td[data-l="Công việc"] { min-width: 200px; }
@media (max-width: 900px) { td[data-l="Công việc"] { min-width: 0; } }
label.f .multi input, label.f input[type="checkbox"], label.f input[type="radio"] { width: auto; }
.multi label { justify-content: flex-start; }
