:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1c2430; --muted: #64707f; --line: #e1e6ed; --line2: #ccd4de;
  --pri: #0b5cab; --pri2: #084a8a; --pri-soft: #e8f1fb; --ok: #1d7a46; --ok-soft: #e5f5ec; --warn: #a65d00; --warn-soft: #fff3df;
  --err: #b42318; --err-soft: #fdecea; --r: 10px; --sh: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--pri); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: #fff; border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #f7f9fb; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); border-color: #f0c2bd; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.rec { background: var(--err); border-color: var(--err); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1f5; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.err { background: var(--err-soft); color: var(--err); } .badge.pri { background: var(--pri-soft); color: var(--pri); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
textarea { min-height: 70px; resize: vertical; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.q { font-size: 12.5px; color: var(--pri); margin-top: 3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.err-box { background: var(--err-soft); color: var(--err); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.ok-box { background: var(--ok-soft); color: var(--ok); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }

/* Đăng nhập */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #0b5cab 0%, #0a3f78 55%, #f4f6f9 55%); }
.auth .card { width: 100%; max-width: 440px; padding: 28px; }
.auth h1 { font-size: 20px; margin: 0 0 4px; } .auth .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; background: #eef1f5; padding: 4px; border-radius: 9px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--sh); }
.pw { position: relative; } .pw input { padding-right: 42px; }
.pw .eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; padding: 6px; color: var(--muted); display: grid; }
.meter { height: 6px; background: #eef1f5; border-radius: 9px; margin-top: 6px; overflow: hidden; } .meter i { display: block; height: 100%; transition: width .2s; }
.rules { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12.5px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px 10px; }
.rules li { color: var(--muted); } .rules li.ok { color: var(--ok); } .rules li::before { content: '○ '; } .rules li.ok::before { content: '✓ '; }

/* Khung chính */
.top { position: sticky; top: 0; z-index: 20; background: #0b3f75; color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 54px; }
.top .brand { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.top nav a { color: #cfe0f3; text-decoration: none; padding: 7px 11px; border-radius: 7px; font-weight: 500; white-space: nowrap; font-size: 14px; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.top .me { display: flex; align-items: center; gap: 8px; font-size: 13.5px; white-space: nowrap; }
.top .me .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 18px 60px; }
h2 { font-size: 21px; margin: 0 0 4px; } h3 { font-size: 16px; margin: 0 0 10px; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.bar input[type=search] { max-width: 320px; }
.bar select { width: auto; }
table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
table.t th { background: #f7f9fb; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); font-weight: 600; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f7fafd; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.prog { width: 110px; height: 7px; background: #eef1f5; border-radius: 9px; overflow: hidden; display: inline-block; vertical-align: middle; }
.prog i { display: block; height: 100%; background: var(--pri); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.stats .card { padding: 14px 16px; } .stats b { font-size: 24px; display: block; }

/* Hồ sơ đơn vị */
.unit-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.unit-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.secnav { position: sticky; top: 70px; padding: 8px; }
.secnav a { display: block; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: 14px; }
.secnav a.on { background: var(--pri-soft); color: var(--pri); font-weight: 600; }
.secnav a small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.secnav .pc { float: right; font-size: 12px; color: var(--muted); font-weight: 500; }
.form { padding: 20px 22px; }
.form .sec-desc { color: var(--muted); font-size: 13.5px; margin: -4px 0 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.formtag { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.chk { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.chk input { margin-top: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 10px; cursor: pointer; font-size: 13px; border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--pri); color: #fff; }
.crit { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; margin-bottom: 10px; }
.crit .hd { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.crit .ma { font-weight: 700; color: var(--pri); min-width: 28px; }
.crit .mc { font-size: 12.5px; color: var(--muted); }
.crit .lv { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0; }
.crit .lv button { border: 1px solid var(--line2); background: #fff; border-radius: 7px; padding: 4px 9px; font-size: 12.5px; cursor: pointer; }
.crit .lv button.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.crit .pts { font-weight: 700; white-space: nowrap; }
.grp { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--pri-soft); }
.grp h4 { margin: 0; font-size: 14.5px; }
.sum { position: sticky; top: 62px; z-index: 5; background: var(--pri-soft); border-radius: 9px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; margin-bottom: 12px; }
.rt td { padding: 6px 8px; } .rt td.c { text-align: center; width: 70px; }
.saving { font-size: 12.5px; color: var(--muted); }

/* Trợ lý AI */
.ai { position: sticky; top: 70px; padding: 16px; max-height: calc(100vh - 86px); overflow-y: auto; }
.ai h3 { display: flex; align-items: center; gap: 8px; }
.recbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; background: #f7f9fb; border-radius: 9px; margin: 10px 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.tr { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13.5px; }
.tr .th { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tr .tx { white-space: pre-wrap; max-height: 160px; overflow-y: auto; }
.sug { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13.5px; }
.sug.off { opacity: .5; }
.sug .lb { font-weight: 600; font-size: 13px; } .sug .v { margin: 3px 0; white-space: pre-wrap; } .sug .cc { font-size: 12px; color: var(--muted); font-style: italic; }
.sug .old { font-size: 12px; color: var(--warn); }

/* Minh chứng */
.evrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.evt { width: 74px; text-align: center; }
.evrow.big .evt { width: 110px; }
.evo { width: 74px; height: 74px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fb; padding: 0; cursor: pointer; overflow: hidden; display: grid; place-items: center; }
.evrow.big .evo { width: 110px; height: 110px; }
.evo img { width: 100%; height: 100%; object-fit: cover; } .evo .ic { font-size: 28px; }
.evn { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evadd { border: 1px dashed var(--line2); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; cursor: pointer; color: var(--pri); background: #fff; }
.evadd:hover { background: var(--pri-soft); }
.drop { border: 2px dashed var(--line2); border-radius: 10px; padding: 14px 16px; margin-bottom: 8px; }
.drop.on { border-color: var(--pri); background: var(--pri-soft); }
#evq { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 340px; max-width: calc(100vw - 32px); max-height: 50vh; overflow-y: auto; padding: 12px; }
.evqh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.evqi { font-size: 12.5px; padding: 6px 0; border-top: 1px solid var(--line); }
.evqi .qn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.evqi .qb { height: 4px; background: #eef1f5; border-radius: 4px; margin: 4px 0; overflow: hidden; } .evqi .qb i { display: block; height: 100%; background: var(--pri); }
.evqi.done .qb i { background: var(--ok); } .evqi.err .qm { color: var(--err); } .evqi.done .qm { color: var(--ok); }

/* Hộp thoại */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal .card { width: 100%; max-width: 480px; padding: 22px; max-height: 92vh; overflow-y: auto; }
.modal.wide .card { max-width: 1000px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.preview { background: #e9ecf0; border-radius: 8px; padding: 10px; max-height: 70vh; overflow: auto; }
.preview .docx-wrapper { background: transparent !important; padding: 0 !important; }
.formlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; margin-bottom: 10px; }
.formlist button { text-align: left; border: 1px solid var(--line2); background: #fff; border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.formlist button.on { border-color: var(--pri); background: var(--pri-soft); color: var(--pri); font-weight: 600; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; }
#toast div { background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 14px; max-width: 90vw; }
#toast div.e { background: var(--err); }

/* Bộ nội dung khảo sát */
.guide .sec { padding: 18px 20px; margin-bottom: 14px; }
.guide ol { margin: 6px 0 0; padding-left: 22px; } .guide li { margin-bottom: 6px; }
.matrix td.x { text-align: center; color: var(--pri); font-weight: 700; }

/* In: bản xem trước docx */
#printzone { display: none; }
@media print {
  .top, .bar, #toast { display: none !important; }
  body { background: #fff; } .card { box-shadow: none; } .guide .sec { break-inside: avoid-page; }
  body.pdoc { margin: 0; }
  body.pdoc > *:not(#printzone) { display: none !important; }
  body.pdoc #printzone { display: block; }
  body.pdoc #printzone .docx-wrapper { background: none !important; padding: 0 !important; display: block !important; }
  body.pdoc #printzone section.docx { box-shadow: none !important; margin: 0 !important; break-after: page; }
}
body.pdoc { }
@media (max-width: 1180px) { .layout { grid-template-columns: 210px minmax(0, 1fr); } .ai { grid-column: 1 / -1; position: static; max-height: none; } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; } .secnav { position: static; display: flex; overflow-x: auto; gap: 4px; } .secnav a { white-space: nowrap; }
  .secnav a small, .secnav .pc { display: none; } .grid2 { grid-template-columns: 1fr; } .form { padding: 16px; }
  .top { gap: 8px; padding: 0 10px; } .top .brand span { display: none; } .top .me .nm { display: none; }
  .wrap { padding: 16px 12px 50px; } .rules { grid-template-columns: 1fr; }
}
