:root {
  --navy: #12355b; --navy2: #1c4a7a; --blue: #1f6feb; --bg: #f2f5f9; --card: #fff; --line: #d9e0ea;
  --text: #1b2430; --muted: #66758a; --ok: #1a7f37; --warn: #b26b00; --bad: #c62828; --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; color: var(--navy); }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--navy); }
h3 { font-size: 15px; margin: 14px 0 6px; }
code { font-size: 12.5px; background: #eef2f8; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .danger { color: var(--bad); }
.warn-text { color: var(--warn); } .dim { opacity: .5; } .nowrap { white-space: nowrap; }
.lead { font-size: 15.5px; color: #344256; }

/* ---------- Đầu trang và tab */
header.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; flex: 1; min-width: 0; }
.brand:hover { text-decoration: none; }
.logo { background: #fff; color: var(--navy); font-weight: 800; font-size: 12px; letter-spacing: .5px;
  border-radius: 8px; padding: 6px 7px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.login-link { color: #fff; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 8px; }

.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; align-items: flex-end;
  background: rgba(255,255,255,.12); padding: 5px 10px; border-radius: 8px; max-width: 46vw; }
.usermenu summary::-webkit-details-marker { display: none; }
.uname { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.urole { font-size: 11px; opacity: .8; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(18,53,91,.18); min-width: 220px; z-index: 50; overflow: hidden; }
.menu-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.menu-head small { font-weight: 400; color: var(--muted); }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: 0;
  font: inherit; color: var(--text); cursor: pointer; }
.menu a:hover, .menu button:hover { background: #f1f5fb; text-decoration: none; }

nav.tabs { background: var(--navy2); display: flex; overflow-x: auto; scrollbar-width: none; padding: 0 8px; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { color: #dbe6f3; padding: 10px 14px; white-space: nowrap; border-bottom: 3px solid transparent; font-size: 14.5px; }
nav.tabs a:hover { color: #fff; text-decoration: none; }
nav.tabs a.on { color: #fff; border-bottom-color: #ffc94a; font-weight: 600; }

/* ---------- Bố cục */
main.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px 28px; flex: 1; }
main.page.narrow { max-width: 520px; }
main.page.center { display: flex; align-items: flex-start; justify-content: center; padding-top: 6vh; }
main.page.with-side { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
main.page.with-side > .body { min-width: 0; }
.subnav { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 10px; }
.subnav-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 10px; }
.subnav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.subnav a:hover { background: #f1f5fb; text-decoration: none; }
.subnav a.on { background: #e6efff; color: var(--blue); font-weight: 600; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 18px 12px 84px; border-top: 1px solid var(--line); margin-top: 24px; }
.foot-brand { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.foot-links { margin-bottom: 8px; }
.foot-links a { color: var(--blue); }
.foot-note { margin-top: 8px; font-size: 11.5px; opacity: .8; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h1, .card-head h2 { margin: 0; }
.card.soon { background: #fbfcfe; border-style: dashed; }
.card.soon ul { margin: 6px 0 0; padding-left: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; } .grid2 + * { margin-top: 16px; }
.hello { margin-bottom: 14px; } .hello h1 { margin-bottom: 2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; color: var(--navy); }
.stat span { font-size: 13px; color: var(--muted); }

.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card .shortcuts { margin-bottom: 0; }
.sc { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfcfe; color: var(--text); }
.sc:hover { border-color: var(--blue); text-decoration: none; }
.sc b { display: block; color: var(--navy); } .sc small { color: var(--muted); }

.pill { display: inline-block; background: #e6efff; color: var(--navy); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge { display: inline-block; font-size: 12px; border-radius: 6px; padding: 1px 7px; background: #eef2f8; color: #344256; }
.badge.st-dang_lam { background: #e7f5ec; color: var(--ok); }
.badge.st-nghi_phep, .badge.st-nghi_om, .badge.st-di_hoc { background: #fff3df; color: var(--warn); }
.badge.st-nghi_viec { background: #f3f3f3; color: #777; }
.badge.ok { background: #e7f5ec; color: var(--ok); } .badge.bad { background: #fdeaea; color: var(--bad); }

ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 5px 0; border-bottom: 1px solid #eef1f5; }
ul.plain li:last-child { border-bottom: 0; }

/* ---------- Bảng */
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
th { background: #f4f7fb; font-weight: 600; color: #344256; white-space: nowrap; }
table.edit input:not([type=checkbox]) { width: 100%; min-width: 70px; padding: 6px 7px; font-size: 13.5px; }
table.edit input.num { width: 64px; min-width: 0; }

/* ---------- Biểu mẫu */
form.card label, .form label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: #344256; }
form.card label small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; color: var(--text); }
form.card label input, form.card label select, form.card label textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,235,.12); }
input:disabled { background: #f4f6f9; color: var(--muted); }
label.check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
label.check input { width: auto !important; margin: 0 !important; }
.form .grid2 { gap: 0 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters input { flex: 1; min-width: 180px; }
.err { color: var(--bad); font-size: 14px; margin: 0 0 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }
.login h1 { margin-bottom: 4px; } .login { width: 100%; }

.btn { display: inline-block; font: inherit; font-size: 14.5px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; line-height: 1.3; }
.btn:hover { border-color: #b8c4d6; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1a5fd0; }
.btn.danger { color: var(--bad); border-color: #f0c4c4; }
.btn.small { font-size: 13px; padding: 5px 10px; }
.btn.block { width: 100%; padding: 11px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
button.link.danger { color: var(--bad); }

.flashes { max-width: 1180px; margin: 12px auto 0; padding: 0 16px; width: 100%; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; background: #e7f5ec; color: #145c2b; border: 1px solid #bfe3cb; }
.flash.err { background: #fdeaea; color: #8e1c1c; border-color: #f3c3c3; }
.flash.info { background: #e6efff; color: #173f7a; border-color: #c4d7f7; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 14px 0; }
.tabs-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs-inline > * { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 13.5px; }
.tabs-inline > .on { background: var(--navy); color: #fff; border-color: var(--navy); }

details > summary { cursor: pointer; padding: 4px 0; }
details.log summary { list-style: none; }
.prose p { margin: 0 0 8px; } .prose ul, .prose ol { margin: 4px 0 8px; padding-left: 22px; }
li.d1 { margin-left: 16px; list-style: circle; } li.d2 { margin-left: 32px; list-style: square; } li.d3 { margin-left: 48px; list-style: square; }

.ann-list { list-style: none; margin: 0; padding: 0; }
.ann { padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.ann:last-child { border-bottom: 0; }
.ann.pinned { background: #fffaf0; margin: 0 -18px; padding: 10px 18px; }
.ann-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.ann-body { margin-top: 4px; }

/* ---------- Trang tra cứu (khung chat cao hết màn hình) */
body.chat-page { height: 100vh; height: 100dvh; overflow: hidden; }
main.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; }
.chat-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; max-width: 840px; width: 100%; margin: 0 auto; padding: 8px 12px 0; }
#msgs { flex: 1; overflow-y: auto; padding: 10px 12px 6px; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 820px; margin: 0 auto; }
.msg { margin: 0 0 12px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.bubble { max-width: 94%; padding: 10px 13px; border-radius: 14px; line-height: 1.55; font-size: 15px; overflow-wrap: anywhere; }
.bot .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.user .bubble { background: var(--blue); color: #fff; border-top-right-radius: 4px; white-space: pre-wrap; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble table { font-size: 13.5px; }
.bubble .fine { margin-top: 8px; font-size: 12px; color: var(--muted); }
.bubble.typing { color: var(--muted); font-style: italic; }
.rate { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rate button { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 10px; cursor: pointer; color: var(--text); }
.rate button:hover { border-color: var(--blue); color: var(--blue); }
.chips { display: flex; flex-direction: column; gap: 7px; margin: 0 0 12px; }
.chips-head { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.chip { text-align: left; background: #fff; border: 1px solid var(--blue); color: var(--blue); border-radius: 10px; padding: 9px 12px; cursor: pointer; line-height: 1.35; font: inherit; font-size: 14.5px; }
.chip:hover, .chip:active { background: #eaf2ff; }
.fu .chip { padding: 7px 11px; font-size: 13.5px; border-radius: 16px; border-color: #9db9e8; }
#bar { background: #fff; border-top: 1px solid var(--line); padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#bar form { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
#bar textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; font-size: 16px; border-radius: 10px; }

/* ---------- Điện thoại */
@media (max-width: 860px) {
  main.page.with-side { grid-template-columns: 1fr; gap: 12px; }
  .subnav { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 6px; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav-title { display: none; }
  .subnav a { white-space: nowrap; flex: none; padding: 7px 11px; font-size: 14px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  header.top { padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); }
  .brand-text small { display: none; }
  .brand-text b { font-size: 14.5px; }
  .urole { display: none; }
  nav.tabs a { padding: 9px 11px; font-size: 14px; }
  main.page { padding: 12px 10px 20px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 > .card { margin-bottom: 0; }
  .card { padding: 13px 14px; }
  .ann.pinned { margin: 0 -14px; padding: 10px 14px; }
  h1 { font-size: 19px; }
  .bubble { max-width: 97%; font-size: 14.5px; padding: 9px 11px; }
  body.typing-mode nav.tabs, body.typing-mode .chat-tools { display: none; }
}

/* Bảng danh sách thành dạng thẻ trên điện thoại */
@media (max-width: 640px) {
  table.rows tr:first-child { display: none; }
  table.rows tr { display: block; padding: 9px 2px; border-bottom: 1px solid var(--line); }
  table.rows td { display: inline-block; border: 0; padding: 1px 8px 1px 0; vertical-align: middle; }
  table.rows td:first-child { color: var(--muted); font-size: 12.5px; }
}

/* ---------- Sổ trực */
main.page.narrow-wide { max-width: 900px; }
.badge.log-dang_ghi { background: #e6efff; color: var(--blue); }
.badge.log-da_giao { background: #fff3df; color: var(--warn); }
.badge.log-da_nhan { background: #e7f5ec; color: var(--ok); }
.badge.big { font-size: 13.5px; padding: 4px 10px; }
.pending { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; color: var(--text); background: #fbfcfe; }
.pending.da_giao { border-left-color: var(--warn); }
.pending:hover { text-decoration: none; border-color: var(--blue); }
.pending .go { margin-left: auto; color: var(--blue); font-size: 13.5px; }
.open-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.log-head h1 { font-size: 18px; margin: 2px 0 0; }
.log-head p { margin: 8px 0; }
.handover-prev { border-left: 4px solid var(--warn); background: #fffaf0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; margin-bottom: 10px; }
.hgrid label { font-size: 13px; font-weight: 600; color: #344256; }
.hgrid input { display: block; width: 100%; margin-top: 3px; font-weight: 400; padding: 7px 9px; }
.hgrid.ro div { padding: 4px 0; }
h2.group-title { font-size: 15px; margin: 18px 0 10px; }
.log-sec h2 { font-size: 15px; }
table.checks td.c, table.checks th.c { text-align: center; width: 90px; }
table.checks td input[type=radio] { width: 20px; height: 20px; }
table.checks td input:not([type=radio]) { width: 100%; padding: 6px 8px; font-size: 14px; }
table.checks tr.bad td { background: #fdeaea; }
.entries { list-style: none; margin: 0 0 10px; padding: 0; }
.entries li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eef1f5; }
.entries .t { flex: none; font-weight: 700; color: var(--navy); min-width: 46px; font-variant-numeric: tabular-nums; }
.entries .ec { flex: 1; min-width: 0; }
.edit-entry { margin-top: 4px; }
.entry-form { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.entry-form input[type=time] { width: 110px; flex: none; }
.entry-form textarea { flex: 1; min-width: 220px; }
.entry-form .actions { flex-basis: 100%; }
.entry-form.add { border-top: 1px dashed var(--line); padding-top: 10px; }
.noinc { margin: 6px 0; }
.checkbox-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 0; font: inherit; cursor: pointer; color: var(--text); }
.checkbox-btn .box { display: inline-flex; width: 22px; height: 22px; border: 2px solid #344256; border-radius: 4px; align-items: center; justify-content: center; font-weight: 800; }
.checkbox-btn.on .box { background: #e7f5ec; border-color: var(--ok); color: var(--ok); }
.checkbox-btn:disabled { opacity: .45; cursor: default; }
#ban-giao textarea { width: 100%; margin-bottom: 8px; }
.sign { display: flex; flex-wrap: wrap; gap: 20px 60px; margin: 12px 0; }
.reopen { margin-top: 10px; }
@media (max-width: 640px) {
  .entry-form input[type=time] { width: 96px; }
  .entry-form textarea { min-width: 0; flex-basis: 100%; }
  .hgrid { grid-template-columns: 1fr 1fr; }
  table.checks td.c, table.checks th.c { width: 54px; }
}

/* ---------- Lịch trực tháng */
.body.wide { max-width: none; min-width: 0; }
.sch-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.sch-head h1 { margin: 0; }
.sch-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.sch-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.sch-bar .grow { flex: 1; }
.sch-set { margin-bottom: 10px; }
.sch-set summary { cursor: pointer; font-weight: 600; }
.sch-wrap { overflow: auto; max-height: 78vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table.sch { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: max-content; min-width: 100%; }
table.sch th, table.sch td { border-right: 1px solid #e3e8ef; border-bottom: 1px solid #e3e8ef; padding: 0; text-align: center; background: #fff; }
table.sch thead th { position: sticky; top: 0; z-index: 3; background: #eef2f8; font-weight: 700; padding: 3px 0; min-width: 28px; }
table.sch thead th small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
table.sch th.we, table.sch td.we { background: #fff7dd; }
table.sch thead th.today { background: #cfe3ff; }
table.sch .c-stt { position: sticky; left: 0; z-index: 2; min-width: 30px; background: #f7f9fc; color: var(--muted); }
table.sch .c-name { position: sticky; left: 30px; z-index: 2; min-width: 170px; max-width: 200px; text-align: left; padding: 3px 8px; background: #f7f9fc; white-space: nowrap; }
table.sch .c-name small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 400; }
table.sch thead .c-stt, table.sch thead .c-name { z-index: 4; background: #e3e9f3; }
table.sch tr.me .c-name { box-shadow: inset 3px 0 0 var(--blue); }
table.sch td.cell { min-width: 28px; height: 30px; cursor: default; font-weight: 600; user-select: none; }
table.sch td.cell:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
table.sch td.cell.sel { box-shadow: inset 0 0 0 2px var(--blue); background-image: linear-gradient(rgba(31,111,235,.16), rgba(31,111,235,.16)); }
table.sch[data-edit="1"] td.cell { cursor: pointer; }
table.sch th.tot, table.sch td.tot { min-width: 54px; padding: 0 4px; font-weight: 700; background: #f1f5fb; }
table.sch td.t-total.low { color: var(--bad); }
table.sch tfoot td { background: #f7f9fc; font-size: 11.5px; color: #44546a; }
table.sch tfoot .c-name { font-weight: 600; }
table.sch.busy { opacity: .7; }
.pal { position: absolute; z-index: 20; display: flex; flex-wrap: wrap; gap: 4px; max-width: 330px; padding: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(15,35,70,.22); }
.pal[hidden] { display: none; }
.pal button { font: inherit; font-size: 13px; font-weight: 700; min-width: 40px; padding: 7px 8px; border: 1px solid #cfd8e6; border-radius: 7px; background: #f3f5f9; cursor: pointer; }
.pal button:hover { border-color: var(--blue); }
.pal button.clear { color: var(--bad); }
.sch-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.sch-legend i.sw { display: inline-block; min-width: 28px; padding: 1px 6px; text-align: center; font-style: normal; font-weight: 700; border-radius: 5px; border: 1px solid #d5dce8; color: var(--text); }
ul.warns { margin: 6px 0 0; padding-left: 20px; }
ul.warns li { margin: 3px 0; font-size: 14px; }
ul.warns li.w-loi { color: var(--bad); }
ul.warns li.w-canh_bao { color: #8a5a00; }
kbd { background: #eef1f6; border: 1px solid #d5dce8; border-radius: 4px; padding: 0 5px; font-size: 12px; }
@media print {
  .sch-wrap { max-height: none; overflow: visible; border: 0; }
  .sch-nav, .sch-bar, .sch-set, .pal, #warnbox, .sch-legend + p { display: none !important; }
}
.form label.full { grid-column: 1 / -1; }
input.w90 { width: 90px; }

/* ---------- Trạng thái làm việc (trang chủ) */
.status { margin-top: 18px; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .status-grid { grid-template-columns: 1fr; } }
.status-grid .card.duty { padding: 12px 14px; }
.duty-half { margin: 14px 0 8px; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.duty-shift { flex-wrap: wrap; row-gap: 4px; }
.duty-list li { align-items: center; }
.duty-list .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duty-list .shc { flex: none; font-size: 11.5px; font-weight: 600; color: var(--navy); background: #eef3fb; border-radius: 6px; padding: 1px 6px; }
.card.duty h3 { margin: 0; font-size: 17px; }
.duty-shift { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.duty-list { list-style: none; margin: 0 0 8px; padding: 0; }
.duty-list li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid #eef1f6; font-size: 14.5px; }
.duty-list li.empty { background: #fff5f5; }
.duty-list .posc { display: inline-block; flex: none; min-width: 40px; font-size: 12.5px; color: var(--navy); }
.ok-text { color: #14702f; }
.warn-text { color: #a15c00; }

/* ---------- Trợ lý AI (ô chat) */
.ai-fab { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60; background: var(--navy); color: #fff;
  border: 0; border-radius: 24px; padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgba(15,35,70,.35); }
.ai-fab:hover { background: var(--navy2); }
.ai-fab[hidden], .ai-panel[hidden] { display: none; }
.ai-panel { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 61; width: 400px; max-width: calc(100vw - 24px);
  height: 560px; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 32px rgba(15,35,70,.3); display: flex; flex-direction: column; overflow: hidden; }
.ai-head { display: flex; align-items: center; gap: 6px; background: var(--navy); color: #fff; padding: 9px 12px; }
.ai-head .grow { flex: 1; }
.ai-hbtn { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 7px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.ai-hbtn:hover { background: rgba(255,255,255,.28); }
.ai-thread { flex: 1; overflow-y: auto; padding: 12px; background: var(--bg); }
.ai-msg { display: flex; margin-bottom: 10px; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: 94%; padding: 9px 12px; border-radius: 14px; line-height: 1.5; font-size: 14.5px; overflow-wrap: anywhere; }
.ai-msg.bot .ai-bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.ai-msg.user .ai-bubble { background: var(--blue); color: #fff; border-top-right-radius: 4px; white-space: pre-wrap; }
.ai-bubble p { margin: 0 0 6px; } .ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 4px 0 6px; padding-left: 20px; }
.ai-bubble .tbl { overflow-x: auto; } .ai-bubble table { font-size: 13px; }
.ai-bubble.ai-typing { color: var(--muted); font-style: italic; }
.ai-bubble.ai-proposal { border-color: var(--blue); width: 100%; max-width: 100%; }
.ai-warn { color: #8a5a00; font-size: 13px; }
.ai-actions { margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.ai-chips { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 6px; background: var(--bg); }
.ai-chips:empty { display: none; }
.ai-chip { text-align: left; background: #fff; border: 1px solid var(--blue); color: var(--blue); border-radius: 10px; padding: 7px 11px; cursor: pointer; font: inherit; font-size: 13.5px; }
.ai-chip:hover { background: #eaf2ff; }
.ai-form { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); background: #fff; align-items: flex-end; }
.ai-form textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; max-height: 120px; }
.ai-fine { margin: 0; padding: 0 12px 8px; font-size: 11.5px; color: var(--muted); background: #fff; }
@media (max-width: 600px) {
  .ai-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 85vh; height: 85dvh; border-radius: 14px 14px 0 0; }
}
@media print { .aichat { display: none !important; } }

/* ---------- Công cụ & tài sản */
.badge.as-tot { background: #e7f5ec; color: var(--ok); }
.badge.as-hong { background: #fdeaea; color: var(--bad); }
.badge.as-dang_muon { background: #fff3d6; color: #8a5a00; }
.badge.as-thanh_ly { background: #f3f3f3; color: #777; }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }

/* ---------- Giám sát thi công */
.badge.tc-dang { background: #e6efff; color: var(--blue); }
.badge.tc-sap { background: #f3f3f3; color: #555; }
.badge.tc-qua_han { background: #fdeaea; color: var(--bad); }
.badge.tc-tam_dung { background: #fff3d6; color: #8a5a00; }
.badge.tc-xong { background: #e7f5ec; color: var(--ok); }
a.stat { color: inherit; text-decoration: none; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 110px 1fr; } }
.filters label { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.filters label input { flex: none; min-width: 0; }
.form label #act-note { display: block; width: 100%; margin-top: 4px; }
p.pre { white-space: pre-wrap; margin: 4px 0 8px; }
.foot-contact { font-size: 13.5px; margin-bottom: 4px; color: var(--text); }

/* Ô chat nằm trong trang của một mục */
.ai-inline { padding: 0; overflow: hidden; margin-bottom: 14px; border-color: #b9cdf0; }
.ai-inline-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #eaf2ff; padding: 8px 14px; }
.ai-inline-head h2 { margin: 0; font-size: 16px; }
.ai-inline .ai-thread { max-height: 360px; min-height: 90px; }
.ai-inline .ai-fine { padding: 0 14px 8px; }
.ai-inline .ai-chips { padding: 0 12px 8px; flex-direction: row; flex-wrap: wrap; }

table.rows td.num, table.rows th.num { text-align: right; }

/* ---------- Giám sát cân hành lý xách tay */
.badge.cn-da { background: #e7f5ec; color: var(--ok); }
.badge.cn-cho { background: #f3f3f3; color: #555; }
.badge.cn-qua_han, .badge.cn-loi { background: #fdeaea; color: var(--bad); }
.scanbox video { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; }
fieldset.chk { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 12px; }
fieldset.chk legend { font-weight: 600; padding: 0 6px; }
fieldset.chk .radio { display: inline-flex; margin-right: 18px; }
.qrimg { display: block; margin: 8px 0; background: #fff; }
fieldset.chk label.radio { display: inline-flex; align-items: center; gap: 8px; margin: 0 18px 8px 0; font-size: 16px; }
fieldset.chk input[type=radio] { width: 22px; height: 22px; margin: 0; flex: none; }
fieldset.chk input:not([type=radio]) { width: 100%; box-sizing: border-box; }

table.rows tr.mine td { background: #fff7dd; }
.training-note { border-left: 4px solid #c9900c; }
.big-code { font-size: 26px; letter-spacing: 4px; }
.ann details > summary { cursor: pointer; list-style: none; }
.ann details > summary::-webkit-details-marker { display: none; }
.ann details > summary::before { content: "▸"; color: #7a8aa0; margin-right: 6px; display: inline-block; transition: transform .15s; }
.ann details[open] > summary::before { transform: rotate(90deg); }
.ann-head b { flex: 1 1 60%; min-width: 0; }
.ann-full { margin: 6px 0 2px 16px; }
.ann-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }

/* Mục Tồn tại: màu theo số ngày tồn; ô «Đã hoàn thành» mở ngay trong dòng */
.badge.age { background: #e7f5ec; color: var(--ok); }
.badge.age.warn { background: #fff3d6; color: #8a5a00; }
.badge.age.bad { background: #fde8e8; color: #b42318; }
.done-box { display: inline-block; vertical-align: top; margin-left: 6px; }
.done-box summary { list-style: none; cursor: pointer; display: inline-block; }
.done-box form { margin-top: 6px; display: grid; gap: 6px; min-width: 220px; }

/* Danh sách dài thu gọn: hiện vài mục đầu, phần còn lại bấm «Xem thêm» */
details.more > summary { list-style: none; cursor: pointer; color: var(--navy); font-size: 13.5px; padding: 6px 0 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▾ "; }
details.more[open] > summary::before { content: "▴ "; font-size: 13.5px; }
details.more[open] > summary { font-size: 0; padding: 0; }
details.more[open] > summary::after { content: "Thu gọn"; font-size: 13.5px; }
details.more[open] { display: flex; flex-direction: column-reverse; }
