/* Vị trí việc làm ISPAE - giao diện chung */
:root {
    --bg: #f4f6f5;
    --surface: #ffffff;
    --surface-2: #f8faf9;
    --line: #dfe5e2;
    --text: #1d2a26;
    --muted: #63736d;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --primary-soft: #e3f3f1;
    --ok: #15803d;
    --ok-soft: #e7f6ec;
    --low: #b45309;
    --low-soft: #fdf3e2;
    --high: #b91c1c;
    --high-soft: #fdecec;
    --info-soft: #e8f0fb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 2px 8px rgba(16, 40, 32, .05);
    font-synthesis: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 6px; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.b { font-weight: 600; }

/* Thanh trên */
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px;
    padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand img { width: 34px; height: 34px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-size: 15px; }
.brand small { font-size: 11px; color: var(--muted); }
.mainnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: 7px 11px; border-radius: 7px; text-decoration: none; color: var(--text); white-space: nowrap; }
.mainnav a:hover { background: var(--surface-2); }
.mainnav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.userbox .uname { display: flex; flex-direction: column; text-align: right; line-height: 1.2; font-weight: 600; }
.userbox .uname small { font-weight: 400; color: var(--muted); }
.userbox a { color: var(--muted); text-decoration: none; }
.userbox a:hover { color: var(--primary); }
.nav-toggle { display: none; margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; font-size: 18px; padding: 2px 10px; }

.page { max-width: 1480px; margin: 0 auto; padding: 18px 20px 60px; }

/* Nút */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #0b5f58; color: var(--primary-ink); }
.btn-danger { color: var(--high); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--high-soft); color: var(--high); }

