/* Bảng màu MasterOffice (2026-10-28): xanh đen thương hiệu, cyan = điện, xanh dương = nước; giống web/src/app/globals.css */
:root {
  --bg: #f4f7fb; --card: #fff; --line: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --accent: #2563eb; --accent-soft: #e8f0fe; --ok: #15803d; --warn: #b45309; --bad: #b42318;
  --ink: #07111f; --navy: #0a1628; --cyan: #22d3ee;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg); }
#doc { background-color: var(--bg); background-image: linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px); background-size: 36px 36px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 6px 12px; }
button:hover { border-color: #c3c9d3; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: linear-gradient(90deg, #0ea5e9, var(--accent)); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 13px; }
button.wide { width: 100%; }
input[type=text], textarea, select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%; }
input:focus, textarea:focus, select:focus, [contenteditable]:focus { outline: 2px solid #9dbdf5; outline-offset: 0; }
textarea { resize: vertical; }

#app { display: grid; grid-template-columns: 44px minmax(0, 1fr) 350px; height: 100vh; }
#side { background: var(--navy); border-right: 1px solid rgba(255, 255, 255, .06); padding: 6px; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#side .raillogo { display: block; width: 32px; height: 32px; margin-top: 2px; }
#side .raillogo img { width: 32px; height: 32px; display: block; }
#side .burger { width: 32px; height: 32px; padding: 0; font-size: 18px; border: 0; color: #cbd5e1; border-radius: 8px; }
#side .burger:hover { background: rgba(255, 255, 255, .08); color: #fff; }
#side .sidebody { display: none; }
#side.open { position: fixed; left: 0; top: 0; bottom: 0; width: 372px; max-width: 92vw; z-index: 40; padding: 0; overflow: auto; background: #fbfcfd; box-shadow: 8px 0 30px rgba(15, 23, 42, .18); animation: slidein .16s ease-out; scrollbar-width: thin; }
#side.open .burger, #side.open .raillogo { display: none; }
#side.open { display: block; }
@keyframes slidein { from { transform: translateX(-18px); opacity: .4; } to { transform: none; opacity: 1; } }
#side.open .sidebody { display: block; }
main { grid-column: 2; } #chat { grid-column: 3; } /* giữ nguyên chỗ khi thanh trái xổ ra đè lên */
.zoom { display: flex; gap: 4px; align-items: center; flex: none; }
#zval { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; white-space: nowrap; }
#doc.pdfmode { padding: 0; overflow: hidden; display: flex; }
iframe.pdf { flex: 1; border: 0; width: 100%; height: 100%; }
.brand { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.cap { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.titem { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 6px; cursor: pointer; }
.titem:hover { background: var(--bg); }
.titem.on { background: var(--accent-soft); }
.badge { flex: none; width: 22px; height: 22px; border-radius: 4px; color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.badge.docx { background: #2b579a; } .badge.xlsx { background: #217346; }
.tname { font-weight: 600; word-break: break-word; }
.tmeta, .hint { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); padding: 10px 4px; }

/* Thanh kho mẫu + danh mục dự án */
.sidebody { padding: 0 12px 16px; }
.shead { position: sticky; top: 0; z-index: 3; margin: 0 -12px; padding: 12px 12px 10px; background: linear-gradient(#fbfcfd 82%, rgba(251, 252, 253, 0)); }
.brandrow { display: flex; align-items: center; gap: 10px; }
.brandrow > div { flex: 1; min-width: 0; }
.brandrow .brand { margin: 0; font-size: 15px; line-height: 1.2; }
.logo { flex: none; width: 34px; height: 34px; border-radius: 9px; display: block; box-shadow: 0 2px 8px rgba(7, 17, 31, .25); }
.bsub { font-size: 12px; color: var(--muted); }
.sbox { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 0 8px; height: 34px; background: #fff; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); transition: border-color .12s, box-shadow .12s; }
.sbox:focus-within { border-color: #9dbdf5; box-shadow: 0 0 0 3px rgba(29, 95, 209, .12); }
.sbox input[type=text] { border: 0; padding: 0; background: none; flex: 1; min-width: 0; outline: none; color: var(--text); }
.ico { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; display: block; }
.c-folder { color: #f0b429; } .c-proj { color: #6366f1; } .c-job { color: #0e9f6e; } .c-bad { color: var(--bad); } .c-soft { color: #9aa3b0; }
button.tool { flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
button.tool:hover { background: #e9edf3; color: var(--text); }
button.tool .ico { width: 15px; height: 15px; }
.sec { display: flex; align-items: center; gap: 7px; margin: 18px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.sec .stitle { font-weight: 700; font-size: 13px; letter-spacing: .01em; }
.sec .scount { font-size: 11px; color: var(--muted); background: #eef1f5; border-radius: 9px; padding: 0 7px; }
.sec .scount:empty { display: none; }
.sec .sp { flex: 1; }
.sec button.add { border-radius: 7px; color: var(--accent); border-color: #c9d8f5; background: #fff; font-weight: 600; padding: 2px 9px; }
.sec button.add:hover { background: var(--accent-soft); }
.tree { user-select: none; }
.tree .cap { margin: 14px 0 4px; }
.trow { position: relative; display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 3px 4px 3px 2px; border-radius: 7px; cursor: pointer; transition: background .1s; }
.trow:hover { background: #eef2f7; }
.trow.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.trow.on .tname { color: #0f3d91; font-weight: 600; }
.trow .caret { flex: none; width: 14px; height: 14px; color: #a3abb8; display: grid; place-items: center; }
.trow .caret .ico { width: 12px; height: 12px; transition: transform .12s; }
.trow .caret.open .ico { transform: rotate(90deg); }
.trow .tname { flex: 1; min-width: 0; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
.trow.dir > .tname { font-weight: 600; }
.trow.proj > .tname { font-weight: 600; }
.trow.grp { min-height: 26px; }
.trow.grp > .tname { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #7b8494; }
.trow.soft > .tname { color: var(--muted); font-weight: 500; }
.trow.two { align-items: center; min-height: 40px; }
.trow.two .tname { display: flex; flex-direction: column; overflow: hidden; line-height: 1.3; }
.tmain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsub { font-size: 11.5px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow.on .tsub { color: #5b78b3; }
.hit { background: #fde68a; border-radius: 2px; font-weight: 700; }
.trow .tcount { flex: none; font-size: 11px; color: var(--muted); background: #eef1f5; border-radius: 9px; padding: 0 7px; line-height: 17px; }
.trow:hover .tcount { background: #fff; }
.trow .tsize { flex: none; font-size: 11px; color: #a3abb8; }
.chip { flex: none; font-size: 10.5px; line-height: 16px; padding: 0 6px; border-radius: 8px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.chip.ok { background: #e3f6ec; color: #17794a; } .chip.warn { background: #fff3d6; color: #a15c07; } .chip.bad { background: #fde8e6; color: var(--bad); }
.fbadge { flex: none; min-width: 20px; height: 18px; padding: 0 3px; border-radius: 4px; display: inline-grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .02em; background: #8a94a3; }
.fbadge.w { background: #2b579a; } .fbadge.x { background: #217346; } .fbadge.pdf { background: #d93025; font-size: 8.5px; } .fbadge.img { background: #8b5cf6; font-size: 8.5px; } .fbadge.oth { font-size: 8.5px; }
.trow .more { flex: none; width: 24px; height: 22px; padding: 0; border: 0; border-radius: 5px; line-height: 1; color: var(--muted); display: none; }
.trow:hover .more { display: block; }
.trow:hover .tsize { display: none; }
.trow .more:hover { background: #dfe5ee; color: var(--text); }
.kids { margin-left: 9px; padding-left: 9px; border-left: 1px solid #e3e7ee; }
.kids:hover { border-left-color: #c9d1dd; }
.trow.none { min-height: 26px; padding-left: 20px; color: var(--muted); font-size: 12px; font-style: italic; cursor: default; display: block; line-height: 20px; white-space: normal; }
.trow.none:hover { background: none; }
.trow.none a { font-style: normal; color: var(--accent); cursor: pointer; white-space: nowrap; }
.trow.none a:hover { text-decoration: underline; }
.tree.recent { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.nores { text-align: center; color: var(--muted); padding: 34px 10px; }
.treehint { margin-top: 18px; padding: 8px 10px; background: #f1f4f8; border-radius: 8px; }
.frow .ico { color: #f0b429; } .frow .ico.c-proj { color: #6366f1; }
.frow.on .ico { color: #fff; }
.srcrow { display: flex; align-items: center; gap: 6px; }
.srcrow a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srcrow button { flex: none; border: 0; padding: 0 6px; }
.fpath { font-size: 12px; opacity: .7; }
.ctx { position: fixed; z-index: 60; min-width: 190px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.ctx button { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; padding: 6px 10px; background: none; }
.ctx button:hover { background: var(--accent-soft); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.ftree { border: 1px solid var(--line); border-radius: 6px; max-height: 46vh; overflow: auto; padding: 4px; margin-top: 8px; user-select: none; }
.frow { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.frow:hover { background: var(--bg); }
.frow.on { background: var(--accent); color: #fff; }
.frow.off { opacity: .4; cursor: not-allowed; }
.fnew { display: flex; gap: 6px; margin-top: 8px; }
.fnew button { flex: none; }

main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
#top { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
#top input.name { font-size: 16px; font-weight: 600; border-color: transparent; flex: 1; min-width: 0; }
#top input.name:hover { border-color: var(--line); }
.tabs { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; flex: none; }
.tabs button { border: 0; border-radius: 0; padding: 6px 14px; }
.tabs button.on { background: var(--accent); color: #fff; }
#toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
#toolbar:empty, #top:empty { display: none; }
#toolbar .sp { flex: 1; }
#fx { flex: 1 1 100%; display: flex; gap: 8px; align-items: center; }
#fx .ref { width: 130px; flex: none; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#work { flex: 1; display: flex; min-height: 0; }
#doc { flex: 1; overflow: auto; padding: 18px; min-width: 0; }
#panel { width: 300px; flex: none; overflow: auto; background: var(--card); border-left: 1px solid var(--line); padding: 12px; }
#panel:empty { display: none; }
.welcome { max-width: 560px; margin: 60px auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.welcome h2 { margin: 0 0 8px; }
.welcome li { margin: 6px 0; }

/* Văn bản Word */
.page { background: #fff; box-sizing: border-box; margin: 0 auto; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.06); font: 12pt/1.15 "Times New Roman", serif; }
.partcap { font: 12px "Segoe UI", sans-serif; color: var(--muted); border-top: 1px dashed var(--line); margin: 22px 0 6px; padding-top: 6px; text-transform: uppercase; }
.p { min-height: 1.15em; white-space: pre-wrap; word-wrap: break-word; padding: 1px 2px; border-radius: 2px; tab-size: 4; }
.p[contenteditable]:hover { background: #f7f9fc; }
.p.gen { background: #f0fdf4; }
table.wtbl { border-collapse: collapse; width: 100%; margin: 0; }
table.wtbl td { border: 1px solid #555; padding: 0 7px; vertical-align: top; }
table.wtbl.fixed { table-layout: fixed; }
table.wtbl td { overflow-wrap: break-word; }
table.wtbl.nob td { border-color: transparent; }
table.wtbl.nob:hover td { border: 1px dashed #d5d9df; }
.box { border: 1px dashed #aab; padding: 4px 8px; margin: 4px 0; }
mark { border-radius: 2px; padding: 0 1px; color: inherit; }
mark.done { background: #bbf7d0 !important; box-shadow: inset 0 -2px 0 var(--ok); }
mark.todo { background: #fef3c7 !important; box-shadow: inset 0 -2px 0 var(--warn); }

/* Bảng Excel */
/* Vẽ sát với Excel thật: font, màu, khung, độ rộng cột, chiều cao dòng lấy từ file (mỗi kiểu ô một lớp .x<số>, xem renderSheets). */
.gridwrap { background: #fff; border: 1px solid #c8ccd0; overflow: auto; max-height: calc(100vh - 262px); }
table.grid { border-collapse: collapse; table-layout: fixed; color: #000; line-height: 1.22; }
table.grid th { position: sticky; top: 0; z-index: 4; height: 20px; box-sizing: border-box; padding: 0; overflow: hidden; background: #f3f3f3; color: #444; font: 12px "Segoe UI", sans-serif; text-align: center; box-shadow: inset -1px -1px 0 #c8ccd0; }
table.grid th.rh { top: auto; left: 0; }
table.grid tr:first-of-type th.rh { top: 0; z-index: 7; }
/* Đường lưới mờ vẽ bằng bóng đổ ở cạnh phải và dưới, để khung thật của ô (border) luôn đè lên. */
table.grid td { padding: 0 3px; white-space: nowrap; vertical-align: bottom; overflow: hidden; cursor: cell; box-shadow: inset -1px -1px 0 #e1e1e1; }
table.grid td.gr { box-shadow: inset -1px 0 0 #e1e1e1; }
table.grid td.gb { box-shadow: inset 0 -1px 0 #e1e1e1; }
table.grid td.g0, table.grid.nogrid td { box-shadow: none; }
table.grid td.num { text-align: right; }
table.grid td { user-select: none; } /* kéo chuột là chọn ô, không bôi đen chữ tràn cả hàng */
table.grid .cv { overflow: hidden; }
table.grid td.spill { overflow: visible; } /* chữ dài tràn sang ô trống bên cạnh */
table.grid td.spill > .cv { pointer-events: none; }
table.grid td.spill > .cv mark { pointer-events: auto; }
table.grid td.fz { position: sticky; z-index: 2; background-color: #fff; } /* dòng / cột được cố định (Freeze Panes) */
table.grid td.sel { outline: 2px solid #217346; outline-offset: -2px; background-image: linear-gradient(rgba(33, 115, 70, .13), rgba(33, 115, 70, .13)); }
/* Thanh sheet nằm dưới bảng như Excel */
.sheets { display: flex; flex-wrap: wrap; align-items: center; background: #f3f3f3; border: 1px solid #c8ccd0; border-top: 0; padding: 0 6px; }
.sheets button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 5px 12px; font-size: 12px; color: #444; white-space: pre; }
.sheets button:hover { background: #e4e4e4; }
.sheets button.on { background: #fff; color: #217346; font-weight: 700; border-bottom-color: #217346; }
.sheets button.hid { font-style: italic; opacity: .75; }
.sheets .xnote { margin-left: auto; padding: 0 10px; font-size: 12px; color: var(--muted); }
.sheets button.more { color: var(--accent); }
.shlist { max-height: 52vh; overflow: auto; margin-top: 10px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; }
.shlist label.opt { margin: 5px 0; }

/* Bảng bên phải */
.ptitle { font-weight: 700; margin: 0 0 4px; }
#panel > .ptitle { font-size: 16px; }
/* Bảng "Hồ sơ mới": các bước đánh số, đầu mục in đậm */
.pstep { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.pstep:first-of-type { margin-top: 10px; }
.pnum { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.phead { font-weight: 700; font-size: 14.5px; color: var(--text); }
.plabel2 { font-weight: 700; font-size: 13px; margin: 10px 0 4px; }
.psrc .srcrow { padding: 2px 0; }
.plink { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--accent); cursor: pointer; }
.plink:hover { text-decoration: underline; }
#panel .row select { flex: 1; min-width: 0; font-weight: 600; }
#panel .flabel { font-weight: 700; }
.field { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; }
.field.zero { border-color: #f1b8b3; background: #fff7f6; }
.frow { display: flex; gap: 6px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.flabel { font-weight: 600; flex: 1; min-width: 0; word-break: break-word; cursor: pointer; }
.fsample { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-word; max-height: 4.4em; overflow: hidden; }
.count { font-size: 12px; color: var(--muted); flex: none; }
.x { border: 0; background: transparent; color: var(--muted); padding: 0 4px; font-size: 16px; line-height: 1; }
.x:hover { color: var(--bad); }
.row { display: flex; gap: 6px; margin: 6px 0; align-items: center; }
.row > select, .row > input { flex: 1; min-width: 0; }
.src { font-size: 12px; padding: 2px 0; word-break: break-word; }
.note { font-size: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 8px 0; color: #444; }
.note.warn { background: #fffbeb; border-color: #f3d58a; }
.note.ok { background: #f0fdf4; border-color: #b7e4c7; }

/* Chat */
#chat { display: flex; flex-direction: column; height: 100vh; background: var(--card); border-left: 1px solid var(--line); min-width: 0; }
.chead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ctitle { font-weight: 700; }
.csub { font-size: 12px; color: var(--muted); }
#msgs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 8px 10px; border-radius: 10px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.claude { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 3px; }
.msg.system { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.msg .who { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.msg img { display: block; max-width: 100%; max-height: 180px; border-radius: 6px; margin-top: 6px; cursor: zoom-in; }
.msg pre { background: rgba(0,0,0,.06); padding: 6px; border-radius: 6px; overflow: auto; font-size: 12px; margin: 4px 0; white-space: pre-wrap; }
.msg code { background: rgba(0,0,0,.07); padding: 0 3px; border-radius: 3px; font-size: 12.5px; }
#cstatus { font-size: 12px; color: var(--muted); padding: 0 12px; min-height: 0; }
#cstatus.on { padding: 6px 12px; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); }
#cstatus .st { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin { width: 12px; height: 12px; border: 2px solid #c9d3e3; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#cthumbs { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px; }
#cthumbs:not(:empty) { padding-top: 8px; }
.thumb { position: relative; }
.thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; padding: 0; font-size: 12px; line-height: 1; }
.cinput { padding: 10px 12px; border-top: 1px solid var(--line); }
.cbtns { display: flex; justify-content: space-between; margin-top: 6px; }

/* Chế độ Người điền phiếu / máy khác trong mạng: không có khung chat */
body.nochat #app { grid-template-columns: 44px minmax(0, 1fr); }
body.nochat #chat { display: none; }
.moderow { display: flex; gap: 6px; margin: 8px 0 4px; flex-wrap: wrap; }
.fillbtn { padding: 1px 8px; font-size: 12px; margin-right: 4px; }
.guide .gstep { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.guide .gstep .hint { margin-top: 2px; line-height: 1.45; }

/* Phiếu nhập dữ liệu của một bộ hồ sơ (phủ cả màn hình) */
#formov { position: fixed; inset: 0; background: rgba(20,25,35,.45); display: none; z-index: 45; padding: 2vh 2vw; }
#formov.on { display: block; }
.fbox { background: var(--bg); border-radius: 10px; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.fhead { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ftitle { font-size: 15px; }
.fproj { display: flex; align-items: center; gap: 6px; font-size: 13px; flex: 1; min-width: 300px; }
.fproj select { max-width: 320px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; }
.fnew { flex: 1; padding: 5px 8px; border: 1px solid var(--accent); border-radius: 6px; }
.fbtns { display: flex; gap: 8px; }
.fmain { flex: 1; display: flex; min-height: 0; }
.fnav { width: 220px; flex: none; overflow: auto; padding: 12px 8px; border-right: 1px solid var(--line); background: var(--card); }
.fnav a { display: block; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--text); }
.fnav a:hover { background: var(--accent-soft); }
.fbody { flex: 1; overflow: auto; padding: 12px 20px 60px; }
.fsec { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 12px 0; scroll-margin-top: 8px; }
.fsec h4 { margin: 0 0 8px; color: var(--accent); text-transform: uppercase; font-size: 13px; letter-spacing: .02em; }
.fitem { padding: 10px 0; border-top: 1px dashed var(--line); max-width: 900px; }
.fitem:first-of-type { border-top: 0; }
.flabel { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; font-size: 13.5px; }
.fwhere { font-size: 11.5px; color: var(--muted); background: #f1f4f8; border-radius: 10px; padding: 1px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
#formov textarea { width: 100%; resize: vertical; field-sizing: content; min-height: 32px; padding: 6px 8px; border: 1px solid #cfd5de; border-radius: 6px; background: #fff; box-sizing: border-box; }
#formov textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
#formov textarea::placeholder { color: #b0b6c0; }
.fex { font-size: 11.5px; color: #9aa1ab; margin-top: 3px; }
.fown { margin-top: 4px; color: var(--accent); }
.fownbox { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-top: 4px; }
.frow1 { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 13px; }
.frow1 > span { width: 160px; flex: none; }
.frow1 input[type=number] { width: 64px; padding: 4px; }
.fdraft { display: flex; align-items: center; gap: 6px; }
/* Các đợt nghiệm thu (mẫu Excel nhiều sheet) */
.fround { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin: 8px 0; background: #fbfcfe; }
.froundh { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.froundh button { margin-left: auto; }
.froundg { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; }
.froundg label { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: #4a5361; }

.froundh { cursor: pointer; }
.fcaret { width: 14px; color: var(--muted); }
.frt h5 { margin: 14px 0 4px; font-size: 13px; color: #34495e; }
.fkt { border-left: 3px solid var(--accent-soft); padding: 4px 0 6px 10px; margin: 8px 0; }
.fkt.off { opacity: .55; border-left-color: #e2e5ea; }
.fkth { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.fktt { flex: 1; padding: 4px 6px; border: 1px solid #cfd5de; border-radius: 5px; }
.fkl { border-collapse: collapse; width: 100%; font-size: 13px; }
.fkl th { background: #f1f3f6; text-align: left; padding: 4px 6px; border: 1px solid #d6dbe2; position: sticky; top: 0; }
.fkl td { border: 1px solid #e1e5ea; padding: 2px 6px; }
.fkl tr.grp td { background: #eef4ff; font-weight: 600; }
.fkl input { width: 110px; padding: 3px 5px; border: 1px solid #cfd5de; border-radius: 4px; }
.nokind .gk { display: none; }

/* Lưới ô kiểu Excel trong phiếu */
.fgridwrap { position: relative; overflow: auto; max-height: 70vh; border: 1px solid #c9ced6; border-radius: 4px; margin-top: 8px; outline: none; background: #fff; }
.fgridwrap:focus { border-color: var(--accent); }
.fgrid { border-collapse: collapse; width: 100%; font-size: 13px; user-select: none; table-layout: auto; }
.fgrid th { position: sticky; top: 0; background: #f1f3f6; color: #3b4452; font-weight: 600; padding: 5px 6px; text-align: left; z-index: 2; white-space: nowrap; border: 1px solid #d6dbe2; }
.fgrid td.gc { border: 1px solid #e1e5ea; padding: 3px 6px; vertical-align: top; white-space: pre-wrap; word-break: break-word; min-width: 70px; max-width: 420px; cursor: cell; height: 20px; }
.fgrid td.gk { min-width: 76px; color: #4a5361; }
.fgrid td.rn, .fgrid th.rn { position: sticky; left: 0; z-index: 1; background: #f1f3f6; color: #7a8290; text-align: center; font-size: 11.5px; width: 34px; min-width: 34px; border: 1px solid #d6dbe2; cursor: grab; padding: 3px 4px; }
.fgrid th.rn { z-index: 3; cursor: pointer; }
.fgrid td.rn.sel { background: #d7e4fb; color: var(--accent); font-weight: 600; }
.fgrid td.gc.sel { background: #e3edfd !important; }
.fgrid td.gc.cur { outline: 2px solid var(--accent); outline-offset: -2px; }
.fgrid tr.k-nhom td.gc { background: #eef4ff; font-weight: 600; }
.fgrid tr.k-nhom_con td.gc { background: #f6f7f9; font-style: italic; font-weight: 600; }
.fgrid td.gempty { padding: 14px; color: var(--muted); font-style: italic; }
#formov textarea.gedit { position: absolute; display: none; z-index: 5; resize: none; field-sizing: content; max-width: 520px; padding: 3px 6px; border: 2px solid var(--accent); border-radius: 0; font-size: 13px; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.factions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

#modal { position: fixed; inset: 0; background: rgba(20,25,35,.45); display: none; place-items: center; z-index: 50; }
#modal.on { display: grid; }
.mbox { background: #fff; border-radius: 10px; padding: 18px; width: min(520px, 92vw); max-height: 88vh; overflow: auto; }
.mbox h3 { margin: 0 0 12px; }
.mbox label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.mbox label.opt { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }
.mbox label.opt input { margin-top: 3px; }
.mrows { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; margin-top: 8px; }
.mrow { display: grid; grid-template-columns: auto 46px minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.mrow .ref { font-size: 12px; color: var(--muted); }
.mrow .msample { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mact { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast { background: #1f2937; color: #fff; padding: 8px 14px; border-radius: 8px; max-width: 70vw; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); }

/* Danh sách tick chọn do Claude đề xuất */
.msg.prop { max-width: 100%; align-self: stretch; background: #fff; border: 1px solid #c9d8f5; }
.pitem { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.pitem input { margin-top: 3px; flex: none; }
.pbody { flex: 1; min-width: 0; }
.pstate { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pstate.yes { color: var(--ok); }
.pundo { flex: none; align-self: center; white-space: nowrap; color: var(--warn); border-color: #f1d9b5; }
.pundo:hover { background: #fff7ed; }
.plabel { font-weight: 600; }
.pdiff { font-size: 13px; margin-top: 2px; }
.pdiff del { color: var(--bad); background: #fdecea; text-decoration: line-through; padding: 0 2px; }
.pdiff ins { color: var(--ok); background: #e7f6ec; text-decoration: none; padding: 0 2px; }
.perr { font-size: 12px; color: var(--bad); }
.pact { display: flex; gap: 6px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.pact .sp { flex: 1; }
.pgo { cursor: pointer; border-radius: 4px; flex: 1; min-width: 0; }
.pgo:hover { background: var(--accent-soft); }
.pgo .plabel::after { content: " ↗"; color: var(--accent); font-weight: 400; }
.pitem.cur .pgo { background: var(--accent-soft); box-shadow: -3px 0 0 var(--accent); }
/* Vị trí đang được chỉ trong văn bản: khung vàng quanh đoạn/ô, cụm chữ cần xem tô cam */
#doc .spot { background: #fef9c3 !important; outline: 2px solid #f59e0b; outline-offset: 2px; border-radius: 2px; }
#doc table.grid td.spot { outline-offset: -2px; }
::highlight(spot) { background: #f97316; color: #fff; }
.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0%, 35% { background: #fde047; box-shadow: 0 0 0 3px #fde047; } 100% { background: transparent; box-shadow: none; } }

/* Trang in: từng trang do Word dựng (hình), phủ lớp chữ trong suốt nằm đúng trên chữ in để bấm sửa, bôi đen, tô màu */
#work { position: relative; }
.pages { width: max-content; margin: 0 auto; font: 12pt/1.15 "Times New Roman", serif; }
.ppage { position: relative; background: #fff; margin: 0 auto 14px; border: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.12); overflow: hidden; }
.ppage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pl { position: absolute; inset: 0; mix-blend-mode: multiply; }
.pl .p { position: absolute; min-height: 0; padding: 0; white-space: normal; }
.pl.edit .p { cursor: text; }
.pl.edit .p:hover { background: #e3edfd; }
.pl .seg { position: absolute; white-space: pre; color: transparent; transform-origin: 0 0; cursor: text; }
.pl:not(.edit) .seg { cursor: default; }
.pl mark { padding: 0; color: transparent; }
.pl ::selection { background: rgba(29, 95, 209, .32); color: transparent; }
.ped { position: absolute; z-index: 3; box-sizing: border-box; background: #fff !important; box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgba(0,0,0,.2); }
.ped.wait { box-shadow: 0 0 0 1px #cbd5e1; color: #334155; }
#pbusy { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 8px; align-items: center; padding: 6px 12px; font-size: 12.5px; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.12); pointer-events: none; }

/* Chọn nhiều chỗ bằng Ctrl */
::highlight(pick) { background: #7db4ff; }
#pickbar { position: absolute; left: 16px; bottom: 14px; z-index: 6; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: calc(100% - 32px); padding: 8px 10px 8px 14px; background: #fff; border: 1px solid #c9d8f5; border-radius: 10px; box-shadow: 0 6px 22px rgba(0,0,0,.2); font-size: 13px; }
#pickbar b { margin-right: 4px; white-space: nowrap; }
.vrow { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line); }

/* Kết quả nạp bảng dữ liệu */
.srow { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.srow .plink { margin: 0; font-weight: 600; }
