/* Soạn hồ sơ ĐKKD – giao diện theo tinh thần giấy tờ hành chính: nền giấy, chữ có chân cho tiêu đề,
   một màu mực xanh đen cho thao tác chính và màu đỏ con dấu cho điểm nhấn. */
:root {
  --paper: #f6f4ef;
  --sheet: #ffffff;
  --ink: #1b1f24;
  --ink-2: #3b414a;
  --muted: #736e65;
  --faint: #a29d93;
  --rule: #e2ddd2;
  --rule-2: #eeeae2;
  --primary: #1f3a5f;
  --primary-2: #172d4a;
  --primary-soft: #e9eef5;
  --seal: #a8231c;
  --seal-soft: #f7e9e7;
  --ok: #2f6b3f;
  --ok-soft: #e7f1e9;
  --warn: #8a5a00;
  --warn-soft: #fbf2de;
  --serif: "Source Serif 4", "Noto Serif", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --r: 6px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 28px; line-height: 1.2; margin: 0; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 22px 0 10px;
     display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
svg.i { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* ----- đầu trang ----- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(246, 244, 239, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 28px; height: 60px; display: flex; align-items: center; gap: 28px; }
.mark { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.mark:hover { text-decoration: none; }
.seal-mark { width: 30px; height: 30px; border: 1.5px solid var(--seal); border-radius: 50%; display: grid; place-items: center; color: var(--seal);
        font: 700 10.5px/1 var(--serif); letter-spacing: .02em; transform: rotate(-8deg); }
.mark b { font: 600 18px/1 var(--serif); }
.mark small { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--ink-2); padding: 18px 12px 16px; border-bottom: 2px solid transparent; font-weight: 500; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); border-bottom-color: var(--seal); }
main { max-width: 1240px; margin: 0 auto; padding: 34px 28px 140px; }

/* ----- tiêu đề trang ----- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 680px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.eyebrow { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); font-weight: 600; margin-bottom: 8px; }

/* ----- tờ giấy ----- */
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 22px 26px; margin-bottom: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.note { border-left: 2px solid var(--primary); background: var(--primary-soft); color: var(--ink-2); padding: 10px 14px; font-size: 13px;
        display: flex; gap: 10px; align-items: flex-start; border-radius: 0 var(--r) var(--r) 0; }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); color: #5e4300; }