/* Ô nhập */
input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
    border-radius: 7px; padding: 7px 9px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.invalid { border-color: var(--high) !important; background: var(--high-soft) !important; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld > span { font-weight: 600; font-size: 13px; }
.fld small { color: var(--muted); font-size: 12px; }
.fld.full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid.one { grid-template-columns: 1fr; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 520px; margin: 20px auto; }
.alert { padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.alert-err { background: var(--high-soft); color: var(--high); }
.alert-warn { background: var(--low-soft); color: #7c3d07; }
.alert-info { background: var(--info-soft); color: #1e3a6b; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.b-draft { background: #eef1f0; color: var(--muted); }
.b-sent { background: var(--info-soft); color: #1e4f9c; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-back { background: var(--low-soft); color: var(--low); }

/* Đăng nhập */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #e3f3f1, #f4f6f5 60%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px rgba(15, 118, 110, .12); display: flex; flex-direction: column; gap: 16px; }
.login-head { display: flex; gap: 12px; align-items: center; }
.login-head img { width: 48px; height: 48px; }
.login-head h1 { font-size: 19px; margin: 0; }
.login-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.login-foot { color: var(--muted); font-size: 12px; margin: 0; text-align: center; }

/* Thanh tổng giờ */
.sumbar {
    position: sticky; top: 51px; z-index: 20; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.viewing { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.sum-grid { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.sum-big { display: flex; flex-direction: column; padding: 4px 16px 4px 12px; border-left: 4px solid; line-height: 1.25; }
.sum-big span { font-size: 12px; color: var(--muted); }
.sum-big b { font-size: 24px; font-variant-numeric: tabular-nums; }
.sum-big em { font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }
.sum-big.ok { border-color: var(--ok); } .sum-big.ok em { color: var(--ok); }
.sum-big.low { border-color: var(--low); } .sum-big.low em { color: var(--low); }
.sum-big.high { border-color: var(--high); } .sum-big.high em { color: var(--high); }
.sum-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.pct { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.pct.ok, .sum-verdict.ok { color: var(--ok); }
.pct.low, .sum-verdict.low { color: var(--low); }
.pct.high, .sum-verdict.high { color: var(--high); }
.bar { position: relative; height: 10px; background: #eaefed; border-radius: 99px; margin: 6px 0; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .3s; }
.bar i.ok { background: var(--ok); } .bar i.low { background: #e0a043; } .bar i.high { background: var(--high); }
.bar s { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0, 0, 0, .25); }
.bar s.full { width: 2px; background: rgba(0, 0, 0, .55); }
.sum-verdict { font-size: 13px; }
.sum-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; max-width: 380px; }

/* Bố cục kê khai */
.kk-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
.kk-side { position: sticky; top: 170px; max-height: calc(100vh - 185px); display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.nhom-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.nhom-mang { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 8px 2px; }
.nhom-item { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; padding: 7px 8px; border-radius: 7px; text-decoration: none; color: var(--text); font-size: 13px; line-height: 1.35; }
.nhom-item span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nhom-item small { display: block; color: var(--muted); font-size: 11px; }
.nhom-item b { font-size: 12px; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nhom-item:hover { background: var(--surface-2); }
.nhom-item.active { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.nhom-item.all { font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0; }
.kk-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.nhom-head { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.nhom-head .code { font-size: 12px; color: var(--primary); font-weight: 600; }
.hint { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.cv-sec { margin: 16px 0 22px; }
.cv-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 8px 10px; background: var(--surface-2); border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: 0; }
.cv-sum { font-weight: 700; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.btn-add { margin-top: 6px; }
.cv-sec { margin: 10px 0 14px; }
.cv-sec:has(.tbl-wrap[hidden]) .cv-head { border-bottom: 1px solid var(--line); border-radius: 8px; }
@media (min-width: 700px) {
    .cv-sec:has(.tbl-wrap[hidden]) { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
    .cv-sec:has(.tbl-wrap[hidden]) .btn-add { margin-top: 0; }
}
.empty { text-align: center; padding: 50px 10px; color: var(--muted); }

/* Bảng task */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; }
table.tk th, table.tk td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tk th { background: var(--surface-2); font-size: 12px; text-align: left; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.tk th.c-n { text-align: right; }
table.tk input, table.tk textarea { padding: 5px 7px; border-color: transparent; background: transparent; }
table.tk input:hover, table.tk textarea:hover { border-color: var(--line); }
table.tk input:focus, table.tk textarea:focus { background: var(--surface); }
table.tk textarea { resize: vertical; min-height: 32px; overflow: hidden; }
table.tk td.num { padding-top: 10px; }
.c-ten { min-width: 280px; width: 36%; }
.c-dvt { width: 90px; min-width: 80px; }
.c-n { width: 82px; min-width: 76px; }
.c-mc { min-width: 160px; width: 18%; }
.c-x { width: 44px; text-align: center; white-space: nowrap; }
tr.dirty td { background: #fffbea; }
.st { display: block; width: 8px; height: 8px; border-radius: 50%; margin: 2px auto 0; }
.st.saving { background: #e0a043; }
.st.saved { background: var(--ok); animation: fade 2s forwards; }
.st.error { background: var(--high); }
@keyframes fade { to { opacity: 0; } }
table.tk.all tr.grp td { background: var(--primary-soft); font-weight: 600; }
table.tk.all tr.grp a { color: var(--text); }
table.tk tfoot td { font-weight: 700; background: var(--surface-2); padding: 8px 6px; }
table.tk tfoot tr.quy td { font-weight: 400; color: var(--muted); }
.total-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--line); }
.total-foot > div { display: flex; flex-direction: column; align-items: flex-end; padding: 8px 14px; border-radius: 8px; background: var(--surface-2); line-height: 1.3; }
.total-foot span { font-size: 12px; color: var(--muted); }
.total-foot b { font-size: 18px; font-variant-numeric: tabular-nums; }
.total-foot em { font-style: normal; font-size: 13px; font-variant-numeric: tabular-nums; }
.total-foot .grand { background: var(--primary-soft); }
.total-foot .grand b { color: var(--primary); }

/* Trang quản trị */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar select { width: auto; min-width: 240px; }
table.grid { background: var(--surface); }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { background: var(--surface-2); font-size: 12px; color: var(--muted); white-space: nowrap; position: sticky; top: 0; }
table.grid tr:hover td { background: #fbfcfc; }
table.grid td.act { white-space: nowrap; text-align: right; }
table.grid td.act .btn { margin-left: 4px; }
.mini-bar { height: 6px; background: #eaefed; border-radius: 99px; overflow: hidden; min-width: 80px; margin-top: 4px; }
.mini-bar i { display: block; height: 100%; }
.mini-bar i.ok { background: var(--ok); } .mini-bar i.low { background: #e0a043; } .mini-bar i.high { background: var(--high); }
.nhom-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.nhom-card > header { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 10px 14px; }
.nhom-card > header .t { flex: 1; min-width: 0; }
.nhom-card > header .t small { color: var(--primary); font-weight: 600; }
.nhom-card .cv-list { border-top: 1px solid var(--line); padding: 4px 14px 10px 30px; }
.cv-row { display: flex; gap: 12px; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.cv-row:last-child { border-bottom: 0; }
.cv-row .t { flex: 1; min-width: 0; }
.tree-unit { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.tree-unit > summary { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none; }
.tree-unit > summary::-webkit-details-marker { display: none; }
.tree-unit > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.tree-unit[open] > summary::before { transform: rotate(90deg); }
.tree-unit[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tu-name { flex: 1; min-width: 0; }
.tu-meta { color: var(--muted); font-size: 12px; }
.tu-meta .warn { color: var(--low); }
.tree-unit .tbl-wrap { border: 0; }
.tree-unit table.grid td { padding: 7px 14px; }
.mang-title { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat span { font-size: 12px; color: var(--muted); display: block; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.doc { max-width: 900px; }
.doc h2 { margin-top: 22px; }
.doc li { margin: 4px 0; }

/* Hộp thoại */
dialog.dlg { border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog.dlg.wide { width: min(900px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(20, 30, 28, .45); }
dialog.dlg form { padding: 20px; }
dialog.dlg h2 { margin-bottom: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1d2a26; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--high); }

/* Điện thoại / máy tính bảng */
@media (max-width: 1100px) {
    .sum-grid { grid-template-columns: 1fr; gap: 10px; }
    .sum-act { justify-content: flex-start; max-width: none; }
    .sumbar { position: static; }
    .kk-side { top: 60px; }
}
@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
    .nav-toggle { display: block; }
    .mainnav, .userbox { display: none; width: 100%; }
    body.nav-open .mainnav { display: flex; flex-direction: column; }
    body.nav-open .userbox { display: flex; flex-wrap: wrap; justify-content: flex-start; }
    .userbox .uname { text-align: left; }
    .page { padding: 12px 16px 50px; }
    .kk-layout { grid-template-columns: 1fr; }
    .kk-side { position: static; max-height: 45vh; }
    .form-grid { grid-template-columns: 1fr; }
    .toolbar select { min-width: 0; width: 100%; }
}
