/* Quản lý công việc Khoa Toán – Tin học — phong cách học thuật, trang nhã */
:root {
  --navy: #1f3a5f; --navy-2: #2b4c7a; --blue: #4a7bb7; --blue-soft: #e8f0fa;
  --bg: #f4f6f9; --card: #ffffff; --line: #dfe4ec; --text: #1d2733; --muted: #5f6b7a;
  --amber: #a8650a; --amber-bg: #fdf1dc; --amber-line: #f0c674;
  --red: #b42318; --red-bg: #fdecea; --red-line: #f3a59c;
  --green: #22703f; --green-bg: #e5f4ea; --purple: #5b4a9e; --purple-bg: #efebfa;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--navy-2); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.08rem; margin: 0 0 .75rem; color: var(--navy); }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--navy); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .mono { font-family: Consolas, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Thanh trên */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .55rem 1.25rem; background: var(--navy); color: #fff;
  position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #fff;
  color: var(--navy); font-weight: 700; letter-spacing: .5px; }
.brand-mark.lg { width: 52px; height: 52px; font-size: 1.2rem; background: var(--navy); color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { opacity: .8; font-size: .75rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { color: #dbe5f3; text-decoration: none; padding: .45rem .8rem; border-radius: 6px; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.12); color: #fff; }
.userbox { display: flex; align-items: center; gap: .8rem; }
.bell { position: relative; color: #fff; display: inline-flex; padding: .3rem; }
.bell .count { position: absolute; top: -4px; right: -8px; background: var(--red); color: #fff; border-radius: 999px;
  font-size: .7rem; padding: 0 .38rem; font-weight: 700; }
.usermenu { position: relative; }
.usermenu summary { cursor: pointer; list-style: none; color: #fff; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: 2rem; background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem; min-width: 240px; display: grid; gap: .4rem; }
.linkbtn { background: none; border: 0; color: var(--red); padding: 0; cursor: pointer; font: inherit; }
.chip { display: inline-block; background: var(--blue-soft); color: var(--navy); border-radius: 999px; padding: 0 .5rem; margin: 0 .2rem .2rem 0; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.25rem; padding-bottom: 5rem; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.panel.narrow { max-width: 460px; margin: 2rem auto; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Chỉ số */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: var(--radius);
  padding: 1rem 1.1rem; text-decoration: none; color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat:hover { border-color: var(--blue); }
.stat-label { color: var(--muted); font-weight: 600; font-size: .9rem; }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-soon { border-left-color: var(--amber); } .stat-soon .stat-num { color: var(--amber); }
.stat-overdue { border-left-color: var(--red); } .stat-overdue .stat-num { color: var(--red); }
.stat-review { border-left-color: var(--purple); } .stat-review .stat-num { color: var(--purple); }

/* Nhãn */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  background: #eef1f5; color: #3d4757; border: 1px solid transparent; white-space: nowrap; }
.st-todo { background: #eef1f5; color: #47505e; } .st-doing { background: var(--blue-soft); color: var(--navy-2); }
.st-review { background: var(--purple-bg); color: var(--purple); } .st-done { background: var(--green-bg); color: var(--green); }
.st-cancelled { background: #f1f1f1; color: #777; text-decoration: line-through; }
.dl-overdue { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.dl-soon { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.ok { background: var(--green-bg); color: var(--green); } .late { background: var(--red-bg); color: var(--red); }
.pr-low { color: #607080; } .pr-high { background: #fff2e0; color: #8a4b00; } .pr-urgent { background: var(--red-bg); color: var(--red); }
.txt-overdue { color: var(--red); font-weight: 700; }

/* Thẻ công việc */
.taskcard { display: block; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: .7rem .85rem;
  margin-bottom: .6rem; text-decoration: none; color: var(--text); background: #fff; }
.taskcard:hover { background: #fafcff; }
.taskcard.is-overdue { border-left-color: var(--red); background: #fffafa; }
.taskcard.is-soon { border-left-color: var(--amber); background: #fffdf7; }
.tc-top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.tc-title { font-weight: 600; }
.tc-meta { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: .2rem 0; }
.tc-bottom { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pct { font-size: .85rem; font-weight: 600; }

progress { appearance: none; -webkit-appearance: none; width: 110px; height: 8px; border: 0; border-radius: 99px; background: #e6eaf0; overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: #e6eaf0; border-radius: 99px; }
progress::-webkit-progress-value { background: var(--blue); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 99px; }
.bigprogress { display: flex; align-items: center; gap: .8rem; margin-top: .8rem; }
.bigprogress progress { flex: 1; height: 12px; width: auto; }

/* Bảng */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: .6rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #f8f9fb; }
.table.compact th, .table.compact td { padding: .4rem .5rem; font-size: .88rem; }
.table tfoot th { color: var(--navy); }
.row-overdue td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.row-soon td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.row-muted { opacity: .6; }
.table-wrap.desktop-only .table { border: 1px solid var(--line); border-radius: var(--radius); }

/* Biểu mẫu */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .7rem; color: #344052; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 500; }
label.check { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0 .8rem .3rem 0; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; font: inherit; color: var(--text); padding: .5rem .6rem;
  border: 1px solid #c9d1dc; border-radius: 7px; background: #fff; }
input[type=checkbox], input[type=range] { width: auto; display: inline-block; margin: 0; padding: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; padding: .6rem .9rem; }
legend { font-weight: 600; color: var(--navy); padding: 0 .3rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.adv-filters { margin: 0; }
.adv-filters[open] { flex-basis: 100%; }
.adv-body { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .3rem; }
.adv-body select, .adv-body input { width: auto; margin: 0; }
.members-pick { display: grid; gap: .35rem; }
.mp-row { display: grid; grid-template-columns: 220px 1fr; gap: .5rem; align-items: center; }
.mp-row input { margin: 0; }
.evidence { display: grid; gap: .3rem; } .evidence label { margin-bottom: .3rem; }
.actions { display: flex; gap: .6rem; }
.checks { margin-bottom: .8rem; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form select { width: auto; margin: 0; }
details { margin: .5rem 0; } summary { cursor: pointer; color: var(--navy-2); font-weight: 600; padding: .3rem 0; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: .5rem .95rem; border-radius: 7px; border: 1px solid #c3ccd8;
  background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: #f3f6fa; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; } .btn.primary:hover { background: var(--navy-2); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warn { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.btn.danger { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: .2rem .55rem; font-size: .8rem; }
.btn.block { display: block; width: 100%; margin-top: .4rem; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid; }
.flash-success { background: var(--green-bg); border-color: #a9d8b9; color: var(--green); }
.flash-error { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }

/* Chi tiết */
.detail-head { margin-bottom: 1rem; } .detail-head h1 { margin: .3rem 0 .4rem; }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem 1rem; margin: 0; }
.facts dt { font-size: .8rem; color: var(--muted); } .facts dd { margin: 0; font-weight: 600; }
.facts .due { color: var(--navy); }
.prose { white-space: pre-wrap; } .prose.result { background: var(--green-bg); padding: .6rem .8rem; border-radius: 8px; }
.memberlist { margin: 0; padding-left: 1.1rem; }
.range-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.range-row input[type=range] { flex: 1; height: 32px; accent-color: var(--navy); }
.range-row input[type=number] { width: 78px; margin: 0; font-size: 1.1rem; font-weight: 700; text-align: center; }
.quick { border-top: 4px solid var(--blue); }
.leader { border-top: 4px solid var(--navy); }
.leader form { margin-bottom: .6rem; }
/* Công đoạn */
.stages { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.stage { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: .6rem .75rem; margin-bottom: .6rem; background: #fff; }
.stage.st-done-row { border-left-color: var(--green); background: #f8fcf9; }
.stage.stage-overdue { border-left-color: var(--red); background: #fffafa; }
.stage.stage-soon { border-left-color: var(--amber); background: #fffdf7; }
.stage-head { display: flex; gap: .6rem; align-items: flex-start; }
.stage-no { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--blue-soft); color: var(--navy);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.st-done-row .stage-no { background: var(--green); color: #fff; }
.stage-overdue .stage-no { background: var(--red); color: #fff; }
.stage-main { flex: 1; min-width: 0; }
.stage-badge { flex: none; }
.stage-result { margin: .35rem 0 0 2.3rem; color: var(--green); }
.stage-actions { margin-left: 2.3rem; display: flex; gap: 0 1rem; flex-wrap: wrap; }
.stage-actions details { flex: 0 1 auto; margin: .1rem 0; }
.stage-actions details[open] { flex-basis: 100%; }
.stage-actions summary { font-size: .88rem; }
.add-stage summary { color: var(--navy); }
.delete-box { border-top: 1px dashed var(--line); margin-top: .8rem; padding-top: .4rem; }
.delete-box summary { color: var(--red); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 .9rem .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline.compact li { padding-bottom: .6rem; }
.tl-head { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.issue { background: var(--amber-bg); padding: .3rem .5rem; border-radius: 6px; margin-top: .2rem; }
.atts { list-style: none; padding: 0; margin: .3rem 0; } .atts li { padding: .2rem 0; }
.comment { border-bottom: 1px solid var(--line); padding: .5rem 0; }
#binh-luan form { margin-top: .6rem; }

/* Thông báo */
.notifs { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem .4rem; border-bottom: 1px solid var(--line); }
.notif.unread { background: #f6f9ff; } .notif.unread a { font-weight: 600; }
.notif.k-overdue.unread { background: #fff6f5; }

/* Đăng nhập */
.auth { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.auth-head { text-align: center; margin-bottom: 1.2rem; } .auth-head h1 { margin-top: .7rem; }
.errcode { font-size: 3rem; font-weight: 700; color: var(--navy); margin: 0; }
.invite-box { border-left: 5px solid var(--green); }
.roles-form { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; }
.actions-cell { display: flex; gap: .3rem; flex-wrap: wrap; }
.report-meta p { margin: .2rem 0; }

.bottomnav { display: none; }
/* KPI */
meter { width: 90px; height: 10px; vertical-align: middle; }
meter.mini { width: 46px; height: 8px; }
.kpi-val { display: inline-block; min-width: 2.6rem; font-weight: 700; color: var(--navy); }
.kpicard { display: block; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .85rem; margin-bottom: .6rem;
  text-decoration: none; color: var(--text); background: #fff; }
.kc-top { display: flex; justify-content: space-between; align-items: baseline; }
.kc-num { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
meter.wide { width: 100%; height: 12px; margin: .2rem 0 .3rem; }
.kc-meta { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .3rem; }
.kc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .8rem; color: var(--muted); }
.kc-stats b { color: var(--text); }
.kc-s { font-size: 1.1rem; color: var(--navy); }
.formula ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.formula summary { font-size: 1rem; }
.mobile-only { display: none; }

/* Điện thoại */
@media (max-width: 860px) {
  .topbar { padding: .5rem .8rem; gap: .6rem; }
  .mainnav { display: none; }
  .brand-text small { display: none; }
  .userbox { margin-left: auto; }
  .usermenu summary { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
  .container { padding: .8rem; padding-bottom: 5.5rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat { padding: .7rem .8rem; } .stat-num { font-size: 1.6rem; }
  .grid2, .detail-grid, .row3 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .mp-row { grid-template-columns: 1fr; }
  .stage-actions, .stage-result { margin-left: 0; }
  .stage-head { flex-wrap: wrap; }
  .stage-badge { flex-basis: 100%; margin-left: 2.3rem; }
  .desktop-only { display: none; } .mobile-only { display: block; }
  .filters input[type=search] { min-width: 100%; }
  .filters select, .filters label.inline { flex: 1 1 45%; }
  /* Trên điện thoại: hạn & tiến độ -> cập nhật nhanh -> điều hành -> nội dung khác */
  .detail-grid { display: flex; flex-direction: column; gap: 0; align-items: stretch; }
  .col-main, .col-side { display: contents; }
  .detail-grid .panel { order: 5; }
  .detail-grid .p-facts { order: 1; }
  .detail-grid .p-stages { order: 2; }
  .detail-grid .quick { order: 2; }
  .detail-grid .leader { order: 3; }
  .detail-grid .p-hist { order: 9; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
    z-index: 30; box-shadow: 0 -2px 8px rgba(0,0,0,.05); }
  .bottomnav a { flex: 1; text-align: center; padding: .75rem .2rem; font-size: .82rem; font-weight: 600; color: var(--navy); text-decoration: none; }
  input, select, textarea { font-size: 16px; } /* tránh iOS tự phóng to */
  .btn { padding: .65rem 1rem; }
}