p.warn { background: var(--warn-soft); color: #5e4300; padding: 8px 12px; border-radius: var(--r); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border: 1px solid var(--rule); border-radius: 3px; font-size: 11.5px;
        font-weight: 500; color: var(--muted); background: #fff; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.chip.seal { border-color: #e6c3bf; color: var(--seal); background: var(--seal-soft); }
.chip.blue { border-color: #c9d5e5; color: var(--primary); background: var(--primary-soft); }

/* ----- ô nhập kiểu điền vào chỗ trống ----- */
.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 18px; margin: 8px 0; }
.fld { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; min-width: 0; }
.fld.w1 { grid-column: span 1; }
.fld.w2 { grid-column: span 3; }
.fld.w3, .fld.w-full { grid-column: 1 / -1; }
.fld > span { font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; min-width: 0; }
input, select { border: 0; border-bottom: 1px solid #cfc9bc; background: transparent; padding: 6px 2px 5px; border-radius: 0; }
select { cursor: pointer; }
textarea { border: 1px solid #d9d3c7; background: #fdfcf9; padding: 8px 10px; border-radius: var(--r); resize: vertical; line-height: 1.5; }
input:hover, select:hover { border-bottom-color: var(--ink-2); }
input:focus, select:focus { outline: none; border-bottom: 1px solid var(--primary); box-shadow: 0 1px 0 var(--primary); }
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 58, 95, .1); background: #fff; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=file] { border: 1px dashed #cfc9bc; padding: 12px; border-radius: var(--r); background: #fdfcf9; }
input[type=file]::file-selector-button { font: 500 13px var(--sans); padding: 6px 12px; margin-right: 10px; border: 1px solid var(--ink); border-radius: var(--r); background: #fff; color: var(--ink); cursor: pointer; }
.chk { display: inline-flex; align-items: center; gap: 9px; margin: 5px 22px 5px 0; cursor: pointer; }
/* ô đánh dấu vuông như trên biểu mẫu: ☐ / ☒ */
.chk input, .tick input { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border: 1.4px solid var(--ink); border-radius: 1px;
                          background: #fff; display: grid; place-items: center; cursor: pointer; flex: none; margin: 0; padding: 0; }
.chk input::after, .tick input::after { content: ""; width: 10px; height: 10px; clip-path: polygon(14% 0, 0 14%, 36% 50%, 0 86%, 14% 100%, 50% 64%, 86% 100%, 100% 86%, 64% 50%, 100% 14%, 86% 0, 50% 36%); background: var(--seal); transform: scale(0); transition: transform .12s; }
.chk input:checked::after, .tick input:checked::after { transform: scale(1); }
.chk input:focus-visible, .tick input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.search { max-width: 320px; border: 1px solid var(--rule); border-radius: var(--r); background: #fff; padding: 8px 12px 8px 34px;
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23736e65' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
          background-repeat: no-repeat; background-position: 11px center; background-size: 15px; }
.search:focus { box-shadow: 0 0 0 3px rgba(31, 58, 95, .1); border-color: var(--primary); }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 500; color: var(--ink-2); border-right: 1px solid var(--rule); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }

/* ----- nút ----- */
.btn { display: inline-flex; align-items: center; vertical-align: middle; gap: 7px; font: 500 14px/1.2 var(--sans); padding: 9px 16px; border-radius: var(--r);
       border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--ink); color: #fff; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.seal { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.seal:hover { filter: brightness(.92); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--rule-2); color: var(--ink); }
.btn.danger { border-color: transparent; color: var(--seal); }
.btn.danger:hover { background: var(--seal-soft); color: var(--seal); }
.btn svg.i { width: 15px; height: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ----- trang chính: mục lục thủ tục ----- */
.home { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 34px; align-items: start; }
.toc { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: grid; grid-template-columns: 34px minmax(0, auto) 1fr auto; align-items: baseline; gap: 10px; padding: 13px 4px; color: var(--ink);
         border-bottom: 1px solid var(--rule-2); }
.toc a::before { content: counter(toc, upper-roman) "."; font: 600 14px var(--serif); color: var(--seal); }
.toc a:hover { text-decoration: none; background: #fff; }
.toc a:hover b { text-decoration: underline; text-underline-offset: 3px; }
.toc b { font: 600 16.5px/1.3 var(--serif); }
.toc .lead { border-bottom: 1.5px dotted #c9c3b6; transform: translateY(-4px); min-width: 20px; }
.toc .mau { font-size: 12px; color: var(--muted); white-space: nowrap; }
.toc .desc { grid-column: 2 / -1; color: var(--muted); font-size: 13px; margin-top: -2px; }
.facts { display: flex; gap: 26px; margin: 4px 0 20px; flex-wrap: wrap; }
.facts div b { display: block; font: 600 30px/1 var(--serif); }
.facts div span { font-size: 12.5px; color: var(--muted); }

/* ----- danh sách dạng sổ ----- */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
table.list th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom-color: var(--rule); }
table.list tbody tr:hover td { background: #fbfaf6; }
table.list td.r { text-align: right; white-space: nowrap; }
.co { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.co:hover { text-decoration: none; }
.co:hover b { text-decoration: underline; text-underline-offset: 3px; }
.av { width: 34px; height: 34px; border: 1px solid var(--rule); border-radius: 50%; background: #fff; color: var(--ink-2); display: grid; place-items: center;
      font: 600 12px var(--serif); flex: none; }
.co b { display: block; font-weight: 600; }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: flex; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule-2); }
.ledger li .t { flex: 1; min-width: 0; }
.ledger li .t b { display: block; font-weight: 500; }
.ledger li time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { font: 500 12.5px var(--sans); padding: 5px 11px; border: 1px solid var(--rule); background: #fff; border-radius: 99px; cursor: pointer; color: var(--ink-2); }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ----- trang soạn hồ sơ: 2 cột ----- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.split > * { min-width: 0; }
.aside { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 16px; }
.aside .card { margin: 0; padding: 18px 20px; }
.aside h2 { font-size: 16px; margin-bottom: 10px; }
.aside .btn { white-space: normal; text-align: left; line-height: 1.3; }
.sheets { list-style: none; margin: 0; padding: 0; }
.sheets li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--rule); font-size: 13px; }
.sheets li:last-child { border-bottom: 0; }
.sheets .pg { width: 24px; height: 30px; border: 1px solid #cfc9bc; background: #fff; position: relative; box-shadow: 2px 2px 0 #ece8df; }
.sheets .pg::before { content: ""; position: absolute; left: 5px; right: 5px; top: 8px; height: 10px;
                      background: repeating-linear-gradient(#cfc9bc 0 1px, transparent 1px 4px); }
.sheets .pg.qd::after { content: ""; position: absolute; right: -4px; bottom: -4px; width: 11px; height: 11px; border: 1.2px solid var(--seal); border-radius: 50%; background: #fff; }
.sheets .nm { min-width: 0; overflow-wrap: anywhere; }
.sheets .nm small { display: block; color: var(--muted); font-size: 11.5px; }
.sheets .ops { display: flex; gap: 2px; }
.sheets .ops button, .sheets .ops a { border: 0; background: none; padding: 4px 6px; border-radius: 4px; color: var(--ink-2); cursor: pointer; font: 500 12px var(--sans); }
.sheets .ops button:hover, .sheets .ops a:hover { background: var(--rule-2); color: var(--ink); text-decoration: none; }
.checks { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.checks li { display: flex; gap: 8px; padding: 5px 0; align-items: flex-start; }
.checks li::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; background: var(--warn); }
.checks li.err::before { background: var(--seal); }
.checks li.ok::before { background: var(--ok); }
.checks li a { color: inherit; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* mục có ô đánh dấu (bật/tắt) */
.secs { counter-reset: sec; }
.sec { padding: 0; overflow: hidden; counter-increment: sec; }
.sec-head { display: flex; align-items: center; gap: 14px; padding: 16px 22px; cursor: pointer; user-select: none; }
.sec-head::before { content: counter(sec, decimal-leading-zero); font: 600 13px var(--serif); color: var(--faint); width: 20px; }
.sec-head .t { flex: 1; }
.sec-head b { display: block; font: 600 16px/1.3 var(--serif); }
.sec-head small { color: var(--muted); font-size: 12.5px; }
.sec-body { padding: 4px 22px 22px 56px; border-top: 1px dashed var(--rule); }
.sec.on { border-color: #cdbfb0; box-shadow: inset 3px 0 0 var(--seal); }
.sec.on .sec-head::before { color: var(--seal); }
.tick { display: inline-flex; }
.tick input { width: 20px; height: 20px; }
.tick input::after { width: 12px; height: 12px; }

/* dòng danh sách (ngành, mục, người) */
.lrow, .person { position: relative; border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 46px 14px 16px; margin: 10px 0; background: #fdfcf9; }
.lrow-title { font: 600 15px var(--serif); margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.lrow .x, .person .x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 4px; background: none;
                       font-size: 19px; color: var(--faint); cursor: pointer; line-height: 1; }
.lrow .x:hover, .person .x:hover { color: var(--seal); background: var(--seal-soft); }
.nganh .lrow-body { display: grid; grid-template-columns: minmax(0, 1fr) 190px 120px; gap: 8px 16px; align-items: end; }
.nganh .fld, .muc .fld { grid-column: auto; }
.nganh .hint { grid-column: 1 / -1; color: var(--muted); }
.nganh .hint:empty { display: none; }
.nganh .hint.warn { color: var(--warn); }
.muc .lrow-body { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px 16px; align-items: end; }
.muc .fld.w-full { grid-column: 1 / -1; }
.roles { display: flex; flex-wrap: wrap; gap: 0 4px; padding: 10px 0 2px; border-top: 1px dashed var(--rule); margin-top: 10px; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 8px; }
select.pick { width: auto; font-size: 13px; padding: 4px 22px 4px 2px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--primary); }
.sub { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 20px 0 6px; }
table.mini { border-collapse: collapse; width: 100%; font-size: 13px; table-layout: fixed; }
table.mini td:first-child, table.mini th:first-child { width: 34%; }
table.mini th, table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--rule-2); text-align: left; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 11.5px; }

/* thanh lưu cố định */
.bar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--ink); color: #fff;
       border-radius: var(--r); padding: 10px 12px 10px 18px; margin-top: 22px; box-shadow: 0 10px 30px rgba(27, 31, 36, .25); }
.bar .grow { flex: 1; }
.bar .state { font-size: 12.5px; color: #c9cdd3; }
.bar .btn, .bar .state { flex: none; }
.bar .btn { border-color: rgba(255, 255, 255, .35); color: #fff; }
.bar .btn:hover { background: rgba(255, 255, 255, .12); }
.bar .btn.primary { background: #fff; color: var(--ink); border-color: #fff; }
.bar .btn.primary:hover { background: #e9e6df; }
.bar .btn.seal:hover { filter: brightness(1.1); }
.bar .btn.danger { color: #f3b7b2; border-color: transparent; }
.bar kbd { font: 11px var(--sans); border: 1px solid rgba(255, 255, 255, .3); border-radius: 3px; padding: 0 4px; margin-left: 2px; color: #c9cdd3; }
.bar .btn.primary kbd { color: var(--muted); border-color: var(--rule); }

/* thông báo nhỏ */
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(14px); background: var(--ink); color: #fff; padding: 10px 18px;
         border-radius: var(--r); opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 60; font-size: 13.5px; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--seal); }

/* xem trước văn bản */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(27, 31, 36, .55); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--ink); color: #fff; }
.viewer-bar b { font: 600 15px var(--serif); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .btn { border-color: rgba(255, 255, 255, .35); color: #fff; }
.viewer-bar .btn:hover { background: rgba(255, 255, 255, .12); }
.viewer-body { flex: 1; overflow: auto; padding: 24px 12px; background: #8d8a84; }
.viewer-body .docx-wrapper { background: transparent !important; padding: 0 !important; }
.viewer-body .docx-wrapper > section.docx { box-shadow: 0 4px 18px rgba(0, 0, 0, .3) !important; margin: 0 auto 22px !important; }
.viewer-msg { color: #fff; text-align: center; padding: 60px 0; }

body.login { display: grid; place-items: center; min-height: 100vh; }
body.login .card { width: min(380px, 92vw); display: flex; flex-direction: column; gap: 16px; padding: 30px; }

code { background: var(--rule-2); color: var(--ink); padding: 1px 6px; border-radius: 3px; font-size: 12.5px; }

/* ----- màn hình hẹp ----- */
@media (max-width: 1060px) {
  .split, .home { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
}
@media (max-width: 760px) {
  .top-in { height: auto; padding: 10px 14px 0; flex-wrap: wrap; gap: 6px; }
  .nav { margin-left: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
  .nav a { padding: 9px 4px 8px; white-space: nowrap; font-size: 13.5px; text-align: center; }
  main { padding: 22px 14px 120px; }
  h1 { font-size: 23px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fld, .fld.w2 { grid-column: 1 / -1; }
  .fld.w1 { grid-column: span 1; }
  .nganh .lrow-body, .muc .lrow-body { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px 16px; }
  .sec-head { padding: 14px 14px; }
  .sec-body { padding: 4px 14px 18px; }
  .btn { white-space: normal; text-align: left; }
  .toc a { grid-template-columns: 28px minmax(0, 1fr); }
  .toc .lead, .toc .mau { display: none; }
  table.list thead { display: none; }
  table.list tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
  table.list td { display: block; border: 0; padding: 3px 0; }
  table.list td.r { text-align: left; }
  .bar kbd { display: none; }
  .bar .btn.seal { flex: 1 1 auto; justify-content: center; }
}

/* ----- trang hướng dẫn ----- */
.guide ol, .guide ul { margin: 0; padding-left: 22px; }
.guide li { margin: 7px 0; line-height: 1.6; }
.guide li ul { margin-top: 4px; }
.guide .card p { margin: 12px 0 0; }
.guide .card { scroll-margin-top: 80px; }
.guide .vd { margin-top: 16px; border-left: 2px solid var(--seal); background: var(--seal-soft); padding: 12px 16px; font-size: 13.5px; line-height: 1.6; }
.guide .muc li { margin: 4px 0; }
kbd { font: 11.5px var(--sans); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: #fff; }
